linux/drivers/usb/misc
Charalampos Mitrodimas 8209fc45b0 usb: misc: apple-mfi-fastcharge: Make power supply names unique
[ Upstream commit 43007b89fb ]

When multiple Apple devices are connected concurrently, the
apple-mfi-fastcharge driver fails to probe the subsequent devices with
the following error:

    sysfs: cannot create duplicate filename '/class/power_supply/apple_mfi_fastcharge'
    apple-mfi-fastcharge 5-2.4.3.3: probe of 5-2.4.3.3 failed with error -17

This happens because the driver uses a fixed power supply name
("apple_mfi_fastcharge") for all devices, causing a sysfs name
conflict when a second device is connected.

Fix this by generating unique names using the USB bus and device
number (e.g., "apple_mfi_fastcharge_5-12"). This ensures each
connected device gets a unique power supply entry in sysfs.

The change requires storing a copy of the power_supply_desc structure
in the per-device mfi_device struct, since the name pointer needs to
remain valid for the lifetime of the power supply registration.

Fixes: 249fa8217b ("USB: Add driver to control USB fast charge for iOS devices")
Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Link: https://lore.kernel.org/r/20250602-apple-mfi-fastcharge-duplicate-sysfs-v1-1-5d84de34fac6@posteo.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-08-15 12:13:34 +02:00
..
sisusbvga USB: sisusbvga: Add endpoint checks 2023-04-20 11:43:22 +02:00
adutux.c usb: misc: adutux: use swap() 2021-08-05 12:31:34 +02:00
apple-mfi-fastcharge.c usb: misc: apple-mfi-fastcharge: Make power supply names unique 2025-08-15 12:13:34 +02:00
appledisplay.c USB: appledisplay: close race between probe and completion handler 2024-09-13 07:54:23 +02:00
brcmstb-usb-pinmap.c usb: misc: brcmstb-usb-pinmap: fix module autoloading 2024-08-25 13:45:56 +02:00
chaoskey.c USB: chaoskey: Fix possible deadlock chaoskey_list_lock 2024-12-05 14:02:36 +01:00
cypress_cy7c63.c USB: misc: cypress_cy7c63: check for short transfer 2024-09-13 07:54:50 +02:00
cytherm.c USB: misc: Remove unnecessary NULL values 2023-08-04 14:48:55 +02:00
ehset.c usb: misc: ehset: fix wrong if condition 2023-07-27 10:37:30 +02:00
emi26.c USB: misc: Remove redundant license text 2017-11-04 11:55:38 +01:00
emi62.c USB: misc: Remove redundant license text 2017-11-04 11:55:38 +01:00
ezusb.c usb: misc: add missing MODULE_DESCRIPTION() macros 2024-06-20 19:18:24 +02:00
idmouse.c usb: idmouse: fix an uninit-value in idmouse_open 2022-09-27 10:37:09 +02:00
iowarrior.c usb: yurex: make waiting on yurex_write interruptible 2024-12-05 14:02:36 +01:00
isight_firmware.c usb: misc: add missing MODULE_DESCRIPTION() macros 2024-06-20 19:18:24 +02:00
Kconfig usb: misc: onboard_usb_dev: introduce new config symbol for usb5744 SMBus support 2024-10-04 15:36:51 +02:00
ldusb.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
legousbtower.c USB: make devnode() callback in usb_class_driver take a const * 2022-10-20 12:11:56 +02:00
lvstest.c usb: remove third argument of usb_maxpacket() 2022-04-23 10:33:53 +02:00
Makefile usb: misc: onboard_hub: rename to onboard_dev 2024-03-27 07:57:16 +01:00
onboard_usb_dev.c usb: misc: onboard_usb_dev: fix build warning for CONFIG_USB_ONBOARD_DEV_USB5744=n 2025-06-19 15:32:37 +02:00
onboard_usb_dev.h usb: misc: onboard_dev: extend platform data to add power on delay field 2024-09-11 15:36:25 +02:00
onboard_usb_dev_pdevs.c usb: misc: onboard_hub: rename to onboard_dev 2024-03-27 07:57:16 +01:00
qcom_eud.c usb: misc: eud: switch to fallback compatible for device matching 2024-07-31 10:42:17 +02:00
trancevibrator.c USB: trancevibrator: fix control-request direction 2021-05-21 20:10:43 +02:00
usb-ljca.c usb: misc: ljca: move usb_autopm_put_interface() after wait for response 2024-12-05 14:03:00 +01:00
usb251xb.c of: remove internal arguments from of_property_for_each_u32() 2024-07-25 06:53:47 -05:00
usb3503.c usb: misc: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-06-20 19:18:57 +02:00
usb4604.c usb: misc: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-06-20 19:18:57 +02:00
usblcd.c USB: usblcd: Remove the superfluous break 2020-08-28 09:48:33 +02:00
usbsevseg.c USB: misc: Remove unnecessary NULL values 2023-08-04 14:48:55 +02:00
usbtest.c usb: usbtest: fix a type promotion bug 2023-10-08 07:50:36 +02:00
uss720.c usb: misc: uss720: check for incompatible versions of the Belkin F5U002 2024-04-04 17:07:48 +02:00
yurex.c usb: yurex: make waiting on yurex_write interruptible 2024-12-05 14:02:36 +01:00