Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH 07/10] Input: stmfts - add optional reset GPIO support
From: Krzysztof Kozlowski @ 2026-03-02 11:17 UTC (permalink / raw)
  To: Konrad Dybcio, david, Dmitry Torokhov, Maxime Coquelin,
	Alexandre Torgue, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Henrik Rydberg, Bjorn Andersson, Konrad Dybcio
  Cc: Petr Hodina, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel, devicetree, linux-arm-msm, phone-devel
In-Reply-To: <5d3694c6-57e7-4943-8dbb-41334086e8ec@oss.qualcomm.com>

On 02/03/2026 12:04, Konrad Dybcio wrote:
> On 3/1/26 6:51 PM, David Heidelberg via B4 Relay wrote:
>> From: Petr Hodina <petr.hodina@protonmail.com>
>>
>> Add support for an optional "reset-gpios" property. If present, the
>> driver drives the reset line high at probe time and releases it during
>> power-on, after the regulators have been enabled.
>>
>> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
>> Co-developed-by: David Heidelberg <david@ixit.cz>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
> 
> [...]
> 
>> +	sdata->reset_gpio = devm_gpiod_get_optional(dev, "reset",
>> +						    GPIOD_OUT_HIGH);
> 
> Are you really sure the reset is active-high?

This is not choice of ACTIVE HIGH here. It's initialization to logical
level to keep device in reset state.

Best regards,
Krzysztof

^ permalink raw reply

* Re: [PATCH 10/10] arm64: dts: qcom: sdm845-google: Add STM FTS touchscreen support
From: Konrad Dybcio @ 2026-03-02 11:06 UTC (permalink / raw)
  To: david, Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Henrik Rydberg,
	Bjorn Andersson, Konrad Dybcio
  Cc: Petr Hodina, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel, Krzysztof Kozlowski, devicetree, linux-arm-msm,
	phone-devel
In-Reply-To: <20260301-stmfts5-v1-10-22c458b9ac68@ixit.cz>

