All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] usb: apple-mfi-fastcharge: Fixes and cleanups
@ 2026-12-06  2:44 Rosen Penev
  2026-12-06  2:44 ` [PATCH 01/12] usb: apple-mfi-fastcharge: Convert to devm resources Rosen Penev
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Rosen Penev @ 2026-12-06  2:44 UTC (permalink / raw)
  To: Bastien Nocera, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

This series fixes several problems in the Apple MFi fast-charge
driver and modernizes it.

Patches 1-6 convert the driver to devm resources, use
pm_runtime_resume_and_get(), fix the usb_control_msg() error check and
timeout, register the power supply as POWER_SUPPLY_TYPE_USB instead of
BATTERY, constify the property array, and name the power supply after
the USB topology (busnum-devpath) instead of the device number, which
changes on every re-enumeration. Patches 4 and 6 change what userspace
sees: the power supply type and its name.

Patch 7 re-sends the fast-charge request on resume. A failure there is
logged but not returned, since an error from a usb_device_driver's
resume makes the USB core skip resuming the device's interfaces.

Patch 8 adds a mutex held across the USB control transfer, so that
concurrent writes to charge_type cannot leave the cached value
different from what was last sent to the device.

Patch 9 enables autosuspend. The device keeps charging at the
fast-charge current while it is USB-suspended.

Patches 10-12 are small cleanups.

Tested on an iPhone (05ac:12a8) connected to an x86 host:
- Fast/Trickle switch the current the phone reports for its USB
  charger between 2400 mA and 500 mA. Invalid values are rejected
  with -EINVAL.
- Two writers sending opposite values plus a reader, for 3 rounds
  (about 670 writes): afterwards the cached value always matched what
  the phone reported.
- With usbmuxd stopped and ipheth unbound, the phone autosuspends
  2 s after its last use. It kept charging while suspended (34% to
  43% in 433 s). Writes to charge_type wake the phone, and it suspends
  again afterwards.
System suspend and unplugging during a write were not tested.

Claude Code (Opus) was used to help prepare these patches.

Rosen Penev (12):
  usb: apple-mfi-fastcharge: Convert to devm resources
  usb: apple-mfi-fastcharge: Use pm_runtime_resume_and_get()
  usb: apple-mfi-fastcharge: Fix usb_control_msg() return check and
    timeout
  usb: apple-mfi-fastcharge: Use POWER_SUPPLY_TYPE_USB instead of
    BATTERY
  usb: apple-mfi-fastcharge: Constify power_supply_property array
  usb: apple-mfi-fastcharge: Use topology-based device name
  usb: apple-mfi-fastcharge: Restore charge current on resume
  usb: apple-mfi-fastcharge: Serialize charge_type access with a mutex
  usb: apple-mfi-fastcharge: Configure runtime PM autosuspend
  usb: apple-mfi-fastcharge: Name the vendor power request
  usb: apple-mfi-fastcharge: Rename battery variables to psy
  usb: apple-mfi-fastcharge: Simplify match and property_is_writeable

 drivers/usb/misc/apple-mfi-fastcharge.c | 171 ++++++++++++------------
 1 file changed, 85 insertions(+), 86 deletions(-)


base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
-- 
2.56.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2026-12-06  3:07 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  2:44 [PATCH 00/12] usb: apple-mfi-fastcharge: Fixes and cleanups Rosen Penev
2026-12-06  2:44 ` [PATCH 01/12] usb: apple-mfi-fastcharge: Convert to devm resources Rosen Penev
2026-12-06  3:00   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 02/12] usb: apple-mfi-fastcharge: Use pm_runtime_resume_and_get() Rosen Penev
2026-12-06  2:44 ` [PATCH 03/12] usb: apple-mfi-fastcharge: Fix usb_control_msg() return check and timeout Rosen Penev
2026-12-06  2:44 ` [PATCH 04/12] usb: apple-mfi-fastcharge: Use POWER_SUPPLY_TYPE_USB instead of BATTERY Rosen Penev
2026-12-06  3:04   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 05/12] usb: apple-mfi-fastcharge: Constify power_supply_property array Rosen Penev
2026-12-06  2:44 ` [PATCH 06/12] usb: apple-mfi-fastcharge: Use topology-based device name Rosen Penev
2026-12-06  2:44 ` [PATCH 07/12] usb: apple-mfi-fastcharge: Restore charge current on resume Rosen Penev
2026-12-06  3:05   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 08/12] usb: apple-mfi-fastcharge: Serialize charge_type access with a mutex Rosen Penev
2026-12-06  3:07   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 09/12] usb: apple-mfi-fastcharge: Configure runtime PM autosuspend Rosen Penev
2026-12-06  3:05   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 10/12] usb: apple-mfi-fastcharge: Name the vendor power request Rosen Penev
2026-12-06  2:44 ` [PATCH 11/12] usb: apple-mfi-fastcharge: Rename battery variables to psy Rosen Penev
2026-12-06  2:58   ` sashiko-bot
2026-12-06  2:44 ` [PATCH 12/12] usb: apple-mfi-fastcharge: Simplify match and property_is_writeable Rosen Penev
2026-12-06  3:06   ` sashiko-bot
2026-12-06  3:07 ` [PATCH 00/12] usb: apple-mfi-fastcharge: Fixes and cleanups sashiko-bot

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.