SA1111 USB cleanups
Subsystems (2)
cover SA1111 USB cleanups
This is the final set for this evening; this is a smaller set of cleanups and updates for the SA1111 OHCI driver. This series depends on the SA1111 patch series.
One of the things it completes is the work in 64a21d025d3 (USB: Properly unregister reboot notifier in case of failure in ehci hcd) by adding the shutdown methods. (That commit notes that it omitted SA1111 due to no shutdown callback. And there is now.)
drivers/usb/host/ohci-sa1111.c | 244 ++++++++++++++++++---------------------- 1 files changed, 108 insertions(+), 136 deletions(-)
PATCH 1/5 USB: sa1111: sparse and checkpatch cleanups
Clean up the ohci-sa1111 driver formatting to be more compliant with current standards, and add 'static' to various function definitions to avoid sparse complaints about undeclared functions. Remove the unnecessary local declaration of 'usb_disabled', which can be found instead in linux/usb.h.
--- drivers/usb/host/ohci-sa1111.c | 33 +++++++++++++++++---------------- 1 files changed, 17 insertions(+), 16 deletions(-)
drivers/usb/host/ohci-sa1111.c +17 -16
@@ -41,8 +41,6 @@#define USB_STATUS_NHCIMFCLR (1 << 10)#define USB_STATUS_USBPWRSENSE (1 << 11) -extern int usb_disabled (void ); -/*-------------------------------------------------------------------------*/ static int sa1111_start_hc (struct sa1111_dev *dev)
@@ -82,6 +80,7 @@ static int sa1111_start_hc(struct sa1111_dev *dev)static void sa1111_stop_hc (struct sa1111_dev *dev) {unsigned int usb_rst; +printk (KERN_DEBUG "%s: stopping SA-1111 OHCI USB Controller\n" , __FILE__);
@@ -106,7 +105,7 @@ static void dump_hci_status(struct usb_hcd *hcd, const char *label) {unsigned long status =sa1111_readl (hcd->regs +USB_STATUS ); - dbg ("%s USB_STATUS = { %s%s%s%s%s}", label, + dbg("%s USB_STATUS = { %s%s%s%s%s}", label, ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""), ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""), ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
@@ -131,15 +130,16 @@ static void dump_hci_status(struct usb_hcd *hcd, const char *label)* * Store this function in the HCD's struct pci_driver as probe(). */ -int usb_hcd_sa1111_probe (const struct hc_driver *driver, -struct sa1111_dev *dev) +static int usb_hcd_sa1111_probe (const struct hc_driver *driver, +struct sa1111_dev *dev) {struct usb_hcd *hcd;int retval; - hcd =usb_create_hcd (driver, &dev->dev,"sa1111" ); + hcd =usb_create_hcd (driver, &dev->dev,"sa1111" );if (!hcd)return -ENOMEM ; + hcd->rsrc_start = dev->res.start; hcd->rsrc_len =resource_size (&dev->res);
@@ -148,6 +148,7 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, retval = -EBUSY ; goto err1; } + hcd->regs = dev->mapbase; ret =sa1111_start_hc (dev);
@@ -180,9 +181,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver,* Reverses the effect of usb_hcd_sa1111_probe(), first invoking * the HCD's stop() method. It is always called from a thread * context, normally "rmmod", "apmd", or something similar. -* */ -void usb_hcd_sa1111_remove (struct usb_hcd *hcd,struct sa1111_dev *dev) +static void usb_hcd_sa1111_remove (struct usb_hcd *hcd,struct sa1111_dev *dev) {usb_remove_hcd (hcd);sa1111_stop_hc (dev);
@@ -192,18 +192,19 @@ void usb_hcd_sa1111_remove (struct usb_hcd *hcd, struct sa1111_dev *dev)/*-------------------------------------------------------------------------*/ -static int __devinit -ohci_sa1111_start (struct usb_hcd *hcd) +static int __devinit ohci_sa1111_start (struct usb_hcd *hcd) { -struct ohci_hcd *ohci =hcd_to_ohci (hcd); -int ret; +struct ohci_hcd *ohci =hcd_to_ohci (hcd); +int ret; -if ((ret =ohci_init (ohci)) <0 ) + ret =ohci_init (ohci); +if (ret <0 )return ret; -if ((ret =ohci_run (ohci)) <0 ) { -err ("can't start %s" , hcd->self.bus_name); -ohci_stop (hcd); + ret =ohci_run (ohci); +if (ret <0 ) { +err ("can't start %s" , hcd->self.bus_name); +ohci_stop (hcd);return ret; }return 0 ;
Signature · 1 line
1.7.4.4
Greg KH
maintainerPATCH 1/5 USB: sa1111: sparse and checkpatch cleanups
Quoted 7 lines · Russell King - ARM Linux
Clean up the ohci-sa1111 driver formatting to be more compliant with current standards, and add 'static' to various function definitions to avoid sparse complaints about undeclared functions. Remove the unnecessary local declaration of '
usb_disabled', which can be found instead inlinux/usb.h.Signed-off-by Russell King <[email protected]>
Do you want me to take these 5 patches through the USB tree? Or are you going to take them through an ARM tree?
Either is fine with me, if ARM, feel free to add:
to them.
greg k-h
PATCH 1/5 USB: sa1111: sparse and checkpatch cleanups
Quoted 11 lines · Greg KH
Quoted 7 lines · Russell King - ARM Linux
Clean up the ohci-sa1111 driver formatting to be more compliant with current standards, and add 'static' to various function definitions to avoid sparse complaints about undeclared functions. Remove the unnecessary local declaration of '
usb_disabled', which can be found instead inlinux/usb.h.Signed-off-by Russell King <[email protected]>Do you want me to take these 5 patches through the USB tree? Or are you going to take them through an ARM tree?
I forgot to send the introduction to linux-usb, so you've probably missed the comment that they depend on some previous patches.
Quoted 4 lines
Either is fine with me, if ARM, feel free to add:
to them.
There was one question mark I had over a patch - that was the addition of the .reset method in the hc_driver for sa1111 stuff. This seems to only get called once during initial driver bring-up. Comments I found in the code suggest that it was used more often in the past. Is that something that's going away?
Greg KH
maintainerPATCH 1/5 USB: sa1111: sparse and checkpatch cleanups
Quoted 8 lines · Russell King - ARM Linux
Quoted 7 lines · Greg KH
Quoted 6 lines · Russell King - ARM Linux
Clean up the ohci-sa1111 driver formatting to be more compliant with current standards, and add 'static' to various function definitions to avoid sparse complaints about undeclared functions. Remove the unnecessary local declaration of '
usb_disabled', which can be found instead inlinux/usb.h.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Russell King <[email protected]>Do you want me to take these 5 patches through the USB tree? Or are you going to take them through an ARM tree?
I forgot to send the introduction to linux-usb, so you've probably missed the comment that they depend on some previous patches.
Yeah, I missed that :)
If these depend on other patches, feel free to take them in your tree then.
Quoted 10 lines
Quoted 4 lines
Either is fine with me, if ARM, feel free to add:
to them.
There was one question mark I had over a patch - that was the addition of the .reset method in the
hc_driverfor sa1111 stuff. This seems to only get called once during initial driver bring-up. Comments I found in the code suggest that it was used more often in the past. Is that something that's going away?
I don't think so, but Alan (on linux-usb@) would be the best to answer that one.
thanks,
greg k-h
Alan Stern
maintainerPATCH 1/5 USB: sa1111: sparse and checkpatch cleanups
Quoted 8 lines · Greg KH
Quoted 5 lines
There was one question mark I had over a patch - that was the addition of the .reset method in the
hc_driverfor sa1111 stuff. This seems to only get called once during initial driver bring-up. Comments I found in the code suggest that it was used more often in the past. Is that something that's going away?I don't think so, but Alan (on linux-usb@) would be the best to answer that one.
The "reset" method is not named very well; it really should be called "initialize". At any rate, you're right -- it gets called exactly once during the lifetime of the HC, and no, that's not going to change.
Alan Stern
PATCH 2/5 USB: sa1111: get rid of nasty printk(KERN_DEBUG "%s: ...", __FILE__)
In reply to Russell King - ARM LinuxUse dev_dbg() instead, it's more friendly.
--- drivers/usb/host/ohci-sa1111.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/usb/host/ohci-sa1111.c +2 -4
@@ -48,8 +48,7 @@ static int sa1111_start_hc(struct sa1111_dev *dev)unsigned int usb_rst =0 ;int ret; -printk (KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n" , - __FILE__); +dev_dbg (&dev->dev,"starting SA-1111 OHCI USB Controller\n" ); if (machine_is_xp860() || machine_has_neponset() ||
@@ -81,8 +80,7 @@ static void sa1111_stop_hc(struct sa1111_dev *dev) {unsigned int usb_rst; -printk (KERN_DEBUG "%s: stopping SA-1111 OHCI USB Controller\n" , - __FILE__); +dev_dbg (&dev->dev,"stopping SA-1111 OHCI USB Controller\n" );/* * Put the USB host controller into reset.
Signature · 1 line
1.7.4.4
PATCH 3/5 USB: sa1111: reorganize ohci-sa1111.c
In reply to Russell King - ARM LinuxCombine usb_hcd_sa1111_probe() and ohci_hcd_sa1111_drv_probe(), doing the same for the remove methods.
Move sa1111_start_hc and sa1111_stop_hc to be located next to these the probe/release functions, as they're only called from them.
Get rid of the /*----*/ breaker lines.
--- drivers/usb/host/ohci-sa1111.c | 227 ++++++++++++++++----------------------- 1 files changed, 93 insertions(+), 134 deletions(-)
drivers/usb/host/ohci-sa1111.c +93 -134
@@ -41,7 +41,78 @@#define USB_STATUS_NHCIMFCLR (1 << 10)#define USB_STATUS_USBPWRSENSE (1 << 11) -/*-------------------------------------------------------------------------*/ +#if 0 +static void dump_hci_status (struct usb_hcd *hcd,const char *label) +{ +unsigned long status =sa1111_readl (hcd->regs +USB_STATUS ); + +dbg ("%s USB_STATUS = { %s%s%s%s%s}" , label, + ((status &USB_STATUS_IRQHCIRMTWKUP ) ?"IRQHCIRMTWKUP " :"" ), + ((status &USB_STATUS_IRQHCIBUFFACC ) ?"IRQHCIBUFFACC " :"" ), + ((status &USB_STATUS_NIRQHCIM ) ?"" :"IRQHCIM " ), + ((status &USB_STATUS_NHCIMFCLR ) ?"" :"HCIMFCLR " ), + ((status &USB_STATUS_USBPWRSENSE ) ?"USBPWRSENSE " :"" )); +} +#endif + +static int __devinit ohci_sa1111_start (struct usb_hcd *hcd) +{ +struct ohci_hcd *ohci =hcd_to_ohci (hcd); +int ret; + + ret =ohci_init (ohci); +if (ret <0 ) +return ret; + + ret =ohci_run (ohci); +if (ret <0 ) { +err ("can't start %s" , hcd->self.bus_name); +ohci_stop (hcd); +return ret; + } +return 0 ; +} + +static const struct hc_driver ohci_sa1111_hc_driver = { + .description = hcd_name, + .product_desc ="SA-1111 OHCI" , + .hcd_priv_size =sizeof (struct ohci_hcd ), + +/* +* generic hardware linkage +*/ + .irq = ohci_irq, + .flags =HCD_USB11 |HCD_MEMORY , + +/* +* basic lifecycle operations +*/ + .start = ohci_sa1111_start, + .stop = ohci_stop, + +/* +* managing i/o requests and associated device resources +*/ + .urb_enqueue = ohci_urb_enqueue, + .urb_dequeue = ohci_urb_dequeue, + .endpoint_disable = ohci_endpoint_disable, + +/* +* scheduling support +*/ + .get_frame_number = ohci_get_frame, + +/* +* root hub support +*/ + .hub_status_data = ohci_hub_status_data, + .hub_control = ohci_hub_control, +#ifdef CONFIG_PM + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, +#endif + .start_port_reset = ohci_start_port_reset, +};static int sa1111_start_hc (struct sa1111_dev *dev) {
@@ -95,46 +166,21 @@ static void sa1111_stop_hc(struct sa1111_dev *dev)sa1111_disable_device (dev); } - -/*-------------------------------------------------------------------------*/ - -#if 0 -static void dump_hci_status (struct usb_hcd *hcd,const char *label) -{ -unsigned long status =sa1111_readl (hcd->regs +USB_STATUS ); - -dbg ("%s USB_STATUS = { %s%s%s%s%s}" , label, - ((status &USB_STATUS_IRQHCIRMTWKUP ) ?"IRQHCIRMTWKUP " :"" ), - ((status &USB_STATUS_IRQHCIBUFFACC ) ?"IRQHCIBUFFACC " :"" ), - ((status &USB_STATUS_NIRQHCIM ) ?"" :"IRQHCIM " ), - ((status &USB_STATUS_NHCIMFCLR ) ?"" :"HCIMFCLR " ), - ((status &USB_STATUS_USBPWRSENSE ) ?"USBPWRSENSE " :"" )); -} -#endif - -/*-------------------------------------------------------------------------*/ - -/* configure so an HC device and id are always provided */ -/* always called with process context; sleeping is OK */ - -/** -* usb_hcd_sa1111_probe - initialize SA-1111-based HCDs -* Context: !in_interrupt() +* ohci_hcd_sa1111_probe - initialize SA-1111-based HCDs * * Allocates basic resources for this USB host controller, and -* then invokes the start() method for the HCD associated with it -* through the hotplug entry's driver_data. -* -* Store this function in the HCD's struct pci_driver as probe(). +* then invokes the start() method for the HCD associated with it. */ -static int usb_hcd_sa1111_probe (const struct hc_driver *driver, -struct sa1111_dev *dev) +static int ohci_hcd_sa1111_probe (struct sa1111_dev *dev) {struct usb_hcd *hcd; -int retval; +int ret; + +if (usb_disabled ()) +return -ENODEV ; - hcd =usb_create_hcd (driver, &dev->dev,"sa1111" ); + hcd =usb_create_hcd (&ohci_sa1111_hc_driver, &dev->dev,"sa1111" );if (!hcd)return -ENOMEM ;
@@ -143,7 +189,7 @@ static int usb_hcd_sa1111_probe(const struct hc_driver *driver,if (!request_mem_region (hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {dbg ("request_mem_region failed" ); - retval = -EBUSY ; + ret = -EBUSY ; goto err1; }
@@ -155,120 +201,34 @@ static int usb_hcd_sa1111_probe(const struct hc_driver *driver,ohci_hcd_init (hcd_to_ohci (hcd)); - retval =usb_add_hcd (hcd, dev->irq[1 ],0 ); -if (retval ==0 ) -return retval; + ret =usb_add_hcd (hcd, dev->irq[1 ],0 ); +if (ret ==0 ) +return ret;sa1111_stop_hc (dev); err2:release_mem_region (hcd->rsrc_start, hcd->rsrc_len); err1:usb_put_hcd (hcd); -return retval; +return ret; } - -/* may be called without controller electrically present */ -/* may be called with controller, bus, and devices active */ -/** -* usb_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs +* ohci_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs * @dev: USB Host Controller being removed -* Context: !in_interrupt() * -* Reverses the effect of usb_hcd_sa1111_probe(), first invoking -* the HCD's stop() method. It is always called from a thread -* context, normally "rmmod", "apmd", or something similar. +* Reverses the effect of ohci_hcd_sa1111_probe(), first invoking +* the HCD's stop() method. */ -static void usb_hcd_sa1111_remove (struct usb_hcd *hcd,struct sa1111_dev *dev) +static int ohci_hcd_sa1111_remove (struct sa1111_dev *dev) { +struct usb_hcd *hcd =sa1111_get_drvdata (dev); +usb_remove_hcd (hcd);sa1111_stop_hc (dev);release_mem_region (hcd->rsrc_start, hcd->rsrc_len);usb_put_hcd (hcd); -} - -/*-------------------------------------------------------------------------*/ -static int __devinit ohci_sa1111_start (struct usb_hcd *hcd) -{ -struct ohci_hcd *ohci =hcd_to_ohci (hcd); -int ret; - - ret =ohci_init (ohci); -if (ret <0 ) -return ret; - - ret =ohci_run (ohci); -if (ret <0 ) { -err ("can't start %s" , hcd->self.bus_name); -ohci_stop (hcd); -return ret; - } -return 0 ; -} - -/*-------------------------------------------------------------------------*/ - -static const struct hc_driver ohci_sa1111_hc_driver = { - .description = hcd_name, - .product_desc ="SA-1111 OHCI" , - .hcd_priv_size =sizeof (struct ohci_hcd ), - -/* -* generic hardware linkage -*/ - .irq = ohci_irq, - .flags =HCD_USB11 |HCD_MEMORY , - -/* -* basic lifecycle operations -*/ - .start = ohci_sa1111_start, - .stop = ohci_stop, - -/* -* managing i/o requests and associated device resources -*/ - .urb_enqueue = ohci_urb_enqueue, - .urb_dequeue = ohci_urb_dequeue, - .endpoint_disable = ohci_endpoint_disable, - -/* -* scheduling support -*/ - .get_frame_number = ohci_get_frame, - -/* -* root hub support -*/ - .hub_status_data = ohci_hub_status_data, - .hub_control = ohci_hub_control, -#ifdef CONFIG_PM - .bus_suspend = ohci_bus_suspend, - .bus_resume = ohci_bus_resume, -#endif - .start_port_reset = ohci_start_port_reset, -}; - -/*-------------------------------------------------------------------------*/ - -static int ohci_hcd_sa1111_drv_probe (struct sa1111_dev *dev) -{ -int ret; - -if (usb_disabled ()) -return -ENODEV ; - - ret =usb_hcd_sa1111_probe (&ohci_sa1111_hc_driver, dev); -return ret; -} - -static int ohci_hcd_sa1111_drv_remove (struct sa1111_dev *dev) -{ -struct usb_hcd *hcd =sa1111_get_drvdata (dev); - -usb_hcd_sa1111_remove (hcd, dev);return 0 ; }
@@ -278,7 +238,6 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = { .owner = THIS_MODULE, }, .devid = SA1111_DEVID_USB, - .probe = ohci_hcd_sa1111_drv_probe, - .remove = ohci_hcd_sa1111_drv_remove, + .probe = ohci_hcd_sa1111_probe, + .remove = ohci_hcd_sa1111_remove, }; -
Signature · 1 line
1.7.4.4
PATCH 4/5 USB: sa1111: add OHCI shutdown methods
In reply to Russell King - ARM LinuxAdd OHCI shutdown methods to cleanly shutdown the OHCI controller on system shutdowns and reboots. This avoids the controller continuing to run should be soft-reboot the platform, potentially scribbling over system memory.
--- drivers/usb/host/ohci-sa1111.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/usb/host/ohci-sa1111.c +12 -0
@@ -89,6 +89,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = {*/ .start = ohci_sa1111_start, .stop = ohci_stop, + .shutdown = ohci_shutdown,/* * managing i/o requests and associated device resources
@@ -232,6 +233,16 @@ static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev)return 0 ; } +static void ohci_hcd_sa1111_shutdown (struct sa1111_dev *dev) +{ +struct usb_hcd *hcd =sa1111_get_drvdata (dev); + +if (test_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags)) { + hcd->driver->shutdown (hcd); +sa1111_stop_hc (dev); + } +} +static struct sa1111_driver ohci_hcd_sa1111_driver = { .drv = { .name ="sa1111-ohci" ,
@@ -240,4 +251,5 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = { .devid = SA1111_DEVID_USB, .probe = ohci_hcd_sa1111_probe, .remove = ohci_hcd_sa1111_remove, + .shutdown = ohci_hcd_sa1111_shutdown, };
Signature · 1 line
1.7.4.4
PATCH 5/5 USB: sa1111: add hcd .reset method
In reply to Russell King - ARM LinuxAdd the .reset method to the HCD, and update the .start method accordingly for this change.
--- drivers/usb/host/ohci-sa1111.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
drivers/usb/host/ohci-sa1111.c +11 -9
@@ -55,22 +55,25 @@ static void dump_hci_status(struct usb_hcd *hcd, const char *label) }#endif +static int ohci_sa1111_reset (struct usb_hcd *hcd) +{ +struct ohci_hcd *ohci =hcd_to_ohci (hcd); + +ohci_hcd_init (ohci); +return ohci_init (ohci); +} +static int __devinit ohci_sa1111_start (struct usb_hcd *hcd) {struct ohci_hcd *ohci =hcd_to_ohci (hcd);int ret; - ret =ohci_init (ohci); -if (ret <0 ) -return ret; - ret =ohci_run (ohci);if (ret <0 ) { -err ("can't start %s" , hcd->self.bus_name); +ohci_err (ohci,"can't start\n" );ohci_stop (hcd); -return ret; } -return 0 ; +return ret; }static const struct hc_driver ohci_sa1111_hc_driver = {
@@ -87,6 +90,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = {/* * basic lifecycle operations */ + .reset = ohci_sa1111_reset, .start = ohci_sa1111_start, .stop = ohci_stop, .shutdown = ohci_shutdown,
@@ -200,8 +204,6 @@ static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)if (ret) goto err2; -ohci_hcd_init (hcd_to_ohci (hcd)); - ret =usb_add_hcd (hcd, dev->irq[1 ],0 );if (ret ==0 )return ret;
Signature · 1 line
1.7.4.4