usb: use single ohci_start()
This patch adds adds an ohci_start() function that easily can be shared
between many ohci drivers. This patch only changes drivers to ohci_start()
when the driver specific implementation exactly match ohci_start(). It also
seems popular to sometimes do ohci_init() in .reset instead of .start, and if
those drivers can be rewritten then it may be possible to use ohci_start()
in even more drivers.
Signed-off-by: Magnus Damm <***@igel.co.jp>
---
drivers/usb/host/ohci-au1xxx.c | 24 +-----------------------
drivers/usb/host/ohci-ep93xx.c | 19 +------------------
drivers/usb/host/ohci-hcd.c | 18 ++++++++++++++++++
drivers/usb/host/ohci-lh7a404.c | 22 +---------------------
drivers/usb/host/ohci-pnx4008.c | 18 +-----------------
drivers/usb/host/ohci-pnx8550.c | 24 +-----------------------
drivers/usb/host/ohci-ppc-of.c | 21 +--------------------
drivers/usb/host/ohci-ppc-soc.c | 20 +-------------------
drivers/usb/host/ohci-s3c2410.c | 21 +--------------------
drivers/usb/host/ohci-sa1111.c | 21 +--------------------
drivers/usb/host/ohci-sm501.c | 19 +------------------
11 files changed, 28 insertions(+), 199 deletions(-)
--- 0001/drivers/usb/host/ohci-au1xxx.c
+++ work/drivers/usb/host/ohci-au1xxx.c 2008-01-13 19:41:47.000000000 +0900
@@ -231,28 +231,6 @@ static void usb_ohci_au1xxx_remove(struc
/*-------------------------------------------------------------------------*/
-static int __devinit
-ohci_au1xxx_start (struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- ohci_dbg (ohci, "ohci_au1xxx_start, ohci:%p", ohci);
-
- if ((ret = ohci_init (ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 0) {
- err ("can't start %s", hcd->self.bus_name);
- ohci_stop (hcd);
- return ret;
- }
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
static const struct hc_driver ohci_au1xxx_hc_driver = {
.description = hcd_name,
.product_desc = "Au1xxx OHCI",
@@ -267,7 +245,7 @@ static const struct hc_driver ohci_au1xx
/*
* basic lifecycle operations
*/
- .start = ohci_au1xxx_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-ep93xx.c
+++ work/drivers/usb/host/ohci-ep93xx.c 2008-01-13 19:41:22.000000000 +0900
@@ -103,30 +103,13 @@ static void usb_hcd_ep93xx_remove(struct
usb_put_hcd(hcd);
}
-static int __devinit ohci_ep93xx_start(struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci(hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run(ohci)) < 0) {
- err("can't start %s", hcd->self.bus_name);
- ohci_stop(hcd);
- return ret;
- }
-
- return 0;
-}
-
static struct hc_driver ohci_ep93xx_hc_driver = {
.description = hcd_name,
.product_desc = "EP93xx OHCI",
.hcd_priv_size = sizeof(struct ohci_hcd),
.irq = ohci_irq,
.flags = HCD_USB11 | HCD_MEMORY,
- .start = ohci_ep93xx_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
.urb_enqueue = ohci_urb_enqueue,
--- 0011/drivers/usb/host/ohci-hcd.c
+++ work/drivers/usb/host/ohci-hcd.c 2008-01-13 19:31:56.000000000 +0900
@@ -79,6 +79,7 @@ static const char hcd_name [] = "ohci_hc
static void ohci_dump (struct ohci_hcd *ohci, int verbose);
static int ohci_init (struct ohci_hcd *ohci);
+static int ohci_start (struct usb_hcd *hcd);
static void ohci_stop (struct usb_hcd *hcd);
#if defined(CONFIG_PM) || defined(CONFIG_PCI)
@@ -870,6 +871,23 @@ static irqreturn_t ohci_irq (struct usb_
/*-------------------------------------------------------------------------*/
+static int ohci_start (struct usb_hcd *hcd)
+{
+ struct device *dev = hcd->self.controller;
+ struct ohci_hcd *ohci = hcd_to_ohci (hcd);
+ int ret;
+
+ if ((ret = ohci_init(ohci)) < 0)
+ return ret;
+
+ if ((ret = ohci_run (ohci)) < 0) {
+ dev_err (dev, "can't start %s", hcd->self.bus_name);
+ ohci_stop (hcd);
+ return ret;
+ }
+ return 0;
+}
+
static void ohci_stop (struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
--- 0001/drivers/usb/host/ohci-lh7a404.c
+++ work/drivers/usb/host/ohci-lh7a404.c 2008-01-13 19:40:59.000000000 +0900
@@ -138,26 +138,6 @@ void usb_hcd_lh7a404_remove (struct usb_
/*-------------------------------------------------------------------------*/
-static int __devinit
-ohci_lh7a404_start (struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- ohci_dbg (ohci, "ohci_lh7a404_start, ohci:%p", ohci);
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 0) {
- err ("can't start %s", hcd->self.bus_name);
- ohci_stop (hcd);
- return ret;
- }
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
static const struct hc_driver ohci_lh7a404_hc_driver = {
.description = hcd_name,
.product_desc = "LH7A404 OHCI",
@@ -172,7 +152,7 @@ static const struct hc_driver ohci_lh7a4
/*
* basic lifecycle operations
*/
- .start = ohci_lh7a404_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-pnx4008.c
+++ work/drivers/usb/host/ohci-pnx4008.c 2008-01-13 19:40:25.000000000 +0900
@@ -230,22 +230,6 @@ static void pnx4008_stop_hc(void)
__raw_writel(tmp, USB_OTG_STAT_CONTROL);
}
-static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci(hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run(ohci)) < 0) {
- dev_err(hcd->self.controller, "can't start\n");
- ohci_stop(hcd);
- return ret;
- }
- return 0;
-}
-
static const struct hc_driver ohci_pnx4008_hc_driver = {
.description = hcd_name,
.product_desc = "pnx4008 OHCI",
@@ -260,7 +244,7 @@ static const struct hc_driver ohci_pnx40
/*
* basic lifecycle operations
*/
- .start = ohci_pnx4008_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-pnx8550.c
+++ work/drivers/usb/host/ohci-pnx8550.c 2008-01-13 19:40:03.000000000 +0900
@@ -145,28 +145,6 @@ void usb_hcd_pnx8550_remove (struct usb_
/*-------------------------------------------------------------------------*/
-static int __devinit
-ohci_pnx8550_start (struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- ohci_dbg (ohci, "ohci_pnx8550_start, ohci:%p", ohci);
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 0) {
- err ("can't start %s", hcd->self.bus_name);
- ohci_stop (hcd);
- return ret;
- }
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
static const struct hc_driver ohci_pnx8550_hc_driver = {
.description = hcd_name,
.product_desc = "PNX8550 OHCI",
@@ -181,7 +159,7 @@ static const struct hc_driver ohci_pnx85
/*
* basic lifecycle operations
*/
- .start = ohci_pnx8550_start,
+ .start = ohci_start,
.stop = ohci_stop,
/*
--- 0001/drivers/usb/host/ohci-ppc-of.c
+++ work/drivers/usb/host/ohci-ppc-of.c 2008-01-13 19:39:14.000000000 +0900
@@ -18,25 +18,6 @@
#include <asm/of_platform.h>
#include <asm/prom.h>
-
-static int __devinit
-ohci_ppc_of_start(struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci(hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run(ohci)) < 0) {
- err("can't start %s", ohci_to_hcd(ohci)->self.bus_name);
- ohci_stop(hcd);
- return ret;
- }
-
- return 0;
-}
-
static const struct hc_driver ohci_ppc_of_hc_driver = {
.description = hcd_name,
.product_desc = "OF OHCI",
@@ -51,7 +32,7 @@ static const struct hc_driver ohci_ppc_o
/*
* basic lifecycle operations
*/
- .start = ohci_ppc_of_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-ppc-soc.c
+++ work/drivers/usb/host/ohci-ppc-soc.c 2008-01-13 19:38:53.000000000 +0900
@@ -120,24 +120,6 @@ static void usb_hcd_ppc_soc_remove(struc
usb_put_hcd(hcd);
}
-static int __devinit
-ohci_ppc_soc_start(struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci(hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run(ohci)) < 0) {
- err("can't start %s", ohci_to_hcd(ohci)->self.bus_name);
- ohci_stop(hcd);
- return ret;
- }
-
- return 0;
-}
-
static const struct hc_driver ohci_ppc_soc_hc_driver = {
.description = hcd_name,
.hcd_priv_size = sizeof(struct ohci_hcd),
@@ -151,7 +133,7 @@ static const struct hc_driver ohci_ppc_s
/*
* basic lifecycle operations
*/
- .start = ohci_ppc_soc_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-s3c2410.c
+++ work/drivers/usb/host/ohci-s3c2410.c 2008-01-13 19:37:52.000000000 +0900
@@ -412,25 +412,6 @@ static int usb_hcd_s3c2410_probe (const
/*-------------------------------------------------------------------------*/
-static int
-ohci_s3c2410_start (struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 0) {
- err ("can't start %s", hcd->self.bus_name);
- ohci_stop (hcd);
- return ret;
- }
-
- return 0;
-}
-
-
static const struct hc_driver ohci_s3c2410_hc_driver = {
.description = hcd_name,
.product_desc = "S3C24XX OHCI",
@@ -445,7 +426,7 @@ static const struct hc_driver ohci_s3c24
/*
* basic lifecycle operations
*/
- .start = ohci_s3c2410_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
--- 0001/drivers/usb/host/ohci-sa1111.c
+++ work/drivers/usb/host/ohci-sa1111.c 2008-01-13 19:37:24.000000000 +0900
@@ -178,25 +178,6 @@ void usb_hcd_sa1111_remove (struct usb_h
/*-------------------------------------------------------------------------*/
-static int __devinit
-ohci_sa1111_start (struct usb_hcd *hcd)
-{
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 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",
@@ -211,7 +192,7 @@ static const struct hc_driver ohci_sa111
/*
* basic lifecycle operations
*/
- .start = ohci_sa1111_start,
+ .start = ohci_start,
.stop = ohci_stop,
/*
--- 0011/drivers/usb/host/ohci-sm501.c
+++ work/drivers/usb/host/ohci-sm501.c 2008-01-13 19:32:03.000000000 +0900
@@ -21,23 +21,6 @@
#include <linux/sm501.h>
#include <linux/sm501-regs.h>
-static int ohci_sm501_start (struct usb_hcd *hcd)
-{
- struct device *dev = hcd->self.controller;
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
- int ret;
-
- if ((ret = ohci_init(ohci)) < 0)
- return ret;
-
- if ((ret = ohci_run (ohci)) < 0) {
- dev_err (dev, "can't start %s", hcd->self.bus_name);
- ohci_stop (hcd);
- return ret;
- }
- return 0;
-}
-
static int usb_hcd_sm501_probe (const struct hc_driver *driver,
struct platform_device *pdev)
{
@@ -180,7 +163,7 @@ static const struct hc_driver ohci_sm501
/*
* basic lifecycle operations
*/
- .start = ohci_sm501_start,
+ .start = ohci_start,
.stop = ohci_stop,
.shutdown = ohci_shutdown,
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel