[PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars

From: Sanjay Govind

Date: Mon Nov 30 2026 - 21:08:12 EST


Rock Band 4 PS5 guitars register a power supply named after their MAC
address, but the driver never reads a MAC address for them, so every
such guitar registers "sony_controller_battery_00:00:00:00:00:00".

With two of these guitars connected, registering the battery of the
second one fails, and as a battery registration failure aborts
sony_input_configured(), the second guitar is not usable at all:

sysfs: cannot create duplicate filename '/class/power_supply/sony_controller_battery_00:00:00:00:00:00'
...
sony 0003:3958:5600.0222: Unable to register battery device
sony 0003:3958:5600.0222: failed to claim input

Allocate a device ID for these guitars, and append it to the battery
name when the MAC address is unknown.

Fixes: e4bdeaef0351 ("HID: sony: add battery status support for Rock Band 4 PS5 guitars")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sanjay Govind <sanjay.govind9@xxxxxxxxx>
---

Notes:
Tested with a Gibson SG (3651:8600) and a Gibson Kramer (3958:5600),
both in PS5 mode over USB and connected at the same time. Without this
patch, the guitar connected second fails to register its battery, with
the sysfs warning above, and has no input device. With it, both guitars
are usable and their batteries are registered as
sony_controller_battery_00:00:00:00:00:00_0 and _1.

Built hid-sony.ko with W=1 against the 7.3.6 headers, no warnings;
checkpatch clean.

The patch and changelog were written with the help of an AI coding
assistant (Claude Opus 5.5).

drivers/hid/hid-sony.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 7a25f5acce88..1f1152575ae4 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -31,6 +31,7 @@

#include <linux/cleanup.h>
#include <linux/device.h>
+#include <linux/etherdevice.h>
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -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;
--
2.56.1