From patchwork Thu Nov 17 23:43:01 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Jungkamp
X-Patchwork-Id: 13047477
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
by smtp.lore.kernel.org (Postfix) with ESMTP id 784F6C4332F
for ; Thu, 17 Nov 2022 23:44:25 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S240664AbiKQXoY (ORCPT );
Thu, 17 Nov 2022 18:44:24 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47238 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S240446AbiKQXno (ORCPT
); Thu, 17 Nov 2022 18:43:44 -0500
Received: from mout.gmx.net (mout.gmx.net [212.227.15.15])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9227F03D
for ; Thu, 17 Nov 2022 15:43:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417;
t=1668728607; bh=zIOolA9952zV+6SNTVjguhB5zc/PxoGHuNoxiOEklMc=;
h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References;
b=a3aFFdv0utipbYgqqPo0yyzmMKrvLplXtl641cJovMznpy/0MCYrbjfAoYoTs+kJF
wESEMwLsbAt0biIjW8OP/LQb9CBwIOW7EkvNnMX0z4322Foe9reaUqqtjzMf01iTo5
I29/G2y/2vOjkkK2hTfe09G4DeuubB55EBMmO+/vcCgUQ6SszTEPfHYDvPoNVv1mB6
se87DNkkXfkIgL8OciutKDICaUy10eY8E73ZADoikq39JTClXecpOlBvzwrl/r0tS7
pmc2nYVcQkicKAeNBgvGBhMjijSPbNZjJy4JwzCLekbQJSbzEhtoFHOzeJ2gM22IRp
gkEQJ5kMNTyFQ==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from localhost.localdomain ([95.223.45.31]) by mail.gmx.net
(mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id
1MVvPD-1oUYG21cJx-00RmWb; Fri, 18 Nov 2022 00:43:27 +0100
From: Philipp Jungkamp
To: Jiri Kosina ,
Jonathan Cameron ,
Srinivas Pandruvada
Cc: linux-iio@vger.kernel.org, Philipp Jungkamp
Subject: [PATCH v2 3/4] IIO: hid-sensor-als: Use generic usage
Date: Fri, 18 Nov 2022 00:43:01 +0100
Message-Id: <20221117234302.3875-3-p.jungkamp@gmx.net>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <20221117234302.3875-1-p.jungkamp@gmx.net>
References: <20221117150508.00002704@Huawei.com>
<20221117234302.3875-1-p.jungkamp@gmx.net>
MIME-Version: 1.0
X-Provags-ID: V03:K1:7vk9XKobwlOkKa8MBfwsRpqxwB2m8AH8laXCv1ibK88eOuivvt3
WHCYi3PBfKAFGIkh59P0b5bj/raNqe9r4mEdTKQV7OGKcYOyKlpFRUycE1Tb1x11js0DZ0U
hksrGoQDp1H6oRHdv3X/8Hea7HDpiSJBXYt0ue31og6rBEwXJ1CXJ8NnJ6h+h73Eg13l/OB
45bzdbCy+57XQ4rUIUmpA==
UI-OutboundReport: notjunk:1;M01:P0:vi66KzIiUuA=;DG/RAFEXHxA0SSz8lmiXERslQrc
LHz0Z1oxlJP3dIRzvXuckyMYhz2TGlz+IkmkwsBaZulYnbaFbikkAkde2CgqiZMxH4YgqdPS/
okaO0msNb5KWtMRjOJVcyVrbySYLX63wz4RdzFMnYZgaA67Nm/Zqv5Y4z3dELCHNjl65FpOK+
nLecJFSWTOzSNEHj2gSkTGbNnqssc1WfDd2eoyTh/rZQyH3FVlFsVRVXVe4zrlsiovPx8vzZm
YV0sBLoPEmMcXI46y7gciGj1R6/lHQSiR7mbGqaIRXpCKk2emH8UcaXz5Pd4midQzXVdMwBem
qCBuefGPLF/1ZPnW3yytv98eZTlQd4+hrLTQRVu3uCiuRnJP9XvGUCNn0/EXg/Dqb6GKvF43W
p9TODPdrNe3fWjkjb3LIt4jiHvBMUd4IYscePmJwWEWjauSHeU9QUO0cVswZG2n/5jZdQM6Wb
NPtQwkeWQgChJ6Bt/pnY8GnNQaTL3KZbWnmXlPMx/KRinGn2vvLyTtvl8IUyfrzriouOM1rgW
518ORme5QaMFHVWa1cp1E7F9wBq+fCVYydGR7j7UwlR7xicfXjSFw+89GPmqYnQ41S+J+4fZi
6ql9Qx0pWWdBJjWNp/1/407iRZevZwJQeNXVpZWSpT4lv48iJKZPepEMyt/bF4EiC1bgHx0jF
1wgdOp+wGEeaXcFV58ZxR76kD7DrXvxkpO577PFgOP51LKgoPZ55fv4cvCvS99V0dihi6x52s
5616x7/cloqmKPjZ/t7FYzUchMFrNs2Wn6An0pp/lzBFSZeKYc7S7+sreF2nwvVWSWj0q6kvf
YXpb8jyaXnFsf/3bULOmTG739me2DJbFdPtVRJfNA5Fc3J0+W0iwx31YkSV+aLIAth8nsbC0t
qS2zFRmb6cI/7kkK4VALxkXYa3KluHNQcYRTbn2xw3Hk4GUIeFES5uMWXTtbW3v3ZtovmIepL
fgE1dw==
Precedence: bulk
List-ID:
X-Mailing-List: linux-iio@vger.kernel.org
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
---
Less unnecessary line breaks in function calls.
drivers/iio/light/hid-sensor-als.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
--
2.38.1
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 5a1a625d8d16..eb1aedad7edc 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -86,6 +86,7 @@ static int als_read_raw(struct iio_dev *indio_dev,
long mask)
{
struct als_state *als_state = iio_priv(indio_dev);
+ struct hid_sensor_hub_device *hsdev = als_state->common_attributes.hsdev;
int report_id = -1;
u32 address;
int ret_type;
@@ -110,11 +111,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
hid_sensor_power_state(&als_state->common_attributes,
true);
*val = sensor_hub_input_attr_get_raw_value(
- als_state->common_attributes.hsdev,
- HID_USAGE_SENSOR_ALS, address,
- report_id,
- SENSOR_HUB_SYNC,
- min < 0);
+ hsdev, hsdev->usage, address, report_id,
+ SENSOR_HUB_SYNC, min < 0);
hid_sensor_power_state(&als_state->common_attributes,
false);
} else {
@@ -259,9 +257,7 @@ static int als_parse_report(struct platform_device *pdev,
dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
st->als_illum.report_id);
- st->scale_precision = hid_sensor_format_scale(
- HID_USAGE_SENSOR_ALS,
- &st->als_illum,
+ st->scale_precision = hid_sensor_format_scale(usage_id, &st->als_illum,
&st->scale_pre_decml, &st->scale_post_decml);
return ret;
@@ -285,7 +281,8 @@ static int hid_als_probe(struct platform_device *pdev)
als_state->common_attributes.hsdev = hsdev;
als_state->common_attributes.pdev = pdev;
- ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_ALS,
+ ret = hid_sensor_parse_common_attributes(hsdev,
+ hsdev->usage,
&als_state->common_attributes,
als_sensitivity_addresses,
ARRAY_SIZE(als_sensitivity_addresses));
@@ -303,7 +300,8 @@ static int hid_als_probe(struct platform_device *pdev)
ret = als_parse_report(pdev, hsdev,
(struct iio_chan_spec *)indio_dev->channels,
- HID_USAGE_SENSOR_ALS, als_state);
+ hsdev->usage,
+ als_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
return ret;
@@ -333,8 +331,7 @@ static int hid_als_probe(struct platform_device *pdev)
als_state->callbacks.send_event = als_proc_event;
als_state->callbacks.capture_sample = als_capture_sample;
als_state->callbacks.pdev = pdev;
- ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_ALS,
- &als_state->callbacks);
+ ret = sensor_hub_register_callback(hsdev, hsdev->usage, &als_state->callbacks);
if (ret < 0) {
dev_err(&pdev->dev, "callback reg failed\n");
goto error_iio_unreg;
@@ -356,7 +353,7 @@ static int hid_als_remove(struct platform_device *pdev)
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct als_state *als_state = iio_priv(indio_dev);
- sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
+ sensor_hub_remove_callback(hsdev, hsdev->usage);
iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes);
@@ -368,6 +365,10 @@ static const struct platform_device_id hid_als_ids[] = {
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200041",
},
+ {
+ /* Format: HID-SENSOR-custom_sensor_tag-usage_id_in_hex_lowercase */
+ .name = "HID-SENSOR-LISS-0041",
+ },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(platform, hid_als_ids);