Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287042
b: refs/heads/master
c: 7c24814
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Jan 25, 2012
1 parent f3e93c1 commit 1a8ef0b
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 94 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b30b3c60a25a4afbc49167ecb6210c291178ee5f
refs/heads/master: 7c24814f7eb9a194b11507b43ca0b947415754c2
59 changes: 38 additions & 21 deletions trunk/drivers/usb/class/cdc-wdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);

#define WDM_MAX 16

/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
#define WDM_DEFAULT_BUFSIZE 256

static DEFINE_MUTEX(wdm_mutex);

Expand Down Expand Up @@ -88,7 +90,8 @@ struct wdm_device {
int count;
dma_addr_t shandle;
dma_addr_t ihandle;
struct mutex lock;
struct mutex wlock;
struct mutex rlock;
wait_queue_head_t wait;
struct work_struct rxwork;
int werr;
Expand Down Expand Up @@ -323,7 +326,7 @@ static ssize_t wdm_write
}

/* concurrent writes and disconnect */
r = mutex_lock_interruptible(&desc->lock);
r = mutex_lock_interruptible(&desc->wlock);
rv = -ERESTARTSYS;
if (r) {
kfree(buf);
Expand Down Expand Up @@ -386,7 +389,7 @@ static ssize_t wdm_write
out:
usb_autopm_put_interface(desc->intf);
outnp:
mutex_unlock(&desc->lock);
mutex_unlock(&desc->wlock);
outnl:
return rv < 0 ? rv : count;
}
Expand All @@ -399,7 +402,7 @@ static ssize_t wdm_read
struct wdm_device *desc = file->private_data;


rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */
rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
if (rv < 0)
return -ERESTARTSYS;

Expand Down Expand Up @@ -467,14 +470,16 @@ static ssize_t wdm_read
for (i = 0; i < desc->length - cntr; i++)
desc->ubuf[i] = desc->ubuf[i + cntr];

spin_lock_irq(&desc->iuspin);
desc->length -= cntr;
spin_unlock_irq(&desc->iuspin);
/* in case we had outstanding data */
if (!desc->length)
clear_bit(WDM_READ, &desc->flags);
rv = cntr;

err:
mutex_unlock(&desc->lock);
mutex_unlock(&desc->rlock);
return rv;
}

Expand Down Expand Up @@ -540,7 +545,8 @@ static int wdm_open(struct inode *inode, struct file *file)
}
intf->needs_remote_wakeup = 1;

mutex_lock(&desc->lock);
/* using write lock to protect desc->count */
mutex_lock(&desc->wlock);
if (!desc->count++) {
desc->werr = 0;
desc->rerr = 0;
Expand All @@ -553,7 +559,7 @@ static int wdm_open(struct inode *inode, struct file *file)
} else {
rv = 0;
}
mutex_unlock(&desc->lock);
mutex_unlock(&desc->wlock);
usb_autopm_put_interface(desc->intf);
out:
mutex_unlock(&wdm_mutex);
Expand All @@ -565,9 +571,11 @@ static int wdm_release(struct inode *inode, struct file *file)
struct wdm_device *desc = file->private_data;

mutex_lock(&wdm_mutex);
mutex_lock(&desc->lock);

/* using write lock to protect desc->count */
mutex_lock(&desc->wlock);
desc->count--;
mutex_unlock(&desc->lock);
mutex_unlock(&desc->wlock);

if (!desc->count) {
dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
Expand Down Expand Up @@ -630,7 +638,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
struct usb_cdc_dmm_desc *dmhd;
u8 *buffer = intf->altsetting->extra;
int buflen = intf->altsetting->extralen;
u16 maxcom = 0;
u16 maxcom = WDM_DEFAULT_BUFSIZE;

if (!buffer)
goto out;
Expand Down Expand Up @@ -665,7 +673,8 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
if (!desc)
goto out;
mutex_init(&desc->lock);
mutex_init(&desc->rlock);
mutex_init(&desc->wlock);
spin_lock_init(&desc->iuspin);
init_waitqueue_head(&desc->wait);
desc->wMaxCommand = maxcom;
Expand Down Expand Up @@ -716,7 +725,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
goto err;

desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf),
desc->bMaxPacketSize0,
desc->wMaxCommand,
GFP_KERNEL,
&desc->response->transfer_dma);
if (!desc->inbuf)
Expand Down Expand Up @@ -779,11 +788,13 @@ static void wdm_disconnect(struct usb_interface *intf)
/* to terminate pending flushes */
clear_bit(WDM_IN_USE, &desc->flags);
spin_unlock_irqrestore(&desc->iuspin, flags);
mutex_lock(&desc->lock);
wake_up_all(&desc->wait);
mutex_lock(&desc->rlock);
mutex_lock(&desc->wlock);
kill_urbs(desc);
cancel_work_sync(&desc->rxwork);
mutex_unlock(&desc->lock);
wake_up_all(&desc->wait);
mutex_unlock(&desc->wlock);
mutex_unlock(&desc->rlock);
if (!desc->count)
cleanup(desc);
mutex_unlock(&wdm_mutex);
Expand All @@ -798,8 +809,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);

/* if this is an autosuspend the caller does the locking */
if (!PMSG_IS_AUTO(message))
mutex_lock(&desc->lock);
if (!PMSG_IS_AUTO(message)) {
mutex_lock(&desc->rlock);
mutex_lock(&desc->wlock);
}
spin_lock_irq(&desc->iuspin);

if (PMSG_IS_AUTO(message) &&
Expand All @@ -815,8 +828,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
kill_urbs(desc);
cancel_work_sync(&desc->rxwork);
}
if (!PMSG_IS_AUTO(message))
mutex_unlock(&desc->lock);
if (!PMSG_IS_AUTO(message)) {
mutex_unlock(&desc->wlock);
mutex_unlock(&desc->rlock);
}

return rv;
}
Expand Down Expand Up @@ -854,7 +869,8 @@ static int wdm_pre_reset(struct usb_interface *intf)
{
struct wdm_device *desc = usb_get_intfdata(intf);

mutex_lock(&desc->lock);
mutex_lock(&desc->rlock);
mutex_lock(&desc->wlock);
kill_urbs(desc);

/*
Expand All @@ -876,7 +892,8 @@ static int wdm_post_reset(struct usb_interface *intf)
int rv;

rv = recover_from_urb_loss(desc);
mutex_unlock(&desc->lock);
mutex_unlock(&desc->wlock);
mutex_unlock(&desc->rlock);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/host/ehci-fsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
*/
if (pdata->init && pdata->init(pdev)) {
retval = -ENODEV;
goto err3;
goto err4;
}

/* Enable USB controller, 83xx or 8536 */
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/usb/host/ehci-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ static int ehci_pci_setup(struct usb_hcd *hcd)

/* Serial Bus Release Number is at PCI 0x60 offset */
pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
if (pdev->vendor == PCI_VENDOR_ID_STMICRO
&& pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST)
ehci->sbrn = 0x20; /* ConneXT has no sbrn register */

/* Keep this around for a while just in case some EHCI
* implementation uses legacy PCI PM support. This test
Expand Down Expand Up @@ -526,6 +529,9 @@ static const struct pci_device_id pci_ids [] = { {
/* handle any USB 2.0 EHCI controller */
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
.driver_data = (unsigned long) &ehci_pci_hc_driver,
}, {
PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
.driver_data = (unsigned long) &ehci_pci_hc_driver,
},
{ /* end: all zeroes */ }
};
Expand Down
12 changes: 10 additions & 2 deletions trunk/drivers/usb/host/ohci-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ urb_print(struct urb * urb, char * str, int small, int status)
ohci_dbg(ohci,format, ## arg ); \
} while (0);

/* Version for use where "next" is the address of a local variable */
#define ohci_dbg_nosw(ohci, next, size, format, arg...) \
do { \
unsigned s_len; \
s_len = scnprintf(*next, *size, format, ## arg); \
*size -= s_len; *next += s_len; \
} while (0);


static void ohci_dump_intr_mask (
struct ohci_hcd *ohci,
Expand Down Expand Up @@ -653,7 +661,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)

/* dump driver info, then registers in spec order */

ohci_dbg_sw (ohci, &next, &size,
ohci_dbg_nosw(ohci, &next, &size,
"bus %s, device %s\n"
"%s\n"
"%s\n",
Expand All @@ -672,7 +680,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)

/* hcca */
if (ohci->hcca)
ohci_dbg_sw (ohci, &next, &size,
ohci_dbg_nosw(ohci, &next, &size,
"hcca frame 0x%04x\n", ohci_frame_no(ohci));

/* other registers mostly affect frame timings */
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/usb/host/ohci-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ static const struct pci_device_id pci_ids [] = { {
/* handle any USB OHCI controller */
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0),
.driver_data = (unsigned long) &ohci_pci_hc_driver,
}, {
/* The device in the ConneXT I/O hub has no class reg */
PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI),
.driver_data = (unsigned long) &ohci_pci_hc_driver,
}, { /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE (pci, pci_ids);
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/usb/host/xhci-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
*
* Returns a zero-based port number, which is suitable for indexing into each of
* the split roothubs' port arrays and bus state arrays.
* Add one to it in order to call xhci_find_slot_id_by_port.
*/
static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
struct xhci_hcd *xhci, u32 port_id)
Expand Down Expand Up @@ -1324,7 +1325,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
xhci_set_link_state(xhci, port_array, faked_port_index,
XDEV_U0);
slot_id = xhci_find_slot_id_by_port(hcd, xhci,
faked_port_index);
faked_port_index + 1);
if (!slot_id) {
xhci_dbg(xhci, "slot_id is zero\n");
goto cleanup;
Expand Down
3 changes: 0 additions & 3 deletions trunk/drivers/usb/misc/emi26.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit);
static int emi26_load_firmware (struct usb_device *dev);
static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id);
static void emi26_disconnect(struct usb_interface *intf);
static int __init emi26_init (void);
static void __exit emi26_exit (void);


/* thanks to drivers/usb/serial/keyspan_pda.c code */
static int emi26_writememory (struct usb_device *dev, int address,
Expand Down
3 changes: 0 additions & 3 deletions trunk/drivers/usb/misc/emi62.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit);
static int emi62_load_firmware (struct usb_device *dev);
static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id);
static void emi62_disconnect(struct usb_interface *intf);
static int __init emi62_init (void);
static void __exit emi62_exit (void);


/* thanks to drivers/usb/serial/keyspan_pda.c code */
static int emi62_writememory(struct usb_device *dev, int address,
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/misc/usbsevseg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define VENDOR_ID 0x0fc5
#define PRODUCT_ID 0x1227
#define MAXLEN 6
#define MAXLEN 8

/* table of devices that work with this driver */
static const struct usb_device_id id_table[] = {
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/usb/otg/mv_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)

static void mv_otg_start_host(struct mv_otg *mvotg, int on)
{
#ifdef CONFIG_USB
struct otg_transceiver *otg = &mvotg->otg;
struct usb_hcd *hcd;

Expand All @@ -216,6 +217,7 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
else
usb_remove_hcd(hcd);
#endif /* CONFIG_USB */
}

static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
Expand Down
Loading

0 comments on commit 1a8ef0b

Please sign in to comment.