diff mbox

[2/3] IIO: call sensor hub open close function

Message ID 1379524399-16995-2-git-send-email-srinivas.pandruvada@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

srinivas pandruvada Sept. 18, 2013, 5:13 p.m. UTC
Call hid_sensor_hub_device_open when user space opens device and call
hid_sensor_hub_device_close when device is closed. This helps in
saving power.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jonathan Cameron Oct. 1, 2013, 8:42 a.m. UTC | #1
On 09/18/13 18:13, Srinivas Pandruvada wrote:
> Call hid_sensor_hub_device_open when user space opens device and call
> hid_sensor_hub_device_close when device is closed. This helps in
> saving power.
> 
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> index 87419c4..b6e77e0 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> @@ -34,6 +34,12 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
>  	struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
>  	int state_val;
>  
> +	if (state) {
> +		if (sensor_hub_device_open(st->hsdev))
> +			return -EIO;
> +	} else
> +		sensor_hub_device_close(st->hsdev);
> +
>  	state_val = state ? 1 : 0;
>  	if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
>  		++state_val;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 87419c4..b6e77e0 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -34,6 +34,12 @@  static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
 	struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
 	int state_val;
 
+	if (state) {
+		if (sensor_hub_device_open(st->hsdev))
+			return -EIO;
+	} else
+		sensor_hub_device_close(st->hsdev);
+
 	state_val = state ? 1 : 0;
 	if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
 		++state_val;