Loading drivers/sensors/sensors_class.c +36 −0 Original line number Diff line number Diff line Loading @@ -349,6 +349,40 @@ static ssize_t sensors_flush_show(struct device *dev, ? "not exist" : "exist"); } static ssize_t sensors_enable_wakeup_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev); ssize_t ret; unsigned long enable; if (sensors_cdev->sensors_enable_wakeup == NULL) { dev_err(dev, "Invalid sensor class enable_wakeup handle\n"); return -EINVAL; } ret = kstrtoul(buf, 10, &enable); if (ret) return ret; enable = enable ? 1 : 0; ret = sensors_cdev->sensors_enable_wakeup(sensors_cdev, enable); if (ret) return ret; sensors_cdev->wakeup = enable; return size; } static ssize_t sensors_enable_wakeup_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev); return snprintf(buf, PAGE_SIZE, "%d\n", sensors_cdev->wakeup); } static ssize_t sensors_calibrate_show(struct device *dev, struct device_attribute *atte, char *buf) { Loading Loading @@ -426,6 +460,8 @@ static struct device_attribute sensors_class_attrs[] = { __ATTR(self_test, 0440, sensors_test_show, NULL), __ATTR(batch, 0660, sensors_batch_show, sensors_batch_store), __ATTR(flush, 0660, sensors_flush_show, sensors_flush_store), __ATTR(enable_wakeup, 0660, sensors_enable_wakeup_show, sensors_enable_wakeup_store), __ATTR(calibrate, 0664, sensors_calibrate_show, sensors_calibrate_store), __ATTR_NULL, Loading include/linux/sensors.h +4 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ struct cal_result_t { * @enabled: Store the sensor driver enable status. * @delay_msec: Store the sensor driver delay value. The data unit is * millisecond. * @wakeup: Indicate if the wake up interrupt has been enabled * @sensors_enable: The handle for enable and disable sensor. * @sensors_poll_delay: The handle for set the sensor polling delay time. * @params The sensor calibrate string format params up to userspace. Loading @@ -133,6 +134,7 @@ struct sensors_classdev { unsigned int batch_mode; unsigned int delay_msec; unsigned int batch_timeout_ms; unsigned int wakeup; char *params; struct cal_result_t cal_result; /* enable and disable the sensor handle*/ Loading @@ -147,6 +149,8 @@ struct sensors_classdev { unsigned int period_ms, unsigned int timeout_ms); int (*sensors_flush)(struct sensors_classdev *sensors_cdev); int (*sensors_enable_wakeup)(struct sensors_classdev *sensors_cdev, unsigned int enable); int (*sensors_calibrate)(struct sensors_classdev *sensor_cdev, int axis, int apply_now); int (*sensors_write_cal_params)(struct sensors_classdev Loading Loading
drivers/sensors/sensors_class.c +36 −0 Original line number Diff line number Diff line Loading @@ -349,6 +349,40 @@ static ssize_t sensors_flush_show(struct device *dev, ? "not exist" : "exist"); } static ssize_t sensors_enable_wakeup_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev); ssize_t ret; unsigned long enable; if (sensors_cdev->sensors_enable_wakeup == NULL) { dev_err(dev, "Invalid sensor class enable_wakeup handle\n"); return -EINVAL; } ret = kstrtoul(buf, 10, &enable); if (ret) return ret; enable = enable ? 1 : 0; ret = sensors_cdev->sensors_enable_wakeup(sensors_cdev, enable); if (ret) return ret; sensors_cdev->wakeup = enable; return size; } static ssize_t sensors_enable_wakeup_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev); return snprintf(buf, PAGE_SIZE, "%d\n", sensors_cdev->wakeup); } static ssize_t sensors_calibrate_show(struct device *dev, struct device_attribute *atte, char *buf) { Loading Loading @@ -426,6 +460,8 @@ static struct device_attribute sensors_class_attrs[] = { __ATTR(self_test, 0440, sensors_test_show, NULL), __ATTR(batch, 0660, sensors_batch_show, sensors_batch_store), __ATTR(flush, 0660, sensors_flush_show, sensors_flush_store), __ATTR(enable_wakeup, 0660, sensors_enable_wakeup_show, sensors_enable_wakeup_store), __ATTR(calibrate, 0664, sensors_calibrate_show, sensors_calibrate_store), __ATTR_NULL, Loading
include/linux/sensors.h +4 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ struct cal_result_t { * @enabled: Store the sensor driver enable status. * @delay_msec: Store the sensor driver delay value. The data unit is * millisecond. * @wakeup: Indicate if the wake up interrupt has been enabled * @sensors_enable: The handle for enable and disable sensor. * @sensors_poll_delay: The handle for set the sensor polling delay time. * @params The sensor calibrate string format params up to userspace. Loading @@ -133,6 +134,7 @@ struct sensors_classdev { unsigned int batch_mode; unsigned int delay_msec; unsigned int batch_timeout_ms; unsigned int wakeup; char *params; struct cal_result_t cal_result; /* enable and disable the sensor handle*/ Loading @@ -147,6 +149,8 @@ struct sensors_classdev { unsigned int period_ms, unsigned int timeout_ms); int (*sensors_flush)(struct sensors_classdev *sensors_cdev); int (*sensors_enable_wakeup)(struct sensors_classdev *sensors_cdev, unsigned int enable); int (*sensors_calibrate)(struct sensors_classdev *sensor_cdev, int axis, int apply_now); int (*sensors_write_cal_params)(struct sensors_classdev Loading