* [PATCH v3 0/2] USB: Simplify running code on shutdown for USB devices @ 2024-07-06 12:02 Aditya Garg 2024-07-06 12:03 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver Aditya Garg 0 siblings, 1 reply; 6+ messages in thread From: Aditya Garg @ 2024-07-06 12:02 UTC (permalink / raw) To: gregkh, oneukum, stern Cc: Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage Currently there is no standardized method for USB drivers to handle shutdown events. The first patch in this series fixes this by simplifying running code on shutdown for USB devices by adding a shutdown callback to usb_driver. The second patch implements this new callback to the UAS driver Kerem Karabay (2): USB: core: add 'shutdown' callback to usb_driver USB: uas: Implement the new shutdown callback drivers/usb/core/driver.c | 14 ++++++++++++++ drivers/usb/storage/uas.c | 5 ++--- include/linux/usb.h | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver 2024-07-06 12:02 [PATCH v3 0/2] USB: Simplify running code on shutdown for USB devices Aditya Garg @ 2024-07-06 12:03 ` Aditya Garg 2024-07-06 12:04 ` [PATCH v3 2/2] USB: uas: Implement the new shutdown callback Aditya Garg 2024-07-06 12:36 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver gregkh 0 siblings, 2 replies; 6+ messages in thread From: Aditya Garg @ 2024-07-06 12:03 UTC (permalink / raw) To: gregkh, oneukum, stern Cc: Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage From: Kerem Karabay <kekrby@gmail.com> Currently there is no standardized method for USB drivers to handle shutdown events. This patch simplifies running code on shutdown for USB devices by adding a shutdown callback to usb_driver. Signed-off-by: Kerem Karabay <kekrby@gmail.com> Signed-off-by: Aditya Garg <gargaditya08@live.com> --- drivers/usb/core/driver.c | 14 ++++++++++++++ include/linux/usb.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index e02ba15f6..b35734d03 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -517,6 +517,19 @@ static int usb_unbind_interface(struct device *dev) return 0; } +static void usb_shutdown_interface(struct device *dev) +{ + struct usb_interface *intf = to_usb_interface(dev); + struct usb_driver *driver; + + if (!dev->driver) + return; + + driver = to_usb_driver(dev->driver); + if (driver->shutdown) + driver->shutdown(intf); +} + /** * usb_driver_claim_interface - bind a driver to an interface * @driver: the driver to be bound @@ -1059,6 +1072,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner, new_driver->driver.bus = &usb_bus_type; new_driver->driver.probe = usb_probe_interface; new_driver->driver.remove = usb_unbind_interface; + new_driver->driver.shutdown = usb_shutdown_interface; new_driver->driver.owner = owner; new_driver->driver.mod_name = mod_name; new_driver->driver.dev_groups = new_driver->dev_groups; diff --git a/include/linux/usb.h b/include/linux/usb.h index 1913a1383..832997a9d 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1171,6 +1171,7 @@ extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf); * post_reset method is called. * @post_reset: Called by usb_reset_device() after the device * has been reset + * @shutdown: Called at shut-down time to quiesce the device. * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. @@ -1222,6 +1223,8 @@ struct usb_driver { int (*pre_reset)(struct usb_interface *intf); int (*post_reset)(struct usb_interface *intf); + void (*shutdown)(struct usb_interface *intf); + const struct usb_device_id *id_table; const struct attribute_group **dev_groups; -- 2.43.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] USB: uas: Implement the new shutdown callback 2024-07-06 12:03 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver Aditya Garg @ 2024-07-06 12:04 ` Aditya Garg 2024-07-06 12:36 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver gregkh 1 sibling, 0 replies; 6+ messages in thread From: Aditya Garg @ 2024-07-06 12:04 UTC (permalink / raw) To: gregkh, oneukum, stern Cc: Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage From: Kerem Karabay <kekrby@gmail.com> A standard implementation of shutdown callback has been implemented for USB drivers. Since the UAS driver implements a shutdown callback this patch enables it to use the new standard implementation. Signed-off-by: Kerem Karabay <kekrby@gmail.com> Signed-off-by: Aditya Garg <gargaditya08@live.com> --- drivers/usb/storage/uas.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index b610a2de4..0cdbcf825 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1232,9 +1232,8 @@ static void uas_disconnect(struct usb_interface *intf) * hang on reboot when the device is still in uas mode. Note the reset is * necessary as some devices won't revert to usb-storage mode without it. */ -static void uas_shutdown(struct device *dev) +static void uas_shutdown(struct usb_interface *intf) { - struct usb_interface *intf = to_usb_interface(dev); struct usb_device *udev = interface_to_usbdev(intf); struct Scsi_Host *shost = usb_get_intfdata(intf); struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; @@ -1257,7 +1256,7 @@ static struct usb_driver uas_driver = { .suspend = uas_suspend, .resume = uas_resume, .reset_resume = uas_reset_resume, - .driver.shutdown = uas_shutdown, + .shutdown = uas_shutdown, .id_table = uas_usb_ids, }; -- 2.43.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver 2024-07-06 12:03 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver Aditya Garg 2024-07-06 12:04 ` [PATCH v3 2/2] USB: uas: Implement the new shutdown callback Aditya Garg @ 2024-07-06 12:36 ` gregkh 2024-07-06 12:46 ` Aditya Garg 1 sibling, 1 reply; 6+ messages in thread From: gregkh @ 2024-07-06 12:36 UTC (permalink / raw) To: Aditya Garg Cc: oneukum, stern, Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage On Sat, Jul 06, 2024 at 12:03:23PM +0000, Aditya Garg wrote: > From: Kerem Karabay <kekrby@gmail.com> > > Currently there is no standardized method for USB drivers to handle > shutdown events. This patch simplifies running code on shutdown for USB > devices by adding a shutdown callback to usb_driver. > > Signed-off-by: Kerem Karabay <kekrby@gmail.com> Where did Kerem do this work? Any reason why they aren't submitting these themselves? Not that this is a problem, just trying to figure out what went wrong with the development process here. thanks, greg k-h ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver 2024-07-06 12:36 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver gregkh @ 2024-07-06 12:46 ` Aditya Garg 2024-07-06 12:56 ` Aditya Garg 0 siblings, 1 reply; 6+ messages in thread From: Aditya Garg @ 2024-07-06 12:46 UTC (permalink / raw) To: gregkh Cc: oneukum, stern, Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage > On 6 Jul 2024, at 6:06 PM, gregkh@linuxfoundation.org wrote: > > On Sat, Jul 06, 2024 at 12:03:23PM +0000, Aditya Garg wrote: >> From: Kerem Karabay <kekrby@gmail.com> >> >> Currently there is no standardized method for USB drivers to handle >> shutdown events. This patch simplifies running code on shutdown for USB >> devices by adding a shutdown callback to usb_driver. >> >> Signed-off-by: Kerem Karabay <kekrby@gmail.com> > > Where did Kerem do this work? Any reason why they aren't submitting > these themselves? Not that this is a problem, just trying to figure out > what went wrong with the development process here. I work at https://t2linux.org/, a project aimed to bring Linux to T2 Macs. Kerem helped in developing the driver for the Touch Bar on these Macs. During development, he did some improvements to the HID core, USB core and DRM, which are not specific to the Macs, but are used in the driver. As to why he didn't submit himself, unfortunately Kerem seems to have left the project and is not contactable at all. Fortunately, the patches he contributed were signed off by him. Since we have his Signed-off-by and the code is GPL2, IMO, I can legally submit this. Link to our patchset: https://github.com/t2linux/linux-t2-patches > > thanks, > > greg k-h ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver 2024-07-06 12:46 ` Aditya Garg @ 2024-07-06 12:56 ` Aditya Garg 0 siblings, 0 replies; 6+ messages in thread From: Aditya Garg @ 2024-07-06 12:56 UTC (permalink / raw) To: gregkh Cc: oneukum, stern, Kerem Karabay, Orlando Chamberlain, Linux Kernel Mailing List, linux-usb, linux-scsi, usb-storage > On 6 Jul 2024, at 6:15 PM, Aditya Garg <gargaditya08@live.com> wrote: > > > >> On 6 Jul 2024, at 6:06 PM, gregkh@linuxfoundation.org wrote: >> >> On Sat, Jul 06, 2024 at 12:03:23PM +0000, Aditya Garg wrote: >>> From: Kerem Karabay <kekrby@gmail.com> >>> >>> Currently there is no standardized method for USB drivers to handle >>> shutdown events. This patch simplifies running code on shutdown for USB >>> devices by adding a shutdown callback to usb_driver. >>> >>> Signed-off-by: Kerem Karabay <kekrby@gmail.com> >> >> Where did Kerem do this work? Any reason why they aren't submitting >> these themselves? Not that this is a problem, just trying to figure out >> what went wrong with the development process here. > > I work at https://t2linux.org/, a project aimed to bring Linux to T2 Macs. > > Kerem helped in developing the driver for the Touch Bar on these Macs. > During development, he did some improvements to the HID core, USB core > and DRM, which are not specific to the Macs, but are used in the driver. > > As to why he didn't submit himself, unfortunately Kerem seems to have left > the project and is not contactable at all. Fortunately, the patches he contributed > were signed off by him. Since we have his Signed-off-by and the code is GPL2, > IMO, I can legally submit this. > > Link to our patchset: https://github.com/t2linux/linux-t2-patches You can also find his linux tree with the driver over here: https://github.com/kekrby/linux-t2/tree/touchbar >> >> thanks, >> >> greg k-h ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-06 12:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-07-06 12:02 [PATCH v3 0/2] USB: Simplify running code on shutdown for USB devices Aditya Garg 2024-07-06 12:03 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver Aditya Garg 2024-07-06 12:04 ` [PATCH v3 2/2] USB: uas: Implement the new shutdown callback Aditya Garg 2024-07-06 12:36 ` [PATCH v3 1/2] USB: core: add 'shutdown' callback to usb_driver gregkh 2024-07-06 12:46 ` Aditya Garg 2024-07-06 12:56 ` Aditya Garg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®