From: Srinivas Pandruvada Date: Wed, 18 Sep 2013 17:13:00 +0000 (+0100) Subject: IIO: call sensor hub open close function X-Git-Tag: firefly_0821_release~176^2~5057^2~453^2~49 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7d3c192df0457195c4cdd5272b39c8db8334be81;p=firefly-linux-kernel-4.4.55.git IIO: call sensor hub open close function 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 Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 87419c41b991..b6e77e0fc420 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;