Skip to content

Commit 3a04a18

Browse files
pjungkampJiri Kosina
authored andcommitted
IIO: hid-sensor-als: Use generic usage
Use a generic 'hsdev->usage' instead of the HID_USAGE_SENSOR_ALS to allow this driver to drive the Lenovo custom ambient light sensor, which is registered under a 'custom' usage and not HID_USAGE_SENSOR_ALS. Add the Lenovo Intelligent Sensing Solution (LISS) ambient light sensor to the platform device ids. Signed-off-by: Philipp Jungkamp <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 48c79bb commit 3a04a18

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

drivers/iio/light/hid-sensor-als.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static int als_read_raw(struct iio_dev *indio_dev,
8686
long mask)
8787
{
8888
struct als_state *als_state = iio_priv(indio_dev);
89+
struct hid_sensor_hub_device *hsdev = als_state->common_attributes.hsdev;
8990
int report_id = -1;
9091
u32 address;
9192
int ret_type;
@@ -110,11 +111,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
110111
hid_sensor_power_state(&als_state->common_attributes,
111112
true);
112113
*val = sensor_hub_input_attr_get_raw_value(
113-
als_state->common_attributes.hsdev,
114-
HID_USAGE_SENSOR_ALS, address,
115-
report_id,
116-
SENSOR_HUB_SYNC,
117-
min < 0);
114+
hsdev, hsdev->usage, address, report_id,
115+
SENSOR_HUB_SYNC, min < 0);
118116
hid_sensor_power_state(&als_state->common_attributes,
119117
false);
120118
} else {
@@ -259,9 +257,7 @@ static int als_parse_report(struct platform_device *pdev,
259257
dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
260258
st->als_illum.report_id);
261259

262-
st->scale_precision = hid_sensor_format_scale(
263-
HID_USAGE_SENSOR_ALS,
264-
&st->als_illum,
260+
st->scale_precision = hid_sensor_format_scale(usage_id, &st->als_illum,
265261
&st->scale_pre_decml, &st->scale_post_decml);
266262

267263
return ret;
@@ -285,7 +281,8 @@ static int hid_als_probe(struct platform_device *pdev)
285281
als_state->common_attributes.hsdev = hsdev;
286282
als_state->common_attributes.pdev = pdev;
287283

288-
ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_ALS,
284+
ret = hid_sensor_parse_common_attributes(hsdev,
285+
hsdev->usage,
289286
&als_state->common_attributes,
290287
als_sensitivity_addresses,
291288
ARRAY_SIZE(als_sensitivity_addresses));
@@ -303,7 +300,8 @@ static int hid_als_probe(struct platform_device *pdev)
303300

304301
ret = als_parse_report(pdev, hsdev,
305302
(struct iio_chan_spec *)indio_dev->channels,
306-
HID_USAGE_SENSOR_ALS, als_state);
303+
hsdev->usage,
304+
als_state);
307305
if (ret) {
308306
dev_err(&pdev->dev, "failed to setup attributes\n");
309307
return ret;
@@ -333,8 +331,7 @@ static int hid_als_probe(struct platform_device *pdev)
333331
als_state->callbacks.send_event = als_proc_event;
334332
als_state->callbacks.capture_sample = als_capture_sample;
335333
als_state->callbacks.pdev = pdev;
336-
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_ALS,
337-
&als_state->callbacks);
334+
ret = sensor_hub_register_callback(hsdev, hsdev->usage, &als_state->callbacks);
338335
if (ret < 0) {
339336
dev_err(&pdev->dev, "callback reg failed\n");
340337
goto error_iio_unreg;
@@ -356,7 +353,7 @@ static int hid_als_remove(struct platform_device *pdev)
356353
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
357354
struct als_state *als_state = iio_priv(indio_dev);
358355

359-
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
356+
sensor_hub_remove_callback(hsdev, hsdev->usage);
360357
iio_device_unregister(indio_dev);
361358
hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes);
362359

@@ -368,6 +365,10 @@ static const struct platform_device_id hid_als_ids[] = {
368365
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
369366
.name = "HID-SENSOR-200041",
370367
},
368+
{
369+
/* Format: HID-SENSOR-custom_sensor_tag-usage_id_in_hex_lowercase */
370+
.name = "HID-SENSOR-LISS-0041",
371+
},
371372
{ /* sentinel */ }
372373
};
373374
MODULE_DEVICE_TABLE(platform, hid_als_ids);

0 commit comments

Comments
 (0)