aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ssu100.c
diff options
context:
space:
mode:
authorBill Pemberton <wfp5p@virginia.edu>2010-08-05 17:01:05 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-23 23:50:15 -0400
commit175230587bcca6dee0a1d6832a8a2138e32ab6ab (patch)
treeee5632466b6d4558749fc7c36dbd144c66b4e781 /drivers/usb/serial/ssu100.c
parent96f2a34d2cec71d59014be9ecd7a038435e88584 (diff)
USB: ssu100: add locking for port private data in ssu100
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/ssu100.c')
-rw-r--r--drivers/usb/serial/ssu100.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 6e82d4f54bc8..2826f013752d 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -99,6 +99,7 @@ static struct usb_driver ssu100_driver = {
99}; 99};
100 100
101struct ssu100_port_private { 101struct ssu100_port_private {
102 spinlock_t status_lock;
102 u8 shadowLSR; 103 u8 shadowLSR;
103 u8 shadowMSR; 104 u8 shadowMSR;
104 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 105 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
@@ -333,6 +334,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
333 struct ssu100_port_private *priv = usb_get_serial_port_data(port); 334 struct ssu100_port_private *priv = usb_get_serial_port_data(port);
334 u8 *data; 335 u8 *data;
335 int result; 336 int result;
337 unsigned long flags;
336 338
337 dbg("%s - port %d", __func__, port->number); 339 dbg("%s - port %d", __func__, port->number);
338 340
@@ -350,11 +352,13 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
350 return result; 352 return result;
351 } 353 }
352 354
355 spin_lock_irqsave(&priv->status_lock, flags);
353 priv->shadowLSR = data[0] & (SERIAL_LSR_OE | SERIAL_LSR_PE | 356 priv->shadowLSR = data[0] & (SERIAL_LSR_OE | SERIAL_LSR_PE |
354 SERIAL_LSR_FE | SERIAL_LSR_BI); 357 SERIAL_LSR_FE | SERIAL_LSR_BI);
355 358
356 priv->shadowMSR = data[1] & (SERIAL_MSR_CTS | SERIAL_MSR_DSR | 359 priv->shadowMSR = data[1] & (SERIAL_MSR_CTS | SERIAL_MSR_DSR |
357 SERIAL_MSR_RI | SERIAL_MSR_CD); 360 SERIAL_MSR_RI | SERIAL_MSR_CD);
361 spin_unlock_irqrestore(&priv->status_lock, flags);
358 362
359 kfree(data); 363 kfree(data);
360 364
@@ -455,6 +459,7 @@ static void ssu100_set_max_packet_size(struct usb_serial_port *port)
455 459
456 unsigned num_endpoints; 460 unsigned num_endpoints;
457 int i; 461 int i;
462 unsigned long flags;
458 463
459 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; 464 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
460 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); 465 dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
@@ -466,7 +471,9 @@ static void ssu100_set_max_packet_size(struct usb_serial_port *port)
466 } 471 }
467 472
468 /* set max packet size based on descriptor */ 473 /* set max packet size based on descriptor */
474 spin_lock_irqsave(&priv->status_lock, flags);
469 priv->max_packet_size = ep_desc->wMaxPacketSize; 475 priv->max_packet_size = ep_desc->wMaxPacketSize;
476 spin_unlock_irqrestore(&priv->status_lock, flags);
470 477
471 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size); 478 dev_info(&udev->dev, "Setting MaxPacketSize %d\n", priv->max_packet_size);
472} 479}
@@ -485,9 +492,9 @@ static int ssu100_attach(struct usb_serial *serial)
485 return -ENOMEM; 492 return -ENOMEM;
486 } 493 }
487 494
495 spin_lock_init(&priv->status_lock);
488 init_waitqueue_head(&priv->delta_msr_wait); 496 init_waitqueue_head(&priv->delta_msr_wait);
489 usb_set_serial_port_data(port, priv); 497 usb_set_serial_port_data(port, priv);
490
491 ssu100_set_max_packet_size(port); 498 ssu100_set_max_packet_size(port);
492 499
493 return ssu100_initdevice(serial->dev); 500 return ssu100_initdevice(serial->dev);