* [PATCH v1 1/1] HID: nintendo: Use %pM format specifier for MAC addresses
@ 2026-06-03 8:28 Andy Shevchenko
2026-06-03 8:39 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-06-03 8:28 UTC (permalink / raw)
To: Jiri Kosina, Daniel J. Ogorchock, linux-input, linux-kernel
Cc: Benjamin Tissoires, Andy Shevchenko
Convert to %pM instead of using custom code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hid/hid-nintendo.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 29008c2cc530..77b14dfdae86 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2431,14 +2431,8 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
for (i = 4, j = 0; j < 6; i++, j++)
ctlr->mac_addr[j] = report->subcmd_reply.data[i];
- ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL,
- "%02X:%02X:%02X:%02X:%02X:%02X",
- ctlr->mac_addr[0],
- ctlr->mac_addr[1],
- ctlr->mac_addr[2],
- ctlr->mac_addr[3],
- ctlr->mac_addr[4],
- ctlr->mac_addr[5]);
+ ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL, "%pM",
+ ctlr->mac_addr);
if (!ctlr->mac_addr_str)
return -ENOMEM;
hid_info(ctlr->hdev, "controller MAC = %s\n", ctlr->mac_addr_str);
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] HID: nintendo: Use %pM format specifier for MAC addresses
2026-06-03 8:28 [PATCH v1 1/1] HID: nintendo: Use %pM format specifier for MAC addresses Andy Shevchenko
@ 2026-06-03 8:39 ` sashiko-bot
2026-06-03 9:05 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-06-03 8:39 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-input, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] ABI Breakage: The patch changes the MAC address exposed via sysfs from uppercase to lowercase, breaking userspace tools that rely on exact string matching.
--
commit 6c8c4e53eb547a4381d6f8dabe9201540c4f0168
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
HID: nintendo: Use %pM format specifier for MAC addresses
This commit refactors the MAC address string generation in the nintendo HID
driver. It replaces a custom sprintf format string with the standard %pM
format specifier.
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index 29008c2cc5304..77b14dfdae867 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -2431,14 +2431,8 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
> for (i = 4, j = 0; j < 6; i++, j++)
> ctlr->mac_addr[j] = report->subcmd_reply.data[i];
>
> - ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL,
> - "%02X:%02X:%02X:%02X:%02X:%02X",
> - ctlr->mac_addr[0],
> - ctlr->mac_addr[1],
> - ctlr->mac_addr[2],
> - ctlr->mac_addr[3],
> - ctlr->mac_addr[4],
> - ctlr->mac_addr[5]);
> + ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL, "%pM",
> + ctlr->mac_addr);
[Severity: Critical]
Does this change the sysfs output from uppercase to lowercase?
The original format string %02X explicitly generated an uppercase MAC
address string, while %pM delegates to hex_byte_pack() and generates a
lowercase string.
Since ctlr->mac_addr_str is exposed to userspace via the uniq attribute,
could this cause an ABI regression?
Userspace utilities and gaming libraries (like SDL and the joycond daemon)
often map USB controllers to their Bluetooth pairings by performing
case-sensitive matching against the uppercase Bluetooth MAC addresses
exposed by BlueZ.
> if (!ctlr->mac_addr_str)
> return -ENOMEM;
> hid_info(ctlr->hdev, "controller MAC = %s\n", ctlr->mac_addr_str);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603082808.119958-1-andriy.shevchenko@linux.intel.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] HID: nintendo: Use %pM format specifier for MAC addresses
2026-06-03 8:39 ` sashiko-bot
@ 2026-06-03 9:05 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-06-03 9:05 UTC (permalink / raw)
To: sashiko-reviews; +Cc: linux-input, dmitry.torokhov
On Wed, Jun 03, 2026 at 08:39:46AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Critical] ABI Breakage: The patch changes the MAC address exposed via sysfs from uppercase to lowercase, breaking userspace tools that rely on exact string matching.
> --
>
> commit 6c8c4e53eb547a4381d6f8dabe9201540c4f0168
> Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> HID: nintendo: Use %pM format specifier for MAC addresses
>
> This commit refactors the MAC address string generation in the nintendo HID
> driver. It replaces a custom sprintf format string with the standard %pM
> format specifier.
>
> > diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> > index 29008c2cc5304..77b14dfdae867 100644
> > --- a/drivers/hid/hid-nintendo.c
> > +++ b/drivers/hid/hid-nintendo.c
> > @@ -2431,14 +2431,8 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
> > for (i = 4, j = 0; j < 6; i++, j++)
> > ctlr->mac_addr[j] = report->subcmd_reply.data[i];
> >
> > - ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL,
> > - "%02X:%02X:%02X:%02X:%02X:%02X",
> > - ctlr->mac_addr[0],
> > - ctlr->mac_addr[1],
> > - ctlr->mac_addr[2],
> > - ctlr->mac_addr[3],
> > - ctlr->mac_addr[4],
> > - ctlr->mac_addr[5]);
> > + ctlr->mac_addr_str = devm_kasprintf(&ctlr->hdev->dev, GFP_KERNEL, "%pM",
> > + ctlr->mac_addr);
>
> [Severity: Critical]
> Does this change the sysfs output from uppercase to lowercase?
I think yes, it does.
> The original format string %02X explicitly generated an uppercase MAC
> address string, while %pM delegates to hex_byte_pack() and generates a
> lowercase string.
>
> Since ctlr->mac_addr_str is exposed to userspace via the uniq attribute,
> could this cause an ABI regression?
This is a good question. This is MAC address string and conceptually the
user space should be prepared to parse it as a mac address and not an arbitrary
string. OTOH, the field is named something like uniq, which means the
driver just supplies MAC as an arbitrary (unique) string.
> Userspace utilities and gaming libraries (like SDL and the joycond daemon)
> often map USB controllers to their Bluetooth pairings by performing
> case-sensitive matching against the uppercase Bluetooth MAC addresses
> exposed by BlueZ.
Hmm... Interesting. Okay, perhaps we need to have %pMU first.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-03 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 8:28 [PATCH v1 1/1] HID: nintendo: Use %pM format specifier for MAC addresses Andy Shevchenko
2026-06-03 8:39 ` sashiko-bot
2026-06-03 9:05 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox