On Wed, 2020-10-21 at 13:53 +0200, Bastien Nocera wrote: <snip> > I'll prepare a patch that adds a match function. I'll let you (Vefa) > look at which of your patches need backporting though, as I'm really > quite a bit lost in the different patch sets and branches :/ Something like that (untested): diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c index b403094a6b3a..bb89dde018b1 100644 --- a/drivers/usb/misc/apple-mfi-fastcharge.c +++ b/drivers/usb/misc/apple-mfi-fastcharge.c @@ -163,17 +163,26 @@ static const struct power_supply_desc apple_mfi_fc_desc = { .property_is_writeable = apple_mfi_fc_property_is_writeable }; +static bool mfi_fc_match(struct usb_device *udev) +{ + int idProduct, idVendor; + + idVendor = le16_to_cpu(udev->descriptor.idVendor); + idProduct = le16_to_cpu(udev->descriptor.idProduct); + /* See comment above mfi_fc_id_table[] */ + return (idVendor == APPLE_VENDOR_ID && + idProduct >= 0x1200 && + idProduct <= 0x12ff); +} + static int mfi_fc_probe(struct usb_device *udev) { struct power_supply_config battery_cfg = {}; struct mfi_device *mfi = NULL; - int err, idProduct; + int err; - idProduct = le16_to_cpu(udev->descriptor.idProduct); - /* See comment above mfi_fc_id_table[] */ - if (idProduct < 0x1200 || idProduct > 0x12ff) { + if (!mfi_fc_probe(udev)) return -ENODEV; - } mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL); if (!mfi) { @@ -217,6 +226,7 @@ static void mfi_fc_disconnect(struct usb_device *udev) static struct usb_device_driver mfi_fc_driver = { .name = "apple-mfi-fastcharge", + .match = mfi_fc_match, .probe = mfi_fc_probe, .disconnect = mfi_fc_disconnect, .id_table = mfi_fc_id_table,