aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7720.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/mos7720.c')
-rw-r--r--drivers/usb/serial/mos7720.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 19bf403f9db2..b563e2ad8728 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -103,11 +103,9 @@ static void mos7720_interrupt_callback(struct urb *urb)
103{ 103{
104 int result; 104 int result;
105 int length; 105 int length;
106 __u32 *data; 106 __u8 *data;
107 unsigned int status;
108 __u8 sp1; 107 __u8 sp1;
109 __u8 sp2; 108 __u8 sp2;
110 __u8 st;
111 109
112 dbg("%s"," : Entering\n"); 110 dbg("%s"," : Entering\n");
113 111
@@ -141,18 +139,19 @@ static void mos7720_interrupt_callback(struct urb *urb)
141 * Byte 2 IIR Port 2 (port.number is 1) 139 * Byte 2 IIR Port 2 (port.number is 1)
142 * Byte 3 -------------- 140 * Byte 3 --------------
143 * Byte 4 FIFO status for both */ 141 * Byte 4 FIFO status for both */
144 if (length && length > 4) { 142
143 /* the above description is inverted
144 * oneukum 2007-03-14 */
145
146 if (unlikely(length != 4)) {
145 dbg("Wrong data !!!"); 147 dbg("Wrong data !!!");
146 return; 148 return;
147 } 149 }
148 150
149 status = *data; 151 sp1 = data[3];
150 152 sp2 = data[2];
151 sp1 = (status & 0xff000000)>>24;
152 sp2 = (status & 0x00ff0000)>>16;
153 st = status & 0x000000ff;
154 153
155 if ((sp1 & 0x01) || (sp2 & 0x01)) { 154 if ((sp1 | sp2) & 0x01) {
156 /* No Interrupt Pending in both the ports */ 155 /* No Interrupt Pending in both the ports */
157 dbg("No Interrupt !!!"); 156 dbg("No Interrupt !!!");
158 } else { 157 } else {
@@ -333,6 +332,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
333 int response; 332 int response;
334 int port_number; 333 int port_number;
335 char data; 334 char data;
335 int allocated_urbs = 0;
336 int j; 336 int j;
337 337
338 serial = port->serial; 338 serial = port->serial;
@@ -353,7 +353,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
353 353
354 /* Initialising the write urb pool */ 354 /* Initialising the write urb pool */
355 for (j = 0; j < NUM_URBS; ++j) { 355 for (j = 0; j < NUM_URBS; ++j) {
356 urb = usb_alloc_urb(0,GFP_ATOMIC); 356 urb = usb_alloc_urb(0,GFP_KERNEL);
357 mos7720_port->write_urb_pool[j] = urb; 357 mos7720_port->write_urb_pool[j] = urb;
358 358
359 if (urb == NULL) { 359 if (urb == NULL) {
@@ -365,10 +365,16 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
365 GFP_KERNEL); 365 GFP_KERNEL);
366 if (!urb->transfer_buffer) { 366 if (!urb->transfer_buffer) {
367 err("%s-out of memory for urb buffers.", __FUNCTION__); 367 err("%s-out of memory for urb buffers.", __FUNCTION__);
368 usb_free_urb(mos7720_port->write_urb_pool[j]);
369 mos7720_port->write_urb_pool[j] = NULL;
368 continue; 370 continue;
369 } 371 }
372 allocated_urbs++;
370 } 373 }
371 374
375 if (!allocated_urbs)
376 return -ENOMEM;
377
372 /* Initialize MCS7720 -- Write Init values to corresponding Registers 378 /* Initialize MCS7720 -- Write Init values to corresponding Registers
373 * 379 *
374 * Register Index 380 * Register Index
@@ -526,7 +532,7 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
526 } 532 }
527 533
528 for (i = 0; i < NUM_URBS; ++i) { 534 for (i = 0; i < NUM_URBS; ++i) {
529 if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) 535 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
530 chars += URB_TRANSFER_BUFFER_SIZE; 536 chars += URB_TRANSFER_BUFFER_SIZE;
531 } 537 }
532 dbg("%s - returns %d", __FUNCTION__, chars); 538 dbg("%s - returns %d", __FUNCTION__, chars);
@@ -629,7 +635,7 @@ static int mos7720_write_room(struct usb_serial_port *port)
629 } 635 }
630 636
631 for (i = 0; i < NUM_URBS; ++i) { 637 for (i = 0; i < NUM_URBS; ++i) {
632 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) 638 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
633 room += URB_TRANSFER_BUFFER_SIZE; 639 room += URB_TRANSFER_BUFFER_SIZE;
634 } 640 }
635 641
@@ -664,7 +670,7 @@ static int mos7720_write(struct usb_serial_port *port,
664 urb = NULL; 670 urb = NULL;
665 671
666 for (i = 0; i < NUM_URBS; ++i) { 672 for (i = 0; i < NUM_URBS; ++i) {
667 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { 673 if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
668 urb = mos7720_port->write_urb_pool[i]; 674 urb = mos7720_port->write_urb_pool[i];
669 dbg("URB:%d",i); 675 dbg("URB:%d",i);
670 break; 676 break;