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