aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c7
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c17
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.h1
-rw-r--r--drivers/iio/gyro/hid-sensor-gyro-3d.c7
-rw-r--r--drivers/iio/light/hid-sensor-als.c7
-rw-r--r--drivers/iio/light/hid-sensor-prox.c7
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c7
-rw-r--r--drivers/iio/orientation/hid-sensor-incl-3d.c7
-rw-r--r--drivers/iio/orientation/hid-sensor-rotation.c8
-rw-r--r--drivers/iio/pressure/hid-sensor-press.c7
-rw-r--r--include/linux/hid-sensor-hub.h2
11 files changed, 39 insertions, 38 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index ca50a91752d8..cf61c87a47e9 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -201,9 +201,8 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev,
201 struct iio_dev *indio_dev = platform_get_drvdata(priv); 201 struct iio_dev *indio_dev = platform_get_drvdata(priv);
202 struct accel_3d_state *accel_state = iio_priv(indio_dev); 202 struct accel_3d_state *accel_state = iio_priv(indio_dev);
203 203
204 dev_dbg(&indio_dev->dev, "accel_3d_proc_event [%d]\n", 204 dev_dbg(&indio_dev->dev, "accel_3d_proc_event\n");
205 accel_state->common_attributes.data_ready); 205 if (atomic_read(&accel_state->common_attributes.data_ready))
206 if (accel_state->common_attributes.data_ready)
207 hid_sensor_push_data(indio_dev, 206 hid_sensor_push_data(indio_dev,
208 accel_state->accel_val, 207 accel_state->accel_val,
209 sizeof(accel_state->accel_val)); 208 sizeof(accel_state->accel_val));
@@ -342,7 +341,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
342 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 341 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
343 goto error_free_dev_mem; 342 goto error_free_dev_mem;
344 } 343 }
345 accel_state->common_attributes.data_ready = false; 344 atomic_set(&accel_state->common_attributes.data_ready, 0);
346 ret = hid_sensor_setup_trigger(indio_dev, name, 345 ret = hid_sensor_setup_trigger(indio_dev, name,
347 &accel_state->common_attributes); 346 &accel_state->common_attributes);
348 if (ret < 0) { 347 if (ret < 0) {
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index dbefbdaf7cd1..73282cee0c81 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -28,16 +28,17 @@
28#include <linux/iio/sysfs.h> 28#include <linux/iio/sysfs.h>
29#include "hid-sensor-trigger.h" 29#include "hid-sensor-trigger.h"
30 30
31static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, 31int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
32 bool state)
33{ 32{
34 struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
35 int state_val; 33 int state_val;
36 int report_val; 34 int report_val;
37 35
38 if (state) { 36 if (state) {
39 if (sensor_hub_device_open(st->hsdev)) 37 if (sensor_hub_device_open(st->hsdev))
40 return -EIO; 38 return -EIO;
39
40 atomic_inc(&st->data_ready);
41
41 state_val = hid_sensor_get_usage_index(st->hsdev, 42 state_val = hid_sensor_get_usage_index(st->hsdev,
42 st->power_state.report_id, 43 st->power_state.report_id,
43 st->power_state.index, 44 st->power_state.index,
@@ -47,6 +48,8 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
47 st->report_state.index, 48 st->report_state.index,
48 HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM); 49 HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
49 } else { 50 } else {
51 if (!atomic_dec_and_test(&st->data_ready))
52 return 0;
50 sensor_hub_device_close(st->hsdev); 53 sensor_hub_device_close(st->hsdev);
51 state_val = hid_sensor_get_usage_index(st->hsdev, 54 state_val = hid_sensor_get_usage_index(st->hsdev,
52 st->power_state.report_id, 55 st->power_state.report_id,
@@ -57,7 +60,6 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
57 st->report_state.index, 60 st->report_state.index,
58 HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM); 61 HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM);
59 } 62 }
60 st->data_ready = state;
61 63
62 if (state_val >= 0) { 64 if (state_val >= 0) {
63 state_val += st->power_state.logical_minimum; 65 state_val += st->power_state.logical_minimum;
@@ -75,6 +77,13 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
75 77
76 return 0; 78 return 0;
77} 79}
80EXPORT_SYMBOL(hid_sensor_power_state);
81
82static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
83 bool state)
84{
85 return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);
86}
78 87
79void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) 88void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
80{ 89{
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index ca02f7811aa8..0f8e78c249d3 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -22,5 +22,6 @@
22int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, 22int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
23 struct hid_sensor_common *attrb); 23 struct hid_sensor_common *attrb);
24void hid_sensor_remove_trigger(struct hid_sensor_common *attrb); 24void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
25int hid_sensor_power_state(struct hid_sensor_common *st, bool state);
25 26
26#endif 27#endif
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 53ac06040fbe..392c30b8cd74 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -201,9 +201,8 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev,
201 struct iio_dev *indio_dev = platform_get_drvdata(priv); 201 struct iio_dev *indio_dev = platform_get_drvdata(priv);
202 struct gyro_3d_state *gyro_state = iio_priv(indio_dev); 202 struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
203 203
204 dev_dbg(&indio_dev->dev, "gyro_3d_proc_event [%d]\n", 204 dev_dbg(&indio_dev->dev, "gyro_3d_proc_event\n");
205 gyro_state->common_attributes.data_ready); 205 if (atomic_read(&gyro_state->common_attributes.data_ready))
206 if (gyro_state->common_attributes.data_ready)
207 hid_sensor_push_data(indio_dev, 206 hid_sensor_push_data(indio_dev,
208 gyro_state->gyro_val, 207 gyro_state->gyro_val,
209 sizeof(gyro_state->gyro_val)); 208 sizeof(gyro_state->gyro_val));
@@ -339,7 +338,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
339 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 338 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
340 goto error_free_dev_mem; 339 goto error_free_dev_mem;
341 } 340 }
342 gyro_state->common_attributes.data_ready = false; 341 atomic_set(&gyro_state->common_attributes.data_ready, 0);
343 ret = hid_sensor_setup_trigger(indio_dev, name, 342 ret = hid_sensor_setup_trigger(indio_dev, name,
344 &gyro_state->common_attributes); 343 &gyro_state->common_attributes);
345 if (ret < 0) { 344 if (ret < 0) {
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 39b50be9d456..e124b395f320 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -180,9 +180,8 @@ static int als_proc_event(struct hid_sensor_hub_device *hsdev,
180 struct iio_dev *indio_dev = platform_get_drvdata(priv); 180 struct iio_dev *indio_dev = platform_get_drvdata(priv);
181 struct als_state *als_state = iio_priv(indio_dev); 181 struct als_state *als_state = iio_priv(indio_dev);
182 182
183 dev_dbg(&indio_dev->dev, "als_proc_event [%d]\n", 183 dev_dbg(&indio_dev->dev, "als_proc_event\n");
184 als_state->common_attributes.data_ready); 184 if (atomic_read(&als_state->common_attributes.data_ready))
185 if (als_state->common_attributes.data_ready)
186 hid_sensor_push_data(indio_dev, 185 hid_sensor_push_data(indio_dev,
187 &als_state->illum, 186 &als_state->illum,
188 sizeof(als_state->illum)); 187 sizeof(als_state->illum));
@@ -305,7 +304,7 @@ static int hid_als_probe(struct platform_device *pdev)
305 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 304 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
306 goto error_free_dev_mem; 305 goto error_free_dev_mem;
307 } 306 }
308 als_state->common_attributes.data_ready = false; 307 atomic_set(&als_state->common_attributes.data_ready, 0);
309 ret = hid_sensor_setup_trigger(indio_dev, name, 308 ret = hid_sensor_setup_trigger(indio_dev, name,
310 &als_state->common_attributes); 309 &als_state->common_attributes);
311 if (ret < 0) { 310 if (ret < 0) {
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index 1894ab196f97..07e98ec8e9f1 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -176,9 +176,8 @@ static int prox_proc_event(struct hid_sensor_hub_device *hsdev,
176 struct iio_dev *indio_dev = platform_get_drvdata(priv); 176 struct iio_dev *indio_dev = platform_get_drvdata(priv);
177 struct prox_state *prox_state = iio_priv(indio_dev); 177 struct prox_state *prox_state = iio_priv(indio_dev);
178 178
179 dev_dbg(&indio_dev->dev, "prox_proc_event [%d]\n", 179 dev_dbg(&indio_dev->dev, "prox_proc_event\n");
180 prox_state->common_attributes.data_ready); 180 if (atomic_read(&prox_state->common_attributes.data_ready))
181 if (prox_state->common_attributes.data_ready)
182 hid_sensor_push_data(indio_dev, 181 hid_sensor_push_data(indio_dev,
183 &prox_state->human_presence, 182 &prox_state->human_presence,
184 sizeof(prox_state->human_presence)); 183 sizeof(prox_state->human_presence));
@@ -297,7 +296,7 @@ static int hid_prox_probe(struct platform_device *pdev)
297 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 296 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
298 goto error_free_dev_mem; 297 goto error_free_dev_mem;
299 } 298 }
300 prox_state->common_attributes.data_ready = false; 299 atomic_set(&prox_state->common_attributes.data_ready, 0);
301 ret = hid_sensor_setup_trigger(indio_dev, name, 300 ret = hid_sensor_setup_trigger(indio_dev, name,
302 &prox_state->common_attributes); 301 &prox_state->common_attributes);
303 if (ret) { 302 if (ret) {
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 131ced0dcb1c..54eea6a17061 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -202,9 +202,8 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
202 struct iio_dev *indio_dev = platform_get_drvdata(priv); 202 struct iio_dev *indio_dev = platform_get_drvdata(priv);
203 struct magn_3d_state *magn_state = iio_priv(indio_dev); 203 struct magn_3d_state *magn_state = iio_priv(indio_dev);
204 204
205 dev_dbg(&indio_dev->dev, "magn_3d_proc_event [%d]\n", 205 dev_dbg(&indio_dev->dev, "magn_3d_proc_event\n");
206 magn_state->common_attributes.data_ready); 206 if (atomic_read(&magn_state->common_attributes.data_ready))
207 if (magn_state->common_attributes.data_ready)
208 hid_sensor_push_data(indio_dev, 207 hid_sensor_push_data(indio_dev,
209 magn_state->magn_val, 208 magn_state->magn_val,
210 sizeof(magn_state->magn_val)); 209 sizeof(magn_state->magn_val));
@@ -343,7 +342,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
343 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 342 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
344 goto error_free_dev_mem; 343 goto error_free_dev_mem;
345 } 344 }
346 magn_state->common_attributes.data_ready = false; 345 atomic_set(&magn_state->common_attributes.data_ready, 0);
347 ret = hid_sensor_setup_trigger(indio_dev, name, 346 ret = hid_sensor_setup_trigger(indio_dev, name,
348 &magn_state->common_attributes); 347 &magn_state->common_attributes);
349 if (ret < 0) { 348 if (ret < 0) {
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index f0c465cc192a..bf11678dd04e 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -200,9 +200,8 @@ static int incl_3d_proc_event(struct hid_sensor_hub_device *hsdev,
200 struct iio_dev *indio_dev = platform_get_drvdata(priv); 200 struct iio_dev *indio_dev = platform_get_drvdata(priv);
201 struct incl_3d_state *incl_state = iio_priv(indio_dev); 201 struct incl_3d_state *incl_state = iio_priv(indio_dev);
202 202
203 dev_dbg(&indio_dev->dev, "incl_3d_proc_event [%d]\n", 203 dev_dbg(&indio_dev->dev, "incl_3d_proc_event\n");
204 incl_state->common_attributes.data_ready); 204 if (atomic_read(&incl_state->common_attributes.data_ready))
205 if (incl_state->common_attributes.data_ready)
206 hid_sensor_push_data(indio_dev, 205 hid_sensor_push_data(indio_dev,
207 (u8 *)incl_state->incl_val, 206 (u8 *)incl_state->incl_val,
208 sizeof(incl_state->incl_val)); 207 sizeof(incl_state->incl_val));
@@ -358,7 +357,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
358 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 357 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
359 goto error_free_dev_mem; 358 goto error_free_dev_mem;
360 } 359 }
361 incl_state->common_attributes.data_ready = false; 360 atomic_set(&incl_state->common_attributes.data_ready, 0);
362 ret = hid_sensor_setup_trigger(indio_dev, name, 361 ret = hid_sensor_setup_trigger(indio_dev, name,
363 &incl_state->common_attributes); 362 &incl_state->common_attributes);
364 if (ret) { 363 if (ret) {
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 51387bbc1ce1..dccf848e8b0f 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -145,10 +145,8 @@ static int dev_rot_proc_event(struct hid_sensor_hub_device *hsdev,
145 struct iio_dev *indio_dev = platform_get_drvdata(priv); 145 struct iio_dev *indio_dev = platform_get_drvdata(priv);
146 struct dev_rot_state *rot_state = iio_priv(indio_dev); 146 struct dev_rot_state *rot_state = iio_priv(indio_dev);
147 147
148 dev_dbg(&indio_dev->dev, "dev_rot_proc_event [%d]\n", 148 dev_dbg(&indio_dev->dev, "dev_rot_proc_event\n");
149 rot_state->common_attributes.data_ready); 149 if (atomic_read(&rot_state->common_attributes.data_ready))
150
151 if (rot_state->common_attributes.data_ready)
152 hid_sensor_push_data(indio_dev, 150 hid_sensor_push_data(indio_dev,
153 (u8 *)rot_state->sampled_vals, 151 (u8 *)rot_state->sampled_vals,
154 sizeof(rot_state->sampled_vals)); 152 sizeof(rot_state->sampled_vals));
@@ -272,7 +270,7 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
272 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 270 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
273 return ret; 271 return ret;
274 } 272 }
275 rot_state->common_attributes.data_ready = false; 273 atomic_set(&rot_state->common_attributes.data_ready, 0);
276 ret = hid_sensor_setup_trigger(indio_dev, name, 274 ret = hid_sensor_setup_trigger(indio_dev, name,
277 &rot_state->common_attributes); 275 &rot_state->common_attributes);
278 if (ret) { 276 if (ret) {
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index ff69da4443b8..39df50c45dab 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -180,9 +180,8 @@ static int press_proc_event(struct hid_sensor_hub_device *hsdev,
180 struct iio_dev *indio_dev = platform_get_drvdata(priv); 180 struct iio_dev *indio_dev = platform_get_drvdata(priv);
181 struct press_state *press_state = iio_priv(indio_dev); 181 struct press_state *press_state = iio_priv(indio_dev);
182 182
183 dev_dbg(&indio_dev->dev, "press_proc_event [%d]\n", 183 dev_dbg(&indio_dev->dev, "press_proc_event\n");
184 press_state->common_attributes.data_ready); 184 if (atomic_read(&press_state->common_attributes.data_ready))
185 if (press_state->common_attributes.data_ready)
186 hid_sensor_push_data(indio_dev, 185 hid_sensor_push_data(indio_dev,
187 &press_state->press_data, 186 &press_state->press_data,
188 sizeof(press_state->press_data)); 187 sizeof(press_state->press_data));
@@ -307,7 +306,7 @@ static int hid_press_probe(struct platform_device *pdev)
307 dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 306 dev_err(&pdev->dev, "failed to initialize trigger buffer\n");
308 goto error_free_dev_mem; 307 goto error_free_dev_mem;
309 } 308 }
310 press_state->common_attributes.data_ready = false; 309 atomic_set(&press_state->common_attributes.data_ready, 0);
311 ret = hid_sensor_setup_trigger(indio_dev, name, 310 ret = hid_sensor_setup_trigger(indio_dev, name,
312 &press_state->common_attributes); 311 &press_state->common_attributes);
313 if (ret) { 312 if (ret) {
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 88d8d636a68f..51f7ccadf923 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -189,7 +189,7 @@ struct hid_sensor_common {
189 struct hid_sensor_hub_device *hsdev; 189 struct hid_sensor_hub_device *hsdev;
190 struct platform_device *pdev; 190 struct platform_device *pdev;
191 unsigned usage_id; 191 unsigned usage_id;
192 bool data_ready; 192 atomic_t data_ready;
193 struct iio_trigger *trigger; 193 struct iio_trigger *trigger;
194 struct hid_sensor_hub_attribute_info poll; 194 struct hid_sensor_hub_attribute_info poll;
195 struct hid_sensor_hub_attribute_info report_state; 195 struct hid_sensor_hub_attribute_info report_state;