On 3/1/26 6:51 PM, David Heidelberg via B4 Relay wrote:
> From: Petr Hodina <petr.hodina@protonmail.com>
> 
> Basic touchscreen connected to second i2c bus.
> 
> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
> Co-developed-by: David Heidelberg <david@ixit.cz>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>  arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts b/arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts
> index fa89be500fb85..2501104b06e1b 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-google-blueline.dts
> @@ -26,7 +26,26 @@ &i2c2 {
>  
>  	status = "okay";
>  
> -	/* ST,FTS @ 49 */
> +	touchscreen@49 {
> +		compatible = "st,stmfts5";
> +		reg = <0x49>;
> +
> +		pinctrl-0 = <&touchscreen_pins &touchscreen_reset>;
> +		pinctrl-names = "default";
> +
> +		interrupt-parent = <&tlmm>;
> +		interrupts = <125 IRQ_TYPE_LEVEL_LOW>;
> +
> +		irq-gpios = <&tlmm 125 GPIO_ACTIVE_HIGH>;

This is an anti-pattern - you can translate the GPIO handle to an
IRQ handle, but unless the hardware is spectacularly odd, an interrupt
reference is usually what you're after

> +		switch-gpios = <&tlmm 136 GPIO_ACTIVE_HIGH>;
> +		reset-gpios = <&tlmm 99 GPIO_ACTIVE_LOW>;
> +
> +		avdd-supply = <&vreg_l14a_1p8>;
> +		vdd-supply = <&vreg_l19a_3p3>;
> +
> +		touchscreen-size-x = <1079>;
> +		touchscreen-size-y = <2159>;

Are you sure about these off-by-ones?

FWIW

input/touchscreen.c:

touchscreen_get_prop_u32(dev, "touchscreen-size-x",
                         input_abs_get_max(input,
                                           axis_x) + 1,

				            notice ^

Konrad

^ permalink raw reply

* Re: [PATCH 07/10] Input: stmfts - add optional reset GPIO support
From: Konrad Dybcio @ 2026-03-02 11:04 UTC (permalink / raw)
  To: david, Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Henrik Rydberg,
	Bjorn Andersson, Konrad Dybcio
  Cc: Petr Hodina, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel, Krzysztof Kozlowski, devicetree, linux-arm-msm,
	phone-devel
In-Reply-To: <20260301-stmfts5-v1-7-22c458b9ac68@ixit.cz>

On 3/1/26 6:51 PM, David Heidelberg via B4 Relay wrote:
> From: Petr Hodina <petr.hodina@protonmail.com>
> 
> Add support for an optional "reset-gpios" property. If present, the
> driver drives the reset line high at probe time and releases it during
> power-on, after the regulators have been enabled.
> 
> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
> Co-developed-by: David Heidelberg <david@ixit.cz>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---

[...]

> +	sdata->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> +						    GPIOD_OUT_HIGH);

Are you really sure the reset is active-high?

Konrad

^ permalink raw reply

* [PATCH v4 4/4] arm64: dts: qcom: milos-fairphone-fp6: Add vibrator support
From: Griffin Kroah-Hartman @ 2026-03-02 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Bjorn Andersson, Konrad Dybcio, Luca Weiss
  Cc: linux-input, devicetree, linux-kernel, linux-arm-msm,
	Griffin Kroah-Hartman, Dmitry Baryshkov, Konrad Dybcio
In-Reply-To: <20260302-aw86938-driver-v4-0-92c865df9cca@fairphone.com>

Add the required node for haptic playback (Awinic AW86938)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
---
 arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts | 26 +++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts b/arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts
index 52895dd9e4fa117aef6822df230ebf644e5f02ba..324d18d9900881a840806ada84e33fe9664296a0 100644
--- a/arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts
+++ b/arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts
@@ -625,7 +625,17 @@ vreg_l7p: ldo7 {
 	};
 
 	/* VL53L3 ToF @ 0x29 */
-	/* AW86938FCR vibrator @ 0x5a */
+
+	vibrator@5a {
+		compatible = "awinic,aw86938", "awinic,aw86927";
+		reg = <0x5a>;
+
+		interrupts-extended = <&tlmm 80 IRQ_TYPE_EDGE_FALLING>;
+		reset-gpios = <&tlmm 78 GPIO_ACTIVE_LOW>;
+
+		pinctrl-0 = <&aw86938_int_default>, <&aw86938_reset_default>;
+		pinctrl-names = "default";
+	};
 };
 
 &pm8550vs_c {
@@ -755,6 +765,20 @@ sdc2_card_det_n: sdc2-card-det-state {
 		bias-pull-up;
 	};
 
+	aw86938_reset_default: aw86938-reset-default-state {
+		pins = "gpio78";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-pull-down;
+	};
+
+	aw86938_int_default: aw86938-int-default-state {
+		pins = "gpio80";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-pull-up;
+	};
+
 	pm8008_int_default: pm8008-int-default-state {
 		pins = "gpio125";
 		function = "gpio";

-- 
2.43.0


^ permalink raw reply related

* [PATCH v4 3/4] Input: aw86938 - add driver for Awinic AW86938
From: Griffin Kroah-Hartman @ 2026-03-02 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Bjorn Andersson, Konrad Dybcio, Luca Weiss
  Cc: linux-input, devicetree, linux-kernel, linux-arm-msm,
	Griffin Kroah-Hartman
In-Reply-To: <20260302-aw86938-driver-v4-0-92c865df9cca@fairphone.com>

Add support for the I2C-connected Awinic AW86938 LRA haptic driver.

The AW86938 has a similar but slightly different register layout. In
particular, the boost mode register values.
The AW86938 also has some extra features that aren't implemented
in this driver yet.

Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
---
 drivers/input/misc/aw86927.c | 52 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 7f8cadda7c456d7b5448d1e23edf6e3f2918ba32..e59b958fac1a1144307cb216560f522485ad26e9 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -43,6 +43,12 @@
 #define AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK	GENMASK(6, 0)
 #define AW86927_PLAYCFG1_BST_8500MV		0x50
 
+#define AW86938_PLAYCFG1_REG			0x06
+#define AW86938_PLAYCFG1_BST_MODE_MASK		GENMASK(5, 5)
+#define AW86938_PLAYCFG1_BST_MODE_BYPASS	0
+#define AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK	GENMASK(4, 0)
+#define AW86938_PLAYCFG1_BST_7000MV		0x11
+
 #define AW86927_PLAYCFG2_REG			0x07
 
 #define AW86927_PLAYCFG3_REG			0x08
@@ -140,6 +146,7 @@
 #define AW86927_CHIPIDH_REG			0x57
 #define AW86927_CHIPIDL_REG			0x58
 #define AW86927_CHIPID				0x9270
+#define AW86938_CHIPID				0x9380
 
 #define AW86927_TMCFG_REG			0x5b
 #define AW86927_TMCFG_UNLOCK			0x7d
@@ -173,7 +180,13 @@ enum aw86927_work_mode {
 	AW86927_RAM_MODE,
 };
 
+enum aw86927_model {
+	AW86927,
+	AW86938,
+};
+
 struct aw86927_data {
+	enum aw86927_model model;
 	struct work_struct play_work;
 	struct device *dev;
 	struct input_dev *input_dev;
@@ -565,13 +578,26 @@ static int aw86927_haptic_init(struct aw86927_data *haptics)
 	if (err)
 		return err;
 
-	err = regmap_update_bits(haptics->regmap,
-				 AW86927_PLAYCFG1_REG,
-				 AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK,
-				 FIELD_PREP(AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK,
-					    AW86927_PLAYCFG1_BST_8500MV));
-	if (err)
-		return err;
+	switch (haptics->model) {
+	case AW86927:
+		err = regmap_update_bits(haptics->regmap,
+				AW86927_PLAYCFG1_REG,
+				AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK,
+				FIELD_PREP(AW86927_PLAYCFG1_BST_VOUT_VREFSET_MASK,
+					AW86927_PLAYCFG1_BST_8500MV));
+		if (err)
+			return err;
+		break;
+	case AW86938:
+		err = regmap_update_bits(haptics->regmap,
+				AW86938_PLAYCFG1_REG,
+				AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK,
+				FIELD_PREP(AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK,
+					AW86938_PLAYCFG1_BST_7000MV));
+		if (err)
+			return err;
+		break;
+	}
 
 	err = regmap_update_bits(haptics->regmap,
 				 AW86927_PLAYCFG3_REG,
@@ -599,6 +625,9 @@ static int aw86927_ram_init(struct aw86927_data *haptics)
 				 FIELD_PREP(AW86927_SYSCTRL3_EN_RAMINIT_MASK,
 					    AW86927_SYSCTRL3_EN_RAMINIT_ON));
 
+	/* AW86938 wants a 1ms delay here */
+	usleep_range(1000, 1500);
+
 	/* Set base address for the start of the SRAM waveforms */
 	err = regmap_write(haptics->regmap,
 			   AW86927_BASEADDRH_REG, AW86927_BASEADDRH_VAL);
@@ -717,7 +746,14 @@ static int aw86927_detect(struct aw86927_data *haptics)
 
 	chip_id = be16_to_cpu(read_buf);
 
-	if (chip_id != AW86927_CHIPID) {
+	switch (chip_id) {
+	case AW86927_CHIPID:
+		haptics->model = AW86927;
+		break;
+	case AW86938_CHIPID:
+		haptics->model = AW86938;
+		break;
+	default:
 		dev_err(haptics->dev, "Unexpected CHIPID value 0x%x\n", chip_id);
 		return -ENODEV;
 	}

-- 
2.43.0


^ permalink raw reply related

* [PATCH v4 2/4] dt-bindings: input: awinic,aw86927: Add Awinic AW86938
From: Griffin Kroah-Hartman @ 2026-03-02 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Bjorn Andersson, Konrad Dybcio, Luca Weiss
  Cc: linux-input, devicetree, linux-kernel, linux-arm-msm,
	Griffin Kroah-Hartman, Krzysztof Kozlowski
In-Reply-To: <20260302-aw86938-driver-v4-0-92c865df9cca@fairphone.com>

Add bindings for the Awinic AW86938 haptic chip which can be found in
smartphones. These two chips require a similar devicetree configuration,
but have a register layout that's not 100% compatible.
Still, because chip model is fully detectable via ID register, these
chips can be documnented in the same file.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
---
 Documentation/devicetree/bindings/input/awinic,aw86927.yaml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/awinic,aw86927.yaml b/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
index b7252916bd727486c1a98913d4ec3ef12422e4bd..bd74b81488f61d72b675b5701b321b30b3430be0 100644
--- a/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
+++ b/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
@@ -11,7 +11,12 @@ maintainers:
 
 properties:
   compatible:
-    const: awinic,aw86927
+    oneOf:
+      - const: awinic,aw86927
+      - items:
+          - enum:
+              - awinic,aw86938
+          - const: awinic,aw86927
 
   reg:
     maxItems: 1

-- 
2.43.0


^ permalink raw reply related

* [PATCH v4 1/4] Input: aw86927 - respect vibration magnitude levels
From: Griffin Kroah-Hartman @ 2026-03-02 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Bjorn Andersson, Konrad Dybcio, Luca Weiss
  Cc: linux-input, devicetree, linux-kernel, linux-arm-msm,
	Griffin Kroah-Hartman
In-Reply-To: <20260302-aw86938-driver-v4-0-92c865df9cca@fairphone.com>

Previously the gain value was hardcoded. Take the magnitude passed via
the input API and configure the gain register accordingly.

Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
---
 drivers/input/misc/aw86927.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 8ad361239cfe3a888628b15e4dbdeed0c9ca3d1a..7f8cadda7c456d7b5448d1e23edf6e3f2918ba32 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -180,7 +180,7 @@ struct aw86927_data {
 	struct i2c_client *client;
 	struct regmap *regmap;
 	struct gpio_desc *reset_gpio;
-	bool running;
+	__u16 level;
 };
 
 static const struct regmap_config aw86927_regmap_config = {
@@ -325,11 +325,12 @@ static int aw86927_haptics_play(struct input_dev *dev, void *data, struct ff_eff
 	if (!level)
 		level = effect->u.rumble.weak_magnitude;
 
-	/* If already running, don't restart playback */
-	if (haptics->running && level)
+	/* If level does not change, don't restart playback */
+	if (haptics->level == level)
 		return 0;
 
-	haptics->running = level;
+	haptics->level = level;
+
 	schedule_work(&haptics->play_work);
 
 	return 0;
@@ -376,8 +377,7 @@ static int aw86927_play_sine(struct aw86927_data *haptics)
 	if (err)
 		return err;
 
-	/* set gain to value lower than 0x80 to avoid distorted playback */
-	err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, 0x7c);
+	err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, haptics->level * 0x80 / 0xffff);
 	if (err)
 		return err;
 
@@ -409,7 +409,7 @@ static void aw86927_haptics_play_work(struct work_struct *work)
 	struct device *dev = &haptics->client->dev;
 	int err;
 
-	if (haptics->running)
+	if (haptics->level)
 		err = aw86927_play_sine(haptics);
 	else
 		err = aw86927_stop(haptics);

-- 
2.43.0


^ permalink raw reply related

* [PATCH v4 0/4] Add support for Awinic AW86938 haptic driver
From: Griffin Kroah-Hartman @ 2026-03-02 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Bjorn Andersson, Konrad Dybcio, Luca Weiss
  Cc: linux-input, devicetree, linux-kernel, linux-arm-msm,
	Griffin Kroah-Hartman, Krzysztof Kozlowski, Dmitry Baryshkov,
	Konrad Dybcio

Add devicetree bindings and driver support for the AW86938 haptic driver
chip, and add it to the devicetree for the Fairphone (Gen. 6) smartphone.

This haptics chip is quite similar to the AW86927, and shares many core
features but has some notable differences, including some extra
features.

Signed-off-by: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
---
Changes in v4:
- Changed how vibration intensity was calculated, added a seperate patch
  for it.
- Link to v3: https://lore.kernel.org/r/20260209-aw86938-driver-v3-0-5c79cff30492@fairphone.com

Changes in v3:
- Changed how compatibility was handled according to feedback
- Added reset gpio config for vibrator node
- Link to v2: https://lore.kernel.org/r/20260128-aw86938-driver-v2-0-b51ee086aaf5@fairphone.com

Changes in v2:
- Added AW86938 specific registers
- Added chip model enum to differentiate chips
- Link to v1: https://lore.kernel.org/r/20251204-aw86938-driver-v1-0-ebd71868df3a@fairphone.com

---
Griffin Kroah-Hartman (4):
      Input: aw86927 - respect vibration magnitude levels
      dt-bindings: input: awinic,aw86927: Add Awinic AW86938
      Input: aw86938 - add driver for Awinic AW86938
      arm64: dts: qcom: milos-fairphone-fp6: Add vibrator support

 .../devicetree/bindings/input/awinic,aw86927.yaml  |  7 ++-
 arch/arm64/boot/dts/qcom/milos-fairphone-fp6.dts   | 26 ++++++++-
 drivers/input/misc/aw86927.c                       | 66 +++++++++++++++++-----
 3 files changed, 82 insertions(+), 17 deletions(-)
---
base-commit: 0364de6be161e2360cbb1f26d5aff5b343ef7bb0
change-id: 20251113-aw86938-driver-b4fa0d3228a2

Best regards,
-- 
Griffin Kroah-Hartman <griffin.kroah@fairphone.com>


^ permalink raw reply

* Re: [PATCH 2/2] HID: input: Add HID_BATTERY_QUIRK_DYNAMIC for Elan touchscreens
From: Hans de Goede @ 2026-03-02  9:19 UTC (permalink / raw)
  To: Dmitry Torokhov, Sebastian Reichel
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, ggrundik
In-Reply-To: <aaTZIcPuY3qz5MJm@google.com>

Hi Dmitry,

On 2-Mar-26 1:44 AM, Dmitry Torokhov wrote:
> Hi Hans,
> 
> On Sat, Feb 28, 2026 at 03:52:58PM +0100, Hans de Goede wrote:
>> Elan touchscreens have a HID-battery device for the stylus which is always
>> there even if there is no stylus.
>>
>> This is causing upower to report an empty battery for the stylus and some
>> desktop-environments will show a notification about this, which is quite
>> annoying.
>>
>> Because of this the HID-battery is being ignored on all Elan I2c and USB
>> touchscreens, but this causes there to be no battery reporting for
>> the stylus at all.
>>
>> This adds a new HID_BATTERY_QUIRK_DYNAMIC and uses these for the Elan
>> touchscreens.
>>
>> This new quirks causes the present value of the battery to start at 0,
>> which will make userspace ignore it and only sets present to 1 after
>> receiving a battery input report which only happens when the stylus
>> gets in range.
> 
> My understanding was that "present" attribute is to be used for
> removable batteries (i.e. when a battery can be extracted from either
> from the system or from a peripheral) and we want to notify userspace of
> that fact).

In this case we have a touchscreen and a stylus with a battery embedded
in the stylus and we're setting present to 0 when the stylus (and thus
the battery) is not there. I realize this is a bit different but it
is close enough IMHO.

Also keep in mind that most people simply do not have the stylus at all,
these styluses are typically an optional accessory and some models where
the touchscreen supports this the vendor is not even selling a stylus to
go with the 2-in-1 laptop (but you may use a compatible stylus from other
vendors).

TL;DR; the user not having a stylus at all is the most common use case here.

> For example, if a laptop can have an additional battery UI
> can show if it is installed or not, and it should not simply ignore such
> power supplies.

As the screenshots of the KDE control-panel in the bug for this:
https://bugzilla.kernel.org/show_bug.cgi?id=221118

Show it is not being ignored, but its charge-level is ignored,
with the battery being shown as not present. Which is pretty much
what we want.

> On the other hand the "Unknown" operating status signals that we
> actually do not know the state of the battery, and fits better in our
> situation.

Reporting "Unknown" in the status attribute is not something which
drivers normally do. It is there in the ABI and upower seems to somewhat
handle it, but upower only handles it in that it forwards it to upower
DBUS API users it does not reset history, etc. as it does for present=0.

The problem with status=Unknown is that its meaning is not really well
defined. Unknown status mostly means that it is unknown if the battery is
charging / discharging / full for some reason. But if there still is a low
capacity reading then userspace might still warn about the low capacity in
this case, since the battery is still almost empty and presumably not
charging.

Also when the stylus is not there, the battery state is not unknown,
the entire stylus, including the battery is simply not there, so
reporting present=0 seems more appropriate and its meaning is well
defined and present=0 causes upower to not read/report any of the
other attributes.

And as mentioned most users will not have the stylus I think having
a non-present "ELAN Touchscreen Stylus battery" being reported makes
some sense to end users, where as having the same battery being
reported "Unknown" status and at 0% charge (Unknown status batteries
do have a charge) is more confusing for users.

> Anyway, I think we need Sebastian's input here.

Ack, Sebastian your input would be appreciated here ?

Regards,

Hans



> 
>>
>> Reported-by: ggrundik@gmail.com
>> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221118
>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
>> ---
>>  drivers/hid/hid-input.c | 14 +++++++++++---
>>  include/linux/hid.h     |  1 +
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
>> index 67ca1e88ce13..8fc20df99b97 100644
>> --- a/drivers/hid/hid-input.c
>> +++ b/drivers/hid/hid-input.c
>> @@ -354,6 +354,7 @@ static enum power_supply_property hidinput_battery_props[] = {
>>  #define HID_BATTERY_QUIRK_FEATURE	(1 << 1) /* ask for feature report */
>>  #define HID_BATTERY_QUIRK_IGNORE	(1 << 2) /* completely ignore the battery */
>>  #define HID_BATTERY_QUIRK_AVOID_QUERY	(1 << 3) /* do not query the battery */
>> +#define HID_BATTERY_QUIRK_DYNAMIC	(1 << 4) /* report present only after life signs */
>>  
>>  static const struct hid_device_id hid_battery_quirks[] = {
>>  	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
>> @@ -398,8 +399,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
>>  	 * Elan HID touchscreens seem to all report a non present battery,
>>  	 * set HID_BATTERY_QUIRK_IGNORE for all Elan I2C and USB HID devices.
>>  	 */
>> -	{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
>> +	{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
>> +	{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
>>  	{}
>>  };
>>  
>> @@ -456,11 +457,14 @@ static int hidinput_get_battery_property(struct power_supply *psy,
>>  	int ret = 0;
>>  
>>  	switch (prop) {
>> -	case POWER_SUPPLY_PROP_PRESENT:
>>  	case POWER_SUPPLY_PROP_ONLINE:
>>  		val->intval = 1;
>>  		break;
>>  
>> +	case POWER_SUPPLY_PROP_PRESENT:
>> +		val->intval = dev->battery_present;
>> +		break;
>> +
>>  	case POWER_SUPPLY_PROP_CAPACITY:
>>  		if (dev->battery_status != HID_BATTERY_REPORTED &&
>>  		    !dev->battery_avoid_query) {
>> @@ -573,6 +577,8 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
>>  	if (quirks & HID_BATTERY_QUIRK_AVOID_QUERY)
>>  		dev->battery_avoid_query = true;
>>  
>> +	dev->battery_present = (quirks & HID_BATTERY_QUIRK_DYNAMIC) ? false : true;
>> +
>>  	dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
>>  	if (IS_ERR(dev->battery)) {
>>  		error = PTR_ERR(dev->battery);
>> @@ -628,6 +634,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
>>  		return;
>>  
>>  	if (hidinput_update_battery_charge_status(dev, usage, value)) {
>> +		dev->battery_present = true;
>>  		power_supply_changed(dev->battery);
>>  		return;
>>  	}
>> @@ -643,6 +650,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
>>  	if (dev->battery_status != HID_BATTERY_REPORTED ||
>>  	    capacity != dev->battery_capacity ||
>>  	    ktime_after(ktime_get_coarse(), dev->battery_ratelimit_time)) {
>> +		dev->battery_present = true;
>>  		dev->battery_capacity = capacity;
>>  		dev->battery_status = HID_BATTERY_REPORTED;
>>  		dev->battery_ratelimit_time =
>> diff --git a/include/linux/hid.h b/include/linux/hid.h
>> index dce862cafbbd..d9b54f0e8671 100644
>> --- a/include/linux/hid.h
>> +++ b/include/linux/hid.h
>> @@ -682,6 +682,7 @@ struct hid_device {
>>  	__s32 battery_charge_status;
>>  	enum hid_battery_status battery_status;
>>  	bool battery_avoid_query;
>> +	bool battery_present;
>>  	ktime_t battery_ratelimit_time;
>>  #endif
>>  
> 
> Thanks.
> 


^ permalink raw reply

* Re: [PATCH v2 0/2] iio: orientation: hid-sensor-rotation: fix quaternion alignment
From: Andy Shevchenko @ 2026-03-02  8:58 UTC (permalink / raw)
  To: David Lechner
  Cc: Jonathan Cameron, Nuno Sá, Andy Shevchenko, Jiri Kosina,
	Srinivas Pandruvada, linux-iio, linux-kernel, Jonathan Cameron,
	linux-input, Lixu Zhang
In-Reply-To: <20260228-iio-fix-repeat-alignment-v2-0-d58bfaa2920d@baylibre.com>

On Sat, Feb 28, 2026 at 02:02:21PM -0600, David Lechner wrote:
> The main point of this series is to fix a regression reported in
> hid-sensor-rotation where the alignment of the quaternion field in the
> data was inadvertently changed from 16 bytes to 8 bytes. This is an
> unusually case (one of only 2 in the kernel) where the .repeat field of
> struct iio_scan_type is used and we have such a requirement. (The other
> case uses u16 instead of u32, so it wasn't affected.)
> 
> To make the reason for the alignment more explicit to future readers,
> we introduce a new macro, IIO_DECLARE_QUATERNION(), to declare the
> array with proper alignment. This is meant to follow the pattern of
> the similar IIO_DECLARE_BUFFER_WITH_TS() macro.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

But this is in conflict with the other hack-patch in another series.
I'm a bit lost what patch 2 fixes here and that hack-patch fixes
in the same driver. Shouldn't survive only one?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH 1/4] iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace
From: Andy Shevchenko @ 2026-03-02  8:50 UTC (permalink / raw)
  To: David Lechner
  Cc: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko, Lars Möllendorf, Lars-Peter Clausen,
	Greg Kroah-Hartman, Jonathan Cameron, Lixu Zhang, linux-input,
	linux-iio, linux-kernel
In-Reply-To: <20260301-iio-fix-timestamp-alignment-v1-1-1a54980bfb90@baylibre.com>

On Sun, Mar 01, 2026 at 02:24:50PM -0600, David Lechner wrote:
> Add a hack to push two timestamps in the hid-sensor-rotation scan data
> to avoid breaking userspace applications that depend on the timestamp
> being at the incorrect location in the scan data due to unintentional
> misalignment in older kernels.
> 
> When this driver was written, the timestamp was in the correct location
> because of the way iio_compute_scan_bytes() was implemented at the time.
> (Samples were 24 bytes each.) Then commit 883f61653069 ("iio: buffer:
> align the size of scan bytes to size of the largest element") changed
> the computed scan_bytes to be a different size (32 bytes), which caused
> iio_push_to_buffers_with_timestamp() to place the timestamp at an
> incorrect offset.
> 
> There have been long periods of time (6 years each) where the timestamp
> was in either location, so to not break either case, we open-code the
> timestamps to be pushed to both locations in the scan data.

...

> +		/*
> +		 * HACK: There are two copies of the same timestamp in case of

Usually we use FIXME in such cases. HACK is something which goes with
"do not apply".

Does it mean it will stay forever?

> +		 * userspace depending on broken alignment from older kernels.
> +		 */
> +		aligned_s64 timestamp[2];

...

> +		/*
> +		 * HACK: IIO previously had an incorrect implementation of

Ditto.

> +		 * iio_push_to_buffers_with_timestamp() that put the timestamp
> +		 * in the last 8 bytes of the buffer, which was incorrect
> +		 * according to the IIO ABI. To avoid breaking userspace that
> +		 * depended on this broken behavior, we put the timestamp in
> +		 * both the correct place and the old incorrect place.
> +		 */
> +		rot_state->scan.timestamp[0] = rot_state->timestamp;
> +		rot_state->scan.timestamp[1] = rot_state->timestamp;

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH 4/4] iio: buffer: fix timestamp alignment when quaternion in scan
From: Andy Shevchenko @ 2026-03-02  8:47 UTC (permalink / raw)
  To: David Lechner
  Cc: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko, Lars Möllendorf, Lars-Peter Clausen,
	Greg Kroah-Hartman, Jonathan Cameron, Lixu Zhang, linux-input,
	linux-iio, linux-kernel
In-Reply-To: <20260301-iio-fix-timestamp-alignment-v1-4-1a54980bfb90@baylibre.com>

On Sun, Mar 01, 2026 at 02:24:53PM -0600, David Lechner wrote:
> Fix timestamp alignment when a scan buffer contains an element larger
> than sizeof(int64_t). Currently s32 quaternions are the only such
> element, and the one driver that has this (hid-sensor-rotation) has a
> workaround in place already so this change does not affect it.
> 
> Previously, we assumed that the timestamp would always be 8-byte aligned
> relative to the end of the scan buffer, but in the case of a scan buffer
> a 16-byte quaternion vector, scan_bytes == 32, but the timestamp needs
> to be placed at offset 16, not 24.

...

> -		((int64_t *)data)[ts_offset] = timestamp;

> +		*(int64_t *)(data + ts_offset) = timestamp;

What's the point in modifying this? The comment you added suffice for
the original line.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH v2] iio: orientation: hid-sensor-rotation: use ext_scan_type
From: Andy Shevchenko @ 2026-03-02  8:17 UTC (permalink / raw)
  To: David Lechner
  Cc: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko, linux-input, linux-iio, linux-kernel
In-Reply-To: <20260301-iio-hid-sensor-rotation-cleanup-v2-1-245c6ad59afc@baylibre.com>

On Sun, Mar 01, 2026 at 05:46:48PM -0600, David Lechner wrote:
> Make use of ext_scan_type to handle the dynamic realbits size of the
> quaternion data. This lets us implement it using static data rather than
> having to duplicate the channel info for each driver instance.

I like this change!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
(assuming somebody from Intel tests and confirms it working)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH 06/10] dt-bindings: input: touchscreen: st,stmfts: Introduce reset GPIO
From: Krzysztof Kozlowski @ 2026-03-02  7:17 UTC (permalink / raw)
  To: David Heidelberg
  Cc: Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Henrik Rydberg,
	Bjorn Andersson, Konrad Dybcio, Petr Hodina, linux-input,
	linux-stm32, linux-arm-kernel, linux-kernel, devicetree,
	linux-arm-msm, phone-devel
In-Reply-To: <20260301-stmfts5-v1-6-22c458b9ac68@ixit.cz>

On Sun, Mar 01, 2026 at 06:51:20PM +0100, David Heidelberg wrote:
> FTS may have associated reset GPIO, document it.

Commit msg is wrong. May have or have? Hardware is fixed, unless you add
the GPIO for driver which does not exist in the hardware.

> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>  Documentation/devicetree/bindings/input/touchscreen/st,stmfts.yaml | 4 ++++
>  1 file changed, 4 insertions(+)

Best regards,
Krzysztof


^ permalink raw reply

* Re: [PATCH v2 1/4] Input: elo - fix style issues
From: Josh Law @ 2026-03-02  7:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Josh Law
In-Reply-To: <aaTYvqdymKquoVWJ@google.com>

2 Mar 2026 00:25:16 Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> Hi Josh,
>
> On Sat, Feb 28, 2026 at 07:52:58PM +0000, Josh Law wrote:
>> Fix array constness and spacing issues reported by checkpatch.
>>
>> Signed-off-by: Josh Law <objecting@objecting.org>
>
> Why the difference between From: and Signed-off-by?
>
>> ---
>> drivers/input/touchscreen/elo.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
>> index 434b9b47e964..40ae132cde21 100644
>> --- a/drivers/input/touchscreen/elo.c
>> +++ b/drivers/input/touchscreen/elo.c
>> @@ -257,7 +257,7 @@ static int elo_command_10(struct elo *elo, unsigned char *packet)
>>
>> static int elo_setup_10(struct elo *elo)
>> {
>> -   static const char *elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" };
>> +   static const char * const elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" };
>>     struct input_dev *dev = elo->dev;
>>     unsigned char packet[ELO10_PACKET_LEN] = { ELO10_ID_CMD };
>>
>> @@ -273,7 +273,7 @@ static int elo_setup_10(struct elo *elo)
>>
>>     dev_info(&elo->serio->dev,
>>          "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n",
>> -        elo_types[(packet[1] -'0') & 0x03],
>> +        elo_types[(packet[1] - '0') & 0x03],
>>          packet[5], packet[4], packet[3], packet[7]);
>>
>>     return 0;
>
> Thanks.
>
> --
> Dmitry



Sorry, because my main email can't send emails and I prefer to use my objecting.org email

V/R

^ permalink raw reply

* Re: [PATCH][next] HID: hid-lenovo-go-s: Fix spelling mistake "configuratiion" -> "configuration"
From: Mark Pearson @ 2026-03-02  1:34 UTC (permalink / raw)
  To: Colin Ian King, Derek J . Clark, Jiri Kosina, Benjamin Tissoires,
	linux-input
  Cc: kernel-janitors, linux-kernel
In-Reply-To: <20260227231606.421263-1-colin.i.king@gmail.com>

On Fri, Feb 27, 2026, at 6:16 PM, Colin Ian King wrote:
> There is a spelling mistake in a dev_err_probe message. Fix it.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  drivers/hid/hid-lenovo-go-s.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-lenovo-go-s.c b/drivers/hid/hid-lenovo-go-s.c
> index cacc5bd5ed2b..dbb88492fbba 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c
> @@ -1401,7 +1401,7 @@ static int hid_gos_cfg_probe(struct hid_device *hdev,
>  	ret = devm_device_add_group(gos_cdev_rgb.led_cdev.dev, &rgb_attr_group);
>  	if (ret) {
>  		dev_err_probe(&hdev->dev, ret,
> -			      "Failed to create RGB configuratiion attributes\n");
> +			      "Failed to create RGB configuration attributes\n");
>  		return ret;
>  	}
> 
> -- 
> 2.51.0

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>

^ permalink raw reply

* Re: [PATCH] HID: hid-lenovo-go: Remove unneeded semicolon
From: Mark Pearson @ 2026-03-02  1:33 UTC (permalink / raw)
  To: Chen Ni, Derek J . Clark
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20260228033936.285945-1-nichen@iscas.ac.cn>

On Fri, Feb 27, 2026, at 10:39 PM, Chen Ni wrote:
> Remove unnecessary semicolons after switch statements and function
> bodies. Most issues were reported by Coccinelle/coccicheck using the
> semantic patch at scripts/coccinelle/misc/semicolon.cocci. Additional
> instances found during manual code review were also fixed.
>
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/hid/hid-lenovo-go.c | 52 ++++++++++++++++++-------------------
>  1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/hid/hid-lenovo-go.c b/drivers/hid/hid-lenovo-go.c
> index 6972d13802e2..77e3823447e5 100644
> --- a/drivers/hid/hid-lenovo-go.c
> +++ b/drivers/hid/hid-lenovo-go.c
> @@ -455,7 +455,7 @@ static int hid_go_feature_status_event(struct 
> command_report *cmd_rep)
>  			return 0;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  	case FEATURE_IMU_BYPASS:
>  		switch (cmd_rep->device_type) {
>  		case LEFT_CONTROLLER:
> @@ -466,7 +466,7 @@ static int hid_go_feature_status_event(struct 
> command_report *cmd_rep)
>  			return 0;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		break;
>  	case FEATURE_LIGHT_ENABLE:
>  		drvdata.rgb_en = cmd_rep->data[0];
> @@ -481,7 +481,7 @@ static int hid_go_feature_status_event(struct 
> command_report *cmd_rep)
>  			return 0;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		break;
>  	case FEATURE_TOUCHPAD_ENABLE:
>  		drvdata.tp_en = cmd_rep->data[0];
> @@ -515,7 +515,7 @@ static int hid_go_motor_event(struct command_report 
> *cmd_rep)
>  			return 0;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		break;
>  	case RUMBLE_MODE:
>  		switch (cmd_rep->device_type) {
> @@ -527,7 +527,7 @@ static int hid_go_motor_event(struct command_report 
> *cmd_rep)
>  			return 0;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  	case TP_VIBRATION_ENABLE:
>  		drvdata.tp_vibration_en = cmd_rep->data[0];
>  		return 0;
> @@ -625,7 +625,7 @@ static int hid_go_os_mode_cfg_event(struct 
> command_report *cmd_rep)
>  		return 0;
>  	default:
>  		return -EINVAL;
> -	};
> +	}
>  }
> 
>  static int hid_go_set_event_return(struct command_report *cmd_rep)
> @@ -699,14 +699,14 @@ static int hid_go_raw_event(struct hid_device 
> *hdev, struct hid_report *report,
>  		default:
>  			ret = -EINVAL;
>  			break;
> -		};
> +		}
>  		break;
>  	case OS_MODE_DATA:
>  		ret = hid_go_os_mode_cfg_event(cmd_rep);
>  		break;
>  	default:
>  		goto passthrough;
> -	};
> +	}
>  	dev_dbg(&hdev->dev, "Rx data as raw input report: [%*ph]\n",
>  		GO_PACKET_SIZE, data);
> 
> @@ -925,7 +925,7 @@ static ssize_t feature_status_store(struct device *dev,
>  		break;
>  	default:
>  		return -EINVAL;
> -	};
> +	}
> 
>  	if (ret < 0)
>  		return ret;
> @@ -1013,7 +1013,7 @@ static ssize_t feature_status_show(struct device *dev,
>  			break;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		count = sysfs_emit(buf, "%u\n", i);
>  		break;
>  	case FEATURE_FPS_SWITCH_STATUS:
> @@ -1032,7 +1032,7 @@ static ssize_t feature_status_show(struct device *dev,
>  		break;
>  	default:
>  		return -EINVAL;
> -	};
> +	}
> 
>  	return count;
>  }
> @@ -1070,7 +1070,7 @@ static ssize_t feature_status_options(struct device *dev,
>  		break;
>  	default:
>  		return -EINVAL;
> -	};
> +	}
> 
>  	if (count)
>  		buf[count - 1] = '\n';
> @@ -1111,7 +1111,7 @@ static ssize_t motor_config_store(struct device *dev,
>  		ret = sysfs_match_string(intensity_text, buf);
>  		val = ret;
>  		break;
> -	};
> +	}
> 
>  	if (ret < 0)
>  		return ret;
> @@ -1161,7 +1161,7 @@ static ssize_t motor_config_show(struct device *dev,
>  			break;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		if (i >= ARRAY_SIZE(enabled_status_text))
>  			return -EINVAL;
> 
> @@ -1177,7 +1177,7 @@ static ssize_t motor_config_show(struct device *dev,
>  			break;
>  		default:
>  			return -EINVAL;
> -		};
> +		}
>  		if (i >= ARRAY_SIZE(rumble_mode_text))
>  			return -EINVAL;
> 
> @@ -1197,7 +1197,7 @@ static ssize_t motor_config_show(struct device *dev,
> 
>  		count = sysfs_emit(buf, "%s\n", intensity_text[i]);
>  		break;
> -	};
> +	}
> 
>  	return count;
>  }
> @@ -1232,7 +1232,7 @@ static ssize_t motor_config_options(struct device *dev,
>  					       enabled_status_text[i]);
>  		}
>  		break;
> -	};
> +	}
> 
>  	if (count)
>  		buf[count - 1] = '\n';
> @@ -1333,7 +1333,7 @@ static ssize_t device_status_show(struct device *dev,
>  		break;
>  	default:
>  		return -EINVAL;
> -	};
> +	}
> 
>  	if (i >= ARRAY_SIZE(cal_status_text))
>  		return -EINVAL;
> @@ -1459,7 +1459,7 @@ static int rgb_attr_show(void)
>  	index = drvdata.rgb_profile + 3;
> 
>  	return rgb_cfg_call(drvdata.hdev, GET_RGB_CFG, index, 0, 0);
> -};
> +}
> 
>  static ssize_t rgb_effect_store(struct device *dev,
>  				struct device_attribute *attr, const char *buf,
> @@ -1489,7 +1489,7 @@ static ssize_t rgb_effect_store(struct device *dev,
> 
>  	drvdata.rgb_effect = effect;
>  	return count;
> -};
> +}
> 
>  static ssize_t rgb_effect_show(struct device *dev,
>  			       struct device_attribute *attr, char *buf)
> @@ -1552,7 +1552,7 @@ static ssize_t rgb_speed_store(struct device *dev,
>  	drvdata.rgb_speed = val;
> 
>  	return count;
> -};
> +}
> 
>  static ssize_t rgb_speed_show(struct device *dev, struct 
> device_attribute *attr,
>  			      char *buf)
> @@ -1594,7 +1594,7 @@ static ssize_t rgb_mode_store(struct device *dev, 
> struct device_attribute *attr,
>  	drvdata.rgb_mode = val;
> 
>  	return count;
> -};
> +}
> 
>  static ssize_t rgb_mode_show(struct device *dev, struct 
> device_attribute *attr,
>  			     char *buf)
> @@ -1609,7 +1609,7 @@ static ssize_t rgb_mode_show(struct device *dev, 
> struct device_attribute *attr,
>  		return -EINVAL;
> 
>  	return sysfs_emit(buf, "%s\n", rgb_mode_text[drvdata.rgb_mode]);
> -};
> +}
> 
>  static ssize_t rgb_mode_index_show(struct device *dev,
>  				   struct device_attribute *attr, char *buf)
> @@ -1649,7 +1649,7 @@ static ssize_t rgb_profile_store(struct device *dev,
>  	drvdata.rgb_profile = val;
> 
>  	return count;
> -};
> +}
> 
>  static ssize_t rgb_profile_show(struct device *dev,
>  				struct device_attribute *attr, char *buf)
> @@ -1665,7 +1665,7 @@ static ssize_t rgb_profile_show(struct device *dev,
>  		return -EINVAL;
> 
>  	return sysfs_emit(buf, "%hhu\n", drvdata.rgb_profile);
> -};
> +}
> 
>  static ssize_t rgb_profile_range_show(struct device *dev,
>  				      struct device_attribute *attr, char *buf)
> @@ -1704,7 +1704,7 @@ static void hid_go_brightness_set(struct 
> led_classdev *led_cdev,
>  		break;
>  	default:
>  		dev_err(led_cdev->dev, "Failed to write RGB profile: %i\n", ret);
> -	};
> +	}
>  }
> 
>  #define LEGO_DEVICE_ATTR_RW(_name, _attrname, _dtype, _rtype, _group)         \
> -- 
> 2.25.1

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>

^ permalink raw reply

* Re: [PATCH] HID: hid-lenovo-go-s: Remove unneeded semicolon
From: Mark Pearson @ 2026-03-02  1:32 UTC (permalink / raw)
  To: Chen Ni, Derek J . Clark
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20260228034343.286005-1-nichen@iscas.ac.cn>

On Fri, Feb 27, 2026, at 10:43 PM, Chen Ni wrote:
> Remove unnecessary semicolons reported by Coccinelle/coccicheck and the
> semantic patch at scripts/coccinelle/misc/semicolon.cocci.
>
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/hid/hid-lenovo-go-s.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-lenovo-go-s.c 
> b/drivers/hid/hid-lenovo-go-s.c
> index cacc5bd5ed2b..d1eb067509f6 100644
> --- a/drivers/hid/hid-lenovo-go-s.c
> +++ b/drivers/hid/hid-lenovo-go-s.c
> @@ -1102,7 +1102,7 @@ static void hid_gos_brightness_set(struct 
> led_classdev *led_cdev,
>  	default:
>  		dev_err(led_cdev->dev, "Failed to write RGB profile: %i\n",
>  			ret);
> -	};
> +	}
>  }
> 
>  #define LEGOS_DEVICE_ATTR_RW(_name, _attrname, _rtype, _group)         
>         \
> -- 
> 2.25.1

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>

^ permalink raw reply

* Re: [PATCH 2/2] HID: input: Add HID_BATTERY_QUIRK_DYNAMIC for Elan touchscreens
From: Dmitry Torokhov @ 2026-03-02  0:44 UTC (permalink / raw)
  To: Hans de Goede, Sebastian Reichel
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, ggrundik
In-Reply-To: <20260228145258.76937-2-johannes.goede@oss.qualcomm.com>

Hi Hans,

On Sat, Feb 28, 2026 at 03:52:58PM +0100, Hans de Goede wrote:
> Elan touchscreens have a HID-battery device for the stylus which is always
> there even if there is no stylus.
> 
> This is causing upower to report an empty battery for the stylus and some
> desktop-environments will show a notification about this, which is quite
> annoying.
> 
> Because of this the HID-battery is being ignored on all Elan I2c and USB
> touchscreens, but this causes there to be no battery reporting for
> the stylus at all.
> 
> This adds a new HID_BATTERY_QUIRK_DYNAMIC and uses these for the Elan
> touchscreens.
> 
> This new quirks causes the present value of the battery to start at 0,
> which will make userspace ignore it and only sets present to 1 after
> receiving a battery input report which only happens when the stylus
> gets in range.

My understanding was that "present" attribute is to be used for
removable batteries (i.e. when a battery can be extracted from either
from the system or from a peripheral) and we want to notify userspace of
that fact). For example, if a laptop can have an additional battery UI
can show if it is installed or not, and it should not simply ignore such
power supplies.

On the other hand the "Unknown" operating status signals that we
actually do not know the state of the battery, and fits better in our
situation.

Anyway, I think we need Sebastian's input here.

> 
> Reported-by: ggrundik@gmail.com
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221118
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
>  drivers/hid/hid-input.c | 14 +++++++++++---
>  include/linux/hid.h     |  1 +
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 67ca1e88ce13..8fc20df99b97 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -354,6 +354,7 @@ static enum power_supply_property hidinput_battery_props[] = {
>  #define HID_BATTERY_QUIRK_FEATURE	(1 << 1) /* ask for feature report */
>  #define HID_BATTERY_QUIRK_IGNORE	(1 << 2) /* completely ignore the battery */
>  #define HID_BATTERY_QUIRK_AVOID_QUERY	(1 << 3) /* do not query the battery */
> +#define HID_BATTERY_QUIRK_DYNAMIC	(1 << 4) /* report present only after life signs */
>  
>  static const struct hid_device_id hid_battery_quirks[] = {
>  	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
> @@ -398,8 +399,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
>  	 * Elan HID touchscreens seem to all report a non present battery,
>  	 * set HID_BATTERY_QUIRK_IGNORE for all Elan I2C and USB HID devices.
>  	 */
> -	{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
> -	{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
> +	{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
> +	{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
>  	{}
>  };
>  
> @@ -456,11 +457,14 @@ static int hidinput_get_battery_property(struct power_supply *psy,
>  	int ret = 0;
>  
>  	switch (prop) {
> -	case POWER_SUPPLY_PROP_PRESENT:
>  	case POWER_SUPPLY_PROP_ONLINE:
>  		val->intval = 1;
>  		break;
>  
> +	case POWER_SUPPLY_PROP_PRESENT:
> +		val->intval = dev->battery_present;
> +		break;
> +
>  	case POWER_SUPPLY_PROP_CAPACITY:
>  		if (dev->battery_status != HID_BATTERY_REPORTED &&
>  		    !dev->battery_avoid_query) {
> @@ -573,6 +577,8 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
>  	if (quirks & HID_BATTERY_QUIRK_AVOID_QUERY)
>  		dev->battery_avoid_query = true;
>  
> +	dev->battery_present = (quirks & HID_BATTERY_QUIRK_DYNAMIC) ? false : true;
> +
>  	dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
>  	if (IS_ERR(dev->battery)) {
>  		error = PTR_ERR(dev->battery);
> @@ -628,6 +634,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
>  		return;
>  
>  	if (hidinput_update_battery_charge_status(dev, usage, value)) {
> +		dev->battery_present = true;
>  		power_supply_changed(dev->battery);
>  		return;
>  	}
> @@ -643,6 +650,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
>  	if (dev->battery_status != HID_BATTERY_REPORTED ||
>  	    capacity != dev->battery_capacity ||
>  	    ktime_after(ktime_get_coarse(), dev->battery_ratelimit_time)) {
> +		dev->battery_present = true;
>  		dev->battery_capacity = capacity;
>  		dev->battery_status = HID_BATTERY_REPORTED;
>  		dev->battery_ratelimit_time =
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index dce862cafbbd..d9b54f0e8671 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -682,6 +682,7 @@ struct hid_device {
>  	__s32 battery_charge_status;
>  	enum hid_battery_status battery_status;
>  	bool battery_avoid_query;
> +	bool battery_present;
>  	ktime_t battery_ratelimit_time;
>  #endif
>  

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v2 1/4] Input: elo - fix style issues
From: Dmitry Torokhov @ 2026-03-02  0:25 UTC (permalink / raw)
  To: Josh Law; +Cc: linux-input, linux-kernel, Josh Law
In-Reply-To: <20260228195258.2468296-1-objecting@objecting.org>

Hi Josh,

On Sat, Feb 28, 2026 at 07:52:58PM +0000, Josh Law wrote:
> Fix array constness and spacing issues reported by checkpatch.
> 
> Signed-off-by: Josh Law <objecting@objecting.org>

Why the difference between From: and Signed-off-by?

> ---
>  drivers/input/touchscreen/elo.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
> index 434b9b47e964..40ae132cde21 100644
> --- a/drivers/input/touchscreen/elo.c
> +++ b/drivers/input/touchscreen/elo.c
> @@ -257,7 +257,7 @@ static int elo_command_10(struct elo *elo, unsigned char *packet)
>  
>  static int elo_setup_10(struct elo *elo)
>  {
> -	static const char *elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" };
> +	static const char * const elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" };
>  	struct input_dev *dev = elo->dev;
>  	unsigned char packet[ELO10_PACKET_LEN] = { ELO10_ID_CMD };
>  
> @@ -273,7 +273,7 @@ static int elo_setup_10(struct elo *elo)
>  
>  	dev_info(&elo->serio->dev,
>  		 "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n",
> -		 elo_types[(packet[1] -'0') & 0x03],
> +		 elo_types[(packet[1] - '0') & 0x03],
>  		 packet[5], packet[4], packet[3], packet[7]);
>  
>  	return 0;

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH v2] iio: orientation: hid-sensor-rotation: use ext_scan_type
From: David Lechner @ 2026-03-01 23:46 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko
  Cc: linux-input, linux-iio, linux-kernel, David Lechner

Make use of ext_scan_type to handle the dynamic realbits size of the
quaternion data. This lets us implement it using static data rather than
having to duplicate the channel info for each driver instance.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
This is something I noticed we could do while looking at an unrelated
bug. I've tested this using the same script from [1] and confirmed that
that the scan type didn't change. Before and after are both:

$ cat in_rot_quaternion_type
le:s16/32X4>>0

[1]: https://lore.kernel.org/linux-iio/20260301-iio-fix-timestamp-alignment-v1-1-1a54980bfb90@baylibre.com/
---
Changes in v2:
- Dropped DEV_ROT_SCAN_TYPE_8BIT.
- Tested using /dev/uhid.
- Link to v1: https://lore.kernel.org/r/20260214-iio-hid-sensor-rotation-cleanup-v1-1-3aec9a533c0f@baylibre.com
---
 drivers/iio/orientation/hid-sensor-rotation.c | 71 ++++++++++++++++-----------
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index e759f91a710a..3cfd0b323514 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -34,6 +34,27 @@ static const u32 rotation_sensitivity_addresses[] = {
 	HID_USAGE_SENSOR_ORIENT_QUATERNION,
 };
 
+enum {
+	DEV_ROT_SCAN_TYPE_16BIT,
+	DEV_ROT_SCAN_TYPE_32BIT,
+};
+
+static const struct iio_scan_type dev_rot_scan_types[] = {
+	[DEV_ROT_SCAN_TYPE_16BIT] = {
+		.sign = 's',
+		.realbits = 16,
+		/* Storage bits has to stay 32 to not break userspace. */
+		.storagebits = 32,
+		.repeat = 4,
+	},
+	[DEV_ROT_SCAN_TYPE_32BIT] = {
+		.sign = 's',
+		.realbits = 32,
+		.storagebits = 32,
+		.repeat = 4,
+	},
+};
+
 /* Channel definitions */
 static const struct iio_chan_spec dev_rot_channels[] = {
 	{
@@ -45,23 +66,14 @@ static const struct iio_chan_spec dev_rot_channels[] = {
 					BIT(IIO_CHAN_INFO_OFFSET) |
 					BIT(IIO_CHAN_INFO_SCALE) |
 					BIT(IIO_CHAN_INFO_HYSTERESIS),
-		.scan_index = 0
+		.scan_index = 0,
+		.has_ext_scan_type = 1,
+		.ext_scan_type = dev_rot_scan_types,
+		.num_ext_scan_type = ARRAY_SIZE(dev_rot_scan_types),
 	},
 	IIO_CHAN_SOFT_TIMESTAMP(1)
 };
 
-/* Adjust channel real bits based on report descriptor */
-static void dev_rot_adjust_channel_bit_mask(struct iio_chan_spec *chan,
-						int size)
-{
-	chan->scan_type.sign = 's';
-	/* Real storage bits will change based on the report desc. */
-	chan->scan_type.realbits = size * 8;
-	/* Maximum size of a sample to capture is u32 */
-	chan->scan_type.storagebits = sizeof(u32) * 8;
-	chan->scan_type.repeat = 4;
-}
-
 /* Channel read_raw handler */
 static int dev_rot_read_raw(struct iio_dev *indio_dev,
 				struct iio_chan_spec const *chan,
@@ -136,9 +148,25 @@ static int dev_rot_write_raw(struct iio_dev *indio_dev,
 	return ret;
 }
 
+static int dev_rot_get_current_scan_type(const struct iio_dev *indio_dev,
+					 const struct iio_chan_spec *chan)
+{
+	struct dev_rot_state *rot_state = iio_priv(indio_dev);
+
+	switch (rot_state->quaternion.size / 4) {
+	case sizeof(s16):
+		return DEV_ROT_SCAN_TYPE_16BIT;
+	case sizeof(s32):
+		return DEV_ROT_SCAN_TYPE_32BIT;
+	default:
+		return -EINVAL;
+	}
+}
+
 static const struct iio_info dev_rot_info = {
 	.read_raw_multi = &dev_rot_read_raw,
 	.write_raw = &dev_rot_write_raw,
+	.get_current_scan_type = &dev_rot_get_current_scan_type,
 };
 
 /* Callback handler to send event after all samples are received and captured */
@@ -196,7 +224,6 @@ static int dev_rot_capture_sample(struct hid_sensor_hub_device *hsdev,
 /* Parse report which is specific to an usage id*/
 static int dev_rot_parse_report(struct platform_device *pdev,
 				struct hid_sensor_hub_device *hsdev,
-				struct iio_chan_spec *channels,
 				unsigned usage_id,
 				struct dev_rot_state *st)
 {
@@ -210,9 +237,6 @@ static int dev_rot_parse_report(struct platform_device *pdev,
 	if (ret)
 		return ret;
 
-	dev_rot_adjust_channel_bit_mask(&channels[0],
-		st->quaternion.size / 4);
-
 	dev_dbg(&pdev->dev, "dev_rot %x:%x\n", st->quaternion.index,
 		st->quaternion.report_id);
 
@@ -271,22 +295,13 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
-					   sizeof(dev_rot_channels),
-					   GFP_KERNEL);
-	if (!indio_dev->channels) {
-		dev_err(&pdev->dev, "failed to duplicate channels\n");
-		return -ENOMEM;
-	}
-
-	ret = dev_rot_parse_report(pdev, hsdev,
-				   (struct iio_chan_spec *)indio_dev->channels,
-					hsdev->usage, rot_state);
+	ret = dev_rot_parse_report(pdev, hsdev, hsdev->usage, rot_state);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to setup attributes\n");
 		return ret;
 	}
 
+	indio_dev->channels = dev_rot_channels;
 	indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
 	indio_dev->info = &dev_rot_info;
 	indio_dev->name = name;

---
base-commit: 3fa5e5702a82d259897bd7e209469bc06368bf31
change-id: 20260214-iio-hid-sensor-rotation-cleanup-84e8410926ef

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


^ permalink raw reply related

* Re: [PATCH 08/10] dt-bindings: input: touchscreen: st,stmfts: Introduce STM FTS5
From: Dmitry Baryshkov @ 2026-03-01 22:40 UTC (permalink / raw)
  To: david
  Cc: Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Henrik Rydberg,
	Bjorn Andersson, Konrad Dybcio, Petr Hodina, linux-input,
	linux-stm32, linux-arm-kernel, linux-kernel, Krzysztof Kozlowski,
	devicetree, linux-arm-msm, phone-devel
In-Reply-To: <20260301-stmfts5-v1-8-22c458b9ac68@ixit.cz>

On Sun, Mar 01, 2026 at 06:51:22PM +0100, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> Introduce more recent STM FTS5 touchscreen support.
> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>  .../bindings/input/touchscreen/st,stmfts.yaml           | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/st,stmfts.yaml b/Documentation/devicetree/bindings/input/touchscreen/st,stmfts.yaml
> index 64c4f24ea3dd0..329d89977bdbc 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/st,stmfts.yaml
> +++ b/Documentation/devicetree/bindings/input/touchscreen/st,stmfts.yaml
> @@ -19,7 +19,9 @@ allOf:
>  
>  properties:
>    compatible:
> -    const: st,stmfts
> +    enum:
> +      - st,stmfts
> +      - st,stmfts5
>  
>    reg:
>      maxItems: 1
> @@ -53,6 +55,19 @@ required:
>  
>  unevaluatedProperties: false
>  
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          const: st,stmfts5
> +    then:
> +      properties:
> +        switch-gpio:
> +          description: Switch between SLPI and AP mode.

This doesn't sounds like the GPIO on the touchscreen, more like the
external schematic component. If it need sto be turned to one position,
it might be better to use GPIO hog for that.

> +
> +      required:
> +        - switch-gpio
> +
>  examples:
>    - |
>      #include <dt-bindings/interrupt-controller/irq.h>
> 
> -- 
> 2.51.0
> 
> 

-- 
With best wishes
Dmitry

^ permalink raw reply

* Re: [PATCH] iio: orientation: hid-sensor-rotation: use ext_scan_type
From: David Lechner @ 2026-03-01 22:12 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko
  Cc: linux-input, linux-iio, linux-kernel
In-Reply-To: <20260214-iio-hid-sensor-rotation-cleanup-v1-1-3aec9a533c0f@baylibre.com>

On 2/14/26 3:25 PM, David Lechner wrote:
> Make use of ext_scan_type to handle the dynamic realbits size of the
> quaternion data. This lets us implement it using static data rather than
> having to duplicate the channel info for each driver instance.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> This is something I noticed we could do while looking at an unrelated
> bug. I'm not sure I have hardware I could test this on, so it is only
> compile-tested. It would be good to get a Tested-by: from someone before
> applying this. Also, I'm not sure if 8, 16 and 32-bit data are all
> possible, so if someone knows, please chime in.
While looking at some bugs in this driver, I found in the code where
we can be certain that only 16 and 32-bit are used. And I figured out
a way to test with /dev/uhid. So I will drop the 8-bit case, test it
and send a v2.


^ permalink raw reply

* Re: [PATCH 09/10] Input: stmfts - support FTS5
From: Dmitry Torokhov @ 2026-03-01 22:10 UTC (permalink / raw)
  To: David Heidelberg via B4 Relay
  Cc: Maxime Coquelin, Alexandre Torgue, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Henrik Rydberg,
	Bjorn Andersson, Konrad Dybcio, Petr Hodina, linux-input,
	linux-stm32, linux-arm-kernel, linux-kernel, Krzysztof Kozlowski,
	devicetree, linux-arm-msm, phone-devel, David Heidelberg
In-Reply-To: <20260301-stmfts5-v1-9-22c458b9ac68@ixit.cz>

Hi David,

On Sun, Mar 01, 2026 at 06:51:23PM +0100, David Heidelberg via B4 Relay wrote:
> From: Petr Hodina <petr.hodina@protonmail.com>
> 
> Introduce basic FTS5 support.
> 
> FTS support SLPI and AP mode, introduce switch GPIO to switch between
> those two. Currently we can handle only full power AP mode, so we just
> switch to it.
> 
> Useful for devices like Pixel 3 (blueline).

I see "is_fts5" sprinkled throughout the code. I wonder: can we define
chip-specific operations and call them instead of doing conditional
logic which is hard to expand (if ever needed) to support additional
variants.
> 
> Nitpick: changed GPL v2 to GPL in module license.

Please split in to a separate patch.

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 4/4] iio: buffer: fix timestamp alignment when quaternion in scan
From: David Lechner @ 2026-03-01 20:24 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Nuno Sá,
	Andy Shevchenko, Lars Möllendorf, Lars-Peter Clausen,
	Greg Kroah-Hartman
  Cc: Jonathan Cameron, Lixu Zhang, linux-input, linux-iio,
	linux-kernel, David Lechner
In-Reply-To: <20260301-iio-fix-timestamp-alignment-v1-0-1a54980bfb90@baylibre.com>

Fix timestamp alignment when a scan buffer contains an element larger
than sizeof(int64_t). Currently s32 quaternions are the only such
element, and the one driver that has this (hid-sensor-rotation) has a
workaround in place already so this change does not affect it.

Previously, we assumed that the timestamp would always be 8-byte aligned
relative to the end of the scan buffer, but in the case of a scan buffer
a 16-byte quaternion vector, scan_bytes == 32, but the timestamp needs
to be placed at offset 16, not 24.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---

To test this, I used hid-sensor-rotation minus the first patch in the
series so that we can see that the timestamp actually moved to the
correct location.

Before this patch, the timestamp (8 bytes ending with "98 18") is in the
wrong location.

00000000  6a 18 00 00 ac f3 ff ff  83 2d 00 00 02 d3 ff ff  |j........-......|
00000010  00 00 00 00 00 00 00 00  5a 17 a0 2a 73 cb 98 18  |........Z..*s...|

00000020  ad 17 00 00 6a f4 ff ff  35 2b 00 00 ca d0 ff ff  |....j...5+......|
00000030  00 00 00 00 00 00 00 00  2a a6 bb 30 73 cb 98 18  |........*..0s...|

00000040  92 1e 00 00 50 ec ff ff  ea c1 ff ff 78 f0 ff ff  |....P.......x...|
00000050  00 00 00 00 00 00 00 00  8f 3b a7 39 77 cb 98 18  |.........;.9w...|

After this patch, timestamp is now in the correct location.

00000000  55 0f 00 00 dd 1f 00 00  af 0b 00 00 ec 3e 00 00  |U............>..|
00000010  c7 17 68 42 6d d0 98 18  00 00 00 00 00 00 00 00  |..hBm...........|

00000020  57 0e 00 00 c8 1f 00 00  d1 0e 00 00 42 3e 00 00  |W...........B>..|
00000030  56 a2 87 48 6d d0 98 18  00 00 00 00 00 00 00 00  |V..Hm...........|

00000040  a3 e2 ff ff d3 1b 00 00  0b c9 ff ff cc 20 00 00  |............. ..|
00000050  27 59 4d b3 72 d0 98 18  00 00 00 00 00 00 00 00  |'YM.r...........|

I also tested this with a different driver not affected by this bug to
make sure that the timestamp is still in the correct location for all
other drivers.
---
 include/linux/iio/buffer.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index d37f82678f71..ac19b39bdbe4 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -34,8 +34,16 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
 	void *data, int64_t timestamp)
 {
 	if (ACCESS_PRIVATE(indio_dev, scan_timestamp)) {
-		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
-		((int64_t *)data)[ts_offset] = timestamp;
+		size_t ts_offset = indio_dev->scan_bytes -
+			ACCESS_PRIVATE(indio_dev, largest_scan_element_size);
+
+		/*
+		 * The size of indio_dev->scan_bytes is always aligned to
+		 * largest_scan_element_size (see iio_compute_scan_bytes()).
+		 * And this size is always going to be >= sizeof(timestamp).
+		 * So to correctly place the timestamp, it goes at this offset.
+		 */
+		*(int64_t *)(data + ts_offset) = timestamp;
 	}
 
 	return iio_push_to_buffers(indio_dev, data);

-- 
2.43.0


^ permalink raw reply related


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