Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aaron Ma" <mapengyu@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 1/2] Input: xpad - query MS OS descriptor for BTP-KP20D
Date: Sat, 01 Aug 2026 08:03:29 +0000	[thread overview]
Message-ID: <20260801080329.B1AB11F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260801075623.2769601-1-mapengyu@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The variable `error` holds positive values on success, violating subsystem naming conventions.
- [Low] Missed opportunity to use modern cleanup primitives for the descriptor buffer.
--

--- Patch [1]: [PATCH v2 1/2] Input: xpad - query MS OS descriptor for BTP-KP20D ---
commit eab43c4126d684c849995489e35829f7af7fb51c
Author: Aaron Ma <mapengyu@gmail.com>

Input: xpad - query MS OS descriptor for BTP-KP20D

This commit adds a quirk to query the MS OS descriptor for the Beitong
BTP-KP20D dongle during probe. This allows the device to stay in Xbox 360
mode.

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index feb8f368f834e..1616047e65f5e 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
[ ... ]
> @@ -786,6 +788,24 @@ static int xpad_start_input(struct usb_xpad *xpad);
>  static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num);
>  static void xpad360w_poweroff_controller(struct usb_xpad *xpad);
>  
> +static void xpad_query_ms_os_descriptor(struct usb_device *udev)
> +{
> +	u8 *descriptor;
> +	int error;

[Severity: Low]
This isn't a bug, but does the error variable receive a positive value here?
The input subsystem maintainer prefers that variables named error or err
should only hold negative error codes or 0 for success. Since
usb_get_descriptor() returns the number of bytes transferred on success,
perhaps a different variable name would be better?

> +
> +	descriptor = kmalloc(18, GFP_KERNEL);

[Severity: Low]
This isn't a bug, but could this use the __free(kfree) primitive for
the allocation to automate cleanup and remove the explicit kfree(descriptor)
below, as encouraged by the maintainer preferences for new code?

> +	if (!descriptor)
> +		return;
> +
> +	error = usb_get_descriptor(udev, USB_DT_STRING, 0xee,
> +				   descriptor, 18);
> +	if (error != 18)
> +		dev_warn(&udev->dev,
> +			 "unable to query MS OS descriptor: %d\n", error);
> +
> +	kfree(descriptor);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260801075623.2769601-1-mapengyu@gmail.com?part=1

  parent reply	other threads:[~2026-08-01  8:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01  7:56 [PATCH v2 1/2] Input: xpad - query MS OS descriptor for BTP-KP20D Aaron Ma
2026-08-01  7:56 ` [PATCH v2 2/2] Input: xpad - add wired Beitong BTP-KP20D support Aaron Ma
2026-08-01  8:11   ` sashiko-bot
2026-08-01  8:03 ` sashiko-bot [this message]
2026-08-03  9:39 ` [PATCH v2 1/2] Input: xpad - query MS OS descriptor for BTP-KP20D Shengyu Qu
2026-08-03 12:13   ` Pengyu Ma
2026-08-03 17:32     ` Shengyu Qu
2026-08-04  5:51       ` Pengyu Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260801080329.B1AB11F00AC4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=mapengyu@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox