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/light/hid-sensor-prox.c | |
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/light/hid-sensor-prox.c')
-rw-r--r-- | drivers/iio/light/hid-sensor-prox.c | 7 |
1 files changed, 3 insertions, 4 deletions
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) { |