summaryrefslogtreecommitdiff
path: root/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-03 13:24:58 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-03 13:24:58 -0800
commit55ef003e4ae684d5660f984eb2352df12572d9df (patch)
treec22f2098485b1f373b52e6d253df5a521a5287bb /drivers/iio/common/hid-sensors/hid-sensor-trigger.c
parent559c71fe5dc3bf2ecc55afb336145db7f0abf810 (diff)
parent419a4aaeb0f7a96359f7e937201b004f23e61976 (diff)
Merge tag 'iio-fixes-for-3.13b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: Second round of IIO fixes for the 3.13 cycle. 2 fixes here. * The gp2ap020a00f is a simple missing kconfig dependency. * The hid sensors hub fix is a work around for an issue introduced by hardware changes due to a certain large software vendor having an 'interesting' interpretation of the specification and hence indexing some arrays from 1 rather than 0. The fix takes advantage of the logical min and max reading facilities introduced by the precursor patch to figure out whether we have a 0 indexed or 1 indexed device and to adjust appropriately. It also drops a previous kconfig option that allowed this issue to be worked around at build time.
Diffstat (limited to 'drivers/iio/common/hid-sensors/hid-sensor-trigger.c')
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index bbd6426c9726..7dcf83998e6f 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -33,24 +33,34 @@ 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;
+ int report_val;
if (state) {
if (sensor_hub_device_open(st->hsdev))
return -EIO;
- } else
+ state_val =
+ HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM;
+ report_val =
+ HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM;
+
+ } else {
sensor_hub_device_close(st->hsdev);
+ state_val =
+ HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM;
+ report_val =
+ HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM;
+ }
- state_val = state ? 1 : 0;
- if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
- ++state_val;
st->data_ready = state;
+ state_val += st->power_state.logical_minimum;
+ report_val += st->report_state.logical_minimum;
sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
st->power_state.index,
(s32)state_val);
sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
st->report_state.index,
- (s32)state_val);
+ (s32)report_val);
return 0;
}