All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sanjay Govind" <sanjay.govind9@gmail.com>, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com
Subject: Re: [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars
Date: Tue, 01 Dec 2026 02:13:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-242361@kernel.org> (raw)
In-Reply-To: <20261201020704.3545243-4-sanjay.govind9@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: sony: unallocated device_id for non-Sixaxis/RB4 battery
  fallback
--

commit 30d3bc106b009d88edc842d4c79b13a204b65426
Author: Sanjay Govind <sanjay.govind9@gmail.com>

HID: sony: fix battery name clash between RB4 PS5 guitars

This commit allocates a device ID for Rock Band 4 PS5 guitars and appends
it to the battery power supply name when sc->mac_address is all zeros.

> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 7a25f5acce884..1f1152575ae4e 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
[ ... ]
> @@ -1906,13 +1907,21 @@ static int sony_battery_get_property(struct power_supply *psy,
>  
>  static int sony_battery_probe(struct sony_sc *sc, int append_dev_id)
>  {
> -	const char *battery_str_fmt = append_dev_id ?
> -		"sony_controller_battery_%pMR_%i" :
> -		"sony_controller_battery_%pMR";
>  	struct power_supply_config psy_cfg = { .drv_data = sc, };
>  	struct hid_device *hdev = sc->hdev;
> +	const char *battery_str_fmt;
>  	int ret;
>  
> +	/*
> +	 * Devices without a MAC address, such as Rock Band 4 PS5 guitars,
> +	 * would all get the same name, so use the device ID to tell them
> +	 * apart.
> +	 */
> +	if (append_dev_id || is_zero_ether_addr(sc->mac_address))
> +		battery_str_fmt = "sony_controller_battery_%pMR_%i";
> +	else
> +		battery_str_fmt = "sony_controller_battery_%pMR";
> +
>  	/*
>  	 * Set the default battery level to 100% to avoid low battery warnings
>  	 * if the battery is polled before the first device report is received.
> @@ -2085,10 +2094,10 @@ static int sony_set_device_id(struct sony_sc *sc)
>  	int ret;
>  
>  	/*
> -	 * Only Sixaxis controllers get an id.
> -	 * All others are set to -1.
> +	 * Only Sixaxis controllers, and Rock Band 4 PS5 guitars which need it
> +	 * to name their battery, get an id. All others are set to -1.
>  	 */
> -	if (sc->quirks & SIXAXIS_CONTROLLER) {
> +	if (sc->quirks & (SIXAXIS_CONTROLLER | RB4_GUITAR_PS5)) {
>  		ret = ida_alloc(&sony_device_id_allocator, GFP_KERNEL);
>  		if (ret < 0) {
>  			sc->device_id = -1;

[Severity: Medium]
Should sony_set_device_id() allocate an ID for all SONY_BATTERY_SUPPORT
devices instead of only SIXAXIS_CONTROLLER | RB4_GUITAR_PS5?

MOTION_CONTROLLER_BT and NAVIGATION_CONTROLLER also register a battery,
and if sony_get_bt_devaddr() cannot parse a MAC address from hdev->uniq
in sony_check_add(), probe continues with sc->mac_address left all zeros
and sc->device_id set to -1.  sony_battery_probe() will then register
"sony_controller_battery_00:00:00:00:00:00_-1", and connecting a second
such controller will fail in devm_power_supply_register() with -EEXIST.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201020704.3545243-2-sanjay.govind9@gmail.com?part=2

  reply	other threads:[~2026-12-01  2:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  2:07 [PATCH 0/2] HID: sony: fix RB4 PS5 guitar battery handling Sanjay Govind
2026-12-01  2:07 ` [PATCH 1/2] HID: sony: handle RB4 PS5 guitars that do not report a battery level Sanjay Govind
2026-12-01  2:07 ` [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars Sanjay Govind
2026-12-01  2:13   ` sashiko-bot [this message]
2026-12-01  2:26     ` Sanjay Govind

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=sashiko-outbox-242361@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sanjay.govind9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.