From 49dd7284ab87a59dad401b1dc89dc0a9950b2810 Mon Sep 17 00:00:00 2001 From: Alessio Igor Bogani Date: Mon, 1 Mar 2010 14:10:56 +0100 Subject: USB: sisusbvga: Remove the BKL from ioctl Seems to me that BKL is not needed here because necessary locking is already provided by mutex sisusb->lock. Also change the returned value to long. Signed-off-by: Alessio Igor Bogani Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index aae95a009bd5..63a6070a478a 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -2974,13 +2974,12 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct sisusb_usb_data *sisusb; struct sisusb_info x; struct sisusb_command y; - int retval = 0; + long retval = 0; u32 __user *argp = (u32 __user *)arg; if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) return -ENODEV; - lock_kernel(); mutex_lock(&sisusb->lock); /* Sanity check */ @@ -3039,7 +3038,6 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) err_out: mutex_unlock(&sisusb->lock); - unlock_kernel(); return retval; } -- cgit v1.2.3 From 2f58662d91c3b1cd459575540face531b328a82a Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 2 Mar 2010 14:52:33 -0800 Subject: USB: cdc-acm: make bitfields unsigned Fix usb/class sparse warnings: drivers/usb/class/cdc-acm.h:128:34: error: dubious one-bit signed bitfield drivers/usb/class/cdc-acm.h:129:24: error: dubious one-bit signed bitfield Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index 4a8e87ec6ce9..5eeb570b9a61 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -124,8 +124,8 @@ struct acm { unsigned char clocal; /* termios CLOCAL */ unsigned int ctrl_caps; /* control capabilities from the class specific header */ unsigned int susp_count; /* number of suspended interfaces */ - int combined_interfaces:1; /* control and data collapsed */ - int is_int_ep:1; /* interrupt endpoints contrary to spec used */ + unsigned int combined_interfaces:1; /* control and data collapsed */ + unsigned int is_int_ep:1; /* interrupt endpoints contrary to spec used */ u8 bInterval; struct acm_wb *delayed_wb; /* write queued for a device about to be woken */ }; -- cgit v1.2.3 From d5ffe2a7b5d1379209ba236dde2b9e5e8c4877a8 Mon Sep 17 00:00:00 2001 From: Ian Munsie Date: Wed, 3 Mar 2010 11:00:37 +1100 Subject: USB: Remove large struct from the stack in USB storage isd200 driver The compiler throws the following warning when compiling for a PowerPC 64 bit machine: drivers/usb/storage/isd200.c:580: warning: the frame size of 2208 bytes is larger than 2048 bytes There is a struct scsi_device which is placed on the stack and is largely responsible for such wastage. The struct is just a dummy struct filled with NULLs and set as the scsi_cmnd->device to make the usb_stor_Bulk_transport function happy. This patch makes the struct static, so that it is never placed onto the stack and silences the compiler warning. Signed-off-by: Ian Munsie Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/isd200.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index fdba2f69d4c9..e9cbc1467f76 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -490,13 +490,13 @@ static int isd200_action( struct us_data *us, int action, void* pointer, int value ) { union ata_cdb ata; - struct scsi_device srb_dev; + /* static to prevent this large struct being placed on the valuable stack */ + static struct scsi_device srb_dev; struct isd200_info *info = (struct isd200_info *)us->extra; struct scsi_cmnd *srb = &info->srb; int status; memset(&ata, 0, sizeof(ata)); - memset(&srb_dev, 0, sizeof(srb_dev)); srb->cmnd = info->cmnd; srb->device = &srb_dev; ++srb->serial_number; -- cgit v1.2.3 From 800defc3d41c3e4ad4a027806f8f487ffc2e6572 Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Thu, 4 Mar 2010 21:57:51 +0800 Subject: USB: remove duplicated #include Remove duplicated #include('s) in drivers/usb/core/hcd.c Signed-off-by: Huang Weiyi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 2f8cedda8007..79b212f02382 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 28236af7cd03463d72e80ea3619905c80dda0085 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 4 Mar 2010 11:32:30 -0500 Subject: USB: remove bogus USB_PORT_FEAT_*_SPEED symbols This patch (as1348) removes the bogus USB_PORT_FEAT_{HIGHSPEED,SUPERSPEED} symbols from hub.h. No such features are defined by the USB spec. (There is a PORT_LOWSPEED feature, but the spec doesn't mention it except to say that host software should never use it.) The speed indicators are port statuses, not port features. As a temporary workaround for the xhci-hcd driver, a fictional USB_PORT_STAT_SUPER_SPEED symbol is added. Signed-off-by: Alan Stern CC: Sarah Sharp Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 8 ++++---- drivers/usb/core/hub.h | 7 ++----- drivers/usb/host/ehci.h | 8 ++++---- drivers/usb/host/isp1760-hcd.c | 2 +- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 7 +++---- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/usb/host/xhci-hub.c | 8 ++++---- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 0940ccd6f4f4..03b4f912fab7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -154,11 +154,11 @@ static int usb_reset_and_verify_device(struct usb_device *udev); static inline char *portspeed(int portstatus) { - if (portstatus & (1 << USB_PORT_FEAT_HIGHSPEED)) + if (portstatus & USB_PORT_STAT_HIGH_SPEED) return "480 Mb/s"; - else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED)) + else if (portstatus & USB_PORT_STAT_LOW_SPEED) return "1.5 Mb/s"; - else if (portstatus & (1 << USB_PORT_FEAT_SUPERSPEED)) + else if (portstatus & USB_PORT_STAT_SUPER_SPEED) return "5.0 Gb/s"; else return "12 Mb/s"; @@ -3076,7 +3076,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, if (!(hcd->driver->flags & HCD_USB3)) udev->speed = USB_SPEED_UNKNOWN; else if ((hdev->parent == NULL) && - (portstatus & (1 << USB_PORT_FEAT_SUPERSPEED))) + (portstatus & USB_PORT_STAT_SUPER_SPEED)) udev->speed = USB_SPEED_SUPER; else udev->speed = USB_SPEED_UNKNOWN; diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index de8081f065ed..2ead36ae0a2f 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -46,11 +46,7 @@ #define USB_PORT_FEAT_RESET 4 #define USB_PORT_FEAT_L1 5 /* L1 suspend */ #define USB_PORT_FEAT_POWER 8 -#define USB_PORT_FEAT_LOWSPEED 9 -/* This value was never in Table 11-17 */ -#define USB_PORT_FEAT_HIGHSPEED 10 -/* This value is also fake */ -#define USB_PORT_FEAT_SUPERSPEED 11 +#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ #define USB_PORT_FEAT_C_CONNECTION 16 #define USB_PORT_FEAT_C_ENABLE 17 #define USB_PORT_FEAT_C_SUSPEND 18 @@ -86,6 +82,7 @@ struct usb_port_status { #define USB_PORT_STAT_TEST 0x0800 #define USB_PORT_STAT_INDICATOR 0x1000 /* bits 13 to 15 are reserved */ +#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */ /* * wPortChange bit field diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index b1dce96dd621..bee7c5ec5905 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -555,20 +555,20 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) case 0: return 0; case 1: - return (1<root_hub[port]; - rh->port &= ~((1 << USB_PORT_FEAT_HIGHSPEED) | - (1 << USB_PORT_FEAT_LOWSPEED)); + rh->port &= ~(USB_PORT_STAT_HIGH_SPEED | USB_PORT_STAT_LOW_SPEED); if (speed == HSMODE) - rh->port |= (1 << USB_PORT_FEAT_HIGHSPEED); + rh->port |= USB_PORT_STAT_HIGH_SPEED; else if (speed == LSMODE) - rh->port |= (1 << USB_PORT_FEAT_LOWSPEED); + rh->port |= USB_PORT_STAT_LOW_SPEED; rh->port &= ~(1 << USB_PORT_FEAT_RESET); rh->port |= 1 << USB_PORT_FEAT_ENABLE; diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index e11cc3aa4b82..a65ca17b81e5 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1121,7 +1121,7 @@ sl811h_timer(unsigned long _sl811) u8 signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE; const u32 mask = (1 << USB_PORT_FEAT_CONNECTION) | (1 << USB_PORT_FEAT_ENABLE) - | (1 << USB_PORT_FEAT_LOWSPEED); + | USB_PORT_STAT_LOW_SPEED; spin_lock_irqsave(&sl811->lock, flags); @@ -1162,7 +1162,7 @@ sl811h_timer(unsigned long _sl811) } else { sl811->port1 |= mask; if (irqstat & SL11H_INTMASK_DP) - sl811->port1 &= ~(1 << USB_PORT_FEAT_LOWSPEED); + sl811->port1 &= ~USB_PORT_STAT_LOW_SPEED; sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD; } @@ -1173,7 +1173,7 @@ sl811h_timer(unsigned long _sl811) #ifdef USE_B sl811->irq_enable |= SL11H_INTMASK_DONE_B; #endif - if (sl811->port1 & (1 << USB_PORT_FEAT_LOWSPEED)) { + if (sl811->port1 & USB_PORT_STAT_LOW_SPEED) { sl811->ctrl1 |= SL11H_CTL1MASK_LSPD; ctrl2 |= SL811HS_CTL2MASK_DSWAP; } diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 208b805b80eb..dd69df1e4558 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -64,15 +64,15 @@ static void xhci_hub_descriptor(struct xhci_hcd *xhci, static unsigned int xhci_port_speed(unsigned int port_status) { if (DEV_LOWSPEED(port_status)) - return 1 << USB_PORT_FEAT_LOWSPEED; + return USB_PORT_STAT_LOW_SPEED; if (DEV_HIGHSPEED(port_status)) - return 1 << USB_PORT_FEAT_HIGHSPEED; + return USB_PORT_STAT_HIGH_SPEED; if (DEV_SUPERSPEED(port_status)) - return 1 << USB_PORT_FEAT_SUPERSPEED; + return USB_PORT_STAT_SUPER_SPEED; /* * FIXME: Yes, we should check for full speed, but the core uses that as * a default in portspeed() in usb/core/hub.c (which is the only place - * USB_PORT_FEAT_*SPEED is used). + * USB_PORT_STAT_*_SPEED is used). */ return 0; } -- cgit v1.2.3 From 6609ff940755ef3fd80f20c854b60fecc1fae33a Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 4 Mar 2010 17:05:08 -0500 Subject: USB: straighten out port feature vs. port status usage This patch (as1349b) clears up the confusion in many USB host controller drivers between port features and port statuses. In mosty cases it's true that the status bit is in the position given by the corresponding feature value, but that's not always true and it's not guaranteed in the USB spec. There's no functional change, just replacing expressions of the form (1 << USB_PORT_FEAT_x) with USB_PORT_STAT_x, which has the same value. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-hub.c | 24 +++++++++---------- drivers/usb/host/isp1362-hcd.c | 2 +- drivers/usb/host/isp1760-hcd.c | 18 +++++++------- drivers/usb/host/oxu210hp-hcd.c | 24 +++++++++---------- drivers/usb/host/r8a66597-hcd.c | 30 ++++++++++++------------ drivers/usb/host/sl811-hcd.c | 52 ++++++++++++++++++++--------------------- drivers/usb/host/xhci-hub.c | 16 ++++++------- drivers/usb/musb/musb_core.c | 7 +++--- drivers/usb/musb/musb_virthub.c | 4 ++-- 10 files changed, 89 insertions(+), 90 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 03b4f912fab7..5c483faba95f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3038,7 +3038,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, /* maybe switch power back on (e.g. root hub was reset) */ if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 - && !(portstatus & (1 << USB_PORT_FEAT_POWER))) + && !(portstatus & USB_PORT_STAT_POWER)) set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); if (portstatus & USB_PORT_STAT_ENABLE) diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 19372673bf09..60ca00895e93 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -659,7 +659,7 @@ static int ehci_hub_control ( * Even if OWNER is set, so the port is owned by the * companion controller, khubd needs to be able to clear * the port-change status bits (especially - * USB_PORT_FEAT_C_CONNECTION). + * USB_PORT_STAT_C_CONNECTION). */ switch (wValue) { @@ -729,12 +729,12 @@ static int ehci_hub_control ( // wPortChange bits if (temp & PORT_CSC) - status |= 1 << USB_PORT_FEAT_C_CONNECTION; + status |= USB_PORT_STAT_C_CONNECTION << 16; if (temp & PORT_PEC) - status |= 1 << USB_PORT_FEAT_C_ENABLE; + status |= USB_PORT_STAT_C_ENABLE << 16; if ((temp & PORT_OCC) && !ignore_oc){ - status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; + status |= USB_PORT_STAT_C_OVERCURRENT << 16; /* * Hubs should disable port power on over-current. @@ -791,7 +791,7 @@ static int ehci_hub_control ( if ((temp & PORT_RESET) && time_after_eq(jiffies, ehci->reset_done[wIndex])) { - status |= 1 << USB_PORT_FEAT_C_RESET; + status |= USB_PORT_STAT_C_RESET << 16; ehci->reset_done [wIndex] = 0; /* force reset to complete */ @@ -833,7 +833,7 @@ static int ehci_hub_control ( */ if (temp & PORT_CONNECT) { - status |= 1 << USB_PORT_FEAT_CONNECTION; + status |= USB_PORT_STAT_CONNECTION; // status may be from integrated TT if (ehci->has_hostpc) { temp1 = ehci_readl(ehci, hostpc_reg); @@ -842,11 +842,11 @@ static int ehci_hub_control ( status |= ehci_port_speed(ehci, temp); } if (temp & PORT_PE) - status |= 1 << USB_PORT_FEAT_ENABLE; + status |= USB_PORT_STAT_ENABLE; /* maybe the port was unsuspended without our knowledge */ if (temp & (PORT_SUSPEND|PORT_RESUME)) { - status |= 1 << USB_PORT_FEAT_SUSPEND; + status |= USB_PORT_STAT_SUSPEND; } else if (test_bit(wIndex, &ehci->suspended_ports)) { clear_bit(wIndex, &ehci->suspended_ports); ehci->reset_done[wIndex] = 0; @@ -855,13 +855,13 @@ static int ehci_hub_control ( } if (temp & PORT_OC) - status |= 1 << USB_PORT_FEAT_OVER_CURRENT; + status |= USB_PORT_STAT_OVERCURRENT; if (temp & PORT_RESET) - status |= 1 << USB_PORT_FEAT_RESET; + status |= USB_PORT_STAT_RESET; if (temp & PORT_POWER) - status |= 1 << USB_PORT_FEAT_POWER; + status |= USB_PORT_STAT_POWER; if (test_bit(wIndex, &ehci->port_c_suspend)) - status |= 1 << USB_PORT_FEAT_C_SUSPEND; + status |= USB_PORT_STAT_C_SUSPEND << 16; #ifndef VERBOSE_DEBUG if (status & ~0xffff) /* only if wPortChange is interesting */ diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 217fb5170200..7a8e05e64464 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c @@ -1265,7 +1265,7 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, /* don't submit to a dead or disabled port */ if (!((isp1362_hcd->rhport[0] | isp1362_hcd->rhport[1]) & - (1 << USB_PORT_FEAT_ENABLE)) || + USB_PORT_STAT_ENABLE) || !HC_IS_RUNNING(hcd->state)) { kfree(ep); retval = -ENODEV; diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index aa19f18e3c77..d26603c42e0e 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c @@ -1923,7 +1923,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, * Even if OWNER is set, so the port is owned by the * companion controller, khubd needs to be able to clear * the port-change status bits (especially - * USB_PORT_FEAT_C_CONNECTION). + * USB_PORT_STAT_C_CONNECTION). */ switch (wValue) { @@ -1987,7 +1987,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, /* wPortChange bits */ if (temp & PORT_CSC) - status |= 1 << USB_PORT_FEAT_C_CONNECTION; + status |= USB_PORT_STAT_C_CONNECTION << 16; /* whoever resumes must GetPortStatus to complete it!! */ @@ -2007,7 +2007,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, /* resume completed? */ else if (time_after_eq(jiffies, priv->reset_done)) { - status |= 1 << USB_PORT_FEAT_C_SUSPEND; + status |= USB_PORT_STAT_C_SUSPEND << 16; priv->reset_done = 0; /* stop resume signaling */ @@ -2031,7 +2031,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, if ((temp & PORT_RESET) && time_after_eq(jiffies, priv->reset_done)) { - status |= 1 << USB_PORT_FEAT_C_RESET; + status |= USB_PORT_STAT_C_RESET << 16; priv->reset_done = 0; /* force reset to complete */ @@ -2062,18 +2062,18 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, printk(KERN_ERR "Warning: PORT_OWNER is set\n"); if (temp & PORT_CONNECT) { - status |= 1 << USB_PORT_FEAT_CONNECTION; + status |= USB_PORT_STAT_CONNECTION; /* status may be from integrated TT */ status |= ehci_port_speed(priv, temp); } if (temp & PORT_PE) - status |= 1 << USB_PORT_FEAT_ENABLE; + status |= USB_PORT_STAT_ENABLE; if (temp & (PORT_SUSPEND|PORT_RESUME)) - status |= 1 << USB_PORT_FEAT_SUSPEND; + status |= USB_PORT_STAT_SUSPEND; if (temp & PORT_RESET) - status |= 1 << USB_PORT_FEAT_RESET; + status |= USB_PORT_STAT_RESET; if (temp & PORT_POWER) - status |= 1 << USB_PORT_FEAT_POWER; + status |= USB_PORT_STAT_POWER; put_unaligned(cpu_to_le32(status), (__le32 *) buf); break; diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index 1b5055363c57..ff1a1d0cd042 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -3202,7 +3202,7 @@ static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq, * Even if OWNER is set, so the port is owned by the * companion controller, khubd needs to be able to clear * the port-change status bits (especially - * USB_PORT_FEAT_C_CONNECTION). + * USB_PORT_STAT_C_CONNECTION). */ switch (wValue) { @@ -3264,11 +3264,11 @@ static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq, /* wPortChange bits */ if (temp & PORT_CSC) - status |= 1 << USB_PORT_FEAT_C_CONNECTION; + status |= USB_PORT_STAT_C_CONNECTION << 16; if (temp & PORT_PEC) - status |= 1 << USB_PORT_FEAT_C_ENABLE; + status |= USB_PORT_STAT_C_ENABLE << 16; if ((temp & PORT_OCC) && !ignore_oc) - status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; + status |= USB_PORT_STAT_C_OVERCURRENT << 16; /* whoever resumes must GetPortStatus to complete it!! */ if (temp & PORT_RESUME) { @@ -3286,7 +3286,7 @@ static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq, /* resume completed? */ else if (time_after_eq(jiffies, oxu->reset_done[wIndex])) { - status |= 1 << USB_PORT_FEAT_C_SUSPEND; + status |= USB_PORT_STAT_C_SUSPEND << 16; oxu->reset_done[wIndex] = 0; /* stop resume signaling */ @@ -3309,7 +3309,7 @@ static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq, if ((temp & PORT_RESET) && time_after_eq(jiffies, oxu->reset_done[wIndex])) { - status |= 1 << USB_PORT_FEAT_C_RESET; + status |= USB_PORT_STAT_C_RESET << 16; oxu->reset_done[wIndex] = 0; /* force reset to complete */ @@ -3348,20 +3348,20 @@ static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq, */ if (temp & PORT_CONNECT) { - status |= 1 << USB_PORT_FEAT_CONNECTION; + status |= USB_PORT_STAT_CONNECTION; /* status may be from integrated TT */ status |= oxu_port_speed(oxu, temp); } if (temp & PORT_PE) - status |= 1 << USB_PORT_FEAT_ENABLE; + status |= USB_PORT_STAT_ENABLE; if (temp & (PORT_SUSPEND|PORT_RESUME)) - status |= 1 << USB_PORT_FEAT_SUSPEND; + status |= USB_PORT_STAT_SUSPEND; if (temp & PORT_OC) - status |= 1 << USB_PORT_FEAT_OVER_CURRENT; + status |= USB_PORT_STAT_OVERCURRENT; if (temp & PORT_RESET) - status |= 1 << USB_PORT_FEAT_RESET; + status |= USB_PORT_STAT_RESET; if (temp & PORT_POWER) - status |= 1 << USB_PORT_FEAT_POWER; + status |= USB_PORT_STAT_POWER; #ifndef OXU_VERBOSE_DEBUG if (status & ~0xffff) /* only if wPortChange is interesting */ diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 785e266feefb..75fc59a33ee0 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -1017,10 +1017,10 @@ static void start_root_hub_sampling(struct r8a66597 *r8a66597, int port, rh->old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port)) & LNST; rh->scount = R8A66597_MAX_SAMPLING; if (connect) - rh->port |= 1 << USB_PORT_FEAT_CONNECTION; + rh->port |= USB_PORT_STAT_CONNECTION; else - rh->port &= ~(1 << USB_PORT_FEAT_CONNECTION); - rh->port |= 1 << USB_PORT_FEAT_C_CONNECTION; + rh->port &= ~USB_PORT_STAT_CONNECTION; + rh->port |= USB_PORT_STAT_C_CONNECTION << 16; r8a66597_root_hub_start_polling(r8a66597); } @@ -1064,8 +1064,8 @@ static void r8a66597_usb_connect(struct r8a66597 *r8a66597, int port) else if (speed == LSMODE) rh->port |= USB_PORT_STAT_LOW_SPEED; - rh->port &= ~(1 << USB_PORT_FEAT_RESET); - rh->port |= 1 << USB_PORT_FEAT_ENABLE; + rh->port &= USB_PORT_STAT_RESET; + rh->port |= USB_PORT_STAT_ENABLE; } /* this function must be called with interrupt disabled */ @@ -1704,7 +1704,7 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port) u16 tmp; struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; - if (rh->port & (1 << USB_PORT_FEAT_RESET)) { + if (rh->port & USB_PORT_STAT_RESET) { unsigned long dvstctr_reg = get_dvstctr_reg(port); tmp = r8a66597_read(r8a66597, dvstctr_reg); @@ -1716,7 +1716,7 @@ static void r8a66597_root_hub_control(struct r8a66597 *r8a66597, int port) r8a66597_usb_connect(r8a66597, port); } - if (!(rh->port & (1 << USB_PORT_FEAT_CONNECTION))) { + if (!(rh->port & USB_PORT_STAT_CONNECTION)) { r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port)); r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); } @@ -2184,7 +2184,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, switch (wValue) { case USB_PORT_FEAT_ENABLE: - rh->port &= ~(1 << USB_PORT_FEAT_POWER); + rh->port &= ~USB_PORT_STAT_POWER; break; case USB_PORT_FEAT_SUSPEND: break; @@ -2225,12 +2225,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, break; case USB_PORT_FEAT_POWER: r8a66597_port_power(r8a66597, port, 1); - rh->port |= (1 << USB_PORT_FEAT_POWER); + rh->port |= USB_PORT_STAT_POWER; break; case USB_PORT_FEAT_RESET: { struct r8a66597_device *dev = rh->dev; - rh->port |= (1 << USB_PORT_FEAT_RESET); + rh->port |= USB_PORT_STAT_RESET; disable_r8a66597_pipe_all(r8a66597, dev); free_usb_address(r8a66597, dev, 1); @@ -2268,12 +2268,12 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd) struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; unsigned long dvstctr_reg = get_dvstctr_reg(port); - if (!(rh->port & (1 << USB_PORT_FEAT_ENABLE))) + if (!(rh->port & USB_PORT_STAT_ENABLE)) continue; dbg("suspend port = %d", port); r8a66597_bclr(r8a66597, UACT, dvstctr_reg); /* suspend */ - rh->port |= 1 << USB_PORT_FEAT_SUSPEND; + rh->port |= USB_PORT_STAT_SUSPEND; if (rh->dev->udev->do_remote_wakeup) { msleep(3); /* waiting last SOF */ @@ -2299,12 +2299,12 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; unsigned long dvstctr_reg = get_dvstctr_reg(port); - if (!(rh->port & (1 << USB_PORT_FEAT_SUSPEND))) + if (!(rh->port & USB_PORT_STAT_SUSPEND)) continue; dbg("resume port = %d", port); - rh->port &= ~(1 << USB_PORT_FEAT_SUSPEND); - rh->port |= 1 << USB_PORT_FEAT_C_SUSPEND; + rh->port &= ~USB_PORT_STAT_SUSPEND; + rh->port |= USB_PORT_STAT_C_SUSPEND < 16; r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg); msleep(50); r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg); diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index a65ca17b81e5..258742b5a933 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -90,10 +90,10 @@ static void port_power(struct sl811 *sl811, int is_on) /* hub is inactive unless the port is powered */ if (is_on) { - if (sl811->port1 & (1 << USB_PORT_FEAT_POWER)) + if (sl811->port1 & USB_PORT_STAT_POWER) return; - sl811->port1 = (1 << USB_PORT_FEAT_POWER); + sl811->port1 = USB_PORT_STAT_POWER; sl811->irq_enable = SL11H_INTMASK_INSRMV; } else { sl811->port1 = 0; @@ -407,7 +407,7 @@ static struct sl811h_ep *start(struct sl811 *sl811, u8 bank) static inline void start_transfer(struct sl811 *sl811) { - if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)) + if (sl811->port1 & USB_PORT_STAT_SUSPEND) return; if (sl811->active_a == NULL) { sl811->active_a = start(sl811, SL811_EP_A(SL811_HOST_BUF)); @@ -721,23 +721,23 @@ retry: * force the reset and make khubd clean up later. */ if (sl811->stat_insrmv & 1) - sl811->port1 |= 1 << USB_PORT_FEAT_CONNECTION; + sl811->port1 |= USB_PORT_STAT_CONNECTION; else - sl811->port1 &= ~(1 << USB_PORT_FEAT_CONNECTION); + sl811->port1 &= ~USB_PORT_STAT_CONNECTION; - sl811->port1 |= 1 << USB_PORT_FEAT_C_CONNECTION; + sl811->port1 |= USB_PORT_STAT_C_CONNECTION << 16; } else if (irqstat & SL11H_INTMASK_RD) { - if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)) { + if (sl811->port1 & USB_PORT_STAT_SUSPEND) { DBG("wakeup\n"); - sl811->port1 |= 1 << USB_PORT_FEAT_C_SUSPEND; + sl811->port1 |= USB_PORT_STAT_C_SUSPEND << 16; sl811->stat_wake++; } else irqstat &= ~SL11H_INTMASK_RD; } if (irqstat) { - if (sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)) + if (sl811->port1 & USB_PORT_STAT_ENABLE) start_transfer(sl811); ret = IRQ_HANDLED; if (retries--) @@ -819,7 +819,7 @@ static int sl811h_urb_enqueue( spin_lock_irqsave(&sl811->lock, flags); /* don't submit to a dead or disabled port */ - if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)) + if (!(sl811->port1 & USB_PORT_STAT_ENABLE) || !HC_IS_RUNNING(hcd->state)) { retval = -ENODEV; kfree(ep); @@ -1119,8 +1119,8 @@ sl811h_timer(unsigned long _sl811) unsigned long flags; u8 irqstat; u8 signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE; - const u32 mask = (1 << USB_PORT_FEAT_CONNECTION) - | (1 << USB_PORT_FEAT_ENABLE) + const u32 mask = USB_PORT_STAT_CONNECTION + | USB_PORT_STAT_ENABLE | USB_PORT_STAT_LOW_SPEED; spin_lock_irqsave(&sl811->lock, flags); @@ -1135,8 +1135,8 @@ sl811h_timer(unsigned long _sl811) switch (signaling) { case SL11H_CTL1MASK_SE0: DBG("end reset\n"); - sl811->port1 = (1 << USB_PORT_FEAT_C_RESET) - | (1 << USB_PORT_FEAT_POWER); + sl811->port1 = (USB_PORT_STAT_C_RESET << 16) + | USB_PORT_STAT_POWER; sl811->ctrl1 = 0; /* don't wrongly ack RD */ if (irqstat & SL11H_INTMASK_INSRMV) @@ -1144,7 +1144,7 @@ sl811h_timer(unsigned long _sl811) break; case SL11H_CTL1MASK_K: DBG("end resume\n"); - sl811->port1 &= ~(1 << USB_PORT_FEAT_SUSPEND); + sl811->port1 &= ~USB_PORT_STAT_SUSPEND; break; default: DBG("odd timer signaling: %02x\n", signaling); @@ -1154,9 +1154,9 @@ sl811h_timer(unsigned long _sl811) if (irqstat & SL11H_INTMASK_RD) { /* usbcore nukes all pending transactions on disconnect */ - if (sl811->port1 & (1 << USB_PORT_FEAT_CONNECTION)) - sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION) - | (1 << USB_PORT_FEAT_C_ENABLE); + if (sl811->port1 & USB_PORT_STAT_CONNECTION) + sl811->port1 |= (USB_PORT_STAT_C_CONNECTION << 16) + | (USB_PORT_STAT_C_ENABLE << 16); sl811->port1 &= ~mask; sl811->irq_enable = SL11H_INTMASK_INSRMV; } else { @@ -1166,7 +1166,7 @@ sl811h_timer(unsigned long _sl811) sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD; } - if (sl811->port1 & (1 << USB_PORT_FEAT_CONNECTION)) { + if (sl811->port1 & USB_PORT_STAT_CONNECTION) { u8 ctrl2 = SL811HS_CTL2_INIT; sl811->irq_enable |= SL11H_INTMASK_DONE_A; @@ -1233,7 +1233,7 @@ sl811h_hub_control( switch (wValue) { case USB_PORT_FEAT_ENABLE: - sl811->port1 &= (1 << USB_PORT_FEAT_POWER); + sl811->port1 &= USB_PORT_STAT_POWER; sl811->ctrl1 = 0; sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); sl811->irq_enable = SL11H_INTMASK_INSRMV; @@ -1241,7 +1241,7 @@ sl811h_hub_control( sl811->irq_enable); break; case USB_PORT_FEAT_SUSPEND: - if (!(sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND))) + if (!(sl811->port1 & USB_PORT_STAT_SUSPEND)) break; /* 20 msec of resume/K signaling, other irqs blocked */ @@ -1290,9 +1290,9 @@ sl811h_hub_control( goto error; switch (wValue) { case USB_PORT_FEAT_SUSPEND: - if (sl811->port1 & (1 << USB_PORT_FEAT_RESET)) + if (sl811->port1 & USB_PORT_STAT_RESET) goto error; - if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))) + if (!(sl811->port1 & USB_PORT_STAT_ENABLE)) goto error; DBG("suspend...\n"); @@ -1303,9 +1303,9 @@ sl811h_hub_control( port_power(sl811, 1); break; case USB_PORT_FEAT_RESET: - if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)) + if (sl811->port1 & USB_PORT_STAT_SUSPEND) goto error; - if (!(sl811->port1 & (1 << USB_PORT_FEAT_POWER))) + if (!(sl811->port1 & USB_PORT_STAT_POWER)) break; /* 50 msec of reset/SE0 signaling, irqs blocked */ @@ -1314,7 +1314,7 @@ sl811h_hub_control( sl811->irq_enable); sl811->ctrl1 = SL11H_CTL1MASK_SE0; sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); - sl811->port1 |= (1 << USB_PORT_FEAT_RESET); + sl811->port1 |= USB_PORT_STAT_RESET; mod_timer(&sl811->timer, jiffies + msecs_to_jiffies(50)); break; diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index dd69df1e4558..325b47a267b9 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -205,27 +205,27 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* wPortChange bits */ if (temp & PORT_CSC) - status |= 1 << USB_PORT_FEAT_C_CONNECTION; + status |= USB_PORT_STAT_C_CONNECTION << 16; if (temp & PORT_PEC) - status |= 1 << USB_PORT_FEAT_C_ENABLE; + status |= USB_PORT_STAT_C_ENABLE << 16; if ((temp & PORT_OCC)) - status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; + status |= USB_PORT_STAT_C_OVERCURRENT << 16; /* * FIXME ignoring suspend, reset, and USB 2.1/3.0 specific * changes */ if (temp & PORT_CONNECT) { - status |= 1 << USB_PORT_FEAT_CONNECTION; + status |= USB_PORT_STAT_CONNECTION; status |= xhci_port_speed(temp); } if (temp & PORT_PE) - status |= 1 << USB_PORT_FEAT_ENABLE; + status |= USB_PORT_STAT_ENABLE; if (temp & PORT_OC) - status |= 1 << USB_PORT_FEAT_OVER_CURRENT; + status |= USB_PORT_STAT_OVERCURRENT; if (temp & PORT_RESET) - status |= 1 << USB_PORT_FEAT_RESET; + status |= USB_PORT_STAT_RESET; if (temp & PORT_POWER) - status |= 1 << USB_PORT_FEAT_POWER; + status |= USB_PORT_STAT_POWER; xhci_dbg(xhci, "Get port status returned 0x%x\n", status); put_unaligned(cpu_to_le32(status), (__le32 *) buf); break; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 0e8b8ab1d168..a453bf3afbb4 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -353,8 +353,7 @@ void musb_hnp_stop(struct musb *musb) * which cause occasional OPT A "Did not receive reset after connect" * errors. */ - musb->port1_status &= - ~(1 << USB_PORT_FEAT_C_CONNECTION); + musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); } #endif @@ -530,8 +529,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb_writeb(mbase, MUSB_DEVCTL, devctl); } else { musb->port1_status |= - (1 << USB_PORT_FEAT_OVER_CURRENT) - | (1 << USB_PORT_FEAT_C_OVER_CURRENT); + USB_PORT_STAT_OVERCURRENT + | (USB_PORT_STAT_C_OVERCURRENT << 16); } break; default: diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index bfe5fe4ebfee..1351d06ef927 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -184,8 +184,8 @@ static void musb_port_reset(struct musb *musb, bool do_reset) void musb_root_disconnect(struct musb *musb) { - musb->port1_status = (1 << USB_PORT_FEAT_POWER) - | (1 << USB_PORT_FEAT_C_CONNECTION); + musb->port1_status = USB_PORT_STAT_POWER + | (USB_PORT_STAT_C_CONNECTION << 16); usb_hcd_poll_rh_status(musb_to_hcd(musb)); musb->is_active = 0; -- cgit v1.2.3 From 1d92699e837fe837a3ce0a10bfc457096c510588 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 5 Mar 2010 15:10:17 -0500 Subject: USB: remove uses of URB_NO_SETUP_DMA_MAP This patch (as1350) removes all usages of coherent buffers for USB control-request setup-packet buffers. There's no good reason to reserve coherent memory for these things; control requests are hardly ever used in large quantity (the major exception is firmware transfers, and they aren't time-critical). Furthermore, only seven drivers used it. We might as well always use streaming DMA mappings for setup-packet buffers, and remove some extra complexity from usbcore. The DMA-mapping portion of hcd.c is currently in flux. A separate patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP after everything else settles down. The removal should go smoothly, as by then nobody will be using it. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/hid/usbhid/hid-core.c | 8 +++----- drivers/hid/usbhid/usbhid.h | 1 - drivers/hid/usbhid/usbkbd.c | 8 +++----- drivers/input/misc/cm109.c | 12 +++--------- drivers/input/misc/powermate.c | 9 ++------- drivers/input/misc/yealink.c | 11 +++-------- drivers/usb/core/urb.c | 4 ++-- drivers/usb/core/usb.c | 18 +++--------------- drivers/usb/misc/usbtest.c | 9 ++------- drivers/usb/storage/transport.c | 2 -- drivers/usb/storage/usb.c | 15 +++++---------- drivers/usb/storage/usb.h | 3 +-- drivers/usb/wusbcore/wa-xfer.c | 2 -- 13 files changed, 27 insertions(+), 75 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 56d06cd8075b..bb550b454c8c 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -787,8 +787,7 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) &usbhid->inbuf_dma); usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL, &usbhid->outbuf_dma); - usbhid->cr = usb_buffer_alloc(dev, sizeof(*usbhid->cr), GFP_KERNEL, - &usbhid->cr_dma); + usbhid->cr = kmalloc(sizeof(*usbhid->cr), GFP_KERNEL); usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL, &usbhid->ctrlbuf_dma); if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr || @@ -846,7 +845,7 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); - usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); + kfree(usbhid->cr); usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); } @@ -1014,9 +1013,8 @@ static int usbhid_start(struct hid_device *hid) usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr, usbhid->ctrlbuf, 1, hid_ctrl, hid); - usbhid->urbctrl->setup_dma = usbhid->cr_dma; usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; - usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); + usbhid->urbctrl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS)) usbhid_init_reports(hid); diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index ec20400c7f29..693fd3e720df 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h @@ -75,7 +75,6 @@ struct usbhid_device { struct urb *urbctrl; /* Control URB */ struct usb_ctrlrequest *cr; /* Control request struct */ - dma_addr_t cr_dma; /* Control request struct dma */ struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */ unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */ char *ctrlbuf; /* Control buffer */ diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index f843443ba5c3..bdc7b09e8670 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c @@ -74,7 +74,6 @@ struct usb_kbd { unsigned char *new; struct usb_ctrlrequest *cr; unsigned char *leds; - dma_addr_t cr_dma; dma_addr_t new_dma; dma_addr_t leds_dma; }; @@ -199,7 +198,7 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) return -1; if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma))) return -1; - if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma))) + if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) return -1; if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma))) return -1; @@ -212,7 +211,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) usb_free_urb(kbd->irq); usb_free_urb(kbd->led); usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); - usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma); + kfree(kbd->cr); usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); } @@ -304,9 +303,8 @@ static int usb_kbd_probe(struct usb_interface *iface, usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), (void *) kbd->cr, kbd->leds, 1, usb_kbd_led, kbd); - kbd->led->setup_dma = kbd->cr_dma; kbd->led->transfer_dma = kbd->leds_dma; - kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); + kbd->led->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(kbd->dev); if (error) diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c index 86457feccfc4..8d2d291ee508 100644 --- a/drivers/input/misc/cm109.c +++ b/drivers/input/misc/cm109.c @@ -102,7 +102,6 @@ struct cm109_dev { struct cm109_ctl_packet *ctl_data; dma_addr_t ctl_dma; struct usb_ctrlrequest *ctl_req; - dma_addr_t ctl_req_dma; struct urb *urb_ctl; /* * The 3 bitfields below are protected by ctl_submit_lock. @@ -629,9 +628,7 @@ static const struct usb_device_id cm109_usb_table[] = { static void cm109_usb_cleanup(struct cm109_dev *dev) { - if (dev->ctl_req) - usb_buffer_free(dev->udev, sizeof(*(dev->ctl_req)), - dev->ctl_req, dev->ctl_req_dma); + kfree(dev->ctl_req); if (dev->ctl_data) usb_buffer_free(dev->udev, USB_PKT_LEN, dev->ctl_data, dev->ctl_dma); @@ -696,8 +693,7 @@ static int cm109_usb_probe(struct usb_interface *intf, if (!dev->ctl_data) goto err_out; - dev->ctl_req = usb_buffer_alloc(udev, sizeof(*(dev->ctl_req)), - GFP_KERNEL, &dev->ctl_req_dma); + dev->ctl_req = kmalloc(sizeof(*(dev->ctl_req)), GFP_KERNEL); if (!dev->ctl_req) goto err_out; @@ -735,10 +731,8 @@ static int cm109_usb_probe(struct usb_interface *intf, usb_fill_control_urb(dev->urb_ctl, udev, usb_sndctrlpipe(udev, 0), (void *)dev->ctl_req, dev->ctl_data, USB_PKT_LEN, cm109_urb_ctl_callback, dev); - dev->urb_ctl->setup_dma = dev->ctl_req_dma; dev->urb_ctl->transfer_dma = dev->ctl_dma; - dev->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP | - URB_NO_TRANSFER_DMA_MAP; + dev->urb_ctl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; dev->urb_ctl->dev = udev; /* find out the physical bus location */ diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index 668913d12044..7ba4b5f53fc2 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c @@ -64,7 +64,6 @@ struct powermate_device { dma_addr_t data_dma; struct urb *irq, *config; struct usb_ctrlrequest *configcr; - dma_addr_t configcr_dma; struct usb_device *udev; struct input_dev *input; spinlock_t lock; @@ -182,8 +181,6 @@ static void powermate_sync_state(struct powermate_device *pm) usb_fill_control_urb(pm->config, pm->udev, usb_sndctrlpipe(pm->udev, 0), (void *) pm->configcr, NULL, 0, powermate_config_complete, pm); - pm->config->setup_dma = pm->configcr_dma; - pm->config->transfer_flags |= URB_NO_SETUP_DMA_MAP; if (usb_submit_urb(pm->config, GFP_ATOMIC)) printk(KERN_ERR "powermate: usb_submit_urb(config) failed"); @@ -281,8 +278,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev if (!pm->data) return -1; - pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), - GFP_ATOMIC, &pm->configcr_dma); + pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL); if (!pm->configcr) return -1; @@ -293,8 +289,7 @@ static void powermate_free_buffers(struct usb_device *udev, struct powermate_dev { usb_buffer_free(udev, POWERMATE_PAYLOAD_SIZE_MAX, pm->data, pm->data_dma); - usb_buffer_free(udev, sizeof(*(pm->configcr)), - pm->configcr, pm->configcr_dma); + kfree(pm->configcr); } /* Called whenever a USB device matching one in our supported devices table is connected */ diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index 93a22ac0f88c..2828328e9dd0 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c @@ -111,7 +111,6 @@ struct yealink_dev { struct yld_ctl_packet *ctl_data; dma_addr_t ctl_dma; struct usb_ctrlrequest *ctl_req; - dma_addr_t ctl_req_dma; struct urb *urb_ctl; char phys[64]; /* physical device path */ @@ -836,8 +835,7 @@ static int usb_cleanup(struct yealink_dev *yld, int err) usb_free_urb(yld->urb_irq); usb_free_urb(yld->urb_ctl); - usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), - yld->ctl_req, yld->ctl_req_dma); + kfree(yld->ctl_req); usb_buffer_free(yld->udev, USB_PKT_LEN, yld->ctl_data, yld->ctl_dma); usb_buffer_free(yld->udev, USB_PKT_LEN, @@ -896,8 +894,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (!yld->ctl_data) return usb_cleanup(yld, -ENOMEM); - yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), - GFP_ATOMIC, &yld->ctl_req_dma); + yld->ctl_req = kmalloc(sizeof(*(yld->ctl_req)), GFP_KERNEL); if (yld->ctl_req == NULL) return usb_cleanup(yld, -ENOMEM); @@ -936,10 +933,8 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0), (void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN, urb_ctl_callback, yld); - yld->urb_ctl->setup_dma = yld->ctl_req_dma; yld->urb_ctl->transfer_dma = yld->ctl_dma; - yld->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP | - URB_NO_TRANSFER_DMA_MAP; + yld->urb_ctl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; yld->urb_ctl->dev = udev; /* find out the physical bus location */ diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 45a32dadb406..0a358da94d7d 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -396,8 +396,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) return -EPIPE; /* The most suitable error code :-) */ /* enforce simple/standard policy */ - allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | - URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER); + allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | + URB_FREE_BUFFER); switch (xfertype) { case USB_ENDPOINT_XFER_BULK: if (is_out) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 0c6581003339..f4660c3a4b87 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -775,7 +775,7 @@ EXPORT_SYMBOL_GPL(usb_buffer_free); * @urb: urb whose transfer_buffer/setup_packet will be mapped * * Return value is either null (indicating no buffer could be mapped), or - * the parameter. URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP are + * the parameter. URB_NO_TRANSFER_DMA_MAP is * added to urb->transfer_flags if the operation succeeds. If the device * is connected to this system through a non-DMA controller, this operation * always succeeds. @@ -803,17 +803,11 @@ struct urb *usb_buffer_map(struct urb *urb) urb->transfer_buffer, urb->transfer_buffer_length, usb_pipein(urb->pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); - if (usb_pipecontrol(urb->pipe)) - urb->setup_dma = dma_map_single(controller, - urb->setup_packet, - sizeof(struct usb_ctrlrequest), - DMA_TO_DEVICE); /* FIXME generic api broken like pci, can't report errors */ /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ } else urb->transfer_dma = ~0; - urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP - | URB_NO_SETUP_DMA_MAP); + urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; return urb; } EXPORT_SYMBOL_GPL(usb_buffer_map); @@ -881,14 +875,8 @@ void usb_buffer_unmap(struct urb *urb) urb->transfer_dma, urb->transfer_buffer_length, usb_pipein(urb->pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); - if (usb_pipecontrol(urb->pipe)) - dma_unmap_single(controller, - urb->setup_dma, - sizeof(struct usb_ctrlrequest), - DMA_TO_DEVICE); } - urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP - | URB_NO_SETUP_DMA_MAP); + urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP; } EXPORT_SYMBOL_GPL(usb_buffer_unmap); #endif /* 0 */ diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index a21cce6f7403..9dcc82337ced 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -977,15 +977,13 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) if (!u) goto cleanup; - reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL, - &u->setup_dma); + reqp = kmalloc(sizeof *reqp, GFP_KERNEL); if (!reqp) goto cleanup; reqp->setup = req; reqp->number = i % NUM_SUBCASES; reqp->expected = expected; u->setup_packet = (char *) &reqp->setup; - u->transfer_flags |= URB_NO_SETUP_DMA_MAP; u->context = &context; u->complete = ctrl_complete; @@ -1017,10 +1015,7 @@ cleanup: if (!urb [i]) continue; urb [i]->dev = udev; - if (urb [i]->setup_packet) - usb_buffer_free (udev, sizeof (struct usb_ctrlrequest), - urb [i]->setup_packet, - urb [i]->setup_dma); + kfree(urb[i]->setup_packet); simple_free_urb (urb [i]); } kfree (urb); diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 468038126e5e..df685bae1238 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -147,11 +147,9 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) * hasn't been mapped for DMA. Yes, this is clunky, but it's * easier than always having the caller tell us whether the * transfer buffer has already been mapped. */ - us->current_urb->transfer_flags = URB_NO_SETUP_DMA_MAP; if (us->current_urb->transfer_buffer == us->iobuf) us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; us->current_urb->transfer_dma = us->iobuf_dma; - us->current_urb->setup_dma = us->cr_dma; /* submit the URB */ status = usb_submit_urb(us->current_urb, GFP_NOIO); diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index bbeeb92a2131..c54a370c76c5 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -407,9 +407,8 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) /* Store our private data in the interface */ usb_set_intfdata(intf, us); - /* Allocate the device-related DMA-mapped buffers */ - us->cr = usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr), - GFP_KERNEL, &us->cr_dma); + /* Allocate the control/setup and DMA-mapped buffers */ + us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL); if (!us->cr) { US_DEBUGP("usb_ctrlrequest allocation failed\n"); return -ENOMEM; @@ -757,13 +756,9 @@ static void dissociate_dev(struct us_data *us) { US_DEBUGP("-- %s\n", __func__); - /* Free the device-related DMA-mapped buffers */ - if (us->cr) - usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, - us->cr_dma); - if (us->iobuf) - usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, - us->iobuf_dma); + /* Free the buffers */ + kfree(us->cr); + usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma); /* Remove our private data from the interface */ usb_set_intfdata(us->pusb_intf, NULL); diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 69717134231b..89d3bfff98df 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -139,8 +139,7 @@ struct us_data { struct usb_ctrlrequest *cr; /* control requests */ struct usb_sg_request current_sg; /* scatter-gather req. */ unsigned char *iobuf; /* I/O buffer */ - dma_addr_t cr_dma; /* buffer DMA addresses */ - dma_addr_t iobuf_dma; + dma_addr_t iobuf_dma; /* buffer DMA addresses */ struct task_struct *ctl_thread; /* the control thread */ /* mutual exclusion and synchronization structures */ diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 489b47833e2c..0f1595187ddb 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -473,8 +473,6 @@ static void __wa_xfer_setup_hdr0(struct wa_xfer *xfer, struct wa_xfer_ctl *xfer_ctl = container_of(xfer_hdr0, struct wa_xfer_ctl, hdr); xfer_ctl->bmAttribute = xfer->is_inbound ? 1 : 0; - BUG_ON(xfer->urb->transfer_flags & URB_NO_SETUP_DMA_MAP - && xfer->urb->setup_packet == NULL); memcpy(&xfer_ctl->baSetupData, xfer->urb->setup_packet, sizeof(xfer_ctl->baSetupData)); break; -- cgit v1.2.3 From 47ac2b5fdf5b61083584871daffae8b5803f1bfc Mon Sep 17 00:00:00 2001 From: Manuel Lauss Date: Mon, 8 Mar 2010 20:43:32 +0100 Subject: USB: ehci-au1xxx does not need EHCI IO watchdog I've been running variations of this patch for well over a year now; my usual zoo of test devices didn't trigger any ill effects even under heavy load. As a nice sideeffect idle-wakeups are reduced from 20/s to about 2/s (EHCI hub with mouse and kbd). Signed-off-by: Manuel Lauss Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-au1xxx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c index e3a74e75e822..7a27b7c4ee84 100644 --- a/drivers/usb/host/ehci-au1xxx.c +++ b/drivers/usb/host/ehci-au1xxx.c @@ -69,6 +69,15 @@ static void au1xxx_stop_ehc(void) au_sync(); } +static int au1xxx_ehci_setup(struct usb_hcd *hcd) +{ + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int ret = ehci_init(hcd); + + ehci->need_io_watchdog = 0; + return ret; +} + static const struct hc_driver ehci_au1xxx_hc_driver = { .description = hcd_name, .product_desc = "Au1xxx EHCI", @@ -86,7 +95,7 @@ static const struct hc_driver ehci_au1xxx_hc_driver = { * FIXME -- ehci_init() doesn't do enough here. * See ehci-ppc-soc for a complete implementation. */ - .reset = ehci_init, + .reset = au1xxx_ehci_setup, .start = ehci_run, .stop = ehci_stop, .shutdown = ehci_shutdown, -- cgit v1.2.3 From 7ab3f0ceb16a62a552c38bf508fb83969ad37bbf Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Mon, 8 Mar 2010 21:50:12 -0600 Subject: usb-serial: Use tty_port version console instead of usb_serial_port Replace all instances of using the console variable in struct usb_serial_port with the struct tty_port version. CC: Alan Cox CC: Alan Stern CC: Oliver Neukum CC: Andrew Morton CC: linux-usb@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Jason Wessel Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/console.c | 5 ++--- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/generic.c | 4 ++-- drivers/usb/serial/pl2303.c | 2 +- drivers/usb/serial/usb-serial.c | 4 ++-- include/linux/usb/serial.h | 2 -- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index f347da2ef00a..4ea64fef6718 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -180,7 +180,6 @@ static int usb_console_setup(struct console *co, char *options) --port->port.count; /* The console is special in terms of closing the device so * indicate this port is now acting as a system console. */ - port->console = 1; port->port.console = 1; mutex_unlock(&serial->disc_mutex); @@ -217,7 +216,7 @@ static void usb_console_write(struct console *co, dbg("%s - port %d, %d byte(s)", __func__, port->number, count); - if (!port->console) { + if (!port->port.console) { dbg("%s - port not opened", __func__); return; } @@ -313,7 +312,7 @@ void usb_serial_console_exit(void) { if (usbcons_info.port) { unregister_console(&usbcons); - usbcons_info.port->console = 0; + usbcons_info.port->port.console = 0; usbcons_info.port = NULL; } } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 1d7c4fac02e8..46a88ae9c46a 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2074,7 +2074,7 @@ static int ftdi_process_packet(struct tty_struct *tty, return 0; /* status only */ ch = packet + 2; - if (!(port->console && port->sysrq) && flag == TTY_NORMAL) + if (!(port->port.console && port->sysrq) && flag == TTY_NORMAL) tty_insert_flip_string(tty, ch, len); else { for (i = 0; i < len; i++, ch++) { diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index f804acb138ec..ba61c745df0b 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -447,7 +447,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port) /* The per character mucking around with sysrq path it too slow for stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases where the USB serial is not a console anyway */ - if (!port->console || !port->sysrq) + if (!port->port.console || !port->sysrq) tty_insert_flip_string(tty, ch, urb->actual_length); else { /* Push data to tty */ @@ -561,7 +561,7 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) int usb_serial_handle_sysrq_char(struct tty_struct *tty, struct usb_serial_port *port, unsigned int ch) { - if (port->sysrq && port->console) { + if (port->sysrq && port->port.console) { if (ch && time_before(jiffies, port->sysrq)) { handle_sysrq(ch, tty); port->sysrq = 0; diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 73d5f346d3e0..1891cfba70d3 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -1056,7 +1056,7 @@ static void pl2303_push_data(struct tty_struct *tty, if (line_status & UART_OVERRUN_ERROR) tty_insert_flip_char(tty, 0, TTY_OVERRUN); - if (tty_flag == TTY_NORMAL && !(port->console && port->sysrq)) + if (tty_flag == TTY_NORMAL && !(port->port.console && port->sysrq)) tty_insert_flip_string(tty, data, urb->actual_length); else { int i; diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 3873660d8217..f3f65171de38 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -289,7 +289,7 @@ static void serial_down(struct tty_port *tport) * The console is magical. Do not hang up the console hardware * or there will be tears. */ - if (port->console) + if (port->port.console) return; if (drv->close) drv->close(port); @@ -328,7 +328,7 @@ static void serial_cleanup(struct tty_struct *tty) /* The console is magical. Do not hang up the console hardware * or there will be tears. */ - if (port->console) + if (port->port.console) return; dbg("%s - port %d", __func__, port->number); diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 0a458b861933..b7682fed1d9c 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -66,7 +66,6 @@ enum port_dev_state { * @work: work queue entry for the line discipline waking up. * @throttled: nonzero if the read urb is inactive to throttle the device * @throttle_req: nonzero if the tty wants to throttle us - * @console: attached usb serial console * @dev: pointer to the serial device * * This structure is used by the usb-serial core and drivers for the specific @@ -106,7 +105,6 @@ struct usb_serial_port { struct work_struct work; char throttled; char throttle_req; - char console; unsigned long sysrq; /* sysrq timeout */ struct device dev; enum port_dev_state dev_state; -- cgit v1.2.3 From 6d64dba9a9ee18136bd3b9309459f5a4b7eb0195 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 12 Mar 2010 10:29:06 +0200 Subject: usb: musb: allow board to pass down fifo mode boards might want to optimize their fifo configuration to the particular needs of that specific board. Allow that by moving all related data structures to Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_core.c | 36 ++++++++++++++++-------------------- include/linux/usb/musb.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index a453bf3afbb4..b51df6622658 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -997,24 +997,13 @@ static ushort __initdata fifo_mode = 2; module_param(fifo_mode, ushort, 0); MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); - -enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed)); -enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed)); - -struct fifo_cfg { - u8 hw_ep_num; - enum fifo_style style; - enum buf_mode mode; - u16 maxpacket; -}; - /* * tables defining fifo_mode values. define more if you like. * for host side, make sure both halves of ep1 are set up. */ /* mode 0 - fits in 2KB */ -static struct fifo_cfg __initdata mode_0_cfg[] = { +static struct musb_fifo_cfg __initdata mode_0_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, @@ -1023,7 +1012,7 @@ static struct fifo_cfg __initdata mode_0_cfg[] = { }; /* mode 1 - fits in 4KB */ -static struct fifo_cfg __initdata mode_1_cfg[] = { +static struct musb_fifo_cfg __initdata mode_1_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, @@ -1032,7 +1021,7 @@ static struct fifo_cfg __initdata mode_1_cfg[] = { }; /* mode 2 - fits in 4KB */ -static struct fifo_cfg __initdata mode_2_cfg[] = { +static struct musb_fifo_cfg __initdata mode_2_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, @@ -1042,7 +1031,7 @@ static struct fifo_cfg __initdata mode_2_cfg[] = { }; /* mode 3 - fits in 4KB */ -static struct fifo_cfg __initdata mode_3_cfg[] = { +static struct musb_fifo_cfg __initdata mode_3_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, @@ -1052,7 +1041,7 @@ static struct fifo_cfg __initdata mode_3_cfg[] = { }; /* mode 4 - fits in 16KB */ -static struct fifo_cfg __initdata mode_4_cfg[] = { +static struct musb_fifo_cfg __initdata mode_4_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, @@ -1083,7 +1072,7 @@ static struct fifo_cfg __initdata mode_4_cfg[] = { }; /* mode 5 - fits in 8KB */ -static struct fifo_cfg __initdata mode_5_cfg[] = { +static struct musb_fifo_cfg __initdata mode_5_cfg[] = { { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, @@ -1121,7 +1110,7 @@ static struct fifo_cfg __initdata mode_5_cfg[] = { */ static int __init fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, - const struct fifo_cfg *cfg, u16 offset) + const struct musb_fifo_cfg *cfg, u16 offset) { void __iomem *mbase = musb->mregs; int size = 0; @@ -1192,17 +1181,23 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); } -static struct fifo_cfg __initdata ep0_cfg = { +static struct musb_fifo_cfg __initdata ep0_cfg = { .style = FIFO_RXTX, .maxpacket = 64, }; static int __init ep_config_from_table(struct musb *musb) { - const struct fifo_cfg *cfg; + const struct musb_fifo_cfg *cfg; unsigned i, n; int offset; struct musb_hw_ep *hw_ep = musb->endpoints; + if (musb->config->fifo_cfg) { + cfg = musb->config->fifo_cfg; + n = musb->config->fifo_cfg_size; + goto done; + } + switch (fifo_mode) { default: fifo_mode = 0; @@ -1237,6 +1232,7 @@ static int __init ep_config_from_table(struct musb *musb) musb_driver_name, fifo_mode); +done: offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0); /* assert(offset > 0) */ diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 7acef0234c0e..f3d68f62dae8 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -22,12 +22,47 @@ enum musb_mode { struct clk; +enum musb_fifo_style { + FIFO_RXTX, + FIFO_TX, + FIFO_RX +} __attribute__ ((packed)); + +enum musb_buf_mode { + BUF_SINGLE, + BUF_DOUBLE +} __attribute__ ((packed)); + +struct musb_fifo_cfg { + u8 hw_ep_num; + enum musb_fifo_style style; + enum musb_buf_mode mode; + u16 maxpacket; +}; + +#define MUSB_EP_FIFO(ep, st, m, pkt) \ +{ \ + .hw_ep_num = ep, \ + .style = st, \ + .mode = m, \ + .maxpacket = pkt, \ +} + +#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \ + MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt) + +#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \ + MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt) + struct musb_hdrc_eps_bits { const char name[16]; u8 bits; }; struct musb_hdrc_config { + struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */ + unsigned fifo_cfg_size; /* size of the fifo configuration */ + /* MUSB configuration-specific details */ unsigned multipoint:1; /* multipoint device */ unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */ -- cgit v1.2.3 From b66e44bd74a7a38ae241556763b3e4c81d7ad73d Mon Sep 17 00:00:00 2001 From: Maulik Mankad Date: Fri, 12 Mar 2010 10:29:07 +0200 Subject: usb: musb: Set transceiver interface type Program the OTG_INTERFSEL register based on transcevier type passed from board file. Adapt signature of musb_platform_init() function for davinci, blackfin and tusb6010. Signed-off-by: Maulik Mankad Cc: David Brownell Cc: Sergei Shtylyov Cc: Olof Johansson Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_core.c | 2 +- drivers/usb/musb/musb_core.h | 2 +- drivers/usb/musb/omap2430.c | 13 +++++++++++-- drivers/usb/musb/tusb6010.c | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index bcee1339d4fd..585b60b4df6e 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -277,7 +277,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return -EIO; } -int __init musb_platform_init(struct musb *musb) +int __init musb_platform_init(struct musb *musb, void *board_data) { /* diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 66913811af5e..39f87a95fca1 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -377,7 +377,7 @@ int musb_platform_set_mode(struct musb *musb, u8 mode) return -EIO; } -int __init musb_platform_init(struct musb *musb) +int __init musb_platform_init(struct musb *musb, void *board_data) { void __iomem *tibase = musb->ctrl_base; u32 revision; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index b51df6622658..f6ab8c1c8c65 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1949,7 +1949,7 @@ bad_config: * isp1504, non-OTG, etc) mostly hooking up through ULPI. */ musb->isr = generic_interrupt; - status = musb_platform_init(musb); + status = musb_platform_init(musb, plat->board_data); if (status < 0) goto fail; diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index cd9f4a9a06c6..a20d4636cf5b 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -608,7 +608,7 @@ extern int musb_platform_get_vbus_status(struct musb *musb); #define musb_platform_get_vbus_status(x) 0 #endif -extern int __init musb_platform_init(struct musb *musb); +extern int __init musb_platform_init(struct musb *musb, void *board_data); extern int musb_platform_exit(struct musb *musb); #endif /* __MUSB_CORE_H__ */ diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 3fe16867b5a8..dd64aebb8965 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -200,9 +200,10 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return 0; } -int __init musb_platform_init(struct musb *musb) +int __init musb_platform_init(struct musb *musb, void *board_data) { u32 l; + struct omap_musb_board_data *data = board_data; #if defined(CONFIG_ARCH_OMAP2430) omap_cfg_reg(AE5_2430_USB0HS_STP); @@ -236,7 +237,15 @@ int __init musb_platform_init(struct musb *musb) musb_writel(musb->mregs, OTG_SYSCONFIG, l); l = musb_readl(musb->mregs, OTG_INTERFSEL); - l |= ULPI_12PIN; + + if (data->interface_type == MUSB_INTERFACE_UTMI) { + /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */ + l &= ~ULPI_12PIN; /* Disable ULPI */ + l |= UTMI_8BIT; /* Enable UTMI */ + } else { + l |= ULPI_12PIN; + } + musb_writel(musb->mregs, OTG_INTERFSEL, l); pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, " diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index ab776a8d98ca..3c48e77a0aa2 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1091,7 +1091,7 @@ err: return -ENODEV; } -int __init musb_platform_init(struct musb *musb) +int __init musb_platform_init(struct musb *musb, void *board_data) { struct platform_device *pdev; struct resource *mem; -- cgit v1.2.3 From 25b8ccd097bf49b3b370ccc0f30a870bbde1824b Mon Sep 17 00:00:00 2001 From: Maulik Mankad Date: Fri, 12 Mar 2010 10:29:08 +0200 Subject: USB: MUSB: Build MUSB driver for OMAP4 This patch updates the Makefile to build the MUSB driver for OMAP4. It also sets the Kconfig options for OMAP4. Signed-off-by: Maulik Mankad Cc: David Brownell Cc: Sergei Shtylyov Cc: Olof Johansson Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/Kconfig | 6 +++++- drivers/usb/musb/Makefile | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index b4c783c284ba..5e3f3eee6a94 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -38,6 +38,7 @@ config USB_MUSB_SOC default y if ARCH_DAVINCI default y if ARCH_OMAP2430 default y if ARCH_OMAP3 + default y if ARCH_OMAP4 default y if (BF54x && !BF544) default y if (BF52x && !BF522 && !BF523) @@ -50,6 +51,9 @@ comment "OMAP 243x high speed USB support" comment "OMAP 343x high speed USB support" depends on USB_MUSB_HDRC && ARCH_OMAP3 +comment "OMAP 44xx high speed USB support" + depends on USB_MUSB_HDRC && ARCH_OMAP4 + comment "Blackfin high speed USB Support" depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523)) @@ -153,7 +157,7 @@ config MUSB_PIO_ONLY config USB_INVENTRA_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY - default ARCH_OMAP2430 || ARCH_OMAP3 || BLACKFIN + default ARCH_OMAP2430 || ARCH_OMAP3 || BLACKFIN || ARCH_OMAP4 help Enable DMA transfers using Mentor's engine. diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 85710ccc1887..6a50cb1c45e2 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -22,6 +22,10 @@ ifeq ($(CONFIG_ARCH_OMAP3430),y) musb_hdrc-objs += omap2430.o endif +ifeq ($(CONFIG_ARCH_OMAP4),y) + musb_hdrc-objs += omap2430.o +endif + ifeq ($(CONFIG_BF54x),y) musb_hdrc-objs += blackfin.o endif -- cgit v1.2.3 From a33eb3b7ab3dc24f0e3a3c2a10e8c949ccbf6155 Mon Sep 17 00:00:00 2001 From: Maulik Mankad Date: Fri, 12 Mar 2010 10:29:09 +0200 Subject: USB: MUSB: Add OMAP4 support in MUSB driver This patch adds CONFIG_ARCH_OMAP4 macro within MUSB driver. Signed-off-by: Maulik Mankad Cc: David Brownell Cc: Sergei Shtylyov Cc: Olof Johansson Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_core.c | 6 ++++-- drivers/usb/musb/musb_core.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index f6ab8c1c8c65..85d9ad7c1984 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -987,7 +987,8 @@ static void musb_shutdown(struct platform_device *pdev) * more than selecting one of a bunch of predefined configurations. */ #if defined(CONFIG_USB_TUSB6010) || \ - defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) + defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \ + || defined(CONFIG_ARCH_OMAP4) static ushort __initdata fifo_mode = 4; #else static ushort __initdata fifo_mode = 2; @@ -1458,7 +1459,8 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) /*-------------------------------------------------------------------------*/ -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) +#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) || \ + defined(CONFIG_ARCH_OMAP4) static irqreturn_t generic_interrupt(int irq, void *__hci) { diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index a20d4636cf5b..f57ecd08141c 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -213,7 +213,8 @@ enum musb_g_ep0_state { */ #if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_ARCH_OMAP2430) \ - || defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_BLACKFIN) + || defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_BLACKFIN) \ + || defined(CONFIG_ARCH_OMAP4) /* REVISIT indexed access seemed to * misbehave (on DaVinci) for at least peripheral IN ... */ @@ -596,7 +597,8 @@ extern void musb_hnp_stop(struct musb *musb); extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode); #if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \ - defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) + defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ + defined(CONFIG_ARCH_OMAP4) extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); #else #define musb_platform_try_idle(x, y) do {} while (0) -- cgit v1.2.3 From 77b554496f19db71620b8d617e2b02d7116039e3 Mon Sep 17 00:00:00 2001 From: Cliff Cai Date: Fri, 12 Mar 2010 10:29:10 +0200 Subject: USB: musb: allow the Blackfin vrsel gpio to be active low Rather than hardcoding the gpio levels for vrsel, allow the platform resources to handle this so boards can be active high or low. Signed-off-by: Cliff Cai Signed-off-by: Mike Frysinger Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 8 ++++---- include/linux/usb/musb.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 585b60b4df6e..7160959495f7 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -245,10 +245,10 @@ static void bfin_vbus_power(struct musb *musb, int is_on, int sleeping) static void bfin_set_vbus(struct musb *musb, int is_on) { - if (is_on) - gpio_set_value(musb->config->gpio_vrsel, 1); - else - gpio_set_value(musb->config->gpio_vrsel, 0); + int value = musb->config->gpio_vrsel_active; + if (!is_on) + value = !value; + gpio_set_value(musb->config->gpio_vrsel, value); DBG(1, "VBUS %s, devctl %02x " /* otg %3x conf %08x prcm %08x */ "\n", diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index f3d68f62dae8..fbb83fe21851 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -88,6 +88,7 @@ struct musb_hdrc_config { #ifdef CONFIG_BLACKFIN /* A GPIO controlling VRSEL in Blackfin */ unsigned int gpio_vrsel; + unsigned int gpio_vrsel_active; #endif }; -- cgit v1.2.3 From dbf4b42bc90228560cbee755f3c21e95fec52909 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 12 Mar 2010 10:29:11 +0200 Subject: usb: musb: add debugfs support for now only a simple register dump entry (which can be rather useful on debugging) and a way to start test modes. Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/Makefile | 4 + drivers/usb/musb/musb_core.c | 5 + drivers/usb/musb/musb_debug.h | 13 ++ drivers/usb/musb/musb_debugfs.c | 295 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 drivers/usb/musb/musb_debugfs.c diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 6a50cb1c45e2..a641a769c456 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -42,6 +42,10 @@ ifeq ($(CONFIG_USB_MUSB_HDRC_HCD),y) musb_hdrc-objs += musb_virthub.o musb_host.o endif +ifeq ($(CONFIG_DEBUG_FS),y) + musb_hdrc-objs += musb_debugfs.o +endif + # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... # PIO only, or DMA (several potential schemes). diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 85d9ad7c1984..69a1429d7bde 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2062,6 +2062,10 @@ bad_config: } + status = musb_init_debugfs(musb); + if (status < 0) + goto fail2; + #ifdef CONFIG_SYSFS status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group); #endif @@ -2147,6 +2151,7 @@ static int __exit musb_remove(struct platform_device *pdev) * - Peripheral mode: peripheral is deactivated (or never-activated) * - OTG mode: both roles are deactivated (or never-activated) */ + musb_exit_debugfs(musb); musb_shutdown(pdev); #ifdef CONFIG_USB_MUSB_HDRC_HCD if (musb->board_mode == MUSB_HOST) diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 9fc1db44c72c..d73afdbde3ee 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h @@ -59,4 +59,17 @@ static inline int _dbg_level(unsigned l) extern const char *otg_state_string(struct musb *); +#ifdef CONFIG_DEBUG_FS +extern int musb_init_debugfs(struct musb *musb); +extern void musb_exit_debugfs(struct musb *musb); +#else +static inline int musb_init_debugfs(struct musb *musb) +{ + return 0; +} +static inline void musb_exit_debugfs(struct musb *musb) +{ +} +#endif + #endif /* __MUSB_LINUX_DEBUG_H__ */ diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c new file mode 100644 index 000000000000..b6a27bab223a --- /dev/null +++ b/drivers/usb/musb/musb_debugfs.c @@ -0,0 +1,295 @@ +/* + * MUSB OTG driver debugfs support + * + * Copyright 2010 Nokia Corporation + * Contact: Felipe Balbi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_ARM +#include +#include +#include +#endif + +#include + +#include "musb_core.h" +#include "musb_debug.h" + +#ifdef CONFIG_ARCH_DAVINCI +#include "davinci.h" +#endif + +struct musb_register_map { + char *name; + unsigned offset; + unsigned size; +}; + +static const struct musb_register_map musb_regmap[] = { + { "FAddr", 0x00, 8 }, + { "Power", 0x01, 8 }, + { "Frame", 0x0c, 16 }, + { "Index", 0x0e, 8 }, + { "Testmode", 0x0f, 8 }, + { "TxMaxPp", 0x10, 16 }, + { "TxCSRp", 0x12, 16 }, + { "RxMaxPp", 0x14, 16 }, + { "RxCSR", 0x16, 16 }, + { "RxCount", 0x18, 16 }, + { "ConfigData", 0x1f, 8 }, + { "DevCtl", 0x60, 8 }, + { "MISC", 0x61, 8 }, + { "TxFIFOsz", 0x62, 8 }, + { "RxFIFOsz", 0x63, 8 }, + { "TxFIFOadd", 0x64, 16 }, + { "RxFIFOadd", 0x66, 16 }, + { "VControl", 0x68, 32 }, + { "HWVers", 0x6C, 16 }, + { "EPInfo", 0x78, 8 }, + { "RAMInfo", 0x79, 8 }, + { "LinkInfo", 0x7A, 8 }, + { "VPLen", 0x7B, 8 }, + { "HS_EOF1", 0x7C, 8 }, + { "FS_EOF1", 0x7D, 8 }, + { "LS_EOF1", 0x7E, 8 }, + { "SOFT_RST", 0x7F, 8 }, + { "DMA_CNTLch0", 0x204, 16 }, + { "DMA_ADDRch0", 0x208, 16 }, + { "DMA_COUNTch0", 0x20C, 16 }, + { "DMA_CNTLch1", 0x214, 16 }, + { "DMA_ADDRch1", 0x218, 16 }, + { "DMA_COUNTch1", 0x21C, 16 }, + { "DMA_CNTLch2", 0x224, 16 }, + { "DMA_ADDRch2", 0x228, 16 }, + { "DMA_COUNTch2", 0x22C, 16 }, + { "DMA_CNTLch3", 0x234, 16 }, + { "DMA_ADDRch3", 0x238, 16 }, + { "DMA_COUNTch3", 0x23C, 16 }, + { "DMA_CNTLch4", 0x244, 16 }, + { "DMA_ADDRch4", 0x248, 16 }, + { "DMA_COUNTch4", 0x24C, 16 }, + { "DMA_CNTLch5", 0x254, 16 }, + { "DMA_ADDRch5", 0x258, 16 }, + { "DMA_COUNTch5", 0x25C, 16 }, + { "DMA_CNTLch6", 0x264, 16 }, + { "DMA_ADDRch6", 0x268, 16 }, + { "DMA_COUNTch6", 0x26C, 16 }, + { "DMA_CNTLch7", 0x274, 16 }, + { "DMA_ADDRch7", 0x278, 16 }, + { "DMA_COUNTch7", 0x27C, 16 }, + { } /* Terminating Entry */ +}; + +static struct dentry *musb_debugfs_root; + +static int musb_regdump_show(struct seq_file *s, void *unused) +{ + struct musb *musb = s->private; + unsigned i; + + seq_printf(s, "MUSB (M)HDRC Register Dump\n"); + + for (i = 0; i < ARRAY_SIZE(musb_regmap); i++) { + switch (musb_regmap[i].size) { + case 8: + seq_printf(s, "%-12s: %02x\n", musb_regmap[i].name, + musb_readb(musb->mregs, musb_regmap[i].offset)); + break; + case 16: + seq_printf(s, "%-12s: %04x\n", musb_regmap[i].name, + musb_readw(musb->mregs, musb_regmap[i].offset)); + break; + case 32: + seq_printf(s, "%-12s: %08x\n", musb_regmap[i].name, + musb_readl(musb->mregs, musb_regmap[i].offset)); + break; + } + } + + return 0; +} + +static int musb_regdump_open(struct inode *inode, struct file *file) +{ + return single_open(file, musb_regdump_show, inode->i_private); +} + +static int musb_test_mode_show(struct seq_file *s, void *unused) +{ + struct musb *musb = s->private; + unsigned test; + + test = musb_readb(musb->mregs, MUSB_TESTMODE); + + if (test & MUSB_TEST_FORCE_HOST) + seq_printf(s, "force host\n"); + + if (test & MUSB_TEST_FIFO_ACCESS) + seq_printf(s, "fifo access\n"); + + if (test & MUSB_TEST_FORCE_FS) + seq_printf(s, "force full-speed\n"); + + if (test & MUSB_TEST_FORCE_HS) + seq_printf(s, "force high-speed\n"); + + if (test & MUSB_TEST_PACKET) + seq_printf(s, "test packet\n"); + + if (test & MUSB_TEST_K) + seq_printf(s, "test K\n"); + + if (test & MUSB_TEST_J) + seq_printf(s, "test J\n"); + + if (test & MUSB_TEST_SE0_NAK) + seq_printf(s, "test SE0 NAK\n"); + + return 0; +} + +static const struct file_operations musb_regdump_fops = { + .open = musb_regdump_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int musb_test_mode_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + + return single_open(file, musb_test_mode_show, inode->i_private); +} + +static ssize_t musb_test_mode_write(struct file *file, + const char __user *ubuf, size_t count, loff_t *ppos) +{ + struct musb *musb = file->private_data; + u8 test = 0; + char buf[18]; + + memset(buf, 0x00, sizeof(buf)); + + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) + return -EFAULT; + + if (!strncmp(buf, "force host", 9)) + test = MUSB_TEST_FORCE_HOST; + + if (!strncmp(buf, "fifo access", 11)) + test = MUSB_TEST_FIFO_ACCESS; + + if (!strncmp(buf, "force full-speed", 15)) + test = MUSB_TEST_FORCE_FS; + + if (!strncmp(buf, "force high-speed", 15)) + test = MUSB_TEST_FORCE_HS; + + if (!strncmp(buf, "test packet", 10)) { + test = MUSB_TEST_PACKET; + musb_load_testpacket(musb); + } + + if (!strncmp(buf, "test K", 6)) + test = MUSB_TEST_K; + + if (!strncmp(buf, "test J", 6)) + test = MUSB_TEST_J; + + if (!strncmp(buf, "test SE0 NAK", 12)) + test = MUSB_TEST_SE0_NAK; + + musb_writeb(musb->mregs, MUSB_TESTMODE, test); + + return count; +} + +static const struct file_operations musb_test_mode_fops = { + .open = musb_test_mode_open, + .write = musb_test_mode_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +int __init musb_init_debugfs(struct musb *musb) +{ + struct dentry *root; + struct dentry *file; + int ret; + + root = debugfs_create_dir("musb", NULL); + if (IS_ERR(root)) { + ret = PTR_ERR(root); + goto err0; + } + + file = debugfs_create_file("regdump", S_IRUGO, root, musb, + &musb_regdump_fops); + if (IS_ERR(file)) { + ret = PTR_ERR(file); + goto err1; + } + + file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, + root, musb, &musb_test_mode_fops); + if (IS_ERR(file)) { + ret = PTR_ERR(file); + goto err1; + } + + musb_debugfs_root = root; + + return 0; + +err1: + debugfs_remove_recursive(root); + +err0: + return ret; +} + +void __exit musb_exit_debugfs(struct musb *musb) +{ + debugfs_remove_recursive(musb_debugfs_root); +} -- cgit v1.2.3 From 282699daaa7783a3cd804912dee9adea62976cbc Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 12 Mar 2010 10:29:12 +0200 Subject: usb: musb: gadget: support musb-specific test modes we can support the musb-specific test modes on the vendor specific range of test selector as stated on USB Specification Table 9-7 Test Mode Selectors. Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_gadget_ep0.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 53d06451f820..21b9788d0243 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -351,6 +351,31 @@ __acquires(musb->lock) musb->test_mode_nr = MUSB_TEST_PACKET; break; + + case 0xc0: + /* TEST_FORCE_HS */ + pr_debug("TEST_FORCE_HS\n"); + musb->test_mode_nr = + MUSB_TEST_FORCE_HS; + break; + case 0xc1: + /* TEST_FORCE_FS */ + pr_debug("TEST_FORCE_FS\n"); + musb->test_mode_nr = + MUSB_TEST_FORCE_FS; + break; + case 0xc2: + /* TEST_FIFO_ACCESS */ + pr_debug("TEST_FIFO_ACCESS\n"); + musb->test_mode_nr = + MUSB_TEST_FIFO_ACCESS; + break; + case 0xc3: + /* TEST_FORCE_HOST */ + pr_debug("TEST_FORCE_HOST\n"); + musb->test_mode_nr = + MUSB_TEST_FORCE_HOST; + break; default: goto stall; } -- cgit v1.2.3 From 47e40ceac6b2d181e8143d4d0e2d952dfc5a017a Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 12 Mar 2010 10:29:13 +0200 Subject: usb: musb: hsdma: use musb_read/writel ... and simplify the was we read/write from/to DMA COUNT register. Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musbhsdma.h | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h index 613f95a058f7..f763d62f151c 100644 --- a/drivers/usb/musb/musbhsdma.h +++ b/drivers/usb/musb/musbhsdma.h @@ -102,26 +102,16 @@ static inline void musb_write_hsdma_addr(void __iomem *mbase, static inline u32 musb_read_hsdma_count(void __iomem *mbase, u8 bchannel) { - u32 count = musb_readw(mbase, + return musb_readl(mbase, MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_HIGH)); - - count = count << 16; - - count |= musb_readw(mbase, - MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_LOW)); - - return count; } static inline void musb_write_hsdma_count(void __iomem *mbase, u8 bchannel, u32 len) { - musb_writew(mbase, - MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_LOW), - ((u16)((u32) len & 0xFFFF))); - musb_writew(mbase, + musb_writel(mbase, MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_HIGH), - ((u16)(((u32) len >> 16) & 0xFFFF))); + len); } #endif /* CONFIG_BLACKFIN */ -- cgit v1.2.3 From 7454dd142849577e1ddffb6d44fd7672755bd8f1 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Mon, 15 Mar 2010 21:38:31 +0100 Subject: USB: f_mass_storage: dynamic buffers for better alignment "Static" buffers in fsg_buffhd structure (ie. fields which are arrays rather then pointers to dynamically allocated memory) are not aligned to any "big" power of two which may lead to poor DMA performance (copying "by hand" of head or tail) or no DMA at all even if otherwise hardware supports it. Therefore, this patch makes mass storage function use kmalloc()ed buffers which are (because of their size) page aligned (which should be enough for any hardware). Signed-off-by: Michal Nazarewicz Cc: Kyungmin Park Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/f_mass_storage.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index f4911c09022e..218f51db9721 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -302,7 +302,6 @@ static const char fsg_string_interface[] = "Mass Storage"; #define FSG_NO_INTR_EP 1 -#define FSG_BUFFHD_STATIC_BUFFER 1 #define FSG_NO_DEVICE_STRINGS 1 #define FSG_NO_OTG 1 #define FSG_NO_INTR_EP 1 @@ -2762,13 +2761,19 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, /* Data buffers cyclic list */ - /* Buffers in buffhds are static -- no need for additional - * allocation. */ bh = common->buffhds; - i = FSG_NUM_BUFFERS - 1; + i = FSG_NUM_BUFFERS; + goto buffhds_first_it; do { bh->next = bh + 1; - } while (++bh, --i); + ++bh; +buffhds_first_it: + bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + if (unlikely(!bh->buf)) { + rc = -ENOMEM; + goto error_release; + } + } while (--i); bh->next = common->buffhds; @@ -2871,6 +2876,7 @@ static void fsg_common_release(struct kref *ref) container_of(ref, struct fsg_common, ref); unsigned i = common->nluns; struct fsg_lun *lun = common->luns; + struct fsg_buffhd *bh; /* If the thread isn't already dead, tell it to exit now */ if (common->state != FSG_STATE_TERMINATED) { @@ -2892,6 +2898,13 @@ static void fsg_common_release(struct kref *ref) } kfree(common->luns); + + i = FSG_NUM_BUFFERS; + bh = common->buffhds; + do { + kfree(bh->buf); + } while (++bh, --i); + if (common->free_storage_on_release) kfree(common); } -- cgit v1.2.3 From f8c027a27412ddcbf8c754e80b71061eb894c0b8 Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Tue, 16 Mar 2010 16:05:44 -0500 Subject: usb-console: pass baud from console to the initial tty open The usb console code has had a long standing problem of not being able to pass the baud rate from the kernel argument console=ttyUSB0,BAUD down to the initial tty open, unless you were willing to settle for 9600 baud. The solution is to directly use tty_init_termios() in usb_console_setup() as this will preserve any changes to the initial termios setting on future opens. CC: Alan Cox CC: Alan Stern Signed-off-by: Jason Wessel Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/console.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 4ea64fef6718..1ee6b2ab0f89 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -66,7 +66,7 @@ static int usb_console_setup(struct console *co, char *options) struct usb_serial_port *port; int retval; struct tty_struct *tty = NULL; - struct ktermios *termios = NULL, dummy; + struct ktermios dummy; dbg("%s", __func__); @@ -141,15 +141,14 @@ static int usb_console_setup(struct console *co, char *options) goto reset_open_count; } kref_init(&tty->kref); - termios = kzalloc(sizeof(*termios), GFP_KERNEL); - if (!termios) { + tty_port_tty_set(&port->port, tty); + tty->driver = usb_serial_tty_driver; + tty->index = co->index; + if (tty_init_termios(tty)) { retval = -ENOMEM; err("no more memory"); goto free_tty; } - memset(&dummy, 0, sizeof(struct ktermios)); - tty->termios = termios; - tty_port_tty_set(&port->port, tty); } /* only call the device specific open if this @@ -161,16 +160,16 @@ static int usb_console_setup(struct console *co, char *options) if (retval) { err("could not open USB console port"); - goto free_termios; + goto fail; } if (serial->type->set_termios) { - termios->c_cflag = cflag; - tty_termios_encode_baud_rate(termios, baud, baud); + tty->termios->c_cflag = cflag; + tty_termios_encode_baud_rate(tty->termios, baud, baud); + memset(&dummy, 0, sizeof(struct ktermios)); serial->type->set_termios(tty, port, &dummy); tty_port_tty_set(&port->port, NULL); - kfree(termios); kfree(tty); } set_bit(ASYNCB_INITIALIZED, &port->port.flags); @@ -185,8 +184,7 @@ static int usb_console_setup(struct console *co, char *options) mutex_unlock(&serial->disc_mutex); return retval; - free_termios: - kfree(termios); + fail: tty_port_tty_set(&port->port, NULL); free_tty: kfree(tty); -- cgit v1.2.3