Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
@ 2019-10-16  9:39 Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 1/6] USB: Export generic USB device driver functions Bastien Nocera
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera

This is version 3 of the patch set.

Changes in v3:
- Add Alan's ack
- don't export usb_device_match_id()

Changes in v2:
- checkpatch.pl is now quiet
- fallback to the generic driver when driver ->probe() fails

Bastien Nocera (6):
  USB: Export generic USB device driver functions
  USB: Make it possible to "subclass" usb_device_driver
  USB: Implement usb_device_match_id()
  USB: Select better matching USB drivers when available
  USB: Fallback to generic driver when specific driver fails
  USB: Add driver to control USB fast charge for iOS devices

 MAINTAINERS                             |   6 +
 drivers/usb/core/driver.c               |  58 +++++-
 drivers/usb/core/generic.c              |  48 ++++-
 drivers/usb/core/usb.h                  |   8 +
 drivers/usb/misc/Kconfig                |  10 +
 drivers/usb/misc/Makefile               |   1 +
 drivers/usb/misc/apple-mfi-fastcharge.c | 237 ++++++++++++++++++++++++
 include/linux/usb.h                     |   7 +
 8 files changed, 360 insertions(+), 15 deletions(-)
 create mode 100644 drivers/usb/misc/apple-mfi-fastcharge.c

-- 
2.21.0


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

* [PATCH v3 1/6] USB: Export generic USB device driver functions
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 2/6] USB: Make it possible to "subclass" usb_device_driver Bastien Nocera
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

This will make it possible to implement device drivers which extend the
generic driver without needing to reimplement it.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/generic.c | 16 ++++++++--------
 drivers/usb/core/usb.h     |  6 ++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git drivers/usb/core/generic.c drivers/usb/core/generic.c
index 38f8b3e31762..28ece4d77749 100644
--- drivers/usb/core/generic.c
+++ drivers/usb/core/generic.c
@@ -195,7 +195,7 @@ int usb_choose_configuration(struct usb_device *udev)
 }
 EXPORT_SYMBOL_GPL(usb_choose_configuration);
 
-static int generic_probe(struct usb_device *udev)
+int usb_generic_driver_probe(struct usb_device *udev)
 {
 	int err, c;
 
@@ -222,7 +222,7 @@ static int generic_probe(struct usb_device *udev)
 	return 0;
 }
 
-static void generic_disconnect(struct usb_device *udev)
+void usb_generic_driver_disconnect(struct usb_device *udev)
 {
 	usb_notify_remove_device(udev);
 
@@ -234,7 +234,7 @@ static void generic_disconnect(struct usb_device *udev)
 
 #ifdef	CONFIG_PM
 
-static int generic_suspend(struct usb_device *udev, pm_message_t msg)
+int usb_generic_driver_suspend(struct usb_device *udev, pm_message_t msg)
 {
 	int rc;
 
@@ -262,7 +262,7 @@ static int generic_suspend(struct usb_device *udev, pm_message_t msg)
 	return rc;
 }
 
-static int generic_resume(struct usb_device *udev, pm_message_t msg)
+int usb_generic_driver_resume(struct usb_device *udev, pm_message_t msg)
 {
 	int rc;
 
@@ -285,11 +285,11 @@ static int generic_resume(struct usb_device *udev, pm_message_t msg)
 
 struct usb_device_driver usb_generic_driver = {
 	.name =	"usb",
-	.probe = generic_probe,
-	.disconnect = generic_disconnect,
+	.probe = usb_generic_driver_probe,
+	.disconnect = usb_generic_driver_disconnect,
 #ifdef	CONFIG_PM
-	.suspend = generic_suspend,
-	.resume = generic_resume,
+	.suspend = usb_generic_driver_suspend,
+	.resume = usb_generic_driver_resume,
 #endif
 	.supports_autosuspend = 1,
 };
diff --git drivers/usb/core/usb.h drivers/usb/core/usb.h
index cf4783cf661a..bbe24817315e 100644
--- drivers/usb/core/usb.h
+++ drivers/usb/core/usb.h
@@ -47,6 +47,12 @@ extern void usb_release_bos_descriptor(struct usb_device *dev);
 extern char *usb_cache_string(struct usb_device *udev, int index);
 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 extern int usb_choose_configuration(struct usb_device *udev);
+extern int usb_generic_driver_probe(struct usb_device *udev);
+extern void usb_generic_driver_disconnect(struct usb_device *udev);
+extern int usb_generic_driver_suspend(struct usb_device *udev,
+		pm_message_t msg);
+extern int usb_generic_driver_resume(struct usb_device *udev,
+		pm_message_t msg);
 
 static inline unsigned usb_get_max_power(struct usb_device *udev,
 		struct usb_host_config *c)
-- 
2.21.0


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

* [PATCH v3 2/6] USB: Make it possible to "subclass" usb_device_driver
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 1/6] USB: Export generic USB device driver functions Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 3/6] USB: Implement usb_device_match_id() Bastien Nocera
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

The kernel currenly has only 2 usb_device_drivers, one generic one, one
that completely replaces the generic one to make USB devices usable over
a network.

Use the newly exported generic driver functions when a driver declares
to want them run, in addition to its own code. This makes it possible to
write drivers that extend the generic USB driver.

Note that this patch is not enough for another driver to automatically
get selected.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/driver.c | 26 +++++++++++++++++++++-----
 include/linux/usb.h       |  4 ++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git drivers/usb/core/driver.c drivers/usb/core/driver.c
index 2b27d232d7a7..d3787d084937 100644
--- drivers/usb/core/driver.c
+++ drivers/usb/core/driver.c
@@ -261,9 +261,16 @@ static int usb_probe_device(struct device *dev)
 	 */
 	if (!udriver->supports_autosuspend)
 		error = usb_autoresume_device(udev);
+	if (error)
+		return error;
 
-	if (!error)
-		error = udriver->probe(udev);
+	if (udriver->generic_subclass)
+		error = usb_generic_driver_probe(udev);
+	if (error)
+		return error;
+
+	error = udriver->probe(udev);
+	/* TODO: fallback to generic driver in case of error */
 	return error;
 }
 
@@ -273,7 +280,10 @@ static int usb_unbind_device(struct device *dev)
 	struct usb_device *udev = to_usb_device(dev);
 	struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
 
-	udriver->disconnect(udev);
+	if (udriver->disconnect)
+		udriver->disconnect(udev);
+	if (udriver->generic_subclass)
+		usb_generic_driver_disconnect(udev);
 	if (!udriver->supports_autosuspend)
 		usb_autosuspend_device(udev);
 	return 0;
@@ -1149,7 +1159,10 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
 		udev->do_remote_wakeup = 0;
 		udriver = &usb_generic_driver;
 	}
-	status = udriver->suspend(udev, msg);
+	if (udriver->suspend)
+		status = udriver->suspend(udev, msg);
+	if (status == 0 && udriver->generic_subclass)
+		status = usb_generic_driver_suspend(udev, msg);
 
  done:
 	dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
@@ -1181,7 +1194,10 @@ static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
 		udev->reset_resume = 1;
 
 	udriver = to_usb_device_driver(udev->dev.driver);
-	status = udriver->resume(udev, msg);
+	if (udriver->generic_subclass)
+		status = usb_generic_driver_resume(udev, msg);
+	if (status == 0 && udriver->resume)
+		status = udriver->resume(udev, msg);
 
  done:
 	dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
diff --git include/linux/usb.h include/linux/usb.h
index e656e7b4b1e4..94bd3b48a485 100644
--- include/linux/usb.h
+++ include/linux/usb.h
@@ -1228,6 +1228,9 @@ struct usb_driver {
  * @drvwrap: Driver-model core structure wrapper.
  * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
  *	for devices bound to this driver.
+ * @generic_subclass: if set to 1, the generic USB driver's probe, disconnect,
+ *	resume and suspend functions will be called in addition to the driver's
+ *	own, so this part of the setup does not need to be replicated.
  *
  * USB drivers must provide all the fields listed above except drvwrap.
  */
@@ -1242,6 +1245,7 @@ struct usb_device_driver {
 	const struct attribute_group **dev_groups;
 	struct usbdrv_wrap drvwrap;
 	unsigned int supports_autosuspend:1;
+	unsigned int generic_subclass:1;
 };
 #define	to_usb_device_driver(d) container_of(d, struct usb_device_driver, \
 		drvwrap.driver)
-- 
2.21.0


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

* [PATCH v3 3/6] USB: Implement usb_device_match_id()
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 1/6] USB: Export generic USB device driver functions Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 2/6] USB: Make it possible to "subclass" usb_device_driver Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 4/6] USB: Select better matching USB drivers when available Bastien Nocera
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

Match a usb_device with a table of IDs.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/driver.c | 14 ++++++++++++++
 drivers/usb/core/usb.h    |  2 ++
 2 files changed, 16 insertions(+)

diff --git drivers/usb/core/driver.c drivers/usb/core/driver.c
index d3787d084937..697898327b44 100644
--- drivers/usb/core/driver.c
+++ drivers/usb/core/driver.c
@@ -800,6 +800,20 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
 }
 EXPORT_SYMBOL_GPL(usb_match_id);
 
+const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
+				const struct usb_device_id *id)
+{
+	if (!id)
+		return NULL;
+
+	for (; id->idVendor || id->idProduct ; id++) {
+		if (usb_match_device(udev, id))
+			return id;
+	}
+
+	return NULL;
+}
+
 static int usb_device_match(struct device *dev, struct device_driver *drv)
 {
 	/* devices and interfaces are handled separately */
diff --git drivers/usb/core/usb.h drivers/usb/core/usb.h
index bbe24817315e..f1dc63848219 100644
--- drivers/usb/core/usb.h
+++ drivers/usb/core/usb.h
@@ -69,6 +69,8 @@ extern int usb_match_one_id_intf(struct usb_device *dev,
 				 const struct usb_device_id *id);
 extern int usb_match_device(struct usb_device *dev,
 			    const struct usb_device_id *id);
+extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
+				const struct usb_device_id *id);
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev);
 
-- 
2.21.0


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

* [PATCH v3 4/6] USB: Select better matching USB drivers when available
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
                   ` (2 preceding siblings ...)
  2019-10-16  9:39 ` [PATCH v3 3/6] USB: Implement usb_device_match_id() Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 5/6] USB: Fallback to generic driver when specific driver fails Bastien Nocera
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

