diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2014-04-18 19:22:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-05-05 05:59:49 -0400 |
commit | 56ff6be608659ac06d4e3cc5827476efa29d610f (patch) | |
tree | 8d08e07b518db810f8f6bee492ba7dba08683b84 /drivers/iio/pressure | |
parent | a269b9a0a27675c34c62c4e20c4ffb62054cd51a (diff) |
iio: hid-sensors: Add API to power on/off
Added an API to allow client drivers to turn ON and OFF sensors for
quick read. Added data_read as counting varaible instead of boolean,
so that sensor is powered off only when last user released it.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/pressure')
-rw-r--r-- | drivers/iio/pressure/hid-sensor-press.c | 7 |
1 files changed, 3 insertions, 4 deletions
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) { |