Commit 55ef003e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-fixes-for-3.13b' of...

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.
parents 559c71fe 419a4aae
...@@ -112,13 +112,15 @@ static int sensor_hub_get_physical_device_count( ...@@ -112,13 +112,15 @@ static int sensor_hub_get_physical_device_count(
static void sensor_hub_fill_attr_info( static void sensor_hub_fill_attr_info(
struct hid_sensor_hub_attribute_info *info, struct hid_sensor_hub_attribute_info *info,
s32 index, s32 report_id, s32 units, s32 unit_expo, s32 size) s32 index, s32 report_id, struct hid_field *field)
{ {
info->index = index; info->index = index;
info->report_id = report_id; info->report_id = report_id;
info->units = units; info->units = field->unit;
info->unit_expo = unit_expo; info->unit_expo = field->unit_exponent;
info->size = size/8; info->size = (field->report_size * field->report_count)/8;
info->logical_minimum = field->logical_minimum;
info->logical_maximum = field->logical_maximum;
} }
static struct hid_sensor_hub_callbacks *sensor_hub_get_callback( static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
...@@ -325,9 +327,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, ...@@ -325,9 +327,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
if (field->physical == usage_id && if (field->physical == usage_id &&
field->logical == attr_usage_id) { field->logical == attr_usage_id) {
sensor_hub_fill_attr_info(info, i, report->id, sensor_hub_fill_attr_info(info, i, report->id,
field->unit, field->unit_exponent, field);
field->report_size *
field->report_count);
ret = 0; ret = 0;
} else { } else {
for (j = 0; j < field->maxusage; ++j) { for (j = 0; j < field->maxusage; ++j) {
...@@ -336,11 +336,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, ...@@ -336,11 +336,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
field->usage[j].collection_index == field->usage[j].collection_index ==
collection_index) { collection_index) {
sensor_hub_fill_attr_info(info, sensor_hub_fill_attr_info(info,
i, report->id, i, report->id, field);
field->unit,
field->unit_exponent,
field->report_size *
field->report_count);
ret = 0; ret = 0;
break; break;
} }
......
...@@ -25,13 +25,4 @@ config HID_SENSOR_IIO_TRIGGER ...@@ -25,13 +25,4 @@ config HID_SENSOR_IIO_TRIGGER
If this driver is compiled as a module, it will be named If this driver is compiled as a module, it will be named
hid-sensor-trigger. hid-sensor-trigger.
config HID_SENSOR_ENUM_BASE_QUIRKS
bool "ENUM base quirks for HID Sensor IIO drivers"
depends on HID_SENSOR_IIO_COMMON
help
Say yes here to build support for sensor hub FW using
enumeration, which is using 1 as base instead of 0.
Since logical minimum is still set 0 instead of 1,
there is no easy way to differentiate.
endmenu endmenu
...@@ -33,24 +33,34 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, ...@@ -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); struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
int state_val; int state_val;
int report_val;
if (state) { if (state) {
if (sensor_hub_device_open(st->hsdev)) if (sensor_hub_device_open(st->hsdev))
return -EIO; 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); 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; 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, sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
st->power_state.index, st->power_state.index,
(s32)state_val); (s32)state_val);
sensor_hub_set_feature(st->hsdev, st->report_state.report_id, sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
st->report_state.index, st->report_state.index,
(s32)state_val); (s32)report_val);
return 0; return 0;
} }
......
...@@ -43,6 +43,7 @@ config GP2AP020A00F ...@@ -43,6 +43,7 @@ config GP2AP020A00F
depends on I2C depends on I2C
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
select IRQ_WORK
help help
Say Y here if you have a Sharp GP2AP020A00F proximity/ALS combo-chip Say Y here if you have a Sharp GP2AP020A00F proximity/ALS combo-chip
hooked to an I2C bus. hooked to an I2C bus.
......
...@@ -42,6 +42,8 @@ struct hid_sensor_hub_attribute_info { ...@@ -42,6 +42,8 @@ struct hid_sensor_hub_attribute_info {
s32 units; s32 units;
s32 unit_expo; s32 unit_expo;
s32 size; s32 size;
s32 logical_minimum;
s32 logical_maximum;
}; };
/** /**
......
...@@ -117,4 +117,16 @@ ...@@ -117,4 +117,16 @@
#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 #define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316
#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 #define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319
/* Power state enumerations */
#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x00
#define HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM 0x01
#define HID_USAGE_SENSOR_PROP_POWER_STATE_D1_LOW_POWER_ENUM 0x02
#define HID_USAGE_SENSOR_PROP_POWER_STATE_D2_STANDBY_WITH_WAKE_ENUM 0x03
#define HID_USAGE_SENSOR_PROP_POWER_STATE_D3_SLEEP_WITH_WAKE_ENUM 0x04
#define HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM 0x05
/* Report State enumerations */
#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x00
#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x01
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment