Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-27 Thread Axel Haslam
On Thu, Oct 27, 2016 at 2:58 AM, David Lechner  wrote:
> On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:
>
>> +module_exit(ohci_da8xx_exit);
>> +MODULE_DESCRIPTION(DRIVER_DESC);
>> +MODULE_LICENSE("GPL");
>>  MODULE_ALIAS("platform:ohci");
>
>
> The "ohci" in MODULE_ALIAS() should also be replaced with hcd_name.

i dont see any other module int the whole kernel that is
using a const char here, ill just change back to #define
the name and use that instead.


>
>


Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-27 Thread Axel Haslam
On Thu, Oct 27, 2016 at 2:58 AM, David Lechner  wrote:
> On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:
>
>> +module_exit(ohci_da8xx_exit);
>> +MODULE_DESCRIPTION(DRIVER_DESC);
>> +MODULE_LICENSE("GPL");
>>  MODULE_ALIAS("platform:ohci");
>
>
> The "ohci" in MODULE_ALIAS() should also be replaced with hcd_name.

i dont see any other module int the whole kernel that is
using a const char here, ill just change back to #define
the name and use that instead.


>
>


Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread David Lechner

On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:

From: Manjunath Goudar 

Separate the Davinci OHCI host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM

Signed-off-by: Manjunath Goudar 
[Axel: adapted and rebased, fixed minor comments]
Signed-off-by: Axel Haslam 
---


This is working for me as a module on LEGO MINDSTORMS EV3.

Tested-By: David Lechner 



Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread David Lechner

On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:

From: Manjunath Goudar 

Separate the Davinci OHCI host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM

Signed-off-by: Manjunath Goudar 
[Axel: adapted and rebased, fixed minor comments]
Signed-off-by: Axel Haslam 
---


This is working for me as a module on LEGO MINDSTORMS EV3.

Tested-By: David Lechner 



Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread David Lechner

On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:


+module_exit(ohci_da8xx_exit);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:ohci");


The "ohci" in MODULE_ALIAS() should also be replaced with hcd_name.




Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread David Lechner

On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:


+module_exit(ohci_da8xx_exit);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:ohci");


The "ohci" in MODULE_ALIAS() should also be replaced with hcd_name.




[PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread ahaslam
From: Manjunath Goudar 

Separate the Davinci OHCI host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM

Signed-off-by: Manjunath Goudar 
[Axel: adapted and rebased, fixed minor comments]
Signed-off-by: Axel Haslam 
---

This was a previews patch submited by Manjunath [1]
that was never taken in because of an undefined symbol
when loading as a module. That symbol is not present anymore
so we can safly build the driver as a module.

I rebased, fixing the minor remaining comments.

Axel.
http://patches.linaro.org/patch/18234/

 drivers/usb/host/Kconfig  |   4 +-
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ohci-da8xx.c | 181 +-
 drivers/usb/host/ohci-hcd.c   |  18 -
 4 files changed, 74 insertions(+), 130 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 83b6cec..6361fc7 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -479,9 +479,9 @@ config USB_OHCI_HCD_OMAP3
  OMAP3 and later chips.
 
 config USB_OHCI_HCD_DAVINCI
-   bool "OHCI support for TI DaVinci DA8xx"
+   tristate "OHCI support for TI DaVinci DA8xx"
depends on ARCH_DAVINCI_DA8XX
-   depends on USB_OHCI_HCD=y
+   depends on USB_OHCI_HCD
select PHY_DA8XX_USB
default y
help
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 6ef785b..2644537 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_USB_OHCI_HCD_AT91)   += ohci-at91.o
 obj-$(CONFIG_USB_OHCI_HCD_S3C2410) += ohci-s3c2410.o
 obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o
 obj-$(CONFIG_USB_OHCI_HCD_PXA27X)  += ohci-pxa27x.o
+obj-$(CONFIG_USB_OHCI_HCD_DAVINCI) += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3656d7c..4e2a61f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -11,16 +11,30 @@
  * kind, whether express or implied.
  */
 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
-#ifndef CONFIG_ARCH_DAVINCI_DA8XX
-#error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
-#endif
+#include "ohci.h"
+
+#define DRIVER_DESC "DA8XX"
+
+static const char hcd_name[] = "ohci";
+
+static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
+
+static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, u16 typeReq,
+   u16 wValue, u16 wIndex, char *buf, u16 wLength);
+static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 static struct clk *usb11_clk;
 static struct phy *usb11_phy;
@@ -74,7 +88,7 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
-static int ohci_da8xx_init(struct usb_hcd *hcd)
+static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
@@ -94,7 +108,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
 */
ohci->num_ports = 1;
 
-   result = ohci_init(ohci);
+   result = ohci_setup(hcd);
if (result < 0) {
ohci_da8xx_disable();
return result;
@@ -122,30 +136,12 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
return result;
 }
 
-static void ohci_da8xx_stop(struct usb_hcd *hcd)
-{
-   ohci_stop(hcd);
-   ohci_da8xx_disable();
-}
-
-static int ohci_da8xx_start(struct usb_hcd *hcd)
-{
-   struct ohci_hcd *ohci   = hcd_to_ohci(hcd);
-   int result;
-
-   result = ohci_run(ohci);
-   if (result < 0)
-   ohci_da8xx_stop(hcd);
-
-   return result;
-}
-
 /*
  * Update the status data from the hub with the over-current indicator change.
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
-   int length  = ohci_hub_status_data(hcd, buf);
+   int length  = orig_ohci_hub_status_data(hcd, buf);
 
/* See if we have OCIC bit set on port 1 */
if (ocic_mask & (1 << 1)) {
@@ -227,66 +223,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
}
}
 
-   return ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
+   return orig_ohci_hub_control(hcd, typeReq, wValue,
+   wIndex, buf, wLength);
 }
 
-static const struct hc_driver ohci_da8xx_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = "DA8xx OHCI",
-   .hcd_priv_size  = 

[PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-26 Thread ahaslam
From: Manjunath Goudar 

Separate the Davinci OHCI host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM

Signed-off-by: Manjunath Goudar 
[Axel: adapted and rebased, fixed minor comments]
Signed-off-by: Axel Haslam 
---

This was a previews patch submited by Manjunath [1]
that was never taken in because of an undefined symbol
when loading as a module. That symbol is not present anymore
so we can safly build the driver as a module.

I rebased, fixing the minor remaining comments.

Axel.
http://patches.linaro.org/patch/18234/

 drivers/usb/host/Kconfig  |   4 +-
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ohci-da8xx.c | 181 +-
 drivers/usb/host/ohci-hcd.c   |  18 -
 4 files changed, 74 insertions(+), 130 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 83b6cec..6361fc7 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -479,9 +479,9 @@ config USB_OHCI_HCD_OMAP3
  OMAP3 and later chips.
 
 config USB_OHCI_HCD_DAVINCI
-   bool "OHCI support for TI DaVinci DA8xx"
+   tristate "OHCI support for TI DaVinci DA8xx"
depends on ARCH_DAVINCI_DA8XX
-   depends on USB_OHCI_HCD=y
+   depends on USB_OHCI_HCD
select PHY_DA8XX_USB
default y
help
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 6ef785b..2644537 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_USB_OHCI_HCD_AT91)   += ohci-at91.o
 obj-$(CONFIG_USB_OHCI_HCD_S3C2410) += ohci-s3c2410.o
 obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o
 obj-$(CONFIG_USB_OHCI_HCD_PXA27X)  += ohci-pxa27x.o
+obj-$(CONFIG_USB_OHCI_HCD_DAVINCI) += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3656d7c..4e2a61f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -11,16 +11,30 @@
  * kind, whether express or implied.
  */
 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
-#ifndef CONFIG_ARCH_DAVINCI_DA8XX
-#error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
-#endif
+#include "ohci.h"
+
+#define DRIVER_DESC "DA8XX"
+
+static const char hcd_name[] = "ohci";
+
+static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
+
+static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, u16 typeReq,
+   u16 wValue, u16 wIndex, char *buf, u16 wLength);
+static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 static struct clk *usb11_clk;
 static struct phy *usb11_phy;
@@ -74,7 +88,7 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
-static int ohci_da8xx_init(struct usb_hcd *hcd)
+static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
@@ -94,7 +108,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
 */
ohci->num_ports = 1;
 
-   result = ohci_init(ohci);
+   result = ohci_setup(hcd);
if (result < 0) {
ohci_da8xx_disable();
return result;
@@ -122,30 +136,12 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
return result;
 }
 
-static void ohci_da8xx_stop(struct usb_hcd *hcd)
-{
-   ohci_stop(hcd);
-   ohci_da8xx_disable();
-}
-
-static int ohci_da8xx_start(struct usb_hcd *hcd)
-{
-   struct ohci_hcd *ohci   = hcd_to_ohci(hcd);
-   int result;
-
-   result = ohci_run(ohci);
-   if (result < 0)
-   ohci_da8xx_stop(hcd);
-
-   return result;
-}
-
 /*
  * Update the status data from the hub with the over-current indicator change.
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
-   int length  = ohci_hub_status_data(hcd, buf);
+   int length  = orig_ohci_hub_status_data(hcd, buf);
 
/* See if we have OCIC bit set on port 1 */
if (ocic_mask & (1 << 1)) {
@@ -227,66 +223,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
}
}
 
-   return ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
+   return orig_ohci_hub_control(hcd, typeReq, wValue,
+   wIndex, buf, wLength);
 }
 
-static const struct hc_driver ohci_da8xx_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = "DA8xx OHCI",
-   .hcd_priv_size  = sizeof(struct ohci_hcd),
-
-   /*
-* generic hardware linkage
-