HID: nintendo: Use %pM format specifier for MAC addresses
Subsystems (2)
PATCH 1/1 HID: nintendo: Use %pM format specifier for MAC addresses
Convert to %pM instead of using custom code.
--- drivers/hid/hid-nintendo.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/hid/hid-nintendo.c +2 -8
@@ -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);
Signature · 1 line
2.50.1
[email protected]
AI reviewThank 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…
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 <[email protected]>
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.
Quoted 8 lines
drivers/hid/hid-nintendo.c +0
-0@@ -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];
drivers/hid/hid-nintendo.c static int joycon_read_info(struct joycon_ctlr *ctlr) · line 2435
Quoted 10 lines
drivers/hid/hid-nintendo.c +2
-8- 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.
Quoted 3 lines
drivers/hid/hid-nintendo.c +0
-0if (!ctlr->mac_addr_str)return -ENOMEM ;hid_info (ctlr->hdev,"controller MAC = %s\n" , ctlr->mac_addr_str);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 21 lines · On Wed, Jun 03, 2026 at 08:39:46AM +0000, [email protected] 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 <[email protected]>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.
Quoted 8 lines
drivers/hid/hid-nintendo.c +0
-0@@ -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];
Quoted 13 lines
drivers/hid/hid-nintendo.c static int joycon_read_info(struct joycon_ctlr *ctlr) · line 2435
Quoted 10 lines
drivers/hid/hid-nintendo.c +2
-8- 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.
Quoted 6 lines
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_stris 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.
Quoted 4 lines
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko