[RFC Patch USB 0/1] Cleanup USB host code of s3c2410

Michael Trimarchi trimarchi at gandalf.sssup.it
Wed Apr 8 15:48:15 CEST 2009


Cleanup code of ohci-s3c2410.

Signed-off-by: Michael Trimarchi <michael at panicking.kicks-ass.org>
---
 drivers/usb/host/ohci-s3c2410.c |   84 +++++++++++++++++++++------------------
 1 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 5d8d556..4c69ee5 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -21,10 +21,11 @@
 
 #include <linux/platform_device.h>
 #include <linux/clk.h>
-
-//#include <mach/hardware.h>
+/*
+#include <mach/hardware.h>
+#include <mach/regs-gpio.h>
+*/
 #include <plat/usb-control.h>
-//#include <mach/regs-gpio.h>
 
 #define valid_port(idx) ((idx) == 1 || (idx) == 2)
 
@@ -59,9 +60,8 @@ static void s3c2410_start_hc(struct platform_device *dev, struct usb_hcd *hcd)
 		info->hcd	= hcd;
 		info->report_oc = s3c2410_hcd_oc;
 
-		if (info->enable_oc != NULL) {
+		if (info->enable_oc != NULL)
 			(info->enable_oc)(info, 1);
-		}
 	}
 }
 
@@ -75,9 +75,8 @@ static void s3c2410_stop_hc(struct platform_device *dev)
 		info->report_oc = NULL;
 		info->hcd	= NULL;
 
-		if (info->enable_oc != NULL) {
+		if (info->enable_oc != NULL)
 			(info->enable_oc)(info, 0);
-		}
 	}
 
 	clk_disable(clk);
@@ -91,14 +90,14 @@ static void s3c2410_stop_hc(struct platform_device *dev)
 */
 
 static int
-ohci_s3c2410_hub_status_data (struct usb_hcd *hcd, char *buf)
+ohci_s3c2410_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
 	struct s3c2410_hcd_info *info = to_s3c2410_info(hcd);
 	struct s3c2410_hcd_port *port;
 	int orig;
 	int portno;
 
-	orig  = ohci_hub_status_data (hcd, buf);
+	orig  = ohci_hub_status_data(hcd, buf);
 
 	if (info == NULL)
 		return orig;
@@ -148,7 +147,7 @@ static void s3c2410_usb_set_power(struct s3c2410_hcd_info *info,
  * request.
 */
 
-static int ohci_s3c2410_hub_control (
+static int ohci_s3c2410_hub_control(
 	struct usb_hcd	*hcd,
 	u16		typeReq,
 	u16		wValue,
@@ -202,9 +201,8 @@ static int ohci_s3c2410_hub_control (
 			dev_dbg(hcd->self.controller,
 				"ClearPortFeature: OVER_CURRENT\n");
 
-			if (valid_port(wIndex)) {
+			if (valid_port(wIndex))
 				info->port[wIndex-1].oc_status = 0;
-			}
 
 			goto out;
 
@@ -245,28 +243,28 @@ static int ohci_s3c2410_hub_control (
 		desc->wHubCharacteristics |= cpu_to_le16(0x0001);
 
 		if (info->enable_oc) {
-			desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
-			desc->wHubCharacteristics |=  cpu_to_le16(0x0008|0x0001);
+			desc->wHubCharacteristics &=
+					~cpu_to_le16(HUB_CHAR_OCPM);
+			desc->wHubCharacteristics |=
+					cpu_to_le16(0x0008|0x0001);
 		}
 
-		dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
+		dev_dbg(hcd->self.controller,
+			"wHubCharacteristics after 0x%04x\n",
 			desc->wHubCharacteristics);
 
 		return ret;
 
 	case GetPortStatus:
 		/* check port status */
-
 		dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
 
 		if (valid_port(wIndex)) {
-			if (info->port[wIndex-1].oc_changed) {
+			if (info->port[wIndex-1].oc_changed)
 				*data |= cpu_to_le32(RH_PS_OCIC);
-			}
 
-			if (info->port[wIndex-1].oc_status) {
+			if (info->port[wIndex-1].oc_status)
 				*data |= cpu_to_le32(RH_PS_POCI);
-			}
 		}
 	}
 
@@ -324,7 +322,7 @@ static ssize_t set_usb_mode(struct device *dev, struct device_attribute *attr,
 			    const char *buf, size_t count)
 {
 	if (!strncmp(buf, "host", 4)) {
-		printk("s3c2410: changing usb to host\n");
+		printk(KERN_WARNING "s3c2410: changing usb to host\n");
 		s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST,
 				      S3C2410_MISCCR_USBHOST);
 		/* FIXME:
@@ -333,11 +331,11 @@ static ssize_t set_usb_mode(struct device *dev, struct device_attribute *attr,
 		 */
 		s3c2410_gpio_setpin(S3C2410_GPB9, 0);
 	} else if (!strncmp(buf, "device", 6)) {
-		printk("s3c2410: changing usb to device\n");
+		printk(KERN_WARNING "s3c2410: changing usb to device\n");
 		s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST, 0);
 		s3c2410_gpio_setpin(S3C2410_GPB9, 1);
 	} else {
-		printk("s3c2410: unknown mode\n");
+		printk(KERN_WARNING "s3c2410: unknown mode\n");
 		return -EINVAL;
 	}
 
@@ -362,9 +360,11 @@ static DEVICE_ATTR(usb_mode, S_IRUGO | S_IWUSR, show_usb_mode, set_usb_mode);
 */
 
 static void
-usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev)
+usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev)
 {
-	//device_remove_file(&dev->dev, &dev_attr_usb_mode);
+/*
+	device_remove_file(&dev->dev, &dev_attr_usb_mode);
+*/
 	usb_remove_hcd(hcd);
 	s3c2410_stop_hc(dev);
 	iounmap(hcd->regs);
@@ -381,8 +381,8 @@ usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev)
  * through the hotplug entry's driver_data.
  *
  */
-static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
-				  struct platform_device *dev)
+static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
+				 struct platform_device *dev)
 {
 	struct usb_hcd *hcd = NULL;
 	int retval;
@@ -432,16 +432,20 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
 	if (retval != 0)
 		goto err_ioremap;
 
-//	retval = device_create_file(&dev->dev, &dev_attr_usb_mode);
-//	if (retval != 0)
-//		goto err_hcd;
+/*
+	retval = device_create_file(&dev->dev, &dev_attr_usb_mode);
+	if (retval != 0)
+		goto err_hcd;
+*/
 
 	return 0;
 
-// err_hcd:
-//	usb_remove_hcd(hcd);
+/*
+err_hcd:
+	usb_remove_hcd(hcd);
+*/
 
- err_ioremap:
+err_ioremap:
 	s3c2410_stop_hc(dev);
 	iounmap(hcd->regs);
 	clk_put(usb_clk);
@@ -460,17 +464,19 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
 /*-------------------------------------------------------------------------*/
 
 static int
-ohci_s3c2410_start (struct usb_hcd *hcd)
+ohci_s3c2410_start(struct usb_hcd *hcd)
 {
-	struct ohci_hcd	*ohci = hcd_to_ohci (hcd);
+	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;
 	}
 
-- 
1.5.6.5




More information about the openmoko-kernel mailing list