Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH v4 6/6] mfd: motorola-cpcap: add support for Mot CPCAP composition
From: Svyatoslav Ryhel @ 2026-04-17  7:11 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Pavel Machek, Svyatoslav Ryhel, David Lechner,
	Tony Lindgren
  Cc: linux-input, devicetree, linux-kernel, linux-leds
In-Reply-To: <20260417071106.21984-1-clamor95@gmail.com>

Add a MFD subdevice composition used in Tegra20 based Mot board
(Motorola Atrix 4G and Droid X2).

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/mfd/motorola-cpcap.c | 50 ++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 516d1e33affa..fdec92f5c6b0 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -335,6 +335,54 @@ static const struct cpcap_chip_data cpcap_mapphone_data = {
 	.num_devices = ARRAY_SIZE(cpcap_mapphone_mfd_devices),
 };
 
+/*
+ * The Mot board features a USB-PHY and charger similar to the ones in
+ * Mapphone; however, because Mot is based on Tegra20, it is incompatible
+ * with the existing implementation, which is tightly interconnected with
+ * the OMAP USB PHY.
+ */
+static const struct mfd_cell cpcap_mot_mfd_devices[] = {
+	{
+		.name          = "cpcap_adc",
+		.of_compatible = "motorola,mot-cpcap-adc",
+	}, {
+		.name          = "cpcap_battery",
+		.of_compatible = "motorola,cpcap-battery",
+	}, {
+		.name          = "cpcap-regulator",
+		.of_compatible = "motorola,mot-cpcap-regulator",
+	}, {
+		.name          = "cpcap-rtc",
+		.of_compatible = "motorola,cpcap-rtc",
+	}, {
+		.name          = "cpcap-pwrbutton",
+		.of_compatible = "motorola,cpcap-pwrbutton",
+	}, {
+		.name          = "cpcap-led",
+		.id            = 0,
+		.of_compatible = "motorola,cpcap-led-red",
+	}, {
+		.name          = "cpcap-led",
+		.id            = 1,
+		.of_compatible = "motorola,cpcap-led-green",
+	}, {
+		.name          = "cpcap-led",
+		.id            = 2,
+		.of_compatible = "motorola,cpcap-led-blue",
+	}, {
+		.name          = "cpcap-led",
+		.id            = 3,
+		.of_compatible = "motorola,cpcap-led-adl",
+	}, {
+		.name          = "cpcap-codec",
+	},
+};
+
+static const struct cpcap_chip_data cpcap_mot_data = {
+	.mfd_devices = cpcap_mot_mfd_devices,
+	.num_devices = ARRAY_SIZE(cpcap_mot_mfd_devices),
+};
+
 static int cpcap_probe(struct spi_device *spi)
 {
 	struct cpcap_ddata *cpcap;
@@ -389,6 +437,7 @@ static int cpcap_probe(struct spi_device *spi)
 static const struct of_device_id cpcap_of_match[] = {
 	{ .compatible = "motorola,cpcap", .data = &cpcap_default_data },
 	{ .compatible = "motorola,mapphone-cpcap", .data = &cpcap_mapphone_data	},
+	{ .compatible = "motorola,mot-cpcap", .data = &cpcap_mot_data },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, cpcap_of_match);
@@ -396,6 +445,7 @@ MODULE_DEVICE_TABLE(of, cpcap_of_match);
 static const struct spi_device_id cpcap_spi_ids[] = {
 	{ .name = "cpcap", .driver_data = (kernel_ulong_t)&cpcap_default_data },
 	{ .name = "mapphone-cpcap", .driver_data = (kernel_ulong_t)&cpcap_mapphone_data },
+	{ .name = "mot-cpcap", .driver_data = (kernel_ulong_t)&cpcap_mot_data },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
-- 
2.51.0


^ permalink raw reply related

* Re: [PATCH v2 1/2] dt-bindings: input: Add PixArt PAJ7620 gesture sensor
From: Krzysztof Kozlowski @ 2026-04-17  9:34 UTC (permalink / raw)
  To: Harpreet Saini
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	David Lechner, devicetree, linux-input, linux-kernel
In-Reply-To: <20260417052527.62535-2-sainiharpreet29@yahoo.com>

On Fri, Apr 17, 2026 at 01:25:26AM -0400, Harpreet Saini wrote:
> Signed-off-by: Harpreet Saini <sainiharpreet29@yahoo.com>
> ---
>  .../bindings/input/pixart,paj7620.yaml        | 70 +++++++++++++++++++
>  .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
>  2 files changed, 72 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/pixart,paj7620.yaml
> 

Comments from v1 apply. Respond to the instead of ignoring.

> diff --git a/Documentation/devicetree/bindings/input/pixart,paj7620.yaml b/Documentation/devicetree/bindings/input/pixart,paj7620.yaml
> new file mode 100644
> index 000000000000..d4f58b712810
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/pixart,paj7620.yaml
> @@ -0,0 +1,70 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org
> +$schema: http://devicetree.org

There is no such syntax. Don't invent own coding style.

Best regards,
Krzysztof


^ permalink raw reply

* Re: [PATCH v2 2/2] input: misc: Add PixArt PAJ7620 gesture sensor driver
From: Krzysztof Kozlowski @ 2026-04-17  9:39 UTC (permalink / raw)
  To: Harpreet Saini
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	David Lechner, devicetree, linux-input, linux-kernel
In-Reply-To: <20260417052527.62535-3-sainiharpreet29@yahoo.com>

On Fri, Apr 17, 2026 at 01:25:27AM -0400, Harpreet Saini wrote:
> +
> +static int paj7620_init(struct paj7620_data *data)
> +{
> +	int state = 0, ret, i;
> +
> +	/* 1. Wake-up sequence: Read register 0x00 until it returns 0x20 */
> +	for (i = 0; i < 10; i++) {
> +		ret = regmap_read(data->regmap, 0x00, &state);
> +		if (ret >= 0 && state == 0x20)
> +			break;
> +		usleep_range(1000, 2000);
> +	}
> +
> +	if (state != 0x20) {
> +		dev_err(&data->client->dev, "Sensor wake-up failed (0x%02x)\n", state);
> +		return -ENODEV;
> +	}
> +
> +	/* 2. Blast full register array into PAJ7620 instantly */
> +	ret = regmap_multi_reg_write(data->regmap, Init_Register,
> +				     ARRAY_SIZE(Init_Register));
> +	if (ret < 0) {
> +		dev_err(&data->client->dev, "Multi-reg write failed (%d)\n", ret);
> +		return ret;
> +	}
> +
> +	ret = regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0x00);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = regmap_multi_reg_write(data->regmap, Init_Gesture_Array,
> +				     ARRAY_SIZE(Init_Gesture_Array));
> +	if (ret < 0) {
> +		dev_err(&data->client->dev, "Multi-reg write failed (%d)\n", ret);
> +		return ret;
> +	}
> +
> +	dev_info(&data->client->dev, "Gesture Sensor Registers Initialized\n");

Drop, driver should be silent.

...

> +	data->client = client;
> +	i2c_set_clientdata(client, data);
> +
> +	data->supplies[0].supply = "vdd";
> +	data->supplies[1].supply = "vbus";
> +	data->supplies[2].supply = "vled";
> +
> +	ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->supplies), data->supplies);
> +	if (ret)
> +		return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
> +
> +	ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies);
> +	if (ret)
> +		return ret;
> +
> +	data->regmap = devm_regmap_init_i2c(client, &paj7620_reg_config);
> +	if (IS_ERR(data->regmap))
> +		return PTR_ERR(data->regmap);

Leaking regulator enable.

> +
> +	ret = paj7620_init(data);
> +	if (ret)
> +		goto err_reg;
> +
> +	data->idev = devm_input_allocate_device(&client->dev);
> +	if (!data->idev) {
> +		ret = -ENOMEM; goto err_reg;

Messed syntax/wrapped lines.

And you must not print error msg on ENOMEM error.

> +	}
> +
> +	data->idev->name = "PAJ7620 Gesture Sensor";
> +	data->idev->id.bustype = BUS_I2C;
> +
> +	input_set_capability(data->idev, EV_KEY, KEY_UP);
> +	input_set_capability(data->idev, EV_KEY, KEY_DOWN);
> +	input_set_capability(data->idev, EV_KEY, KEY_LEFT);
> +	input_set_capability(data->idev, EV_KEY, KEY_RIGHT);
> +	input_set_capability(data->idev, EV_KEY, KEY_ENTER);
> +	input_set_capability(data->idev, EV_KEY, KEY_BACK);
> +	input_set_capability(data->idev, EV_KEY, KEY_NEXT);
> +	input_set_capability(data->idev, EV_KEY, KEY_PREVIOUS);
> +	input_set_capability(data->idev, EV_KEY, KEY_MENU);
> +
> +	ret = input_register_device(data->idev);
> +	if (ret)
> +		goto err_reg;
> +
> +	pm_runtime_set_active(&client->dev);
> +	pm_runtime_enable(&client->dev);
> +	pm_runtime_set_autosuspend_delay(&client->dev, 2000);
> +	pm_runtime_use_autosuspend(&client->dev);
> +
> +	ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
> +					paj7620_irq_thread, IRQF_ONESHOT,
> +					"paj7620", data);
> +	if (ret)
> +		goto err_reg;
> +
> +	dev_info(&client->dev, "Gesture Sensor Initialized\n");

Pointless message, drop. Driver should be silent on success.


> +	return 0;
> +
> +err_reg:
> +	dev_err_probe(&client->dev, ret, "%s: failed with error %d\n", __func__, ret);

No, move it to individual errors, but only where applicable. For example
devm_request_threaded_irq() must not have it.

Neither devm_input_allocate_device.


> +	if (pm_runtime_enabled(&client->dev)) {
> +		pm_runtime_disable(&client->dev);
> +		pm_runtime_dont_use_autosuspend(&client->dev);
> +	}
> +	regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
> +	return ret;
> +}
> +
> +static void paj7620_remove(struct i2c_client *client)
> +{
> +	int ret;
> +	struct paj7620_data *data = i2c_get_clientdata(client);
> +
> +	pm_runtime_get_sync(&client->dev);
> +	pm_runtime_disable(&client->dev);
> +	pm_runtime_dont_use_autosuspend(&client->dev);
> +	pm_runtime_put_noidle(&client->dev);
> +
> +	ret = paj7620_power_down(data);
> +	if (ret)
> +		dev_err(&data->client->dev, "Sensor power down failed\n");
> +
> +	ret = regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
> +	if (ret)
> +		dev_err(&data->client->dev, "Sensor regulator disable failed\n");
> +}
> +
> +static const struct of_device_id paj7620_of_match[] = {
> +	{ .compatible = "pixart,paj7620" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, paj7620_of_match);
> +
> +static struct i2c_driver paj7620_driver = {
> +	.driver = {
> +		.name = "paj7620",
> +		.of_match_table = paj7620_of_match,
> +		.pm = &paj7620_pm_ops,
> +	},
> +	.probe = paj7620_probe,
> +	.remove = paj7620_remove,
> +};
> +module_i2c_driver(paj7620_driver);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Harpreet Saini");
> +MODULE_DESCRIPTION("PAJ7620 Gesture Input Driver");
> -- 
> 2.43.0
> 

^ permalink raw reply

* [PATCH] iio: magnetometer: hid-sensor-magn-3d: prefer 'unsigned int'
From: Joshua Crofts @ 2026-04-17 11:28 UTC (permalink / raw)
  To: jikos, jic23, srinivas.pandruvada
  Cc: dlechner, nuno.sa, andy, linux-input, linux-iio, linux-kernel,
	Joshua Crofts

Use 'unsigned int' instead of bare 'unsigned' to resolve checkpatch.pl
warnings and adhere to kernel coding style.

No functional change.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/hid-sensor-magn-3d.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index c673f9323e..67550f16a9 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -280,7 +280,7 @@ static const struct iio_info magn_3d_info = {
 
 /* Callback handler to send event after all samples are received and captured */
 static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
-				unsigned usage_id,
+				unsigned int usage_id,
 				void *priv)
 {
 	struct iio_dev *indio_dev = platform_get_drvdata(priv);
@@ -302,7 +302,7 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev,
 
 /* Capture samples in local storage */
 static int magn_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
-				unsigned usage_id,
+				unsigned int usage_id,
 				size_t raw_len, char *raw_data,
 				void *priv)
 {
@@ -350,7 +350,7 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 				struct hid_sensor_hub_device *hsdev,
 				struct iio_chan_spec **channels,
 				int *chan_count,
-				unsigned usage_id,
+				unsigned int usage_id,
 				struct magn_3d_state *st)
 {
 	int i;
-- 
2.47.3


^ permalink raw reply related

* Re: [PATCH] iio: magnetometer: hid-sensor-magn-3d: prefer 'unsigned int'
From: Andy Shevchenko @ 2026-04-17 11:33 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: jikos, jic23, srinivas.pandruvada, dlechner, nuno.sa, andy,
	linux-input, linux-iio, linux-kernel
In-Reply-To: <20260417112808.1280-1-joshua.crofts1@gmail.com>

On Fri, Apr 17, 2026 at 11:28:08AM +0000, Joshua Crofts wrote:
> Use 'unsigned int' instead of bare 'unsigned' to resolve checkpatch.pl
> warnings and adhere to kernel coding style.
> 
> No functional change.

Please, use the same types as defined in the respective data structure.
https://elixir.bootlin.com/linux/v7.0/source/include/linux/hid-sensor-hub.h#L87

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH] iio: magnetometer: hid-sensor-magn-3d: prefer 'unsigned int'
From: Joshua Crofts @ 2026-04-17 11:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: jikos, jic23, srinivas.pandruvada, dlechner, nuno.sa, andy,
	linux-input, linux-iio, linux-kernel
In-Reply-To: <aeIajr-NaBGdhvK9@ashevche-desk.local>

On Fri, 17 Apr 2026 at 13:33, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> Please, use the same types as defined in the respective data structure.
> https://elixir.bootlin.com/linux/v7.0/source/include/linux/hid-sensor-hub.h#L87

Fair enough, I'll send a version using u32 tomorrow.

-- 
Kind regards

CJD

^ permalink raw reply

* [PATCH] HID: playstation: Clamp num_touch_reports
From: T.J. Mercier @ 2026-04-17 15:47 UTC (permalink / raw)
  To: roderick.colenbrander, linux-input, Jiri Kosina,
	Benjamin Tissoires
  Cc: T.J. Mercier, stable, Xingyu Jin, Roderick Colenbrander,
	linux-kernel

A device would never lie about the number of touch reports would it?

If it does the loop in dualshock4_parse_report will read off the end of
the touch_reports array, up to about 2 KiB for the maximum number of 256
loop iteraions. The data that is read is emitted via evdev if the
DS4_TOUCH_POINT_INACTIVE bit happens to be set. Protect against this by
clamping the num_touch_reports value provided by the device to the
maximum size of the touch_reports array.

Fixes: 752038248808 ("HID: playstation: add DualShock4 touchpad support.")
Cc: stable@vger.kernel.org
Reported-by: Xingyu Jin <xingyuj@google.com>
Signed-off-by: T.J. Mercier <tjmercier@google.com>
---
 drivers/hid/hid-playstation.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 3c0db8f93c82..8d06ddff356a 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -2378,7 +2378,8 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report *
 			(struct dualshock4_input_report_usb *)data;
 
 		ds4_report = &usb->common;
-		num_touch_reports = usb->num_touch_reports;
+		num_touch_reports = min_t(u8, usb->num_touch_reports,
+					  ARRAY_SIZE(usb->touch_reports));
 		touch_reports = usb->touch_reports;
 	} else if (hdev->bus == BUS_BLUETOOTH && report->id == DS4_INPUT_REPORT_BT &&
 		   size == DS4_INPUT_REPORT_BT_SIZE) {
@@ -2392,7 +2393,8 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report *
 		}
 
 		ds4_report = &bt->common;
-		num_touch_reports = bt->num_touch_reports;
+		num_touch_reports = min_t(u8, bt->num_touch_reports,
+					  ARRAY_SIZE(bt->touch_reports));
 		touch_reports = bt->touch_reports;
 	} else if (hdev->bus == BUS_BLUETOOTH &&
 		   report->id == DS4_INPUT_REPORT_BT_MINIMAL &&

base-commit: 3cd8b194bf3428dfa53120fee47e827a7c495815
-- 
2.54.0.rc1.513.gad8abe7a5a-goog


^ permalink raw reply related

* Re: [PATCH v2 2/2] input: misc: Add PixArt PAJ7620 gesture sensor driver
From: Dmitry Torokhov @ 2026-04-17 21:24 UTC (permalink / raw)
  To: Harpreet Saini
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, David Lechner,
	devicetree, linux-input, linux-kernel
In-Reply-To: <20260417052527.62535-3-sainiharpreet29@yahoo.com>

Hi Harpreet,

On Fri, Apr 17, 2026 at 01:25:27AM -0400, Harpreet Saini wrote:
> This driver adds support for the PixArt PAJ7620 gesture sensor.
> It implements hand gesture recognition (up, down, left, right,
> etc.) and reports them as standard input key events. The driver
> includes power management support via Runtime PM.

Sashiko has identified a number of valid concerns, please address them.

Also consider:

- moving powering up and down the chip into open()/close() for input
  device
- getting keymap from device properties and allowing adjusting it from
  userspace vi EVIOCSKEYCODE
- no capitals in type names
- use 'error' instead of 'ret' for variables holding only error code
  or 0.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v4 1/6] dt-bindings: leds: leds-cpcap: convert to DT schema
From: Rob Herring (Arm) @ 2026-04-17 21:53 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: devicetree, Krzysztof Kozlowski, linux-input, Lee Jones,
	Dmitry Torokhov, Conor Dooley, David Lechner, Pavel Machek,
	Tony Lindgren, linux-leds, linux-kernel
In-Reply-To: <20260417071106.21984-2-clamor95@gmail.com>


On Fri, 17 Apr 2026 10:11:01 +0300, Svyatoslav Ryhel wrote:
> Convert LEDs devicetree bindings for the Motorola CPCAP MFD from TXT to
> YAML format. This patch does not change any functionality; the bindings
> remain the same.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  .../devicetree/bindings/leds/leds-cpcap.txt   | 29 -------------
>  .../bindings/leds/motorola,cpcap-leds.yaml    | 42 +++++++++++++++++++
>  2 files changed, 42 insertions(+), 29 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/leds/leds-cpcap.txt
>  create mode 100644 Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:


doc reference errors (make refcheckdocs):
Warning: Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Warning: Documentation/devicetree/bindings/mfd/motorola-cpcap.txt references a file that doesn't exist: Documentation/devicetree/bindings/leds/leds-cpcap.txt
Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt: Documentation/devicetree/bindings/leds/leds-cpcap.txt

See https://patchwork.kernel.org/project/devicetree/patch/20260417071106.21984-2-clamor95@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply

* Re: [PATCH v4 2/6] dt-bindings: input: cpcap-pwrbutton: convert to DT schema
From: Rob Herring (Arm) @ 2026-04-17 21:53 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Tony Lindgren, Pavel Machek, devicetree, David Lechner,
	linux-kernel, Conor Dooley, Dmitry Torokhov, Lee Jones,
	linux-input, linux-leds, Krzysztof Kozlowski
In-Reply-To: <20260417071106.21984-3-clamor95@gmail.com>


On Fri, 17 Apr 2026 10:11:02 +0300, Svyatoslav Ryhel wrote:
> Convert power button devicetree bindings for the Motorola CPCAP MFD from
> TXT to YAML format. This patch does not change any functionality; the
> bindings remain the same.
> 
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  .../bindings/input/cpcap-pwrbutton.txt        | 20 ------------
>  .../input/motorola,cpcap-pwrbutton.yaml       | 32 +++++++++++++++++++
>  2 files changed, 32 insertions(+), 20 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
>  create mode 100644 Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:


doc reference errors (make refcheckdocs):
Warning: Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Warning: Documentation/devicetree/bindings/mfd/motorola-cpcap.txt references a file that doesn't exist: Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt: Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt

See https://patchwork.kernel.org/project/devicetree/patch/20260417071106.21984-3-clamor95@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply

* [PATCH 0/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, linux-iio, linux-input

This patch series introduces a generic helper function to handle channel bit mask adjustments 
for HID sensors. Currently, multiple drivers implement identical logic for this task

Natália Salvino André (7):
  iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
  iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
  iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
  iio: light: HID: Replace method als_adjust_channel_bit_mask()
  iio: light: HID: Replace method prox_adjust_channel_bit_mask()
  iio: magnetometer: HID: Replace method
    magn_3d_adjust_channel_bit_mask()
  iio: pressure: HID: Replace method press_adjust_channel_bit_mask()

 drivers/iio/accel/hid-sensor-accel-3d.c             | 13 +------------
 .../iio/common/hid-sensors/hid-sensor-attributes.c  | 11 +++++++++++
 drivers/iio/gyro/hid-sensor-gyro-3d.c               | 13 +------------
 drivers/iio/light/hid-sensor-als.c                  | 13 +------------
 drivers/iio/light/hid-sensor-prox.c                 | 13 +------------
 drivers/iio/magnetometer/hid-sensor-magn-3d.c       | 13 +------------
 drivers/iio/pressure/hid-sensor-press.c             | 13 +------------
 include/linux/hid-sensor-hub.h                      |  3 +++
 8 files changed, 20 insertions(+), 72 deletions(-)

-- 
2.51.0


^ permalink raw reply

* [PATCH 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Add helper method to deduplicate code in HID sensors.

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 .../iio/common/hid-sensors/hid-sensor-attributes.c    | 11 +++++++++++
 include/linux/hid-sensor-hub.h                        |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index c115a72832b2..12728cfa5d44 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -589,6 +589,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
 }
 EXPORT_SYMBOL_NS(hid_sensor_parse_common_attributes, "IIO_HID");
 
+void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
+					int channel, int size)
+{
+	channels[channel].scan_type.sign = 's';
+	/* Real storage bits will change based on the report desc. */
+	channels[channel].scan_type.realbits = size * 8;
+	/* Maximum size of a sample to capture is u32 */
+	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
+}
+EXPORT_SYMBOL_NS(hid_sensor_adjust_channel_bit_mask, "IIO_HID");
+
 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
 MODULE_DESCRIPTION("HID Sensor common attribute processing");
 MODULE_LICENSE("GPL");
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index e71056553108..6523d46c63e0 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -281,4 +281,7 @@ bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st);
 int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency);
 int hid_sensor_get_report_latency(struct hid_sensor_common *st);
 
+void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
+					int channel, int size);
+
 #endif
-- 
2.51.0


^ permalink raw reply related

* [PATCH 2/7] iio: accel: HID: Replace method accel_3d_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method accel_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/accel/hid-sensor-accel-3d.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2ff591b3458f..75f93b52a926 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -119,17 +119,6 @@ static const struct iio_chan_spec gravity_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP),
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void accel_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-						int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int accel_3d_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -307,7 +296,7 @@ static int accel_3d_parse_report(struct platform_device *pdev,
 				&st->accel[CHANNEL_SCAN_INDEX_X + i]);
 		if (ret < 0)
 			break;
-		accel_3d_adjust_channel_bit_mask(channels,
+		hid_sensor_adjust_channel_bit_mask(channels,
 				CHANNEL_SCAN_INDEX_X + i,
 				st->accel[CHANNEL_SCAN_INDEX_X + i].size);
 	}
-- 
2.51.0


^ permalink raw reply related

* [PATCH 3/7] iio: gyro: HID: Replace method gyro_3d_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method gyro_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index c340cc899a7c..15704e05ad32 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -82,17 +82,6 @@ static const struct iio_chan_spec gyro_3d_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void gyro_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-						int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int gyro_3d_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -258,7 +247,7 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
 				&st->gyro[CHANNEL_SCAN_INDEX_X + i]);
 		if (ret < 0)
 			break;
-		gyro_3d_adjust_channel_bit_mask(channels,
+		hid_sensor_adjust_channel_bit_mask(channels,
 				CHANNEL_SCAN_INDEX_X + i,
 				st->gyro[CHANNEL_SCAN_INDEX_X + i].size);
 	}
-- 
2.51.0


^ permalink raw reply related

* [PATCH 4/7] iio: light: HID: Replace method als_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method als_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/light/hid-sensor-als.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 384572844162..16ef9a37aeae 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -117,17 +117,6 @@ static const struct iio_chan_spec als_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void als_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-					int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int als_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -335,7 +324,7 @@ static int als_parse_report(struct platform_device *pdev,
 
 		channels[index] = als_channels[i];
 		st->als_scan_mask[0] |= BIT(i);
-		als_adjust_channel_bit_mask(channels, index, st->als[i].size);
+		hid_sensor_adjust_channel_bit_mask(channels, index, st->als[i].size);
 		++index;
 
 		dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
-- 
2.51.0


^ permalink raw reply related

* [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method prox_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/light/hid-sensor-prox.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index efa904a70d0e..61f4627cffab 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -67,17 +67,6 @@ static const struct iio_chan_spec prox_channels[] = {
 	PROX_CHANNEL(false, 0),
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void prox_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-					int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int prox_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -250,7 +239,7 @@ static int prox_parse_report(struct platform_device *pdev,
 		st->scan_mask[0] |= BIT(index);
 		channels[index] = prox_channels[i];
 		channels[index].scan_index = index;
-		prox_adjust_channel_bit_mask(channels, index,
+		hid_sensor_adjust_channel_bit_mask(channels, index,
 					     st->prox_attr[index].size);
 		dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
 			st->prox_attr[index].report_id);
-- 
2.51.0


^ permalink raw reply related

* [PATCH 6/7] iio: magnetometer: HID: Replace method magn_3d_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method magn_3d_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/magnetometer/hid-sensor-magn-3d.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index c673f9323e47..48a968b3aebb 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -132,17 +132,6 @@ static const struct iio_chan_spec magn_3d_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(7)
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void magn_3d_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-						int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int magn_3d_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -418,7 +407,7 @@ static int magn_3d_parse_report(struct platform_device *pdev,
 			if (i != CHANNEL_SCAN_INDEX_TIMESTAMP) {
 				/* Set magn_val_addr to iio value address */
 				st->magn_val_addr[i] = &st->iio_vals[*chan_count];
-				magn_3d_adjust_channel_bit_mask(_channels,
+				hid_sensor_adjust_channel_bit_mask(_channels,
 								*chan_count,
 								st->magn[i].size);
 			}
-- 
2.51.0


^ permalink raw reply related

* [PATCH 7/7] iio: pressure: HID: Replace method press_adjust_channel_bit_mask()
From: Natália Salvino André @ 2026-04-17 22:58 UTC (permalink / raw)
  To: andy, bentiss, dlechner, jic23, jikos, nuno.sa,
	srinivas.pandruvada
  Cc: Natália Salvino André, Pietro Di Consolo Gregorio,
	linux-iio, linux-input
In-Reply-To: <20260417225959.16688-1-natalia.andre@ime.usp.br>

Replace method press_adjust_channel_bit_mask()
with helper method hid_sensor_adjust_channel_bit_mask().

Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
---
 drivers/iio/pressure/hid-sensor-press.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 5f1d6abda3e4..3d609436a85a 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -53,17 +53,6 @@ static const struct iio_chan_spec press_channels[] = {
 
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void press_adjust_channel_bit_mask(struct iio_chan_spec *channels,
-					int channel, int size)
-{
-	channels[channel].scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	channels[channel].scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
-}
-
 /* Channel read_raw handler */
 static int press_read_raw(struct iio_dev *indio_dev,
 			      struct iio_chan_spec const *chan,
@@ -225,7 +214,7 @@ static int press_parse_report(struct platform_device *pdev,
 			&st->press_attr);
 	if (ret < 0)
 		return ret;
-	press_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
+	hid_sensor_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_PRESSURE,
 					st->press_attr.size);
 
 	dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index,
-- 
2.51.0


^ permalink raw reply related

* [PATCH] HID: usbhid: sanitize hid->uniq against non-printable bytes
From: Taylor Hewetson @ 2026-04-18  2:58 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: linux-usb, linux-input, linux-kernel, Taylor Hewetson

Some USB HID devices (observed on ASUS ROG Azoth via its 2.4GHz
dongle, USB ID 0b05:1a85) report an iSerialNumber string whose
USB string descriptor declares a longer length than the actual
serial, leaving uninitialized firmware memory - including control
characters such as 0x18 - appended to the returned string.

These non-printable bytes propagate into hid->uniq, which in turn
populates /sys/class/input/inputN/uniq. Downstream userspace
components (systemd sd-device property_is_valid(), and by extension
mutter input enumeration on GNOME Wayland sessions) reject devices
with control characters in their uniq, rendering otherwise-
functional input devices unusable in graphical sessions despite
the kernel input layer correctly translating keypresses.

Truncate hid->uniq at the first byte outside the printable ASCII
range (0x20..0x7e) after the serial is read.

Signed-off-by: Taylor Hewetson <taylor@exponent.digital>
---
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1427,8 +1427,17 @@
 		snprintf(hid->phys + len, sizeof(hid->phys) - len,
 			 "%d", intf->altsetting[0].desc.bInterfaceNumber);
 
-	if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
+	if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) {
 		hid->uniq[0] = 0;
+	} else {
+		size_t i;
+		for (i = 0; i < sizeof(hid->uniq) && hid->uniq[i]; i++) {
+			if (hid->uniq[i] < 0x20 || hid->uniq[i] > 0x7e) {
+				hid->uniq[i] = 0;
+				break;
+			}
+		}
+	}
 
 	usbhid = kzalloc(sizeof(*usbhid), GFP_KERNEL);
 	if (usbhid == NULL) {

^ permalink raw reply

* [PATCH v3 1/2] dt-bindings: input: Add PixArt PAJ7620 gesture sensor
From: Harpreet Saini @ 2026-04-18  6:22 UTC (permalink / raw)
  To: Rob Herring, linux-input, devicetree, linux-kernel
  Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley
In-Reply-To: <20260418062241.104697-1-sainiharpreet29@yahoo.com>

Add Device Tree bindings for Pixart PAJ7620 gesture sensor.
The sensor supports 9 hand gestures via I2C interface.

The binding include mandatory power supplies (vdd, vbus, vled)
and optional GPIO controller properties to describe the hardware's
ability to repurpose SPI pins opeating in I2C mode.

Signed-off-by: Harpreet Saini <sainiharpreet29@yahoo.com>
---
 .../bindings/input/pixart,paj7620.yaml        | 79 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 2 files changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/pixart,paj7620.yaml

diff --git a/Documentation/devicetree/bindings/input/pixart,paj7620.yaml b/Documentation/devicetree/bindings/input/pixart,paj7620.yaml
new file mode 100644
index 000000000000..ad051cf641a6
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/pixart,paj7620.yaml
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/pixart,paj7620.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PixArt PAJ7620 Gesture Sensor
+
+maintainers:
+  - Harpreet Saini <sainiharpreet29@yahoo.com>
+
+description: |
+  The PixArt PAJ7620 is a gesture recognition sensor with an integrated
+  infrared LED and CMOS array. It communicates over an I2C interface and
+  provides gesture data via a dedicated interrupt pin.
+
+properties:
+  compatible:
+    const: pixart,paj7620
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  vdd-supply:
+    description: Main power supply.
+
+  vbus-supply:
+    description: I/O and I2C bus power supply.
+
+  vled-supply:
+    description: Power for the integrated IR LED.
+
+  linux,keycodes:
+    minItems: 9
+    maxItems: 9
+    description: |
+      List of keycodes mapping to the 9 supported gestures.
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - vdd-supply
+  - vbus-supply
+  - vled-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/input.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        gesture@73 {
+            compatible = "pixart,paj7620";
+            reg = <0x73>;
+            interrupt-parent = <&gpio>;
+            interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
+            vdd-supply = <&reg_3v3>;
+            vbus-supply = <&reg_1v8>;
+            vled-supply = <&reg_3v3>;
+            linux,keycodes = <KEY_UP KEY_DOWN KEY_LEFT KEY_RIGHT
+                             KEY_ENTER KEY_BACK KEY_NEXT KEY_PREVIOUS
+                             KEY_MENU>;
+            gpio-controller;
+            #gpio-cells = <2>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index ee7fd3cfe203..d73a0bf62b62 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1273,6 +1273,8 @@ patternProperties:
     description: Pine64
   "^pineriver,.*":
     description: Shenzhen PineRiver Designs Co., Ltd.
+  "^pixart,.*":
+    description: PixArt Imaging Inc.
   "^pixcir,.*":
     description: PIXCIR MICROELECTRONICS Co., Ltd
   "^plantower,.*":
-- 
2.43.0


^ permalink raw reply related

* [PATCH v3 0/2] Add PixArt PAJ7620 gesture sensor support
From: Harpreet Saini @ 2026-04-18  6:22 UTC (permalink / raw)
  To: Rob Herring, linux-input, devicetree, linux-kernel
  Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley
In-Reply-To: <20260418062241.104697-1-sainiharpreet29.ref@yahoo.com>

This series adds support for the PixArt PAJ7620 gesture sensor.
The first patch provides the DT bindings, and the second patch
implements the input driver.

Changes in v3:
- Moved sensor power-up and paj7620_init() to input open/close 
  callbacks
- Implemented dynamic keymap support via 'linux,keycodes' DT property
  and enabled userspace adjustment via EVIOCSKEYCODE.
- Updated YAML bindings to include mandatory vdd, vbus, and vled
  supplies.
- Added gpio-controller properties to YAML for hardware completeness.
- Verified with dt_binding_check and checkpatch.pl --strict.

Harpreet Saini (2):
  dt-bindings: input: Add PixArt PAJ7620 gesture sensor
  input: misc: Add PixArt PAJ7620 gesture sensor driver

 .../bindings/input/pixart,paj7620.yaml        |  79 ++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/input/misc/Kconfig                    |  12 +
 drivers/input/misc/Makefile                   |   1 +
 drivers/input/misc/paj7620.c                  | 338 ++++++++++++++++++
 5 files changed, 432 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/
 pixart,paj7620.yaml
 create mode 100644 drivers/input/misc/paj7620.c

-- 
2.43.0


^ permalink raw reply

* [PATCH v3 2/2] input: misc: Add PixArt PAJ7620 gesture sensor driver
From: Harpreet Saini @ 2026-04-18  6:22 UTC (permalink / raw)
  To: Rob Herring, linux-input, devicetree, linux-kernel
  Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley
In-Reply-To: <20260418062241.104697-1-sainiharpreet29@yahoo.com>

This driver adds support for the PixArt PAJ7620 gesture sensor.
It implements hand gesture recognition (up, down, left, right,
etc.) and reports them as standard input key events. The driver
includes power management support via Runtime PM.

Signed-off-by: Harpreet Saini <sainiharpreet29@yahoo.com>
---
 drivers/input/misc/Kconfig   |  12 ++
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/paj7620.c | 338 +++++++++++++++++++++++++++++++++++
 3 files changed, 351 insertions(+)
 create mode 100644 drivers/input/misc/paj7620.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 94a753fcb64f..de4206c297f2 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -453,6 +453,18 @@ config INPUT_KXTJ9
 	  To compile this driver as a module, choose M here: the module will
 	  be called kxtj9.
 
+config INPUT_PAJ7620
+	tristate "PixArt PAJ7620 Gesture Sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y here if you want to support the PixArt PAJ7620 gesture
+	  sensor. This sensor supports 9 hand gestures and communicates
+	  over the I2C bus.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called paj7620.
+
 config INPUT_POWERMATE
 	tristate "Griffin PowerMate and Contour Jog support"
 	depends on USB_ARCH_HAS_HCD
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 415fc4e2918b..dec8b8d0cdf4 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_INPUT_PF1550_ONKEY)	+= pf1550-onkey.o
 obj-$(CONFIG_INPUT_PM8941_PWRKEY)	+= pm8941-pwrkey.o
 obj-$(CONFIG_INPUT_PM8XXX_VIBRATOR)	+= pm8xxx-vibrator.o
 obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)	+= pmic8xxx-pwrkey.o
+obj-$(CONFIG_INPUT_PAJ7620) 		+= paj7620.o
 obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_PWM_VIBRA)		+= pwm-vibra.o
diff --git a/drivers/input/misc/paj7620.c b/drivers/input/misc/paj7620.c
new file mode 100644
index 000000000000..8738c174bcc1
--- /dev/null
+++ b/drivers/input/misc/paj7620.c
@@ -0,0 +1,338 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * PixArt PAJ7620 Gesture Sensor - Input driver
+ *
+ * Copyright (C) 2026 Harpreet Saini <sainiharpreet29@yahoo.com>
+ */
+
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+
+/* Registers */
+#define PAJ7620_REG_BANK_SEL        0xEF
+#define PAJ7620_REG_GES_RESULT1     0x43
+#define PAJ7620_REG_GES_RESULT2     0x44
+#define PAJ7620_REG_SLEEP_BANK0     0x65
+#define PAJ7620_REG_SLEEP_BANK1     0x05
+#define PAJ7620_REG_AUTO_STANDBY    0x073
+
+/* Gesture bits */
+#define PAJ_UP           BIT(0)
+#define PAJ_DOWN         BIT(1)
+#define PAJ_LEFT         BIT(2)
+#define PAJ_RIGHT        BIT(3)
+#define PAJ_FORWARD      BIT(4)
+#define PAJ_BACKWARD     BIT(5)
+#define PAJ_CLOCKWISE    BIT(6)
+#define PAJ_ANTICLOCK    BIT(7)
+#define PAJ_WAVE         BIT(8)
+#define PAJ_MAX_GESTURES 9
+
+struct paj7620_data {
+	struct i2c_client *client;
+	struct regmap *regmap;
+	struct input_dev *idev;
+	struct regulator_bulk_data supplies[3];
+	u32 keymap[PAJ_MAX_GESTURES];
+};
+
+/*
+ * The following arrays contain undocumented register sequences required to
+ * initialize the sensor's internal DSP and gesture engine.
+ * These were derived from vendor reference code and verified via testing.
+ */
+static const struct reg_sequence init_register[] = {
+	{ 0xEF, 0x00 }, { 0x37, 0x07 }, { 0x38, 0x17 }, { 0x39, 0x06 },
+	{ 0x41, 0x00 }, { 0x42, 0x00 }, { 0x46, 0x2D }, { 0x47, 0x0F },
+	{ 0x48, 0x3C }, { 0x49, 0x00 }, { 0x4A, 0x1E }, { 0x4C, 0x20 },
+	{ 0x51, 0x10 }, { 0x5E, 0x10 }, { 0x60, 0x27 }, { 0x80, 0x42 },
+	{ 0x81, 0x44 }, { 0x82, 0x04 }, { 0x8B, 0x01 }, { 0x90, 0x06 },
+	{ 0x95, 0x0A }, { 0x96, 0x0C }, { 0x97, 0x05 }, { 0x9A, 0x14 },
+	{ 0x9C, 0x3F }, { 0xA5, 0x19 }, { 0xCC, 0x19 }, { 0xCD, 0x0B },
+	{ 0xCE, 0x13 }, { 0xCF, 0x64 }, { 0xD0, 0x21 }, { 0xEF, 0x01 },
+	{ 0x02, 0x0F }, { 0x03, 0x10 }, { 0x04, 0x02 }, { 0x25, 0x01 },
+	{ 0x27, 0x39 }, { 0x28, 0x7F }, { 0x29, 0x08 }, { 0x3E, 0xFF },
+	{ 0x5E, 0x3D }, { 0x65, 0x96 }, { 0x67, 0x97 }, { 0x69, 0xCD },
+	{ 0x6A, 0x01 }, { 0x6D, 0x2C }, { 0x6E, 0x01 }, { 0x72, 0x01 },
+	{ 0x73, 0x35 }, { 0x74, 0x00 }, { 0x77, 0x01 },
+};
+
+/*
+ * Specific configuration overrides required to enable the internal
+ * 8-gesture state machine.
+ */
+static const struct reg_sequence init_gesture_array[] = {
+	{ 0xEF, 0x00 }, { 0x41, 0x00 }, { 0x42, 0x00 }, { 0xEF, 0x00 },
+	{ 0x48, 0x3C }, { 0x49, 0x00 }, { 0x51, 0x10 }, { 0x83, 0x20 },
+	{ 0x9F, 0xF9 }, { 0xEF, 0x01 }, { 0x01, 0x1E }, { 0x02, 0x0F },
+	{ 0x03, 0x10 }, { 0x04, 0x02 }, { 0x41, 0x40 }, { 0x43, 0x30 },
+	{ 0x65, 0x96 }, { 0x66, 0x00 }, { 0x67, 0x97 }, { 0x68, 0x01 },
+	{ 0x69, 0xCD }, { 0x6A, 0x01 }, { 0x6B, 0xB0 }, { 0x6C, 0x04 },
+	{ 0x6D, 0x2C }, { 0x6E, 0x01 }, { 0x74, 0x00 }, { 0xEF, 0x00 },
+	{ 0x41, 0xFF }, { 0x42, 0x01 },
+};
+
+static const struct reg_sequence paj7620_suspend_regs[] = {
+	{ PAJ7620_REG_BANK_SEL, 0x00 },
+	{ PAJ7620_REG_SLEEP_BANK0, 0x01 },
+	{ PAJ7620_REG_BANK_SEL, 0x01 },
+	{ PAJ7620_REG_SLEEP_BANK1, 0x01 },
+};
+
+static void paj7620_report_keys(struct paj7620_data *data, int gesture)
+{
+	int i;
+
+	for (i = 0; i < PAJ_MAX_GESTURES; i++) {
+		if (gesture & BIT(i)) {
+			int key = data->keymap[i];
+
+			input_report_key(data->idev, key, 1);
+			input_sync(data->idev);
+			input_report_key(data->idev, key, 0);
+			input_sync(data->idev);
+		}
+	}
+}
+
+static irqreturn_t paj7620_irq_thread(int irq, void *ptr)
+{
+	struct paj7620_data *data = ptr;
+	unsigned int g1, g2;
+	int error;
+
+	/* 2. RUNTIME PM: Force awake to read registers */
+	pm_runtime_get_sync(&data->client->dev);
+
+	regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0);
+	error = regmap_read(data->regmap, PAJ7620_REG_GES_RESULT1, &g1);
+	error |= regmap_read(data->regmap, PAJ7620_REG_GES_RESULT2, &g2);
+
+	if (!error && (g1 || g2))
+		paj7620_report_keys(data, (g2 << 8) | g1);
+
+	pm_runtime_mark_last_busy(&data->client->dev);
+	pm_runtime_put_autosuspend(&data->client->dev);
+
+	return IRQ_HANDLED;
+}
+
+static int paj7620_init(struct paj7620_data *data)
+{
+	int state = 0, error, i;
+
+	/* 1. Wake-up sequence: Read register 0x00 until it returns 0x20 */
+	for (i = 0; i < 10; i++) {
+		error = regmap_read(data->regmap, 0x00, &state);
+		if (error >= 0 && state == 0x20)
+			break;
+		usleep_range(1000, 2000);
+	}
+
+	if (state != 0x20) {
+		dev_err(&data->client->dev, "Sensor wake-up failed (0x%02x)\n", state);
+		return -ENODEV;
+	}
+
+	/* 2. Blast full register array into PAJ7620 instantly */
+	error = regmap_multi_reg_write(data->regmap, init_register,
+				       ARRAY_SIZE(init_register));
+	if (error < 0) {
+		dev_err(&data->client->dev, "Multi-reg write failed (%d)\n", error);
+		return error;
+	}
+
+	error = regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0x00);
+	if (error < 0)
+		return error;
+
+	error = regmap_multi_reg_write(data->regmap, init_gesture_array,
+				       ARRAY_SIZE(init_gesture_array));
+	if (error < 0) {
+		dev_err(&data->client->dev, "Multi-reg write failed (%d)\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int paj7620_input_open(struct input_dev *idev)
+{
+	int error;
+	struct paj7620_data *data = input_get_drvdata(idev);
+
+	error = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies);
+	if (error)
+		return error;
+
+	error = paj7620_init(data);
+	if (error) {
+		regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
+		return error;
+	}
+
+	return 0;
+}
+
+static void paj7620_input_close(struct input_dev *idev)
+{
+	struct paj7620_data *data = input_get_drvdata(idev);
+
+	regmap_multi_reg_write(data->regmap, paj7620_suspend_regs,
+			       ARRAY_SIZE(paj7620_suspend_regs));
+
+	regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
+}
+
+static int paj7620_runtime_suspend(struct device *dev)
+{
+	int error;
+	struct paj7620_data *data = dev_get_drvdata(dev);
+
+	error = regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0x01);
+	if (error)
+		return error;
+
+	error = regmap_write(data->regmap, PAJ7620_REG_AUTO_STANDBY, 0x30);
+	if (error)
+		return error;
+
+	return 0;
+}
+
+static int paj7620_runtime_resume(struct device *dev)
+{
+	int error;
+	struct paj7620_data *data = dev_get_drvdata(dev);
+
+	error = regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0x01);
+	if (error)
+		return error;
+
+	error = regmap_write(data->regmap, PAJ7620_REG_AUTO_STANDBY, 0x00);
+	if (error)
+		return error;
+
+	error = regmap_write(data->regmap, PAJ7620_REG_BANK_SEL, 0x00);
+	if (error)
+		return error;
+
+	usleep_range(1000, 2000);	// Stabilization delay (1ms minimum)
+	return 0;
+}
+
+static const struct dev_pm_ops paj7620_pm_ops = {
+	SET_RUNTIME_PM_OPS(paj7620_runtime_suspend, paj7620_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+};
+
+static const struct regmap_config paj7620_reg_config = {
+	.reg_bits = 8, .val_bits = 8, .max_register = 0xEF,
+};
+
+static void paj7620_disable_pm(void *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_dont_use_autosuspend(dev);
+}
+
+static int paj7620_probe(struct i2c_client *client)
+{
+	struct paj7620_data *data;
+	int error, i;
+
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->client = client;
+	i2c_set_clientdata(client, data);
+
+	data->supplies[0].supply = "vdd";
+	data->supplies[1].supply = "vbus";
+	data->supplies[2].supply = "vled";
+
+	error = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->supplies), data->supplies);
+	if (error)
+		return dev_err_probe(&client->dev, error, "Failed to get regulators\n");
+
+	error = device_property_read_u32_array(&client->dev, "linux,keycodes",
+					       data->keymap, ARRAY_SIZE(data->keymap));
+
+	if (error) {
+		data->keymap[0] = KEY_UP;
+		data->keymap[1] = KEY_DOWN;
+		data->keymap[2] = KEY_LEFT;
+		data->keymap[3] = KEY_RIGHT;
+		data->keymap[4] = KEY_ENTER;
+		data->keymap[5] = KEY_BACK;
+		data->keymap[6] = KEY_NEXT;
+		data->keymap[7] = KEY_PREVIOUS;
+		data->keymap[8] = KEY_MENU;
+	}
+
+	data->regmap = devm_regmap_init_i2c(client, &paj7620_reg_config);
+	if (IS_ERR(data->regmap))
+		return PTR_ERR(data->regmap);
+
+	data->idev = devm_input_allocate_device(&client->dev);
+	if (!data->idev)
+		return -ENOMEM;
+
+	data->idev->name = "PAJ7620 Gesture Sensor";
+	data->idev->id.bustype = BUS_I2C;
+	data->idev->open = paj7620_input_open;
+	data->idev->close = paj7620_input_close;
+	data->idev->keycode = data->keymap;
+	data->idev->keycodemax = ARRAY_SIZE(data->keymap);
+	data->idev->keycodesize = sizeof(u32);
+
+	for (i = 0; i < ARRAY_SIZE(data->keymap); i++)
+		input_set_capability(data->idev, EV_KEY, data->keymap[i]);
+
+	input_set_drvdata(data->idev, data);
+
+	error = input_register_device(data->idev);
+	if (error)
+		return error;
+
+	pm_runtime_set_active(&client->dev);
+	pm_runtime_enable(&client->dev);
+	pm_runtime_set_autosuspend_delay(&client->dev, 2000);
+	pm_runtime_use_autosuspend(&client->dev);
+
+	error = devm_add_action_or_reset(&client->dev, paj7620_disable_pm, &client->dev);
+	if (error)
+		return error;
+
+	return devm_request_threaded_irq(&client->dev, client->irq,
+									 NULL, paj7620_irq_thread,
+									 IRQF_ONESHOT, "paj7620",
+									 data);
+}
+
+static const struct of_device_id paj7620_of_match[] = {
+	{ .compatible = "pixart,paj7620" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, paj7620_of_match);
+
+static struct i2c_driver paj7620_driver = {
+	.driver = {
+		.name = "paj7620",
+		.of_match_table = paj7620_of_match,
+		.pm = &paj7620_pm_ops,
+	},
+	.probe = paj7620_probe,
+};
+module_i2c_driver(paj7620_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Harpreet Saini");
+MODULE_DESCRIPTION("PAJ7620 Gesture Input Driver");
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH] HID: usbhid: sanitize hid->uniq against non-printable bytes
From: Greg KH @ 2026-04-18  7:14 UTC (permalink / raw)
  To: Taylor Hewetson
  Cc: Jiri Kosina, Benjamin Tissoires, linux-usb, linux-input,
	linux-kernel
In-Reply-To: <20260418025823.21767-1-taylor@exponent.digital>

On Sat, Apr 18, 2026 at 02:58:23PM +1200, Taylor Hewetson wrote:
> Some USB HID devices (observed on ASUS ROG Azoth via its 2.4GHz
> dongle, USB ID 0b05:1a85) report an iSerialNumber string whose
> USB string descriptor declares a longer length than the actual
> serial, leaving uninitialized firmware memory - including control
> characters such as 0x18 - appended to the returned string.
> 
> These non-printable bytes propagate into hid->uniq, which in turn
> populates /sys/class/input/inputN/uniq. Downstream userspace
> components (systemd sd-device property_is_valid(), and by extension
> mutter input enumeration on GNOME Wayland sessions) reject devices
> with control characters in their uniq, rendering otherwise-
> functional input devices unusable in graphical sessions despite
> the kernel input layer correctly translating keypresses.
> 
> Truncate hid->uniq at the first byte outside the printable ASCII
> range (0x20..0x7e) after the serial is read.

Why aren't we doing this in the USB core instead of forcing all users of
this to do it instead?

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 1/7] iio: HID: Add helper method hid_sensor_adjust_channel_bit_mask()
From: David Lechner @ 2026-04-18 16:32 UTC (permalink / raw)
  To: Natália Salvino André, andy, bentiss, jic23, jikos,
	nuno.sa, srinivas.pandruvada
  Cc: Pietro Di Consolo Gregorio, linux-iio, linux-input
In-Reply-To: <20260417225959.16688-2-natalia.andre@ime.usp.br>

On 4/17/26 5:58 PM, Natália Salvino André wrote:
> Add helper method to deduplicate code in HID sensors.
> 
> Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
> Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> ---
>  .../iio/common/hid-sensors/hid-sensor-attributes.c    | 11 +++++++++++
>  include/linux/hid-sensor-hub.h                        |  3 +++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> index c115a72832b2..12728cfa5d44 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> @@ -589,6 +589,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
>  }
>  EXPORT_SYMBOL_NS(hid_sensor_parse_common_attributes, "IIO_HID");
>  
> +void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
> +					int channel, int size)
> +{
> +	channels[channel].scan_type.sign = 's';

We recently renamed the `sign` field to `format`, so it would be nice
to use the new name in new code. (If it is already used in this file,
make a precursor patch to do the rename of existing ones first.)

> +	/* Real storage bits will change based on the report desc. */
> +	channels[channel].scan_type.realbits = size * 8;

There is a BITS_PER_BYTE macro that would make sense here.

> +	/* Maximum size of a sample to capture is u32 */
> +	channels[channel].scan_type.storagebits = sizeof(u32) * 8;

and here.

> +}
> +EXPORT_SYMBOL_NS(hid_sensor_adjust_channel_bit_mask, "IIO_HID");
> +
>  MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
>  MODULE_DESCRIPTION("HID Sensor common attribute processing");
>  MODULE_LICENSE("GPL");
> diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
> index e71056553108..6523d46c63e0 100644
> --- a/include/linux/hid-sensor-hub.h
> +++ b/include/linux/hid-sensor-hub.h
> @@ -281,4 +281,7 @@ bool hid_sensor_batch_mode_supported(struct hid_sensor_common *st);
>  int hid_sensor_set_report_latency(struct hid_sensor_common *st, int latency);
>  int hid_sensor_get_report_latency(struct hid_sensor_common *st);
>  
> +void hid_sensor_adjust_channel_bit_mask(struct iio_chan_spec *channels,
> +					int channel, int size);
> +
>  #endif


^ permalink raw reply

* Re: [PATCH 5/7] iio: light: HID: Replace method prox_adjust_channel_bit_mask()
From: David Lechner @ 2026-04-18 16:34 UTC (permalink / raw)
  To: Natália Salvino André, andy, bentiss, jic23, jikos,
	nuno.sa, srinivas.pandruvada
  Cc: Pietro Di Consolo Gregorio, linux-iio, linux-input
In-Reply-To: <20260417225959.16688-6-natalia.andre@ime.usp.br>

On 4/17/26 5:58 PM, Natália Salvino André wrote:
> Replace method prox_adjust_channel_bit_mask()
> with helper method hid_sensor_adjust_channel_bit_mask().
> 
> Signed-off-by: Natália Salvino André <natalia.andre@ime.usp.br>
> Co-developed-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> Signed-off-by: Pietro Di Consolo Gregorio <pietro.gregorio@usp.br>
> ---
>  drivers/iio/light/hid-sensor-prox.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
> index efa904a70d0e..61f4627cffab 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
> @@ -67,17 +67,6 @@ static const struct iio_chan_spec prox_channels[] = {
>  	PROX_CHANNEL(false, 0),
>  };
>  
> -/* Adjust channel real bits based on report descriptor */
> -static void prox_adjust_channel_bit_mask(struct iio_chan_spec *channels,
> -					int channel, int size)
> -{
> -	channels[channel].scan_type.sign = 's';
> -	/* Real storage bits will change based on the report desc. */
> -	channels[channel].scan_type.realbits = size * 8;
> -	/* Maximum size of a sample to capture is u32 */
> -	channels[channel].scan_type.storagebits = sizeof(u32) * 8;
> -}
> -
>  /* Channel read_raw handler */
>  static int prox_read_raw(struct iio_dev *indio_dev,
>  			      struct iio_chan_spec const *chan,
> @@ -250,7 +239,7 @@ static int prox_parse_report(struct platform_device *pdev,
>  		st->scan_mask[0] |= BIT(index);
>  		channels[index] = prox_channels[i];
>  		channels[index].scan_index = index;
> -		prox_adjust_channel_bit_mask(channels, index,
> +		hid_sensor_adjust_channel_bit_mask(channels, index,
>  					     st->prox_attr[index].size);

Make sure to fix the alignment with `(`. Check the other patches too.

If it makes the line too long, just use one tab indent more than the previous line.

>  		dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index,
>  			st->prox_attr[index].report_id);


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox