Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
From: Jiri Kosina @ 2025-08-12 12:35 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, bentiss, Dmitry.Torokhov, stable, Ping Cheng
In-Reply-To: <20250710212859.7892-1-ping.cheng@wacom.com>

Both applied to hid.git#for-6.18/core, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH] HID: hid-ntrig: fix unable to handle page fault in ntrig_report_version()
From: Jiri Kosina @ 2025-08-12 12:46 UTC (permalink / raw)
  To: Minjong Kim; +Cc: Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20250717-hid-ntrig-page-fault-fix-v1-1-96fa145a137f@samsung.com>

On Thu, 17 Jul 2025, Minjong Kim wrote:

> in ntrig_report_version(), hdev parameter passed from hid_probe().
> sending descriptor to /dev/uhid can make hdev->dev.parent->parent to null
> if hdev->dev.parent->parent is null, usb_dev has
> invalid address(0xffffffffffffff58) that hid_to_usb_dev(hdev) returned
> when usb_rcvctrlpipe() use usb_dev,it trigger
> page fault error for address(0xffffffffffffff58)
> 
> add null check logic to ntrig_report_version()
> before calling hid_to_usb_dev()
> 
> Signed-off-by: Minjong Kim <minbell.kim@samsung.com>
> ---
>  drivers/hid/hid-ntrig.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> index 2738ce947434f904f32e9a1979b1681c66972ff9..96d3300655b5aa1621015b8e1fb511e6f616a713 100644
> --- a/drivers/hid/hid-ntrig.c
> +++ b/drivers/hid/hid-ntrig.c
> @@ -139,6 +139,10 @@ static inline void ntrig_set_mode(struct hid_device *hdev, const int mode)
>  
>  static void ntrig_report_version(struct hid_device *hdev)
>  {
> +
> +	if (!hdev->dev.parent->parent)
> +		return;
> +
>  	int ret;
>  	char buf[20];
>  	struct usb_device *usb_dev = hid_to_usb_dev(hdev);

I know that mixing declarations and code is fine these days, but we 
haven't been progressive enough to switch to that coding style in HID 
subsystem yet :) Would you be willing to move it below the declarations?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH] HID: steelseries: refactor probe() and remove()
From: Jiri Kosina @ 2025-08-12 12:48 UTC (permalink / raw)
  To: Jeongjun Park; +Cc: bentiss, hadess, linux-input, linux-kernel
In-Reply-To: <20250717112643.1410093-1-aha310510@gmail.com>

On Thu, 17 Jul 2025, Jeongjun Park wrote:

> steelseries_srws1_probe() still does not use devm_kzalloc() and
> devm_led_classdev_register(), so there is a lot of code to safely manage
> heap, which reduces readability and may cause memory leaks due to minor
> patch mistakes in the future.
> 
> Therefore, it should be changed to use devm_kzalloc() and
> devm_led_classdev_register() to easily and safely manage heap.
> 
> Also, the current steelseries driver mainly checks sd->quriks to determine
> which product a specific HID device is, which is not the correct way.
> 
> remove(), unlike probe(), does not receive struct hid_device_id as an
> argument, so it must check hdev unconditionally to know which product
> it is.
> 
> However, since struct steelseries_device and struct steelseries_srws1_data
> have different structures, if SRWS1 is removed in remove(), converts
> hdev->dev, which is initialized to struct steelseries_srws1_data,
> to struct steelseries_device and uses it. This causes various
> memory-related bugs as completely unexpected values exist in member
> variables of the structure.
> 
> Therefore, in order to modify probe() and remove() to work properly,
> Arctis 1, 9 should be added to HID_USB_DEVICE and some functions should be
> modified to check hdev->product when determining HID device product.
> 
> Fixes: a0c76896c3fb ("HID: steelseries: Add support for Arctis 1 XBox")
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>

Applied to hid.git#for-6.18/steelseries, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH] HID: intel-ish-hid: Increase ISHTP resume ack timeout to 300ms
From: Jiri Kosina @ 2025-08-12 12:49 UTC (permalink / raw)
  To: Zhang Lixu
  Cc: linux-input, srinivas.pandruvada, benjamin.tissoires, hua.he,
	wenji1.yang, juswin.hsueh, henry.yeh, neo.wong
In-Reply-To: <20250723013132.479762-1-lixu.zhang@intel.com>

On Wed, 23 Jul 2025, Zhang Lixu wrote:

> During s2idle suspend/resume testing on some systems, occasional several
> tens of seconds delays were observed in HID sensor resume handling. Trace
> analysis revealed repeated "link not ready" timeout errors during
> set/get_report operations, which were traced to the
> hid_ishtp_cl_resume_handler() timing out while waiting for the ISHTP
> resume acknowledgment. The previous timeout was set to 50ms, which proved
> insufficient on affected machines.
> 
> Empirical measurements on failing systems showed that the time from ISH
> resume initiation to receiving the ISHTP resume ack could be as long as
> 180ms. As a result, the 50ms timeout caused failures.
> 
> To address this, increase the wait timeout for ISHTP resume ack from 50ms
> to 300ms, providing a safer margin for slower hardware. Additionally, add
> error logging when a timeout occurs to aid future debugging and issue
> triage. No functional changes are made beyond the timeout adjustment and
> improved error reporting.
> 
> Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Applied to hid.git#for-6.17/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH] HID: Intel-thc-hid: Intel-thc: Use str_true_false() helper
From: Jiri Kosina @ 2025-08-12 12:50 UTC (permalink / raw)
  To: liu.xuemei1
  Cc: bentiss, even.xu, xinpeng.sun, srinivas.pandruvada, liu.song13,
	linux-input, linux-kernel
In-Reply-To: <20250724103626535JRNAc8OZvk4dXKn-b0CVZ@zte.com.cn>

On Thu, 24 Jul 2025, liu.xuemei1@zte.com.cn wrote:

> From: Liu Song <liu.song13@zte.com.cn>
> 
> Remove hard-coded strings by using the str_true_false() helper function.
> 
> Signed-off-by: Liu Song <liu.song13@zte.com.cn>

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH] HID: uclogic: Use str_true_false() helper
From: Jiri Kosina @ 2025-08-12 12:51 UTC (permalink / raw)
  To: liu.xuemei1; +Cc: bentiss, linux-input, liu.song13
In-Reply-To: <20250724103816237r5sdS6T9M3uypp0-8vi4w@zte.com.cn>

On Thu, 24 Jul 2025, liu.xuemei1@zte.com.cn wrote:

> From: Liu Song <liu.song13@zte.com.cn>
> 
> Remove hard-coded strings by using the str_true_false() helper function.
> 
> Signed-off-by: Liu Song <liu.song13@zte.com.cn>

Applied, thank you.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH][next] HID: Kconfig: Fix spelling mistake "enthropy" -> "entropy"
From: Jiri Kosina @ 2025-08-12 12:52 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Benjamin Tissoires, linux-input, kernel-janitors, linux-kernel
In-Reply-To: <20250724111118.141114-1-colin.i.king@gmail.com>

On Thu, 24 Jul 2025, Colin Ian King wrote:

> There is a spelling mistake in the HID_U2FZERO description. Fix it.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  drivers/hid/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index a57901203aeb..79997553d8f9 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -1243,7 +1243,7 @@ config HID_U2FZERO
>  
>  	  U2F Zero supports custom commands for blinking the LED
>  	  and getting data from the internal hardware RNG.
> -	  The internal hardware can be used to feed the enthropy pool.
> +	  The internal hardware can be used to feed the entropy pool.
>  
>  	  U2F Zero only supports blinking its LED, so this driver doesn't
>  	  allow setting the brightness to anything but 1, which will

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH v2 RESEND] HID: multitouch: fix slab out-of-bounds access in mt_report_fixup()
From: Jiri Kosina @ 2025-08-12 12:53 UTC (permalink / raw)
  To: Qasim Ijaz; +Cc: bentiss, linux-input, linux-kernel, stable, Jiri Slaby
In-Reply-To: <20250810180924.44582-1-qasdev00@gmail.com>

On Sun, 10 Aug 2025, Qasim Ijaz wrote:

> A malicious HID device can trigger a slab out-of-bounds during
> mt_report_fixup() by passing in report descriptor smaller than
> 607 bytes. mt_report_fixup() attempts to patch byte offset 607
> of the descriptor with 0x25 by first checking if byte offset
> 607 is 0x15 however it lacks bounds checks to verify if the
> descriptor is big enough before conducting this check. Fix
> this bug by ensuring the descriptor size is at least 608
> bytes before accessing it.
> 
> Below is the KASAN splat after the out of bounds access happens:
> 
> [   13.671954] ==================================================================
> [   13.672667] BUG: KASAN: slab-out-of-bounds in mt_report_fixup+0x103/0x110
> [   13.673297] Read of size 1 at addr ffff888103df39df by task kworker/0:1/10
> [   13.673297]
> [   13.673297] CPU: 0 UID: 0 PID: 10 Comm: kworker/0:1 Not tainted 6.15.0-00005-gec5d573d83f4-dirty #3
> [   13.673297] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/04
> [   13.673297] Call Trace:
> [   13.673297]  <TASK>
> [   13.673297]  dump_stack_lvl+0x5f/0x80
> [   13.673297]  print_report+0xd1/0x660
> [   13.673297]  kasan_report+0xe5/0x120
> [   13.673297]  __asan_report_load1_noabort+0x18/0x20
> [   13.673297]  mt_report_fixup+0x103/0x110
> [   13.673297]  hid_open_report+0x1ef/0x810
> [   13.673297]  mt_probe+0x422/0x960
> [   13.673297]  hid_device_probe+0x2e2/0x6f0
> [   13.673297]  really_probe+0x1c6/0x6b0
> [   13.673297]  __driver_probe_device+0x24f/0x310
> [   13.673297]  driver_probe_device+0x4e/0x220
> [   13.673297]  __device_attach_driver+0x169/0x320
> [   13.673297]  bus_for_each_drv+0x11d/0x1b0
> [   13.673297]  __device_attach+0x1b8/0x3e0
> [   13.673297]  device_initial_probe+0x12/0x20
> [   13.673297]  bus_probe_device+0x13d/0x180
> [   13.673297]  device_add+0xe3a/0x1670
> [   13.673297]  hid_add_device+0x31d/0xa40
> [...]
> 
> Fixes: c8000deb6836 ("HID: multitouch: Add support for GT7868Q")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
> Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
> ---
> v2:
> - Simplify fix with a if-size check after discussion with Jiri Slaby
> - Change explanation of bug to reflect inclusion of a if-size check

Applied to hid.git#for-6.17/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH v2] HID: lg-g15 - Add support for Logitech G13.
From: Markus Elfring @ 2025-08-12 12:55 UTC (permalink / raw)
  To: Leo L. Schwab, linux-input
  Cc: LKML, Benjamin Tissoires, Hans de Goede, Jiri Kosina, Kate Hsuan
In-Reply-To: <20250812065327.515098-2-ewhac@ewhac.org>

…
> +++ b/drivers/hid/hid-lg-g15.c
> +static int lg_g13_get_leds_state(struct lg_g15_data *g15)
> +{
> +	for (int i = LG_G15_MACRO_PRESET1;  i < LG_G15_LED_MAX;  ++i)
…
+static int lg_g13_mkey_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
+{
…
> +	for (i = LG_G15_MACRO_PRESET1;  i < LG_G15_LED_MAX;  ++i) {
…

Please reconsider the usage of double space characters at some source code places.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.17-rc1#n234

Regards,
Markus

^ permalink raw reply

* Re: [PATCH] HID: Wacom: Add a new Art Pen
From: Jiri Kosina @ 2025-08-12 12:57 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, bentiss, Ping Cheng
In-Reply-To: <20250811054030.18331-1-ping.cheng@wacom.com>

On Sun, 10 Aug 2025, Ping Cheng wrote:

> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 955b39d22524..9b2c710f8da1 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -684,6 +684,7 @@ static bool wacom_is_art_pen(int tool_id)
>  	case 0x885:	/* Intuos3 Marker Pen */
>  	case 0x804:	/* Intuos4/5 13HD/24HD Marker Pen */
>  	case 0x10804:	/* Intuos4/5 13HD/24HD Art Pen */
> +	case 0x204:     /* Art Pen 2 */
>  		is_art_pen = true;
>  		break;

Applied to hid.git#for-6.17/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
From: Cheng, Ping @ 2025-08-12 13:43 UTC (permalink / raw)
  To: Jiri Kosina, Ping Cheng
  Cc: linux-input@vger.kernel.org, bentiss@kernel.org,
	Dmitry.Torokhov@gmail.com, stable@kernel.org
In-Reply-To: <29911p88-1n01-s610-9opn-98n874r84srr@xreary.bet>

Hi Jiri,

Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...

Thank you for your effort. And sorry for the trouble.
Ping

________________________________________
From: Jiri Kosina <jikos@kernel.org>
Sent: Tuesday, August 12, 2025 5:35 AM
To: Ping Cheng <pinglinux@gmail.com>
Cc: linux-input@vger.kernel.org <linux-input@vger.kernel.org>; bentiss@kernel.org <bentiss@kernel.org>; Dmitry.Torokhov@gmail.com <Dmitry.Torokhov@gmail.com>; stable@kernel.org <stable@kernel.org>; Cheng, Ping <Ping.Cheng@wacom.com>
Subject: Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen

Both applied to hid.git#for-6.18/core, thanks.

--
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCH v2 RESEND] HID: multitouch: fix slab out-of-bounds access in mt_report_fixup()
From: Qasim Ijaz @ 2025-08-12 14:22 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: bentiss, linux-input, linux-kernel, stable, Jiri Slaby
In-Reply-To: <6o42n3q5-sq57-q7nq-rpn6-50np33r5ssqp@xreary.bet>

On Tue, Aug 12, 2025 at 02:53:50PM +0200, Jiri Kosina wrote:
> On Sun, 10 Aug 2025, Qasim Ijaz wrote:
> 
> > A malicious HID device can trigger a slab out-of-bounds during
> > mt_report_fixup() by passing in report descriptor smaller than
> > 607 bytes. mt_report_fixup() attempts to patch byte offset 607
> > of the descriptor with 0x25 by first checking if byte offset
> > 607 is 0x15 however it lacks bounds checks to verify if the
> > descriptor is big enough before conducting this check. Fix
> > this bug by ensuring the descriptor size is at least 608
> > bytes before accessing it.
> > 
> > Below is the KASAN splat after the out of bounds access happens:
> > 
> > [   13.671954] ==================================================================
> > [   13.672667] BUG: KASAN: slab-out-of-bounds in mt_report_fixup+0x103/0x110
> > [   13.673297] Read of size 1 at addr ffff888103df39df by task kworker/0:1/10
> > [   13.673297]
> > [   13.673297] CPU: 0 UID: 0 PID: 10 Comm: kworker/0:1 Not tainted 6.15.0-00005-gec5d573d83f4-dirty #3
> > [   13.673297] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/04
> > [   13.673297] Call Trace:
> > [   13.673297]  <TASK>
> > [   13.673297]  dump_stack_lvl+0x5f/0x80
> > [   13.673297]  print_report+0xd1/0x660
> > [   13.673297]  kasan_report+0xe5/0x120
> > [   13.673297]  __asan_report_load1_noabort+0x18/0x20
> > [   13.673297]  mt_report_fixup+0x103/0x110
> > [   13.673297]  hid_open_report+0x1ef/0x810
> > [   13.673297]  mt_probe+0x422/0x960
> > [   13.673297]  hid_device_probe+0x2e2/0x6f0
> > [   13.673297]  really_probe+0x1c6/0x6b0
> > [   13.673297]  __driver_probe_device+0x24f/0x310
> > [   13.673297]  driver_probe_device+0x4e/0x220
> > [   13.673297]  __device_attach_driver+0x169/0x320
> > [   13.673297]  bus_for_each_drv+0x11d/0x1b0
> > [   13.673297]  __device_attach+0x1b8/0x3e0
> > [   13.673297]  device_initial_probe+0x12/0x20
> > [   13.673297]  bus_probe_device+0x13d/0x180
> > [   13.673297]  device_add+0xe3a/0x1670
> > [   13.673297]  hid_add_device+0x31d/0xa40
> > [...]
> > 
> > Fixes: c8000deb6836 ("HID: multitouch: Add support for GT7868Q")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
> > Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
> > ---
> > v2:
> > - Simplify fix with a if-size check after discussion with Jiri Slaby
> > - Change explanation of bug to reflect inclusion of a if-size check
> 
> Applied to hid.git#for-6.17/upstream-fixes, thanks.
> 
Thanks Jiri. Would it also be possible to review this one:
<https://lore.kernel.org/all/20250810181041.44874-1-qasdev00@gmail.com/>,
I resent it but it probably got buried in your inbox.

Thanks,
Qasim
> -- 
> Jiri Kosina
> SUSE Labs
> 

^ permalink raw reply

* Re: [PATCH v2 RESEND] HID: multitouch: fix slab out-of-bounds access in mt_report_fixup()
From: Jiri Kosina @ 2025-08-12 14:25 UTC (permalink / raw)
  To: Qasim Ijaz; +Cc: bentiss, linux-input, linux-kernel, stable, Jiri Slaby
In-Reply-To: <aJtOG7bqgC8wUxta@gmail.com>

On Tue, 12 Aug 2025, Qasim Ijaz wrote:

> Thanks Jiri. Would it also be possible to review this one:
> <https://lore.kernel.org/all/20250810181041.44874-1-qasdev00@gmail.com/>,
> I resent it but it probably got buried in your inbox.

That one is still in my queue to review, in didn't fall in between cracks.

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH 2/8] mfd: dt-bindings: ti,twl6040: convert to DT schema
From: Rob Herring @ 2025-08-12 14:54 UTC (permalink / raw)
  To: Jihed Chaibi
  Cc: tiwai, devicetree, linux-usb, gregkh, ukleinek, krzk+dt,
	dmitry.torokhov, broonie, linux-pwm, lee, linux-sound, lgirdwood,
	peter.ujfalusi, linux-kernel, linux-input, shuah, conor+dt
In-Reply-To: <175496188325.1486426.9118766970247515386.robh@kernel.org>

On Mon, Aug 11, 2025 at 08:24:43PM -0500, Rob Herring (Arm) wrote:
> 
> On Tue, 12 Aug 2025 00:47:33 +0200, Jihed Chaibi wrote:
> > Convert the legacy TXT binding for the TWL6040 MFD
> > to the modern YAML DT schema format. This adds formal validation
> > and improves documentation.
> > 
> > Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
> > ---
> >  .../devicetree/bindings/mfd/ti,twl6040.yaml   | 155 ++++++++++++++++++
> >  .../devicetree/bindings/mfd/twl6040.txt       |  67 --------
> >  2 files changed, 155 insertions(+), 67 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl6040.yaml
> >  delete mode 100644 Documentation/devicetree/bindings/mfd/twl6040.txt
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,twl6040.example.dtb: 
> twl@4b (ti,twl6040): 'twl6040,audpwron-gpio' does not match any of 
> the regexes: '^#.*', 
> '^(at25|bm|devbus|dmacap|dsa|exynos|fsi[ab]|gpio-fan|gpio-key|gpio|gpmc|hdmi|i2c-gpio),.*', 
> '^(keypad|m25p|max8952|max8997|max8998|mpmc),.*', 
> '^(pciclass|pinctrl-single|#pinctrl-single|PowerPC),.*', 
> '^(pl022|pxa-mmc|rcar_sound|rotary-encoder|s5m8767|sdhci),.*', 
> '^(simple-audio-card|st-plgpio|st-spics|ts),.*',

You will need to add 'twl6040' to this list of exceptions in 
vendor-prefixes.yaml.

Rob

^ permalink raw reply

* Re: [PATCH 1/8] mfd: dt-bindings: ti,twl4030-audio: convert to DT schema
From: Rob Herring @ 2025-08-12 14:58 UTC (permalink / raw)
  To: Jihed Chaibi
  Cc: linux-kernel, peter.ujfalusi, dmitry.torokhov, krzk+dt, lgirdwood,
	tiwai, conor+dt, lee, ukleinek, broonie, gregkh, linux-input,
	devicetree, linux-pwm, linux-sound, linux-usb, shuah
In-Reply-To: <20250811224739.53869-2-jihed.chaibi.dev@gmail.com>

On Tue, Aug 12, 2025 at 12:47:32AM +0200, Jihed Chaibi wrote:
> Convert the legacy TXT binding for the TWL4030 audio module
> to the modern YAML DT schema format. This adds formal validation
> and improves documentation.
> 
> Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
> ---
>  .../bindings/mfd/ti,twl4030-audio.yaml        | 91 +++++++++++++++++++
>  .../devicetree/bindings/mfd/twl4030-audio.txt | 46 ----------

Shouldn't this move to bindings/sound/?

>  2 files changed, 91 insertions(+), 46 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl4030-audio.yaml
>  delete mode 100644 Documentation/devicetree/bindings/mfd/twl4030-audio.txt
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,twl4030-audio.yaml b/Documentation/devicetree/bindings/mfd/ti,twl4030-audio.yaml
> new file mode 100644
> index 000000000..16ddcf007
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/ti,twl4030-audio.yaml
> @@ -0,0 +1,91 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/ti,twl4030-audio.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Texas Instruments TWL4030-family Audio Module
> +
> +maintainers:
> +  - Peter Ujfalusi <peter.ujfalusi@gmail.com>
> +
> +description: |

Don't need '|' if no formatting to preserve.

> +  The audio module within the TWL4030-family of companion chips consists
> +  of an audio codec and a vibra driver. This binding describes the parent
> +  node for these functions.
> +
> +properties:
> +  compatible:
> +    const: ti,twl4030-audio
> +
> +  codec:
> +    type: object
> +    description: Node containing properties for the audio codec functionality.

       additionalProperties: false

and a blank line here.

> +    properties:
> +      ti,digimic_delay:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Delay in milliseconds after enabling digital microphones to reduce
> +          artifacts.
> +
> +      ti,ramp_delay_value:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Headset ramp delay configuration to reduce pop noise.
> +
> +      ti,hs_extmute:
> +        type: boolean
> +        description:
> +          Enable the use of an external mute for headset pop reduction.
> +
> +      ti,hs_extmute_gpio:
> +        $ref: /schemas/types.yaml#/definitions/phandle-array
> +        description:
> +          The GPIO specifier for the external mute control.
> +        maxItems: 1
> +
> +      ti,offset_cncl_path:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Offset cancellation path selection. Refer to the Technical
> +          Reference Manual for valid values.

Constraints for any of these properties?

> +
> +    # The 'codec' node itself is optional, but if it exists, it can be empty.
> +    # We don't require any of its sub-properties.
> +
> +  ti,enable-vibra:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      Set to 1 to enable the vibra functionality, if missing
> +      or it is 0, the vibra functionality is disabled.

Sounds like constraints. Don't write constraints in prose.

> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +
> +examples:
> +  - |
> +    i2c {
> +
> +      clock-frequency = <2600000>;

Drop. Not relevant to this binding.

> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      twl: twl@48 {
> +        reg = <0x48>;
> +        interrupts = <7>; /* SYS_NIRQ cascaded to intc */
> +        interrupt-parent = <&intc>;
> +
> +        twl_audio: audio {
> +          compatible = "ti,twl4030-audio";
> +
> +          ti,enable-vibra = <1>;
> +
> +          codec {
> +            ti,ramp_delay_value = <3>;
> +          };
> +
> +        };
> +      };
> +    };

^ permalink raw reply

* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
From: Benjamin Tissoires @ 2025-08-12 15:14 UTC (permalink / raw)
  To: Cheng, Ping
  Cc: Jiri Kosina, Ping Cheng, linux-input@vger.kernel.org,
	Dmitry.Torokhov@gmail.com, stable@kernel.org
In-Reply-To: <GV2PR07MB9153ED83B6705961417EA1969B2BA@GV2PR07MB9153.eurprd07.prod.outlook.com>

On Aug 12 2025, Cheng, Ping wrote:
> Hi Jiri,
> 
> Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...

Furthermore:
  CC      drivers/hid/hid-input.o
drivers/hid/hid-input.c: In function 'hidinput_configure_usage':
drivers/hid/hid-input.c:863:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
  863 |                         if ((field->application & 0xff) == 0x02) {
      |                            ^
drivers/hid/hid-input.c:872:17: note: here
  872 |                 case HID_GD_X: case HID_GD_Y:
      |                 ^~~~

So this breaks compilation entirely :(

[Sorry I'm just back from vacations, and hadn't had the time to look at
the pile of emails]

Cheers,
Benjamin

> 
> Thank you for your effort. And sorry for the trouble.
> Ping
> 
> ________________________________________
> From: Jiri Kosina <jikos@kernel.org>
> Sent: Tuesday, August 12, 2025 5:35 AM
> To: Ping Cheng <pinglinux@gmail.com>
> Cc: linux-input@vger.kernel.org <linux-input@vger.kernel.org>; bentiss@kernel.org <bentiss@kernel.org>; Dmitry.Torokhov@gmail.com <Dmitry.Torokhov@gmail.com>; stable@kernel.org <stable@kernel.org>; Cheng, Ping <Ping.Cheng@wacom.com>
> Subject: Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
> 
> Both applied to hid.git#for-6.18/core, thanks.
> 
> --
> Jiri Kosina
> SUSE Labs

^ permalink raw reply

* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
From: Jiri Kosina @ 2025-08-12 15:31 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Cheng, Ping, Ping Cheng, linux-input@vger.kernel.org,
	Dmitry.Torokhov@gmail.com, stable@kernel.org
In-Reply-To: <qylywmhjcciqyqbyyoa5lmgdne3mcfexbzy2lk36mhhindepf7@laz3kov67brd>

On Tue, 12 Aug 2025, Benjamin Tissoires wrote:

> On Aug 12 2025, Cheng, Ping wrote:
> > Hi Jiri,
> > 
> > Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...
> 
> Furthermore:
>   CC      drivers/hid/hid-input.o
> drivers/hid/hid-input.c: In function 'hidinput_configure_usage':
> drivers/hid/hid-input.c:863:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
>   863 |                         if ((field->application & 0xff) == 0x02) {
>       |                            ^
> drivers/hid/hid-input.c:872:17: note: here
>   872 |                 case HID_GD_X: case HID_GD_Y:
>       |                 ^~~~
> 
> So this breaks compilation entirely :(

Hm, I really wonder how this escaped me, as I always run a compile+boot 
battery before pushing out.
Sorry for the hassle, I'll investigate more where the glitch was on the 
side of my automation.

Now dropped.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply

* Re: [PATCH 2/8] mfd: dt-bindings: ti,twl6040: convert to DT schema
From: Jihed Chaibi @ 2025-08-12 16:06 UTC (permalink / raw)
  To: Rob Herring
  Cc: tiwai, devicetree, linux-usb, gregkh, ukleinek, krzk+dt,
	dmitry.torokhov, broonie, linux-pwm, lee, linux-sound, lgirdwood,
	peter.ujfalusi, linux-kernel, linux-input, shuah, conor+dt
In-Reply-To: <20250812145415.GA3607226-robh@kernel.org>

On Tue, Aug 12, 2025 at 4:54 PM Rob Herring <robh@kernel.org> wrote:
>
> On Mon, Aug 11, 2025 at 08:24:43PM -0500, Rob Herring (Arm) wrote:
> >
> > On Tue, 12 Aug 2025 00:47:33 +0200, Jihed Chaibi wrote:
> > > Convert the legacy TXT binding for the TWL6040 MFD
> > > to the modern YAML DT schema format. This adds formal validation
> > > and improves documentation.
> > >
> > > Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
> > > ---
> > >  .../devicetree/bindings/mfd/ti,twl6040.yaml   | 155 ++++++++++++++++++
> > >  .../devicetree/bindings/mfd/twl6040.txt       |  67 --------
> > >  2 files changed, 155 insertions(+), 67 deletions(-)
> > >  create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl6040.yaml
> > >  delete mode 100644 Documentation/devicetree/bindings/mfd/twl6040.txt
> > >
> >
> > My bot found errors running 'make dt_binding_check' on your patch:
> >
> > yamllint warnings/errors:
> >
> > dtschema/dtc warnings/errors:
> > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,twl6040.example.dtb:
> > twl@4b (ti,twl6040): 'twl6040,audpwron-gpio' does not match any of
> > the regexes: '^#.*',
> > '^(at25|bm|devbus|dmacap|dsa|exynos|fsi[ab]|gpio-fan|gpio-key|gpio|gpmc|hdmi|i2c-gpio),.*',
> > '^(keypad|m25p|max8952|max8997|max8998|mpmc),.*',
> > '^(pciclass|pinctrl-single|#pinctrl-single|PowerPC),.*',
> > '^(pl022|pxa-mmc|rcar_sound|rotary-encoder|s5m8767|sdhci),.*',
> > '^(simple-audio-card|st-plgpio|st-spics|ts),.*',
>
> You will need to add 'twl6040' to this list of exceptions in
> vendor-prefixes.yaml.
>
> Rob

Hi Rob, thanks for the feedback.

Wouldn't it be simpler if we put 'ti' (the actual vendor) instead of 'twl6040'?
No other file is using the current name, so there would be no need for
additional editing.

Cheers,

(CCing everyone, sorry for emailing twice)

^ permalink raw reply

* Re: (subset) [PATCH 00/21] gpiolib: fence off legacy interfaces
From: Mark Brown @ 2025-08-12 16:23 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, linux-gpio, Arnd Bergmann
  Cc: Arnd Bergmann, Andrew Lunn, Sebastian Hesselbarth,
	Gregory Clement, Russell King, Daniel Mack, Haojian Zhuang,
	Robert Jarzmik, Krzysztof Kozlowski, Alim Akhtar,
	Geert Uytterhoeven, Thomas Bogendoerfer, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Dmitry Torokhov, Lee Jones, Pavel Machek, Mauro Carvalho Chehab,
	Matti Vaittinen, Florian Fainelli, Jeff Johnson, Hans de Goede,
	Ilpo Järvinen, Greg Kroah-Hartman, Jaroslav Kysela,
	Takashi Iwai, Liam Girdwood, Andy Shevchenko,
	Dr. David Alan Gilbert, linux-arm-kernel, linux-kernel,
	linux-samsung-soc, linux-m68k, linux-mips, linux-sh, linux-input,
	linux-leds, linux-media, patches, netdev, linux-wireless, ath10k,
	platform-driver-x86, linux-usb, linux-sound
In-Reply-To: <20250808151822.536879-1-arnd@kernel.org>

On Fri, 08 Aug 2025 17:17:44 +0200, Arnd Bergmann wrote:
> Commit 678bae2eaa81 ("gpiolib: make legacy interfaces optional") was
> merged for linux-6.17, so now it is possible to use the legacy interfaces
> conditionally and eventually have the support left out of the kernel
> whenever it is not needed.
> 
> I created six patches to force-enable CONFIG_GPIOLIB_LEGACY on the
> few (mostly ancient) platforms that still require this, plus a set of
> patches to either add the corresponding Kconfig dependencies that make
> the device drivers conditional on that symbol, or change them to no
> longer require it.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[08/21] ASoC: add GPIOLIB_LEGACY dependency where needed
        commit: 5383d67e2430822fa7bd20dcbbebbd8ae808e386
[20/21] ASoC: pxa: add GPIOLIB_LEGACY dependency
        commit: 2d86d2585ab929a143d1e6f8963da1499e33bf13

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply

* Re: [PATCH v2] HID: lg-g15 - Add support for Logitech G13.
From: kernel test robot @ 2025-08-13  0:11 UTC (permalink / raw)
  To: Leo L. Schwab, Hans de Goede
  Cc: oe-kbuild-all, Kate Hsuan, Leo L. Schwab, Jiri Kosina,
	Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <20250812065327.515098-2-ewhac@ewhac.org>

Hi Leo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on hid/for-next]
[also build test WARNING on linus/master v6.17-rc1 next-20250812]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Leo-L-Schwab/HID-lg-g15-Add-support-for-Logitech-G13/20250812-151139
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
patch link:    https://lore.kernel.org/r/20250812065327.515098-2-ewhac%40ewhac.org
patch subject: [PATCH v2] HID: lg-g15 - Add support for Logitech G13.
config: arm-randconfig-004-20250813 (https://download.01.org/0day-ci/archive/20250813/202508130759.HscxexZX-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250813/202508130759.HscxexZX-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508130759.HscxexZX-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/hid/hid-lg-g15.c: In function 'lg_g13_event':
>> drivers/hid/hid-lg-g15.c:660:7: warning: unused variable 'hw_brightness_changed' [-Wunused-variable]
     bool hw_brightness_changed;
          ^~~~~~~~~~~~~~~~~~~~~


vim +/hw_brightness_changed +660 drivers/hid/hid-lg-g15.c

   655	
   656	static int lg_g13_event(struct lg_g15_data *g15, u8 const *data)
   657	{
   658		struct g13_input_report const * const rep = (struct g13_input_report *) data;
   659		int i, val;
 > 660		bool hw_brightness_changed;
   661	
   662		/*
   663		 * Main macropad and menu keys.
   664		 * Emit key events defined for each bit position.
   665		 */
   666		for (i = 0;  i < ARRAY_SIZE(g13_keys_for_bits);  ++i) {
   667			if (g13_keys_for_bits[i]) {
   668				val = TEST_BIT(rep->keybits, i);
   669				input_report_key(g15->input, g13_keys_for_bits[i], val);
   670			}
   671		}
   672		input_sync(g15->input);
   673	
   674		/*
   675		 * Joystick.
   676		 * Emit button and deflection events.
   677		 */
   678		for (i = 0;  i < ARRAY_SIZE(g13_keys_for_bits_js);  ++i) {
   679			if (g13_keys_for_bits_js[i]) {
   680				val = TEST_BIT(rep->keybits, i + 33);
   681				input_report_key(g15->input_js, g13_keys_for_bits_js[i], val);
   682			}
   683		}
   684		input_report_abs(g15->input_js, ABS_X, rep->joy_x);
   685		input_report_abs(g15->input_js, ABS_Y, rep->joy_y);
   686		input_sync(g15->input_js);
   687	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply

* Re: [PATCH v2] HID: hid-ntrig: fix unable to handle page fault in ntrig_report_version()
From: Minjong Kim @ 2025-08-13  5:17 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel
In-Reply-To: <rqo85n88-82s2-30s6-qn80-r4r943p4q59o@xreary.bet>

[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]

On Tue, Aug 12, 2025 at 02:46:24PM +0200, Jiri Kosina wrote:
> 
> I know that mixing declarations and code is fine these days, but we 
> haven't been progressive enough to switch to that coding style in HID 
> subsystem yet :) Would you be willing to move it below the declarations?
>  

From 75e52defd4b2fd138285c5ad953942e2e6cf2fbb Mon Sep 17 00:00:00 2001
From: Minjong Kim <minbell.kim@samsung.com>
Date: Thu, 17 Jul 2025 14:37:47 +0900
Subject: [PATCH v2] HID: hid-ntrig: fix unable to handle page fault in
 ntrig_report_version()

in ntrig_report_version(), hdev parameter passed from hid_probe().
sending descriptor to /dev/uhid can make hdev->dev.parent->parent to null
if hdev->dev.parent->parent is null, usb_dev has
invalid address(0xffffffffffffff58) that hid_to_usb_dev(hdev) returned
when usb_rcvctrlpipe() use usb_dev,it trigger
page fault error for address(0xffffffffffffff58)

add null check logic to ntrig_report_version()
before calling hid_to_usb_dev()

Signed-off-by: Minjong Kim <minbell.kim@samsung.com>
---
 drivers/hid/hid-ntrig.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 2738ce947434..fa948d9e236c 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -144,6 +144,9 @@ static void ntrig_report_version(struct hid_device *hdev)
 	struct usb_device *usb_dev = hid_to_usb_dev(hdev);
 	unsigned char *data = kmalloc(8, GFP_KERNEL);

+	if (!hdev->dev.parent->parent)
+		return;
+
 	if (!data)
 		goto err_free;

--
2.34.1

I move it below the declarations.

Best regards,


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related

* [hid:for-6.18/core 1/2] drivers/hid/hid-input.c:863:28: warning: this statement may fall through
From: kernel test robot @ 2025-08-13  6:44 UTC (permalink / raw)
  To: Ping Cheng; +Cc: oe-kbuild-all, linux-input, Jiri Kosina

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-6.18/core
head:   eb5a60cc53d31f3f94537308147769363ad9fcb5
commit: f5013c67d914a4bd7ad403ac792056ae16d37e03 [1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
config: arc-randconfig-001-20250813 (https://download.01.org/0day-ci/archive/20250813/202508131442.PaMZ9pxz-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250813/202508131442.PaMZ9pxz-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508131442.PaMZ9pxz-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/hid/hid-input.c: In function 'hidinput_configure_usage':
>> drivers/hid/hid-input.c:863:28: warning: this statement may fall through [-Wimplicit-fallthrough=]
     863 |                         if ((field->application & 0xff) == 0x02) {
         |                            ^
   drivers/hid/hid-input.c:872:17: note: here
     872 |                 case HID_GD_X: case HID_GD_Y:
         |                 ^~~~


vim +863 drivers/hid/hid-input.c

   665	
   666	static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
   667					     struct hid_usage *usage, unsigned int usage_index)
   668	{
   669		struct input_dev *input = hidinput->input;
   670		struct hid_device *device = input_get_drvdata(input);
   671		const struct usage_priority *usage_priority = NULL;
   672		int max = 0, code;
   673		unsigned int i = 0;
   674		unsigned long *bit = NULL;
   675	
   676		field->hidinput = hidinput;
   677	
   678		if (field->flags & HID_MAIN_ITEM_CONSTANT)
   679			goto ignore;
   680	
   681		/* Ignore if report count is out of bounds. */
   682		if (field->report_count < 1)
   683			goto ignore;
   684	
   685		/* only LED usages are supported in output fields */
   686		if (field->report_type == HID_OUTPUT_REPORT &&
   687				(usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
   688			goto ignore;
   689		}
   690	
   691		/* assign a priority based on the static list declared here */
   692		for (i = 0; i < ARRAY_SIZE(hidinput_usages_priorities); i++) {
   693			if (usage->hid == hidinput_usages_priorities[i].usage) {
   694				usage_priority = &hidinput_usages_priorities[i];
   695	
   696				field->usages_priorities[usage_index] =
   697					(ARRAY_SIZE(hidinput_usages_priorities) - i) << 8;
   698				break;
   699			}
   700		}
   701	
   702		/*
   703		 * For slotted devices, we need to also add the slot index
   704		 * in the priority.
   705		 */
   706		if (usage_priority && usage_priority->global)
   707			field->usages_priorities[usage_index] |=
   708				usage_priority->slot_overwrite;
   709		else
   710			field->usages_priorities[usage_index] |=
   711				(0xff - field->slot_idx) << 16;
   712	
   713		if (device->driver->input_mapping) {
   714			int ret = device->driver->input_mapping(device, hidinput, field,
   715					usage, &bit, &max);
   716			if (ret > 0)
   717				goto mapped;
   718			if (ret < 0)
   719				goto ignore;
   720		}
   721	
   722		switch (usage->hid & HID_USAGE_PAGE) {
   723		case HID_UP_UNDEFINED:
   724			goto ignore;
   725	
   726		case HID_UP_KEYBOARD:
   727			set_bit(EV_REP, input->evbit);
   728	
   729			if ((usage->hid & HID_USAGE) < 256) {
   730				if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore;
   731				map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
   732			} else
   733				map_key(KEY_UNKNOWN);
   734	
   735			break;
   736	
   737		case HID_UP_BUTTON:
   738			code = ((usage->hid - 1) & HID_USAGE);
   739	
   740			switch (field->application) {
   741			case HID_GD_MOUSE:
   742			case HID_GD_POINTER:  code += BTN_MOUSE; break;
   743			case HID_GD_JOYSTICK:
   744					if (code <= 0xf)
   745						code += BTN_JOYSTICK;
   746					else
   747						code += BTN_TRIGGER_HAPPY - 0x10;
   748					break;
   749			case HID_GD_GAMEPAD:
   750					if (code <= 0xf)
   751						code += BTN_GAMEPAD;
   752					else
   753						code += BTN_TRIGGER_HAPPY - 0x10;
   754					break;
   755			case HID_CP_CONSUMER_CONTROL:
   756					if (hidinput_field_in_collection(device, field,
   757									 HID_COLLECTION_NAMED_ARRAY,
   758									 HID_CP_PROGRAMMABLEBUTTONS)) {
   759						if (code <= 0x1d)
   760							code += KEY_MACRO1;
   761						else
   762							code += BTN_TRIGGER_HAPPY - 0x1e;
   763						break;
   764					}
   765					fallthrough;
   766			default:
   767				switch (field->physical) {
   768				case HID_GD_MOUSE:
   769				case HID_GD_POINTER:  code += BTN_MOUSE; break;
   770				case HID_GD_JOYSTICK: code += BTN_JOYSTICK; break;
   771				case HID_GD_GAMEPAD:  code += BTN_GAMEPAD; break;
   772				default:              code += BTN_MISC;
   773				}
   774			}
   775	
   776			map_key(code);
   777			break;
   778	
   779		case HID_UP_SIMULATION:
   780			switch (usage->hid & 0xffff) {
   781			case 0xba: map_abs(ABS_RUDDER);   break;
   782			case 0xbb: map_abs(ABS_THROTTLE); break;
   783			case 0xc4: map_abs(ABS_GAS);      break;
   784			case 0xc5: map_abs(ABS_BRAKE);    break;
   785			case 0xc8: map_abs(ABS_WHEEL);    break;
   786			default:   goto ignore;
   787			}
   788			break;
   789	
   790		case HID_UP_GENDESK:
   791			if ((usage->hid & 0xf0) == 0x80) {	/* SystemControl */
   792				switch (usage->hid & 0xf) {
   793				case 0x1: map_key_clear(KEY_POWER);  break;
   794				case 0x2: map_key_clear(KEY_SLEEP);  break;
   795				case 0x3: map_key_clear(KEY_WAKEUP); break;
   796				case 0x4: map_key_clear(KEY_CONTEXT_MENU); break;
   797				case 0x5: map_key_clear(KEY_MENU); break;
   798				case 0x6: map_key_clear(KEY_PROG1); break;
   799				case 0x7: map_key_clear(KEY_HELP); break;
   800				case 0x8: map_key_clear(KEY_EXIT); break;
   801				case 0x9: map_key_clear(KEY_SELECT); break;
   802				case 0xa: map_key_clear(KEY_RIGHT); break;
   803				case 0xb: map_key_clear(KEY_LEFT); break;
   804				case 0xc: map_key_clear(KEY_UP); break;
   805				case 0xd: map_key_clear(KEY_DOWN); break;
   806				case 0xe: map_key_clear(KEY_POWER2); break;
   807				case 0xf: map_key_clear(KEY_RESTART); break;
   808				default: goto unknown;
   809				}
   810				break;
   811			}
   812	
   813			if ((usage->hid & 0xf0) == 0x90) { /* SystemControl & D-pad */
   814				switch (usage->hid) {
   815				case HID_GD_UP:	   usage->hat_dir = 1; break;
   816				case HID_GD_DOWN:  usage->hat_dir = 5; break;
   817				case HID_GD_RIGHT: usage->hat_dir = 3; break;
   818				case HID_GD_LEFT:  usage->hat_dir = 7; break;
   819				case HID_GD_DO_NOT_DISTURB:
   820					map_key_clear(KEY_DO_NOT_DISTURB); break;
   821				default: goto unknown;
   822				}
   823	
   824				if (usage->hid <= HID_GD_LEFT) {
   825					if (field->dpad) {
   826						map_abs(field->dpad);
   827						goto ignore;
   828					}
   829					map_abs(ABS_HAT0X);
   830				}
   831				break;
   832			}
   833	
   834			if ((usage->hid & 0xf0) == 0xa0) {	/* SystemControl */
   835				switch (usage->hid & 0xf) {
   836				case 0x9: map_key_clear(KEY_MICMUTE); break;
   837				case 0xa: map_key_clear(KEY_ACCESSIBILITY); break;
   838				default: goto ignore;
   839				}
   840				break;
   841			}
   842	
   843			if ((usage->hid & 0xf0) == 0xb0) {	/* SC - Display */
   844				switch (usage->hid & 0xf) {
   845				case 0x05: map_key_clear(KEY_SWITCHVIDEOMODE); break;
   846				default: goto ignore;
   847				}
   848				break;
   849			}
   850	
   851			/*
   852			 * Some lazy vendors declare 255 usages for System Control,
   853			 * leading to the creation of ABS_X|Y axis and too many others.
   854			 * It wouldn't be a problem if joydev doesn't consider the
   855			 * device as a joystick then.
   856			 */
   857			if (field->application == HID_GD_SYSTEM_CONTROL)
   858				goto ignore;
   859	
   860			switch (usage->hid) {
   861			case HID_GD_Z:
   862				/* HID_GD_Z is mapped to ABS_DISTANCE for stylus/pen */
 > 863				if ((field->application & 0xff) == 0x02) {
   864					if (field->flags & HID_MAIN_ITEM_RELATIVE)
   865						map_rel(usage->hid & 0xf);
   866					else
   867						map_abs_clear(ABS_DISTANCE);
   868					break;
   869				}
   870				/* fall through for other devices/tools */
   871			/* These usage IDs map directly to the usage codes. */
   872			case HID_GD_X: case HID_GD_Y:
   873			case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
   874				if (field->flags & HID_MAIN_ITEM_RELATIVE)
   875					map_rel(usage->hid & 0xf);
   876				else
   877					map_abs_clear(usage->hid & 0xf);
   878				break;
   879	
   880			case HID_GD_WHEEL:
   881				if (field->flags & HID_MAIN_ITEM_RELATIVE) {
   882					set_bit(REL_WHEEL, input->relbit);
   883					map_rel(REL_WHEEL_HI_RES);
   884				} else {
   885					map_abs(usage->hid & 0xf);
   886				}
   887				break;
   888			case HID_GD_SLIDER: case HID_GD_DIAL:
   889				if (field->flags & HID_MAIN_ITEM_RELATIVE)
   890					map_rel(usage->hid & 0xf);
   891				else
   892					map_abs(usage->hid & 0xf);
   893				break;
   894	
   895			case HID_GD_HATSWITCH:
   896				usage->hat_min = field->logical_minimum;
   897				usage->hat_max = field->logical_maximum;
   898				map_abs(ABS_HAT0X);
   899				break;
   900	
   901			case HID_GD_START:	map_key_clear(BTN_START);	break;
   902			case HID_GD_SELECT:	map_key_clear(BTN_SELECT);	break;
   903	
   904			case HID_GD_RFKILL_BTN:
   905				/* MS wireless radio ctl extension, also check CA */
   906				if (field->application == HID_GD_WIRELESS_RADIO_CTLS) {
   907					map_key_clear(KEY_RFKILL);
   908					/* We need to simulate the btn release */
   909					field->flags |= HID_MAIN_ITEM_RELATIVE;
   910					break;
   911				}
   912				goto unknown;
   913	
   914			default: goto unknown;
   915			}
   916	
   917			break;
   918	
   919		case HID_UP_LED:
   920			switch (usage->hid & 0xffff) {		      /* HID-Value:                   */
   921			case 0x01:  map_led (LED_NUML);     break;    /*   "Num Lock"                 */
   922			case 0x02:  map_led (LED_CAPSL);    break;    /*   "Caps Lock"                */
   923			case 0x03:  map_led (LED_SCROLLL);  break;    /*   "Scroll Lock"              */
   924			case 0x04:  map_led (LED_COMPOSE);  break;    /*   "Compose"                  */
   925			case 0x05:  map_led (LED_KANA);     break;    /*   "Kana"                     */
   926			case 0x27:  map_led (LED_SLEEP);    break;    /*   "Stand-By"                 */
   927			case 0x4c:  map_led (LED_SUSPEND);  break;    /*   "System Suspend"           */
   928			case 0x09:  map_led (LED_MUTE);     break;    /*   "Mute"                     */
   929			case 0x4b:  map_led (LED_MISC);     break;    /*   "Generic Indicator"        */
   930			case 0x19:  map_led (LED_MAIL);     break;    /*   "Message Waiting"          */
   931			case 0x4d:  map_led (LED_CHARGING); break;    /*   "External Power Connected" */
   932	
   933			default: goto ignore;
   934			}
   935			break;
   936	
   937		case HID_UP_DIGITIZER:
   938			if ((field->application & 0xff) == 0x01) /* Digitizer */
   939				__set_bit(INPUT_PROP_POINTER, input->propbit);
   940			else if ((field->application & 0xff) == 0x02) /* Pen */
   941				__set_bit(INPUT_PROP_DIRECT, input->propbit);
   942	
   943			switch (usage->hid & 0xff) {
   944			case 0x00: /* Undefined */
   945				goto ignore;
   946	
   947			case 0x30: /* TipPressure */
   948				if (!test_bit(BTN_TOUCH, input->keybit)) {
   949					device->quirks |= HID_QUIRK_NOTOUCH;
   950					set_bit(EV_KEY, input->evbit);
   951					set_bit(BTN_TOUCH, input->keybit);
   952				}
   953				map_abs_clear(ABS_PRESSURE);
   954				break;
   955	
   956			case 0x32: /* InRange */
   957				switch (field->physical) {
   958				case HID_DG_PUCK:
   959					map_key(BTN_TOOL_MOUSE);
   960					break;
   961				case HID_DG_FINGER:
   962					map_key(BTN_TOOL_FINGER);
   963					break;
   964				default:
   965					/*
   966					 * If the physical is not given,
   967					 * rely on the application.
   968					 */
   969					if (!field->physical) {
   970						switch (field->application) {
   971						case HID_DG_TOUCHSCREEN:
   972						case HID_DG_TOUCHPAD:
   973							map_key_clear(BTN_TOOL_FINGER);
   974							break;
   975						default:
   976							map_key_clear(BTN_TOOL_PEN);
   977						}
   978					} else {
   979						map_key(BTN_TOOL_PEN);
   980					}
   981					break;
   982				}
   983				break;
   984	
   985			case 0x3b: /* Battery Strength */
   986				hidinput_setup_battery(device, HID_INPUT_REPORT, field, false);
   987				usage->type = EV_PWR;
   988				return;
   989	
   990			case 0x3c: /* Invert */
   991				device->quirks &= ~HID_QUIRK_NOINVERT;
   992				map_key_clear(BTN_TOOL_RUBBER);
   993				break;
   994	
   995			case 0x3d: /* X Tilt */
   996				map_abs_clear(ABS_TILT_X);
   997				break;
   998	
   999			case 0x3e: /* Y Tilt */
  1000				map_abs_clear(ABS_TILT_Y);
  1001				break;
  1002	
  1003			case 0x33: /* Touch */
  1004			case 0x42: /* TipSwitch */
  1005			case 0x43: /* TipSwitch2 */
  1006				device->quirks &= ~HID_QUIRK_NOTOUCH;
  1007				map_key_clear(BTN_TOUCH);
  1008				break;
  1009	
  1010			case 0x44: /* BarrelSwitch */
  1011				map_key_clear(BTN_STYLUS);
  1012				break;
  1013	
  1014			case 0x45: /* ERASER */
  1015				/*
  1016				 * This event is reported when eraser tip touches the surface.
  1017				 * Actual eraser (BTN_TOOL_RUBBER) is set and released either
  1018				 * by Invert if tool reports proximity or by Eraser directly.
  1019				 */
  1020				if (!test_bit(BTN_TOOL_RUBBER, input->keybit)) {
  1021					device->quirks |= HID_QUIRK_NOINVERT;
  1022					set_bit(BTN_TOOL_RUBBER, input->keybit);
  1023				}
  1024				map_key_clear(BTN_TOUCH);
  1025				break;
  1026	
  1027			case 0x46: /* TabletPick */
  1028			case 0x5a: /* SecondaryBarrelSwitch */
  1029				map_key_clear(BTN_STYLUS2);
  1030				break;
  1031	
  1032			case 0x5b: /* TransducerSerialNumber */
  1033			case 0x6e: /* TransducerSerialNumber2 */
  1034				map_msc(MSC_SERIAL);
  1035				break;
  1036	
  1037			default:  goto unknown;
  1038			}
  1039			break;
  1040	
  1041		case HID_UP_TELEPHONY:
  1042			switch (usage->hid & HID_USAGE) {
  1043			case 0x2f: map_key_clear(KEY_MICMUTE);		break;
  1044			case 0xb0: map_key_clear(KEY_NUMERIC_0);	break;
  1045			case 0xb1: map_key_clear(KEY_NUMERIC_1);	break;
  1046			case 0xb2: map_key_clear(KEY_NUMERIC_2);	break;
  1047			case 0xb3: map_key_clear(KEY_NUMERIC_3);	break;
  1048			case 0xb4: map_key_clear(KEY_NUMERIC_4);	break;
  1049			case 0xb5: map_key_clear(KEY_NUMERIC_5);	break;
  1050			case 0xb6: map_key_clear(KEY_NUMERIC_6);	break;
  1051			case 0xb7: map_key_clear(KEY_NUMERIC_7);	break;
  1052			case 0xb8: map_key_clear(KEY_NUMERIC_8);	break;
  1053			case 0xb9: map_key_clear(KEY_NUMERIC_9);	break;
  1054			case 0xba: map_key_clear(KEY_NUMERIC_STAR);	break;
  1055			case 0xbb: map_key_clear(KEY_NUMERIC_POUND);	break;
  1056			case 0xbc: map_key_clear(KEY_NUMERIC_A);	break;
  1057			case 0xbd: map_key_clear(KEY_NUMERIC_B);	break;
  1058			case 0xbe: map_key_clear(KEY_NUMERIC_C);	break;
  1059			case 0xbf: map_key_clear(KEY_NUMERIC_D);	break;
  1060			default: goto ignore;
  1061			}
  1062			break;
  1063	
  1064		case HID_UP_CONSUMER:	/* USB HUT v1.12, pages 75-84 */
  1065			switch (usage->hid & HID_USAGE) {
  1066			case 0x000: goto ignore;
  1067			case 0x030: map_key_clear(KEY_POWER);		break;
  1068			case 0x031: map_key_clear(KEY_RESTART);		break;
  1069			case 0x032: map_key_clear(KEY_SLEEP);		break;
  1070			case 0x034: map_key_clear(KEY_SLEEP);		break;
  1071			case 0x035: map_key_clear(KEY_KBDILLUMTOGGLE);	break;
  1072			case 0x036: map_key_clear(BTN_MISC);		break;
  1073	
  1074			case 0x040: map_key_clear(KEY_MENU);		break; /* Menu */
  1075			case 0x041: map_key_clear(KEY_SELECT);		break; /* Menu Pick */
  1076			case 0x042: map_key_clear(KEY_UP);		break; /* Menu Up */
  1077			case 0x043: map_key_clear(KEY_DOWN);		break; /* Menu Down */
  1078			case 0x044: map_key_clear(KEY_LEFT);		break; /* Menu Left */
  1079			case 0x045: map_key_clear(KEY_RIGHT);		break; /* Menu Right */
  1080			case 0x046: map_key_clear(KEY_ESC);		break; /* Menu Escape */
  1081			case 0x047: map_key_clear(KEY_KPPLUS);		break; /* Menu Value Increase */
  1082			case 0x048: map_key_clear(KEY_KPMINUS);		break; /* Menu Value Decrease */
  1083	
  1084			case 0x060: map_key_clear(KEY_INFO);		break; /* Data On Screen */
  1085			case 0x061: map_key_clear(KEY_SUBTITLE);	break; /* Closed Caption */
  1086			case 0x063: map_key_clear(KEY_VCR);		break; /* VCR/TV */
  1087			case 0x065: map_key_clear(KEY_CAMERA);		break; /* Snapshot */
  1088			case 0x069: map_key_clear(KEY_RED);		break;
  1089			case 0x06a: map_key_clear(KEY_GREEN);		break;
  1090			case 0x06b: map_key_clear(KEY_BLUE);		break;
  1091			case 0x06c: map_key_clear(KEY_YELLOW);		break;
  1092			case 0x06d: map_key_clear(KEY_ASPECT_RATIO);	break;
  1093	
  1094			case 0x06f: map_key_clear(KEY_BRIGHTNESSUP);		break;
  1095			case 0x070: map_key_clear(KEY_BRIGHTNESSDOWN);		break;
  1096			case 0x072: map_key_clear(KEY_BRIGHTNESS_TOGGLE);	break;
  1097			case 0x073: map_key_clear(KEY_BRIGHTNESS_MIN);		break;
  1098			case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX);		break;
  1099			case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO);		break;
  1100	
  1101			case 0x076: map_key_clear(KEY_CAMERA_ACCESS_ENABLE);	break;
  1102			case 0x077: map_key_clear(KEY_CAMERA_ACCESS_DISABLE);	break;
  1103			case 0x078: map_key_clear(KEY_CAMERA_ACCESS_TOGGLE);	break;
  1104	
  1105			case 0x079: map_key_clear(KEY_KBDILLUMUP);	break;
  1106			case 0x07a: map_key_clear(KEY_KBDILLUMDOWN);	break;
  1107			case 0x07c: map_key_clear(KEY_KBDILLUMTOGGLE);	break;
  1108	
  1109			case 0x082: map_key_clear(KEY_VIDEO_NEXT);	break;
  1110			case 0x083: map_key_clear(KEY_LAST);		break;
  1111			case 0x084: map_key_clear(KEY_ENTER);		break;
  1112			case 0x088: map_key_clear(KEY_PC);		break;
  1113			case 0x089: map_key_clear(KEY_TV);		break;
  1114			case 0x08a: map_key_clear(KEY_WWW);		break;
  1115			case 0x08b: map_key_clear(KEY_DVD);		break;
  1116			case 0x08c: map_key_clear(KEY_PHONE);		break;
  1117			case 0x08d: map_key_clear(KEY_PROGRAM);		break;
  1118			case 0x08e: map_key_clear(KEY_VIDEOPHONE);	break;
  1119			case 0x08f: map_key_clear(KEY_GAMES);		break;
  1120			case 0x090: map_key_clear(KEY_MEMO);		break;
  1121			case 0x091: map_key_clear(KEY_CD);		break;
  1122			case 0x092: map_key_clear(KEY_VCR);		break;
  1123			case 0x093: map_key_clear(KEY_TUNER);		break;
  1124			case 0x094: map_key_clear(KEY_EXIT);		break;
  1125			case 0x095: map_key_clear(KEY_HELP);		break;
  1126			case 0x096: map_key_clear(KEY_TAPE);		break;
  1127			case 0x097: map_key_clear(KEY_TV2);		break;
  1128			case 0x098: map_key_clear(KEY_SAT);		break;
  1129			case 0x09a: map_key_clear(KEY_PVR);		break;
  1130	
  1131			case 0x09c: map_key_clear(KEY_CHANNELUP);	break;
  1132			case 0x09d: map_key_clear(KEY_CHANNELDOWN);	break;
  1133			case 0x0a0: map_key_clear(KEY_VCR2);		break;
  1134	
  1135			case 0x0b0: map_key_clear(KEY_PLAY);		break;
  1136			case 0x0b1: map_key_clear(KEY_PAUSE);		break;
  1137			case 0x0b2: map_key_clear(KEY_RECORD);		break;
  1138			case 0x0b3: map_key_clear(KEY_FASTFORWARD);	break;
  1139			case 0x0b4: map_key_clear(KEY_REWIND);		break;
  1140			case 0x0b5: map_key_clear(KEY_NEXTSONG);	break;
  1141			case 0x0b6: map_key_clear(KEY_PREVIOUSSONG);	break;
  1142			case 0x0b7: map_key_clear(KEY_STOPCD);		break;
  1143			case 0x0b8: map_key_clear(KEY_EJECTCD);		break;
  1144			case 0x0bc: map_key_clear(KEY_MEDIA_REPEAT);	break;
  1145			case 0x0b9: map_key_clear(KEY_SHUFFLE);		break;
  1146			case 0x0bf: map_key_clear(KEY_SLOW);		break;
  1147	
  1148			case 0x0cd: map_key_clear(KEY_PLAYPAUSE);	break;
  1149			case 0x0cf: map_key_clear(KEY_VOICECOMMAND);	break;
  1150	
  1151			case 0x0d8: map_key_clear(KEY_DICTATE);		break;
  1152			case 0x0d9: map_key_clear(KEY_EMOJI_PICKER);	break;
  1153	
  1154			case 0x0e0: map_abs_clear(ABS_VOLUME);		break;
  1155			case 0x0e2: map_key_clear(KEY_MUTE);		break;
  1156			case 0x0e5: map_key_clear(KEY_BASSBOOST);	break;
  1157			case 0x0e9: map_key_clear(KEY_VOLUMEUP);	break;
  1158			case 0x0ea: map_key_clear(KEY_VOLUMEDOWN);	break;
  1159			case 0x0f5: map_key_clear(KEY_SLOW);		break;
  1160	
  1161			case 0x181: map_key_clear(KEY_BUTTONCONFIG);	break;
  1162			case 0x182: map_key_clear(KEY_BOOKMARKS);	break;
  1163			case 0x183: map_key_clear(KEY_CONFIG);		break;
  1164			case 0x184: map_key_clear(KEY_WORDPROCESSOR);	break;
  1165			case 0x185: map_key_clear(KEY_EDITOR);		break;
  1166			case 0x186: map_key_clear(KEY_SPREADSHEET);	break;
  1167			case 0x187: map_key_clear(KEY_GRAPHICSEDITOR);	break;
  1168			case 0x188: map_key_clear(KEY_PRESENTATION);	break;
  1169			case 0x189: map_key_clear(KEY_DATABASE);	break;
  1170			case 0x18a: map_key_clear(KEY_MAIL);		break;
  1171			case 0x18b: map_key_clear(KEY_NEWS);		break;
  1172			case 0x18c: map_key_clear(KEY_VOICEMAIL);	break;
  1173			case 0x18d: map_key_clear(KEY_ADDRESSBOOK);	break;
  1174			case 0x18e: map_key_clear(KEY_CALENDAR);	break;
  1175			case 0x18f: map_key_clear(KEY_TASKMANAGER);	break;
  1176			case 0x190: map_key_clear(KEY_JOURNAL);		break;
  1177			case 0x191: map_key_clear(KEY_FINANCE);		break;
  1178			case 0x192: map_key_clear(KEY_CALC);		break;
  1179			case 0x193: map_key_clear(KEY_PLAYER);		break;
  1180			case 0x194: map_key_clear(KEY_FILE);		break;
  1181			case 0x196: map_key_clear(KEY_WWW);		break;
  1182			case 0x199: map_key_clear(KEY_CHAT);		break;
  1183			case 0x19c: map_key_clear(KEY_LOGOFF);		break;
  1184			case 0x19e: map_key_clear(KEY_COFFEE);		break;
  1185			case 0x19f: map_key_clear(KEY_CONTROLPANEL);		break;
  1186			case 0x1a2: map_key_clear(KEY_APPSELECT);		break;
  1187			case 0x1a3: map_key_clear(KEY_NEXT);		break;
  1188			case 0x1a4: map_key_clear(KEY_PREVIOUS);	break;
  1189			case 0x1a6: map_key_clear(KEY_HELP);		break;
  1190			case 0x1a7: map_key_clear(KEY_DOCUMENTS);	break;
  1191			case 0x1ab: map_key_clear(KEY_SPELLCHECK);	break;
  1192			case 0x1ae: map_key_clear(KEY_KEYBOARD);	break;
  1193			case 0x1b1: map_key_clear(KEY_SCREENSAVER);		break;
  1194			case 0x1b4: map_key_clear(KEY_FILE);		break;
  1195			case 0x1b6: map_key_clear(KEY_IMAGES);		break;
  1196			case 0x1b7: map_key_clear(KEY_AUDIO);		break;
  1197			case 0x1b8: map_key_clear(KEY_VIDEO);		break;
  1198			case 0x1bc: map_key_clear(KEY_MESSENGER);	break;
  1199			case 0x1bd: map_key_clear(KEY_INFO);		break;
  1200			case 0x1cb: map_key_clear(KEY_ASSISTANT);	break;
  1201			case 0x201: map_key_clear(KEY_NEW);		break;
  1202			case 0x202: map_key_clear(KEY_OPEN);		break;
  1203			case 0x203: map_key_clear(KEY_CLOSE);		break;
  1204			case 0x204: map_key_clear(KEY_EXIT);		break;
  1205			case 0x207: map_key_clear(KEY_SAVE);		break;
  1206			case 0x208: map_key_clear(KEY_PRINT);		break;
  1207			case 0x209: map_key_clear(KEY_PROPS);		break;
  1208			case 0x21a: map_key_clear(KEY_UNDO);		break;
  1209			case 0x21b: map_key_clear(KEY_COPY);		break;
  1210			case 0x21c: map_key_clear(KEY_CUT);		break;
  1211			case 0x21d: map_key_clear(KEY_PASTE);		break;
  1212			case 0x21f: map_key_clear(KEY_FIND);		break;
  1213			case 0x221: map_key_clear(KEY_SEARCH);		break;
  1214			case 0x222: map_key_clear(KEY_GOTO);		break;
  1215			case 0x223: map_key_clear(KEY_HOMEPAGE);	break;
  1216			case 0x224: map_key_clear(KEY_BACK);		break;
  1217			case 0x225: map_key_clear(KEY_FORWARD);		break;
  1218			case 0x226: map_key_clear(KEY_STOP);		break;
  1219			case 0x227: map_key_clear(KEY_REFRESH);		break;
  1220			case 0x22a: map_key_clear(KEY_BOOKMARKS);	break;
  1221			case 0x22d: map_key_clear(KEY_ZOOMIN);		break;
  1222			case 0x22e: map_key_clear(KEY_ZOOMOUT);		break;
  1223			case 0x22f: map_key_clear(KEY_ZOOMRESET);	break;
  1224			case 0x232: map_key_clear(KEY_FULL_SCREEN);	break;
  1225			case 0x233: map_key_clear(KEY_SCROLLUP);	break;
  1226			case 0x234: map_key_clear(KEY_SCROLLDOWN);	break;
  1227			case 0x238: /* AC Pan */
  1228				set_bit(REL_HWHEEL, input->relbit);
  1229				map_rel(REL_HWHEEL_HI_RES);
  1230				break;
  1231			case 0x23d: map_key_clear(KEY_EDIT);		break;
  1232			case 0x25f: map_key_clear(KEY_CANCEL);		break;
  1233			case 0x269: map_key_clear(KEY_INSERT);		break;
  1234			case 0x26a: map_key_clear(KEY_DELETE);		break;
  1235			case 0x279: map_key_clear(KEY_REDO);		break;
  1236	
  1237			case 0x289: map_key_clear(KEY_REPLY);		break;
  1238			case 0x28b: map_key_clear(KEY_FORWARDMAIL);	break;
  1239			case 0x28c: map_key_clear(KEY_SEND);		break;
  1240	
  1241			case 0x29d: map_key_clear(KEY_KBD_LAYOUT_NEXT);	break;
  1242	
  1243			case 0x2a2: map_key_clear(KEY_ALL_APPLICATIONS);	break;
  1244	
  1245			case 0x2c7: map_key_clear(KEY_KBDINPUTASSIST_PREV);		break;
  1246			case 0x2c8: map_key_clear(KEY_KBDINPUTASSIST_NEXT);		break;
  1247			case 0x2c9: map_key_clear(KEY_KBDINPUTASSIST_PREVGROUP);		break;
  1248			case 0x2ca: map_key_clear(KEY_KBDINPUTASSIST_NEXTGROUP);		break;
  1249			case 0x2cb: map_key_clear(KEY_KBDINPUTASSIST_ACCEPT);	break;
  1250			case 0x2cc: map_key_clear(KEY_KBDINPUTASSIST_CANCEL);	break;
  1251	
  1252			case 0x29f: map_key_clear(KEY_SCALE);		break;
  1253	
  1254			default: map_key_clear(KEY_UNKNOWN);
  1255			}
  1256			break;
  1257	
  1258		case HID_UP_GENDEVCTRLS:
  1259			switch (usage->hid) {
  1260			case HID_DC_BATTERYSTRENGTH:
  1261				hidinput_setup_battery(device, HID_INPUT_REPORT, field, false);
  1262				usage->type = EV_PWR;
  1263				return;
  1264			}
  1265			goto unknown;
  1266	
  1267		case HID_UP_BATTERY:
  1268			switch (usage->hid) {
  1269			case HID_BAT_ABSOLUTESTATEOFCHARGE:
  1270				hidinput_setup_battery(device, HID_INPUT_REPORT, field, true);
  1271				usage->type = EV_PWR;
  1272				return;
  1273			case HID_BAT_CHARGING:
  1274				usage->type = EV_PWR;
  1275				return;
  1276			}
  1277			goto unknown;
  1278		case HID_UP_CAMERA:
  1279			switch (usage->hid & HID_USAGE) {
  1280			case 0x020:
  1281				map_key_clear(KEY_CAMERA_FOCUS);	break;
  1282			case 0x021:
  1283				map_key_clear(KEY_CAMERA);		break;
  1284			default:
  1285				goto ignore;
  1286			}
  1287			break;
  1288	
  1289		case HID_UP_HPVENDOR:	/* Reported on a Dutch layout HP5308 */
  1290			set_bit(EV_REP, input->evbit);
  1291			switch (usage->hid & HID_USAGE) {
  1292			case 0x021: map_key_clear(KEY_PRINT);           break;
  1293			case 0x070: map_key_clear(KEY_HP);		break;
  1294			case 0x071: map_key_clear(KEY_CAMERA);		break;
  1295			case 0x072: map_key_clear(KEY_SOUND);		break;
  1296			case 0x073: map_key_clear(KEY_QUESTION);	break;
  1297			case 0x080: map_key_clear(KEY_EMAIL);		break;
  1298			case 0x081: map_key_clear(KEY_CHAT);		break;
  1299			case 0x082: map_key_clear(KEY_SEARCH);		break;
  1300			case 0x083: map_key_clear(KEY_CONNECT);	        break;
  1301			case 0x084: map_key_clear(KEY_FINANCE);		break;
  1302			case 0x085: map_key_clear(KEY_SPORT);		break;
  1303			case 0x086: map_key_clear(KEY_SHOP);	        break;
  1304			default:    goto ignore;
  1305			}
  1306			break;
  1307	
  1308		case HID_UP_HPVENDOR2:
  1309			set_bit(EV_REP, input->evbit);
  1310			switch (usage->hid & HID_USAGE) {
  1311			case 0x001: map_key_clear(KEY_MICMUTE);		break;
  1312			case 0x003: map_key_clear(KEY_BRIGHTNESSDOWN);	break;
  1313			case 0x004: map_key_clear(KEY_BRIGHTNESSUP);	break;
  1314			default:    goto ignore;
  1315			}
  1316			break;
  1317	
  1318		case HID_UP_MSVENDOR:
  1319			goto ignore;
  1320	
  1321		case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */
  1322			set_bit(EV_REP, input->evbit);
  1323			goto ignore;
  1324	
  1325		case HID_UP_LOGIVENDOR:
  1326			/* intentional fallback */
  1327		case HID_UP_LOGIVENDOR2:
  1328			/* intentional fallback */
  1329		case HID_UP_LOGIVENDOR3:
  1330			goto ignore;
  1331	
  1332		case HID_UP_PID:
  1333			switch (usage->hid & HID_USAGE) {
  1334			case 0xa4: map_key_clear(BTN_DEAD);	break;
  1335			default: goto ignore;
  1336			}
  1337			break;
  1338	
  1339		default:
  1340		unknown:
  1341			if (field->report_size == 1) {
  1342				if (field->report->type == HID_OUTPUT_REPORT) {
  1343					map_led(LED_MISC);
  1344					break;
  1345				}
  1346				map_key(BTN_MISC);
  1347				break;
  1348			}
  1349			if (field->flags & HID_MAIN_ITEM_RELATIVE) {
  1350				map_rel(REL_MISC);
  1351				break;
  1352			}
  1353			map_abs(ABS_MISC);
  1354			break;
  1355		}
  1356	
  1357	mapped:
  1358		/* Mapping failed, bail out */
  1359		if (!bit)
  1360			return;
  1361	
  1362		if (device->driver->input_mapped &&
  1363		    device->driver->input_mapped(device, hidinput, field, usage,
  1364						 &bit, &max) < 0) {
  1365			/*
  1366			 * The driver indicated that no further generic handling
  1367			 * of the usage is desired.
  1368			 */
  1369			return;
  1370		}
  1371	
  1372		set_bit(usage->type, input->evbit);
  1373	
  1374		/*
  1375		 * This part is *really* controversial:
  1376		 * - HID aims at being generic so we should do our best to export
  1377		 *   all incoming events
  1378		 * - HID describes what events are, so there is no reason for ABS_X
  1379		 *   to be mapped to ABS_Y
  1380		 * - HID is using *_MISC+N as a default value, but nothing prevents
  1381		 *   *_MISC+N to overwrite a legitimate even, which confuses userspace
  1382		 *   (for instance ABS_MISC + 7 is ABS_MT_SLOT, which has a different
  1383		 *   processing)
  1384		 *
  1385		 * If devices still want to use this (at their own risk), they will
  1386		 * have to use the quirk HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE, but
  1387		 * the default should be a reliable mapping.
  1388		 */
  1389		while (usage->code <= max && test_and_set_bit(usage->code, bit)) {
  1390			if (device->quirks & HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE) {
  1391				usage->code = find_next_zero_bit(bit,
  1392								 max + 1,
  1393								 usage->code);
  1394			} else {
  1395				device->status |= HID_STAT_DUP_DETECTED;
  1396				goto ignore;
  1397			}
  1398		}
  1399	
  1400		if (usage->code > max)
  1401			goto ignore;
  1402	
  1403		if (usage->type == EV_ABS) {
  1404	
  1405			int a = field->logical_minimum;
  1406			int b = field->logical_maximum;
  1407	
  1408			if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
  1409				a = field->logical_minimum = 0;
  1410				b = field->logical_maximum = 255;
  1411			}
  1412	
  1413			if (field->application == HID_GD_GAMEPAD || field->application == HID_GD_JOYSTICK)
  1414				input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4);
  1415			else	input_set_abs_params(input, usage->code, a, b, 0, 0);
  1416	
  1417			input_abs_set_res(input, usage->code,
  1418					  hidinput_calc_abs_res(field, usage->code));
  1419	
  1420			/* use a larger default input buffer for MT devices */
  1421			if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0)
  1422				input_set_events_per_packet(input, 60);
  1423		}
  1424	
  1425		if (usage->type == EV_ABS &&
  1426		    (usage->hat_min < usage->hat_max || usage->hat_dir)) {
  1427			int i;
  1428			for (i = usage->code; i < usage->code + 2 && i <= max; i++) {
  1429				input_set_abs_params(input, i, -1, 1, 0, 0);
  1430				set_bit(i, input->absbit);
  1431			}
  1432			if (usage->hat_dir && !field->dpad)
  1433				field->dpad = usage->code;
  1434		}
  1435	
  1436		/* for those devices which produce Consumer volume usage as relative,
  1437		 * we emulate pressing volumeup/volumedown appropriate number of times
  1438		 * in hidinput_hid_event()
  1439		 */
  1440		if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
  1441				(usage->code == ABS_VOLUME)) {
  1442			set_bit(KEY_VOLUMEUP, input->keybit);
  1443			set_bit(KEY_VOLUMEDOWN, input->keybit);
  1444		}
  1445	
  1446		if (usage->type == EV_KEY) {
  1447			set_bit(EV_MSC, input->evbit);
  1448			set_bit(MSC_SCAN, input->mscbit);
  1449		}
  1450	
  1451		return;
  1452	
  1453	ignore:
  1454		usage->type = 0;
  1455		usage->code = 0;
  1456	}
  1457	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply

* Re: [PATCH v2] HID: hid-ntrig: fix unable to handle page fault in ntrig_report_version()
From: Benjamin Tissoires @ 2025-08-13  8:39 UTC (permalink / raw)
  To: Minjong Kim; +Cc: Jiri Kosina, linux-input, linux-kernel
In-Reply-To: <20250813051751.z6vxd6tvrfelmxou@minbellkim-500TGA-500SGA>

On Aug 13 2025, Minjong Kim wrote:
> On Tue, Aug 12, 2025 at 02:46:24PM +0200, Jiri Kosina wrote:
> > 
> > I know that mixing declarations and code is fine these days, but we 
> > haven't been progressive enough to switch to that coding style in HID 
> > subsystem yet :) Would you be willing to move it below the declarations?
> >  
> 
> From 75e52defd4b2fd138285c5ad953942e2e6cf2fbb Mon Sep 17 00:00:00 2001
> From: Minjong Kim <minbell.kim@samsung.com>
> Date: Thu, 17 Jul 2025 14:37:47 +0900
> Subject: [PATCH v2] HID: hid-ntrig: fix unable to handle page fault in
>  ntrig_report_version()
> 
> in ntrig_report_version(), hdev parameter passed from hid_probe().
> sending descriptor to /dev/uhid can make hdev->dev.parent->parent to null
> if hdev->dev.parent->parent is null, usb_dev has
> invalid address(0xffffffffffffff58) that hid_to_usb_dev(hdev) returned
> when usb_rcvctrlpipe() use usb_dev,it trigger
> page fault error for address(0xffffffffffffff58)
> 
> add null check logic to ntrig_report_version()
> before calling hid_to_usb_dev()
> 
> Signed-off-by: Minjong Kim <minbell.kim@samsung.com>
> ---
>  drivers/hid/hid-ntrig.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> index 2738ce947434..fa948d9e236c 100644
> --- a/drivers/hid/hid-ntrig.c
> +++ b/drivers/hid/hid-ntrig.c
> @@ -144,6 +144,9 @@ static void ntrig_report_version(struct hid_device *hdev)
>  	struct usb_device *usb_dev = hid_to_usb_dev(hdev);
>  	unsigned char *data = kmalloc(8, GFP_KERNEL);
> 
> +	if (!hdev->dev.parent->parent)

Why simply not use if(!hid_is_usb(hdev)) instead?

Cheers,
Benjamin

> +		return;
> +
>  	if (!data)
>  		goto err_free;
> 
> --
> 2.34.1
> 
> I move it below the declarations.
> 
> Best regards,
> 



^ permalink raw reply

* Re: [PATCH v3] HID: hid-ntrig: fix unable to handle page fault in ntrig_report_version()
From: Minjong Kim @ 2025-08-13  9:22 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Jiri Kosina, linux-input, linux-kernel
In-Reply-To: <elszhqc5knv2o4mvq2frul6vglqxsdyrjepzgmda45lmrh4ylp@qvdvsgumuigx>

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

On Wed, Aug 13, 2025 at 10:39:37AM +0200, Benjamin Tissoires wrote:
> On Aug 13 2025, Minjong Kim wrote:
> > 
> > From 75e52defd4b2fd138285c5ad953942e2e6cf2fbb Mon Sep 17 00:00:00 2001
> > From: Minjong Kim <minbell.kim@samsung.com>
> > Date: Thu, 17 Jul 2025 14:37:47 +0900
> > Subject: [PATCH v2] HID: hid-ntrig: fix unable to handle page fault in
> >  ntrig_report_version()
> > 
> > in ntrig_report_version(), hdev parameter passed from hid_probe().
> > sending descriptor to /dev/uhid can make hdev->dev.parent->parent to null
> > if hdev->dev.parent->parent is null, usb_dev has
> > invalid address(0xffffffffffffff58) that hid_to_usb_dev(hdev) returned
> > when usb_rcvctrlpipe() use usb_dev,it trigger
> > page fault error for address(0xffffffffffffff58)
> > 
> > add null check logic to ntrig_report_version()
> > before calling hid_to_usb_dev()
> > 
> > Signed-off-by: Minjong Kim <minbell.kim@samsung.com>
> > ---
> >  drivers/hid/hid-ntrig.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
> > index 2738ce947434..fa948d9e236c 100644
> > --- a/drivers/hid/hid-ntrig.c
> > +++ b/drivers/hid/hid-ntrig.c
> > @@ -144,6 +144,9 @@ static void ntrig_report_version(struct hid_device *hdev)
> >  	struct usb_device *usb_dev = hid_to_usb_dev(hdev);
> >  	unsigned char *data = kmalloc(8, GFP_KERNEL);
> > 
> > +	if (!hdev->dev.parent->parent)
> 
> Why simply not use if(!hid_is_usb(hdev)) instead?
> 
> Cheers,
> Benjamin
>

From 61818c85614ad40beab53cee421272814576836d Mon Sep 17 00:00:00 2001
From: Minjong Kim <minbell.kim@samsung.com>
Date: Thu, 17 Jul 2025 14:37:47 +0900
Subject: [PATCH v3] HID: hid-ntrig: fix unable to handle page fault in
 ntrig_report_version()

in ntrig_report_version(), hdev parameter passed from hid_probe().
sending descriptor to /dev/uhid can make hdev->dev.parent->parent to null
if hdev->dev.parent->parent is null, usb_dev has
invalid address(0xffffffffffffff58) that hid_to_usb_dev(hdev) returned
when usb_rcvctrlpipe() use usb_dev,it trigger
page fault error for address(0xffffffffffffff58)

add null check logic to ntrig_report_version()
before calling hid_to_usb_dev()

Signed-off-by: Minjong Kim <minbell.kim@samsung.com>
---
 drivers/hid/hid-ntrig.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 2738ce947434..0f76e241e0af 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -144,6 +144,9 @@ static void ntrig_report_version(struct hid_device *hdev)
 	struct usb_device *usb_dev = hid_to_usb_dev(hdev);
 	unsigned char *data = kmalloc(8, GFP_KERNEL);
 
+	if (!hid_is_usb(hdev))
+		return;
+
 	if (!data)
 		goto err_free;
 
-- 
2.34.1


I checked that crashes didn't occuered this patch
then, I'm just wondering why it is effective?
could you explain me about this?

Best regards,

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related

* Re: [PATCH v2 11/11] HID: multitouch: add haptic multitouch support
From: Benjamin Tissoires @ 2025-08-13  9:22 UTC (permalink / raw)
  To: Jonathan Denose
  Cc: Jiri Kosina, Dmitry Torokhov, Jonathan Corbet, Henrik Rydberg,
	linux-input, linux-kernel, linux-doc, Angela Czubak,
	Sean O'Brien
In-Reply-To: <20250804-support-forcepads-v2-11-138ca980261d@google.com>

On Aug 04 2025, Jonathan Denose wrote:
> From: Angela Czubak <aczubak@google.com>
> 
> Add new option (MULTITOUCH_HAPTIC) to mark whether hid-multitouch
> should try and configure simple haptic device.
> Once this option is configured, and the device is recognized to have simple
> haptic capabilities, check input frames for pressure and handle it using
> hid_haptic_* API.

Why creating a new option? It seems it'll add unwanted work from
distributions when we should have something that "just works" no?

It makes sense to depend on FF, but adding a new option is probably
useless IMO.


> 
> Signed-off-by: Angela Czubak <aczubak@google.com>
> Co-developed-by: Jonathan Denose <jdenose@google.com>
> Signed-off-by: Jonathan Denose <jdenose@google.com>
> ---
>  drivers/hid/Kconfig          |  11 ++++
>  drivers/hid/Makefile         |   2 +-
>  drivers/hid/hid-haptic.h     |  52 +++++++++++++++++
>  drivers/hid/hid-multitouch.c | 136 ++++++++++++++++++++++++++++++++++++++++++-
>  4 files changed, 199 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index ad6bcc4248cc111705d7cfde2b1481b46353e2d7..b7452f11a4f914f92af582ed054d42ecbcd6cb9e 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -817,6 +817,17 @@ config HID_MULTITOUCH
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called hid-multitouch.
>  
> +config MULTITOUCH_HAPTIC
> +	bool "Simple haptic multitouch support"
> +	depends on HID_MULTITOUCH
> +	select HID_HAPTIC
> +	default n
> +	help
> +	Support for simple multitouch haptic devices.
> +	Adds extra parsing and FF device for the hid multitouch driver.
> +	It can be used for Elan 2703 haptic touchpad.
> +	To enable, say Y.
> +
>  config HID_NINTENDO
>  	tristate "Nintendo Joy-Con, NSO, and Pro Controller support"
>  	depends on NEW_LEDS
> diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> index 361a7daedeb85454114def8afb5f58caeab58a00..be09b4f13b2058a0a1d7eab79f35def758120fc4 100644
> --- a/drivers/hid/Makefile
> +++ b/drivers/hid/Makefile
> @@ -4,7 +4,7 @@
>  #
>  hid-y			:= hid-core.o hid-input.o hid-quirks.o
>  hid-$(CONFIG_DEBUG_FS)		+= hid-debug.o
> -hid-$(CONFIG_HID_HAPTIC)	+= hid-haptic.o
> +hid-$(CONFIG_MULTITOUCH_HAPTIC)	+= hid-haptic.o
>  
>  obj-$(CONFIG_HID_BPF)		+= bpf/
>  
> diff --git a/drivers/hid/hid-haptic.h b/drivers/hid/hid-haptic.h
> index 0a34b0c6d706a985630962acc41f7a8eb73cd343..808cec0b4e51eba1f58b839f3e552493655b7899 100644
> --- a/drivers/hid/hid-haptic.h
> +++ b/drivers/hid/hid-haptic.h
> @@ -58,6 +58,7 @@ struct hid_haptic_device {
>  	struct hid_haptic_effect stop_effect;
>  };
>  
> +#ifdef CONFIG_MULTITOUCH_HAPTIC

There is something wrong with your ifdef usages:
- here, you define the functions below conditionally to
	CONFIG_MULTITOUCH_HAPTIC, which is fine
- but in hid-multitouch, you also check for CONFIG_MULTITOUCH_HAPTIC
	before calling the same set of functions.

Either only define the haptic functions when CONFIG_MULTITOUCH_HAPTIC is
set, and in multitouch check for that define, or define it conditionally
and remove the checks in hid-multitouch (but probably add a comment).

>  void hid_haptic_feature_mapping(struct hid_device *hdev,
>  				struct hid_haptic_device *haptic,
>  				struct hid_field *field, struct hid_usage
> @@ -77,3 +78,54 @@ void hid_haptic_handle_press_release(struct hid_haptic_device *haptic);
>  void hid_haptic_pressure_reset(struct hid_haptic_device *haptic);
>  void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
>  				  __s32 pressure);
> +#else
> +static inline
> +void hid_haptic_feature_mapping(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_field *field, struct hid_usage
> +				*usage)
> +{}
> +static inline
> +bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
> +				    struct hid_input *hi, struct hid_field *field)
> +{
> +	return false;
> +}
> +static inline
> +int hid_haptic_input_mapping(struct hid_device *hdev,
> +			     struct hid_haptic_device *haptic,
> +			     struct hid_input *hi,
> +			     struct hid_field *field, struct hid_usage *usage,
> +			     unsigned long **bit, int *max)
> +{
> +	return 0;
> +}
> +static inline
> +int hid_haptic_input_configured(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_input *hi)
> +{
> +	return 0;
> +}
> +static inline
> +void hid_haptic_reset(struct hid_device *hdev, struct hid_haptic_device *haptic)
> +{}
> +static inline
> +int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device **haptic_ptr)
> +{
> +	return 0;
> +}
> +static inline
> +void hid_haptic_handle_press_release(struct hid_haptic_device *haptic) {}
> +static inline
> +bool hid_haptic_handle_input(struct hid_haptic_device *haptic)
> +{
> +	return false;
> +}
> +static inline
> +void hid_haptic_pressure_reset(struct hid_haptic_device *haptic) {}
> +static inline
> +void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
> +				  __s32 pressure)
> +{}
> +#endif
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index b41001e02da7e02d492bd85743b359ed7ec16e7f..4ff9ac5022b13a0739dbc7ae5f6ebd84f0114a73 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -49,6 +49,8 @@ MODULE_LICENSE("GPL");
>  
>  #include "hid-ids.h"
>  
> +#include "hid-haptic.h"
> +
>  /* quirks to control the device */
>  #define MT_QUIRK_NOT_SEEN_MEANS_UP	BIT(0)
>  #define MT_QUIRK_SLOT_IS_CONTACTID	BIT(1)
> @@ -167,11 +169,13 @@ struct mt_report_data {
>  struct mt_device {
>  	struct mt_class mtclass;	/* our mt device class */
>  	struct timer_list release_timer;	/* to release sticky fingers */
> +	struct hid_haptic_device *haptic;	/* haptic related configuration */
>  	struct hid_device *hdev;	/* hid_device we're attached to */
>  	unsigned long mt_io_flags;	/* mt flags (MT_IO_FLAGS_*) */
>  	__u8 inputmode_value;	/* InputMode HID feature value */
>  	__u8 maxcontacts;
>  	bool is_buttonpad;	/* is this device a button pad? */
> +	bool is_haptic_touchpad;	/* is this device a haptic touchpad? */
>  	bool serial_maybe;	/* need to check for serial protocol */
>  
>  	struct list_head applications;
> @@ -490,6 +494,95 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report)
>  	kfree(buf);
>  }
>  
> +#if defined(CONFIG_MULTITOUCH_HAPTIC)
> +static int mt_haptic_init(struct hid_device *hdev,
> +				struct hid_haptic_device **haptic_ptr)
> +{
> +	return hid_haptic_init(hdev, haptic_ptr);
> +}
> +
> +static void mt_haptic_feature_mapping(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_field *field, struct hid_usage *usage)
> +{
> +	return hid_haptic_feature_mapping(hdev, haptic, field, usage);
> +}
> +
> +static bool mt_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
> +				    struct hid_input *hi, struct hid_field *field)
> +{
> +	return hid_haptic_check_pressure_unit(haptic, hi, field);
> +}
> +
> +static void mt_haptic_pressure_reset(struct hid_haptic_device *haptic)
> +{
> +	return hid_haptic_pressure_reset(haptic);
> +}
> +
> +static void mt_haptic_pressure_increase(struct hid_haptic_device *haptic,
> +				 __s32 pressure)
> +{
> +	return hid_haptic_pressure_increase(haptic, pressure);
> +}
> +
> +static int mt_haptic_input_mapping(struct hid_device *hdev,
> +			     struct hid_haptic_device *haptic,
> +			     struct hid_input *hi,
> +			     struct hid_field *field, struct hid_usage *usage,
> +			     unsigned long **bit, int *max)
> +{
> +	return hid_haptic_input_mapping(hdev, haptic, hi, field, usage, bit, max);
> +}
> +
> +static int mt_haptic_input_configured(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_input *hi)
> +{
> +	return hid_haptic_input_configured(hdev, haptic, hi);
> +}
> +#else
> +static int mt_haptic_init(struct hid_device *hdev,
> +				struct hid_haptic_device **haptic_ptr)
> +{
> +	return 0;
> +}
> +
> +static void mt_haptic_feature_mapping(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_field *field, struct hid_usage *usage)
> +{}
> +
> +static bool mt_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
> +				    struct hid_input *hi, struct hid_field *field)
> +{
> +	return 0;
> +}
> +
> +static void mt_haptic_pressure_reset(struct hid_haptic_device *haptic)
> +{}
> +
> +static void mt_haptic_pressure_increase(struct hid_haptic_device *haptic,
> +				 __s32 pressure)
> +{}
> +
> +static int mt_haptic_input_mapping(struct hid_device *hdev,
> +			     struct hid_haptic_device *haptic,
> +			     struct hid_input *hi,
> +			     struct hid_field *field, struct hid_usage *usage,
> +			     unsigned long **bit, int *max)
> +{
> +	return 0;
> +}
> +
> +static int mt_haptic_input_configured(struct hid_device *hdev,
> +				struct hid_haptic_device *haptic,
> +				struct hid_input *hi)
> +{
> +	return 0;
> +}
> +#endif
> +
> +
>  static void mt_feature_mapping(struct hid_device *hdev,
>  		struct hid_field *field, struct hid_usage *usage)
>  {
> @@ -525,6 +618,8 @@ static void mt_feature_mapping(struct hid_device *hdev,
>  			mt_get_feature(hdev, field->report);
>  		break;
>  	}
> +
> +	mt_haptic_feature_mapping(hdev, td->haptic, field, usage);
>  }
>  
>  static void set_abs(struct input_dev *input, unsigned int code,
> @@ -856,6 +951,9 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  		case HID_DG_TIPPRESSURE:
>  			set_abs(hi->input, ABS_MT_PRESSURE, field,
>  				cls->sn_pressure);
> +			td->is_haptic_touchpad =
> +				mt_haptic_check_pressure_unit(td->haptic,
> +							       hi, field);
>  			MT_STORE_FIELD(p);
>  			return 1;
>  		case HID_DG_SCANTIME:
> @@ -980,6 +1078,8 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
>  
>  	app->num_received = 0;
>  	app->left_button_state = 0;
> +	if (td->is_haptic_touchpad)
> +		mt_haptic_pressure_reset(td->haptic);
>  
>  	if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags))
>  		set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
> @@ -1137,6 +1237,9 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
>  			minor = minor >> 1;
>  		}
>  
> +		if (td->is_haptic_touchpad)
> +			mt_haptic_pressure_increase(td->haptic, *slot->p);
> +
>  		x = hdev->quirks & HID_QUIRK_X_INVERT ?
>  			input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x :
>  			*slot->x;
> @@ -1324,6 +1427,9 @@ static int mt_touch_input_configured(struct hid_device *hdev,
>  	if (cls->is_indirect)
>  		app->mt_flags |= INPUT_MT_POINTER;
>  
> +	if (td->is_haptic_touchpad)
> +		app->mt_flags |= INPUT_MT_TOTAL_FORCE;
> +
>  	if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
>  		app->mt_flags |= INPUT_MT_DROP_UNUSED;
>  
> @@ -1359,6 +1465,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  	struct mt_device *td = hid_get_drvdata(hdev);
>  	struct mt_application *application;
>  	struct mt_report_data *rdata;
> +	int ret;
>  
>  	rdata = mt_find_report_data(td, field->report);
>  	if (!rdata) {
> @@ -1421,6 +1528,11 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  	if (field->physical == HID_DG_STYLUS)
>  		hi->application = HID_DG_STYLUS;
>  
> +	ret = mt_haptic_input_mapping(hdev, td->haptic, hi, field, usage, bit,
> +				       max);
> +	if (ret != 0)
> +		return ret;
> +
>  	/* let hid-core decide for the others */
>  	return 0;
>  }
> @@ -1635,6 +1747,14 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
>  	struct hid_report *report;
>  	int ret;
>  
> +	if (td->is_haptic_touchpad && (td->mtclass.name == MT_CLS_WIN_8 ||
> +	    td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT)) {
> +		if (mt_haptic_input_configured(hdev, td->haptic, hi) == 0)
> +			td->is_haptic_touchpad = false;
> +	} else {
> +		td->is_haptic_touchpad = false;
> +	}
> +
>  	list_for_each_entry(report, &hi->reports, hidinput_list) {
>  		rdata = mt_find_report_data(td, report);
>  		if (!rdata) {
> @@ -1764,7 +1884,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	int ret, i;
>  	struct mt_device *td;
>  	const struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */
> -

unrelated change (line removed).

>  	for (i = 0; mt_classes[i].name ; i++) {
>  		if (id->driver_data == mt_classes[i].name) {
>  			mtclass = &(mt_classes[i]);
> @@ -1777,6 +1896,10 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  		dev_err(&hdev->dev, "cannot allocate multitouch data\n");
>  		return -ENOMEM;
>  	}
> +	td->haptic = kzalloc(sizeof(*(td->haptic)), GFP_KERNEL);

Please make use of the devm api, you are leaking the allocated memory in
the regular case (AFAICT).

> +	if (!td->haptic)
> +		return -ENOMEM;

One extra blank line wouldn't hurt here :)

> +	td->haptic->hdev = hdev;
>  	td->hdev = hdev;
>  	td->mtclass = *mtclass;
>  	td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN;
> @@ -1840,6 +1963,17 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  
>  	mt_set_modes(hdev, HID_LATENCY_NORMAL, TOUCHPAD_REPORT_ALL);
>  
> +	if (td->is_haptic_touchpad) {
> +		if (mt_haptic_init(hdev, &td->haptic)) {
> +			dev_warn(&hdev->dev, "Cannot allocate haptic for %s\n",
> +				 hdev->name);
> +			td->is_haptic_touchpad = false;
> +			kfree(td->haptic);
> +		}
> +	} else {
> +		kfree(td->haptic);
> +	}
> +
>  	return 0;
>  }
>  
> 
> -- 
> 2.50.1.565.gc32cd1483b-goog
> 

Cheers,
Benjamin

^ 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