Now that USB device drivers can reuse code from the generic USB device
driver, we need to make sure that they get selected rather than the
generic driver. Add an id_table and match vfunc to the usb_device_driver
struct, which will get used to select a better matching driver at
->probe time.

This is a similar mechanism to that used in the HID drivers, with the
generic driver being selected unless there's a better matching one found
in the registered drivers (see hid_generic_match() in
drivers/hid/hid-generic.c).

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/driver.c  | 15 +++++++++++++--
 drivers/usb/core/generic.c | 29 +++++++++++++++++++++++++++++
 include/linux/usb.h        |  2 ++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git drivers/usb/core/driver.c drivers/usb/core/driver.c
index 697898327b44..9d1502a9571d 100644
--- drivers/usb/core/driver.c
+++ drivers/usb/core/driver.c
@@ -818,13 +818,24 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
 {
 	/* devices and interfaces are handled separately */
 	if (is_usb_device(dev)) {
+		struct usb_device *udev;
+		struct usb_device_driver *udrv;
 
 		/* interface drivers never match devices */
 		if (!is_usb_device_driver(drv))
 			return 0;
 
-		/* TODO: Add real matching code */
-		return 1;
+		udev = to_usb_device(dev);
+		udrv = to_usb_device_driver(drv);
+
+		if (udrv->id_table &&
+		    usb_device_match_id(udev, udrv->id_table) != NULL) {
+			return 1;
+		}
+
+		if (udrv->match)
+			return udrv->match(udev);
+		return 0;
 
 	} else if (is_usb_interface(dev)) {
 		struct usb_interface *intf;
diff --git drivers/usb/core/generic.c drivers/usb/core/generic.c
index 28ece4d77749..84da85c13825 100644
--- drivers/usb/core/generic.c
+++ drivers/usb/core/generic.c
@@ -195,6 +195,34 @@ int usb_choose_configuration(struct usb_device *udev)
 }
 EXPORT_SYMBOL_GPL(usb_choose_configuration);
 
+static int __check_usb_generic(struct device_driver *drv, void *data)
+{
+	struct usb_device *udev = data;
+	struct usb_device_driver *udrv;
+
+	if (!is_usb_device_driver(drv))
+		return 0;
+	udrv = to_usb_device_driver(drv);
+	if (udrv == &usb_generic_driver)
+		return 0;
+	if (!udrv->id_table)
+		return 0;
+
+	return usb_device_match_id(udev, udrv->id_table) != NULL;
+}
+
+static bool usb_generic_driver_match(struct usb_device *udev)
+{
+	/*
+	 * If any other driver wants the device, leave the device to this other
+	 * driver.
+	 */
+	if (bus_for_each_drv(&usb_bus_type, NULL, udev, __check_usb_generic))
+		return false;
+
+	return true;
+}
+
 int usb_generic_driver_probe(struct usb_device *udev)
 {
 	int err, c;
@@ -285,6 +313,7 @@ int usb_generic_driver_resume(struct usb_device *udev, pm_message_t msg)
 
 struct usb_device_driver usb_generic_driver = {
 	.name =	"usb",
+	.match = usb_generic_driver_match,
 	.probe = usb_generic_driver_probe,
 	.disconnect = usb_generic_driver_disconnect,
 #ifdef	CONFIG_PM
diff --git include/linux/usb.h include/linux/usb.h
index 94bd3b48a485..3663bd7b1fa4 100644
--- include/linux/usb.h
+++ include/linux/usb.h
@@ -1237,6 +1237,7 @@ struct usb_driver {
 struct usb_device_driver {
 	const char *name;
 
+	bool (*match) (struct usb_device *udev);
 	int (*probe) (struct usb_device *udev);
 	void (*disconnect) (struct usb_device *udev);
 
@@ -1244,6 +1245,7 @@ struct usb_device_driver {
 	int (*resume) (struct usb_device *udev, pm_message_t message);
 	const struct attribute_group **dev_groups;
 	struct usbdrv_wrap drvwrap;
+	const struct usb_device_id *id_table;
 	unsigned int supports_autosuspend:1;
 	unsigned int generic_subclass:1;
 };
-- 
2.21.0


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

* [PATCH v3 5/6] USB: Fallback to generic driver when specific driver fails
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
                   ` (3 preceding siblings ...)
  2019-10-16  9:39 ` [PATCH v3 4/6] USB: Select better matching USB drivers when available Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-10-16  9:39 ` [PATCH v3 6/6] USB: Add driver to control USB fast charge for iOS devices Bastien Nocera
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

If ->probe fails for a device specific driver, ask the driver core to
reprobe us, after having flagged the device for the generic driver to be
forced.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/driver.c  | 5 ++++-
 drivers/usb/core/generic.c | 3 +++
 include/linux/usb.h        | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git drivers/usb/core/driver.c drivers/usb/core/driver.c
index 9d1502a9571d..f81606c6a35b 100644
--- drivers/usb/core/driver.c
+++ drivers/usb/core/driver.c
@@ -270,7 +270,10 @@ static int usb_probe_device(struct device *dev)
 		return error;
 
 	error = udriver->probe(udev);
-	/* TODO: fallback to generic driver in case of error */
+	if (error == -ENODEV && udriver != &usb_generic_driver) {
+		udev->use_generic_driver = 1;
+		return -EPROBE_DEFER;
+	}
 	return error;
 }
 
diff --git drivers/usb/core/generic.c drivers/usb/core/generic.c
index 84da85c13825..4626227a6dd2 100644
--- drivers/usb/core/generic.c
+++ drivers/usb/core/generic.c
@@ -213,6 +213,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
 
 static bool usb_generic_driver_match(struct usb_device *udev)
 {
+	if (udev->use_generic_driver)
+		return true;
+
 	/*
 	 * If any other driver wants the device, leave the device to this other
 	 * driver.
diff --git include/linux/usb.h include/linux/usb.h
index 3663bd7b1fa4..ca1a5f1e1c5e 100644
--- include/linux/usb.h
+++ include/linux/usb.h
@@ -708,6 +708,7 @@ struct usb_device {
 	unsigned lpm_disable_count;
 
 	u16 hub_delay;
+	unsigned use_generic_driver:1;
 };
 #define	to_usb_device(d) container_of(d, struct usb_device, dev)
 
-- 
2.21.0


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

* [PATCH v3 6/6] USB: Add driver to control USB fast charge for iOS devices
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
                   ` (4 preceding siblings ...)
  2019-10-16  9:39 ` [PATCH v3 5/6] USB: Fallback to generic driver when specific driver fails Bastien Nocera
@ 2019-10-16  9:39 ` Bastien Nocera
  2019-11-21 15:20 ` [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
  2020-02-12 19:06 ` Greg Kroah-Hartman
  7 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2019-10-16  9:39 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Benjamin Tissoires, Bastien Nocera, Alan Stern

iOS devices will not draw more than 500mA unless instructed to do so.
Setting the charge type power supply property to "fast" tells the device
to start drawing more power, using the same procedure that official
"MFi" chargers would.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 MAINTAINERS                             |   6 +
 drivers/usb/misc/Kconfig                |  10 +
 drivers/usb/misc/Makefile               |   1 +
 drivers/usb/misc/apple-mfi-fastcharge.c | 237 ++++++++++++++++++++++++
 4 files changed, 254 insertions(+)
 create mode 100644 drivers/usb/misc/apple-mfi-fastcharge.c

diff --git MAINTAINERS MAINTAINERS
index 94ce075907a0..9e8f9fc972f5 100644
--- MAINTAINERS
+++ MAINTAINERS
@@ -16728,6 +16728,12 @@ S:	Maintained
 F:	Documentation/usb/acm.rst
 F:	drivers/usb/class/cdc-acm.*
 
+USB APPLE MFI FASTCHARGE DRIVER
+M:	Bastien Nocera <hadess@hadess.net>
+L:	linux-usb@vger.kernel.org
+S:	Maintained
+F:	drivers/usb/misc/apple-mfi-fastcharge.c
+
 USB AR5523 WIRELESS DRIVER
 M:	Pontus Fuchs <pontus.fuchs@gmail.com>
 L:	linux-wireless@vger.kernel.org
diff --git drivers/usb/misc/Kconfig drivers/usb/misc/Kconfig
index bdae62b2ffe0..f52a49478f1c 100644
--- drivers/usb/misc/Kconfig
+++ drivers/usb/misc/Kconfig
@@ -147,6 +147,16 @@ config USB_APPLEDISPLAY
 	  Say Y here if you want to control the backlight of Apple Cinema
 	  Displays over USB. This driver provides a sysfs interface.
 
+config APPLE_MFI_FASTCHARGE
+	tristate "Fast charge control for iOS devices"
+	select POWER_SUPPLY
+	help
+	  Say Y here if you want to control whether iOS devices will
+	  fast charge from the USB interface, as implemented in "MFi"
+	  chargers.
+
+	  It is safe to say M here.
+
 source "drivers/usb/misc/sisusbvga/Kconfig"
 
 config USB_LD
diff --git drivers/usb/misc/Makefile drivers/usb/misc/Makefile
index 109f54f5b9aa..b75106cf3948 100644
--- drivers/usb/misc/Makefile
+++ drivers/usb/misc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_EMI26)			+= emi26.o
 obj-$(CONFIG_USB_EMI62)			+= emi62.o
 obj-$(CONFIG_USB_EZUSB_FX2)		+= ezusb.o
 obj-$(CONFIG_USB_FTDI_ELAN)		+= ftdi-elan.o
+obj-$(CONFIG_APPLE_MFI_FASTCHARGE)	+= apple-mfi-fastcharge.o
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
 obj-$(CONFIG_USB_ISIGHTFW)		+= isight_firmware.o
diff --git drivers/usb/misc/apple-mfi-fastcharge.c drivers/usb/misc/apple-mfi-fastcharge.c
new file mode 100644
index 000000000000..f1c4461a9a3c
--- /dev/null
+++ drivers/usb/misc/apple-mfi-fastcharge.c
@@ -0,0 +1,237 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Fast-charge control for Apple "MFi" devices
+ *
+ * Copyright (C) 2019 Bastien Nocera <hadess@hadess.net>
+ */
+
+/* Standard include files */
+#include <linux/module.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+
+MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>");
+MODULE_DESCRIPTION("Fast-charge control for Apple \"MFi\" devices");
+MODULE_LICENSE("GPL");
+
+#define TRICKLE_CURRENT_MA		0
+#define FAST_CURRENT_MA			2500
+
+#define APPLE_VENDOR_ID			0x05ac	/* Apple */
+
+/* The product ID is defined as starting with 0x12nn, as per the
+ * "Choosing an Apple Device USB Configuration" section in
+ * release R9 (2012) of the "MFi Accessory Hardware Specification"
+ *
+ * To distinguish an Apple device, a USB host can check the device
+ * descriptor of attached USB devices for the following fields:
+ * ■ Vendor ID: 0x05AC
+ * ■ Product ID: 0x12nn
+ *
+ * Those checks will be done in .match() and .probe().
+ */
+
+static const struct usb_device_id mfi_fc_id_table[] = {
+	{ .idVendor = APPLE_VENDOR_ID,
+	  .match_flags = USB_DEVICE_ID_MATCH_VENDOR },
+	{},
+};
+
+MODULE_DEVICE_TABLE(usb, mfi_fc_id_table);
+
+/* Driver-local specific stuff */
+struct mfi_device {
+	struct usb_device *udev;
+	struct power_supply *battery;
+	int charge_type;
+};
+
+static int apple_mfi_fc_set_charge_type(struct mfi_device *mfi,
+					const union power_supply_propval *val)
+{
+	int current_ma;
+	int retval;
+	__u8 request_type;
+
+	if (mfi->charge_type == val->intval) {
+		dev_dbg(&mfi->udev->dev, "charge type %d already set\n",
+				mfi->charge_type);
+		return 0;
+	}
+
+	switch (val->intval) {
+	case POWER_SUPPLY_CHARGE_TYPE_TRICKLE:
+		current_ma = TRICKLE_CURRENT_MA;
+		break;
+	case POWER_SUPPLY_CHARGE_TYPE_FAST:
+		current_ma = FAST_CURRENT_MA;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	request_type = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
+	retval = usb_control_msg(mfi->udev, usb_sndctrlpipe(mfi->udev, 0),
+				 0x40, /* Vendor‐defined power request */
+				 request_type,
+				 current_ma, /* wValue, current offset */
+				 current_ma, /* wIndex, current offset */
+				 NULL, 0, USB_CTRL_GET_TIMEOUT);
+	if (retval) {
+		dev_dbg(&mfi->udev->dev, "retval = %d\n", retval);
+		return retval;
+	}
+
+	mfi->charge_type = val->intval;
+
+	return 0;
+}
+
+static int apple_mfi_fc_get_property(struct power_supply *psy,
+		enum power_supply_property psp,
+		union power_supply_propval *val)
+{
+	struct mfi_device *mfi = power_supply_get_drvdata(psy);
+
+	dev_dbg(&mfi->udev->dev, "prop: %d\n", psp);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_CHARGE_TYPE:
+		val->intval = mfi->charge_type;
+		break;
+	case POWER_SUPPLY_PROP_SCOPE:
+		val->intval = POWER_SUPPLY_SCOPE_DEVICE;
+		break;
+	default:
+		return -ENODATA;
+	}
+
+	return 0;
+}
+
+static int apple_mfi_fc_set_property(struct power_supply *psy,
+		enum power_supply_property psp,
+		const union power_supply_propval *val)
+{
+	struct mfi_device *mfi = power_supply_get_drvdata(psy);
+	int ret;
+
+	dev_dbg(&mfi->udev->dev, "prop: %d\n", psp);
+
+	ret = pm_runtime_get_sync(&mfi->udev->dev);
+	if (ret < 0)
+		return ret;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_CHARGE_TYPE:
+		ret = apple_mfi_fc_set_charge_type(mfi, val);
+		break;
+	default:
+		ret = -EINVAL;
+	}
+
+	pm_runtime_mark_last_busy(&mfi->udev->dev);
+	pm_runtime_put_autosuspend(&mfi->udev->dev);
+
+	return ret;
+}
+
+static int apple_mfi_fc_property_is_writeable(struct power_supply *psy,
+					      enum power_supply_property psp)
+{
+	switch (psp) {
+	case POWER_SUPPLY_PROP_CHARGE_TYPE:
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static enum power_supply_property apple_mfi_fc_properties[] = {
+	POWER_SUPPLY_PROP_CHARGE_TYPE,
+	POWER_SUPPLY_PROP_SCOPE
+};
+
+static const struct power_supply_desc apple_mfi_fc_desc = {
+	.name                   = "apple_mfi_fastcharge",
+	.type                   = POWER_SUPPLY_TYPE_BATTERY,
+	.properties             = apple_mfi_fc_properties,
+	.num_properties         = ARRAY_SIZE(apple_mfi_fc_properties),
+	.get_property           = apple_mfi_fc_get_property,
+	.set_property           = apple_mfi_fc_set_property,
+	.property_is_writeable  = apple_mfi_fc_property_is_writeable
+};
+
+static int mfi_fc_probe(struct usb_device *udev)
+{
+	struct power_supply_config battery_cfg = {};
+	struct mfi_device *mfi = NULL;
+	int err;
+
+	/* See comment above mfi_fc_id_table[] */
+	if (udev->descriptor.idProduct < 0x1200 ||
+	    udev->descriptor.idProduct > 0x12ff) {
+		return -ENODEV;
+	}
+
+	mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL);
+	if (!mfi) {
+		err = -ENOMEM;
+		goto error;
+	}
+
+	battery_cfg.drv_data = mfi;
+
+	mfi->charge_type = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+	mfi->battery = power_supply_register(&udev->dev,
+						&apple_mfi_fc_desc,
+						&battery_cfg);
+	if (IS_ERR(mfi->battery)) {
+		dev_err(&udev->dev, "Can't register battery\n");
+		err = PTR_ERR(mfi->battery);
+		goto error;
+	}
+
+	mfi->udev = usb_get_dev(udev);
+	dev_set_drvdata(&udev->dev, mfi);
+
+	return 0;
+
+error:
+	kfree(mfi);
+	return err;
+}
+
+static void mfi_fc_disconnect(struct usb_device *udev)
+{
+	struct mfi_device *mfi;
+
+	mfi = dev_get_drvdata(&udev->dev);
+	if (mfi->battery)
+		power_supply_unregister(mfi->battery);
+	dev_set_drvdata(&udev->dev, NULL);
+	usb_put_dev(mfi->udev);
+	kfree(mfi);
+}
+
+static struct usb_device_driver mfi_fc_driver = {
+	.name =		"apple-mfi-fastcharge",
+	.probe =	mfi_fc_probe,
+	.disconnect =	mfi_fc_disconnect,
+	.id_table =	mfi_fc_id_table,
+	.generic_subclass = 1,
+};
+
+static int __init mfi_fc_driver_init(void)
+{
+	return usb_register_device_driver(&mfi_fc_driver, THIS_MODULE);
+}
+
+static void __exit mfi_fc_driver_exit(void)
+{
+	usb_deregister_device_driver(&mfi_fc_driver);
+}
+
+module_init(mfi_fc_driver_init);
+module_exit(mfi_fc_driver_exit);
-- 
2.21.0


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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
                   ` (5 preceding siblings ...)
  2019-10-16  9:39 ` [PATCH v3 6/6] USB: Add driver to control USB fast charge for iOS devices Bastien Nocera
@ 2019-11-21 15:20 ` Bastien Nocera
  2020-01-07  8:46   ` Bastien Nocera
  2020-02-12 19:06 ` Greg Kroah-Hartman
  7 siblings, 1 reply; 17+ messages in thread
From: Bastien Nocera @ 2019-11-21 15:20 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Benjamin Tissoires, Alan Stern

Hey,

Any updates on getting this into the USB tree?

Alan acked the patchset more than a month ago.

On Wed, 2019-10-16 at 11:39 +0200, Bastien Nocera wrote:
> This is version 3 of the patch set.
> 
> Changes in v3:
> - Add Alan's ack
> - don't export usb_device_match_id()




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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2019-11-21 15:20 ` [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
@ 2020-01-07  8:46   ` Bastien Nocera
  2020-01-07  9:35     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 17+ messages in thread
From: Bastien Nocera @ 2020-01-07  8:46 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Benjamin Tissoires, Alan Stern

Hey,

On Thu, 2019-11-21 at 16:20 +0100, Bastien Nocera wrote:
> Hey,
> 
> Any updates on getting this into the USB tree?
> 
> Alan acked the patchset more than a month ago.

Thought I'd ask again, the 6 patches were acked by Alan, and tested by
me. Is there any chance they could be considered for merging, or
reviewed?

Cheers

> On Wed, 2019-10-16 at 11:39 +0200, Bastien Nocera wrote:
> > This is version 3 of the patch set.
> > 
> > Changes in v3:
> > - Add Alan's ack
> > - don't export usb_device_match_id()
> 
> 


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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-01-07  8:46   ` Bastien Nocera
@ 2020-01-07  9:35     ` Greg Kroah-Hartman
  2020-01-07  9:48       ` Bastien Nocera
  2020-02-11  0:21       ` Bastien Nocera
  0 siblings, 2 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2020-01-07  9:35 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-usb, Benjamin Tissoires, Alan Stern

On Tue, Jan 07, 2020 at 09:46:50AM +0100, Bastien Nocera wrote:
> Hey,
> 
> On Thu, 2019-11-21 at 16:20 +0100, Bastien Nocera wrote:
> > Hey,
> > 
> > Any updates on getting this into the USB tree?
> > 
> > Alan acked the patchset more than a month ago.
> 
> Thought I'd ask again, the 6 patches were acked by Alan, and tested by
> me. Is there any chance they could be considered for merging, or
> reviewed?

Ugh, sorry, these fell through the cracks.  They are still in my
"to-review" queue, I'll try to get to them by the end of the week.

thanks,

greg k-h

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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-01-07  9:35     ` Greg Kroah-Hartman
@ 2020-01-07  9:48       ` Bastien Nocera
  2020-02-11  0:21       ` Bastien Nocera
  1 sibling, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2020-01-07  9:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Benjamin Tissoires, Alan Stern

On Tue, 2020-01-07 at 10:35 +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 07, 2020 at 09:46:50AM +0100, Bastien Nocera wrote:
> > Hey,
> > 
> > On Thu, 2019-11-21 at 16:20 +0100, Bastien Nocera wrote:
> > > Hey,
> > > 
> > > Any updates on getting this into the USB tree?
> > > 
> > > Alan acked the patchset more than a month ago.
> > 
> > Thought I'd ask again, the 6 patches were acked by Alan, and tested
> > by
> > me. Is there any chance they could be considered for merging, or
> > reviewed?
> 
> Ugh, sorry, these fell through the cracks.  They are still in my
> "to-review" queue, I'll try to get to them by the end of the week.

No worries, looking forward to the review.


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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-01-07  9:35     ` Greg Kroah-Hartman
  2020-01-07  9:48       ` Bastien Nocera
@ 2020-02-11  0:21       ` Bastien Nocera
  2020-02-12 17:52         ` Greg Kroah-Hartman
  1 sibling, 1 reply; 17+ messages in thread
From: Bastien Nocera @ 2020-02-11  0:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Benjamin Tissoires, Alan Stern

On Tue, 2020-01-07 at 10:35 +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 07, 2020 at 09:46:50AM +0100, Bastien Nocera wrote:
> > Hey,
> > 
> > On Thu, 2019-11-21 at 16:20 +0100, Bastien Nocera wrote:
> > > Hey,
> > > 
> > > Any updates on getting this into the USB tree?
> > > 
> > > Alan acked the patchset more than a month ago.
> > 
> > Thought I'd ask again, the 6 patches were acked by Alan, and tested
> > by
> > me. Is there any chance they could be considered for merging, or
> > reviewed?
> 
> Ugh, sorry, these fell through the cracks.  They are still in my
> "to-review" queue, I'll try to get to them by the end of the week.

Hey,

It's been a month, and it missed the last merge window. Is there
anything else I should be doing?

Cheers


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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-02-11  0:21       ` Bastien Nocera
@ 2020-02-12 17:52         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2020-02-12 17:52 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-usb, Benjamin Tissoires, Alan Stern

On Tue, Feb 11, 2020 at 01:21:15AM +0100, Bastien Nocera wrote:
> On Tue, 2020-01-07 at 10:35 +0100, Greg Kroah-Hartman wrote:
> > On Tue, Jan 07, 2020 at 09:46:50AM +0100, Bastien Nocera wrote:
> > > Hey,
> > > 
> > > On Thu, 2019-11-21 at 16:20 +0100, Bastien Nocera wrote:
> > > > Hey,
> > > > 
> > > > Any updates on getting this into the USB tree?
> > > > 
> > > > Alan acked the patchset more than a month ago.
> > > 
> > > Thought I'd ask again, the 6 patches were acked by Alan, and tested
> > > by
> > > me. Is there any chance they could be considered for merging, or
> > > reviewed?
> > 
> > Ugh, sorry, these fell through the cracks.  They are still in my
> > "to-review" queue, I'll try to get to them by the end of the week.
> 
> Hey,
> 
> It's been a month, and it missed the last merge window. Is there
> anything else I should be doing?

{sigh} my fault, will look at this today, sorry...

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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
                   ` (6 preceding siblings ...)
  2019-11-21 15:20 ` [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
@ 2020-02-12 19:06 ` Greg Kroah-Hartman
  2020-02-12 23:05   ` Bastien Nocera
  7 siblings, 1 reply; 17+ messages in thread
From: Greg Kroah-Hartman @ 2020-02-12 19:06 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-usb, Benjamin Tissoires

On Wed, Oct 16, 2019 at 11:39:27AM +0200, Bastien Nocera wrote:
> This is version 3 of the patch set.
> 
> Changes in v3:
> - Add Alan's ack
> - don't export usb_device_match_id()
> 
> Changes in v2:
> - checkpatch.pl is now quiet
> - fallback to the generic driver when driver ->probe() fails

Sorry for the long response to this, my fault.

At first, I really don't like the idea of using the usb device driver
interface, but I don't think there's a better way.  And, you did the
work to make it so that it works cleanly, which is always appreciated.

So all now queued up, let's see what breaks in linux-next with it! :)

One note, your patches had to be applied with "-p0" to git, normally we
do it with "-p1", I don't know how you generated your patches at 0
depth.

thanks,

greg k-h

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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-02-12 19:06 ` Greg Kroah-Hartman
@ 2020-02-12 23:05   ` Bastien Nocera
  2020-02-12 23:17     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 17+ messages in thread
From: Bastien Nocera @ 2020-02-12 23:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Benjamin Tissoires

On Wed, 2020-02-12 at 11:06 -0800, Greg Kroah-Hartman wrote:
> On Wed, Oct 16, 2019 at 11:39:27AM +0200, Bastien Nocera wrote:
> > This is version 3 of the patch set.
> > 
> > Changes in v3:
> > - Add Alan's ack
> > - don't export usb_device_match_id()
> > 
> > Changes in v2:
> > - checkpatch.pl is now quiet
> > - fallback to the generic driver when driver ->probe() fails
> 
> Sorry for the long response to this, my fault.
> 
> At first, I really don't like the idea of using the usb device driver
> interface, but I don't think there's a better way.  And, you did the
> work to make it so that it works cleanly, which is always
> appreciated.

I'm hoping that a few user-space drivers end up upstream in the kernel
for hardware that needs it.

> So all now queued up, let's see what breaks in linux-next with it! :)

And I sure hope I won't be break anything!

> One note, your patches had to be applied with "-p0" to git, normally
> we
> do it with "-p1", I don't know how you generated your patches at 0
> depth.

My fault. I tried to use the "noprefix" git diff option to make it
easier to visualise changes, but that leaked into generated patches as
well. I've disabled it since.

I plan on making some more changes to the USB subsystem in the (near)
future, so it's to get my feet wet with this.

Cheers


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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-02-12 23:05   ` Bastien Nocera
@ 2020-02-12 23:17     ` Greg Kroah-Hartman
  2020-02-12 23:24       ` Bastien Nocera
  0 siblings, 1 reply; 17+ messages in thread
From: Greg Kroah-Hartman @ 2020-02-12 23:17 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-usb, Benjamin Tissoires

On Thu, Feb 13, 2020 at 12:05:13AM +0100, Bastien Nocera wrote:
> On Wed, 2020-02-12 at 11:06 -0800, Greg Kroah-Hartman wrote:
> > On Wed, Oct 16, 2019 at 11:39:27AM +0200, Bastien Nocera wrote:
> > > This is version 3 of the patch set.
> > > 
> > > Changes in v3:
> > > - Add Alan's ack
> > > - don't export usb_device_match_id()
> > > 
> > > Changes in v2:
> > > - checkpatch.pl is now quiet
> > > - fallback to the generic driver when driver ->probe() fails
> > 
> > Sorry for the long response to this, my fault.
> > 
> > At first, I really don't like the idea of using the usb device driver
> > interface, but I don't think there's a better way.  And, you did the
> > work to make it so that it works cleanly, which is always
> > appreciated.
> 
> I'm hoping that a few user-space drivers end up upstream in the kernel
> for hardware that needs it.

And here I am wanting to move more USB drivers to userspace :)

What ones do you see that are currently in userspace that should be in
the kernel?  The power control one here makes sense, are there others
like this?

> I plan on making some more changes to the USB subsystem in the (near)
> future, so it's to get my feet wet with this.

That was a serious modification to "start" with, nice work.

greg k-h

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

* Re: [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver
  2020-02-12 23:17     ` Greg Kroah-Hartman
@ 2020-02-12 23:24       ` Bastien Nocera
  0 siblings, 0 replies; 17+ messages in thread
From: Bastien Nocera @ 2020-02-12 23:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Benjamin Tissoires

On Wed, 2020-02-12 at 15:17 -0800, Greg Kroah-Hartman wrote:
> On Thu, Feb 13, 2020 at 12:05:13AM +0100, Bastien Nocera wrote:
> > On Wed, 2020-02-12 at 11:06 -0800, Greg Kroah-Hartman wrote:
> > > On Wed, Oct 16, 2019 at 11:39:27AM +0200, Bastien Nocera wrote:
> > > > This is version 3 of the patch set.
> > > > 
> > > > Changes in v3:
> > > > - Add Alan's ack
> > > > - don't export usb_device_match_id()
> > > > 
> > > > Changes in v2:
> > > > - checkpatch.pl is now quiet
> > > > - fallback to the generic driver when driver ->probe() fails
> > > 
> > > Sorry for the long response to this, my fault.
> > > 
> > > At first, I really don't like the idea of using the usb device
> > > driver
> > > interface, but I don't think there's a better way.  And, you did
> > > the
> > > work to make it so that it works cleanly, which is always
> > > appreciated.
> > 
> > I'm hoping that a few user-space drivers end up upstream in the
> > kernel
> > for hardware that needs it.
> 
> And here I am wanting to move more USB drivers to userspace :)
> 
> What ones do you see that are currently in userspace that should be
> in
> the kernel?  The power control one here makes sense, are there others
> like this?

Well, I don't know yet. I would expect them to be of similar ilk, and
fit in with the type of devices the kernel already handles but would
use interfaces for on other devices.

As I mentioned at the beginning of the discussion, I'm not trying to
bring in user-space drivers that don't fit in an existing subsystem,
but rather those that are badly designed ;)

> > I plan on making some more changes to the USB subsystem in the
> > (near)
> > future, so it's to get my feet wet with this.
> 
> That was a serious modification to "start" with, nice work.

I think what I want to work on, revoke support for USB devices, might
be more complicated/racy/full of security problems.


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

end of thread, back to index

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16  9:39 [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 1/6] USB: Export generic USB device driver functions Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 2/6] USB: Make it possible to "subclass" usb_device_driver Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 3/6] USB: Implement usb_device_match_id() Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 4/6] USB: Select better matching USB drivers when available Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 5/6] USB: Fallback to generic driver when specific driver fails Bastien Nocera
2019-10-16  9:39 ` [PATCH v3 6/6] USB: Add driver to control USB fast charge for iOS devices Bastien Nocera
2019-11-21 15:20 ` [PATCH v3 0/6] Add Apple MFi fastcharge USB device driver Bastien Nocera
2020-01-07  8:46   ` Bastien Nocera
2020-01-07  9:35     ` Greg Kroah-Hartman
2020-01-07  9:48       ` Bastien Nocera
2020-02-11  0:21       ` Bastien Nocera
2020-02-12 17:52         ` Greg Kroah-Hartman
2020-02-12 19:06 ` Greg Kroah-Hartman
2020-02-12 23:05   ` Bastien Nocera
2020-02-12 23:17     ` Greg Kroah-Hartman
2020-02-12 23:24       ` Bastien Nocera

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git