From 56ff6be608659ac06d4e3cc5827476efa29d610f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: 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 Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/hid-sensor-press.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/iio/pressure') diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index ff69da4..39df50c 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, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct press_state *press_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "press_proc_event [%d]\n", - press_state->common_attributes.data_ready); - if (press_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "press_proc_event\n"); + if (atomic_read(&press_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, &press_state->press_data, sizeof(press_state->press_data)); @@ -307,7 +306,7 @@ static int hid_press_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - press_state->common_attributes.data_ready = false; + atomic_set(&press_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &press_state->common_attributes); if (ret) { -- cgit v1.1