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.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 439c951f261b..4eb277225a77 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * mos7720.c 2 * mos7720.c
3 * Controls the Moschip 7720 usb to dual port serial convertor 3 * Controls the Moschip 7720 usb to dual port serial converter
4 * 4 *
5 * Copyright 2006 Moschip Semiconductor Tech. Ltd. 5 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
6 * 6 *
@@ -22,7 +22,6 @@
22 */ 22 */
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/tty.h> 26#include <linux/tty.h>
28#include <linux/tty_driver.h> 27#include <linux/tty_driver.h>
@@ -46,7 +45,7 @@
46#define MOS_WRITE 0x0E 45#define MOS_WRITE 0x0E
47#define MOS_READ 0x0D 46#define MOS_READ 0x0D
48 47
49/* Interrupt Rotinue Defines */ 48/* Interrupt Routines Defines */
50#define SERIAL_IIR_RLS 0x06 49#define SERIAL_IIR_RLS 0x06
51#define SERIAL_IIR_RDA 0x04 50#define SERIAL_IIR_RDA 0x04
52#define SERIAL_IIR_CTI 0x0c 51#define SERIAL_IIR_CTI 0x0c
@@ -362,15 +361,13 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
362 361
363 /* create and initialize the control urb and containing urbtracker */ 362 /* create and initialize the control urb and containing urbtracker */
364 urbtrack = kmalloc(sizeof(struct urbtracker), GFP_ATOMIC); 363 urbtrack = kmalloc(sizeof(struct urbtracker), GFP_ATOMIC);
365 if (urbtrack == NULL) { 364 if (!urbtrack)
366 dev_err(&usbdev->dev, "out of memory");
367 return -ENOMEM; 365 return -ENOMEM;
368 } 366
369 kref_get(&mos_parport->ref_count); 367 kref_get(&mos_parport->ref_count);
370 urbtrack->mos_parport = mos_parport; 368 urbtrack->mos_parport = mos_parport;
371 urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC); 369 urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC);
372 if (urbtrack->urb == NULL) { 370 if (!urbtrack->urb) {
373 dev_err(&usbdev->dev, "out of urbs");
374 kfree(urbtrack); 371 kfree(urbtrack);
375 return -ENOMEM; 372 return -ENOMEM;
376 } 373 }
@@ -440,7 +437,7 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
440 * not called the release function yet because someone has a serial port open. 437 * not called the release function yet because someone has a serial port open.
441 * The shared release_lock prevents the first, and the mutex and disconnected 438 * The shared release_lock prevents the first, and the mutex and disconnected
442 * flag maintained by usbserial covers the second. We also use the msg_pending 439 * flag maintained by usbserial covers the second. We also use the msg_pending
443 * flag to ensure that all synchronous usb messgage calls have completed before 440 * flag to ensure that all synchronous usb message calls have completed before
444 * our release function can return. 441 * our release function can return.
445 */ 442 */
446static int parport_prologue(struct parport *pp) 443static int parport_prologue(struct parport *pp)
@@ -471,7 +468,7 @@ static int parport_prologue(struct parport *pp)
471} 468}
472 469
473/* 470/*
474 * This is the the common bottom part of all parallel port functions that send 471 * This is the common bottom part of all parallel port functions that send
475 * synchronous messages to the device. 472 * synchronous messages to the device.
476 */ 473 */
477static inline void parport_epilogue(struct parport *pp) 474static inline void parport_epilogue(struct parport *pp)
@@ -702,10 +699,9 @@ static int mos7715_parport_init(struct usb_serial *serial)
702 699
703 /* allocate and initialize parallel port control struct */ 700 /* allocate and initialize parallel port control struct */
704 mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL); 701 mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL);
705 if (mos_parport == NULL) { 702 if (!mos_parport)
706 dev_dbg(&serial->dev->dev, "%s: kzalloc failed\n", __func__);
707 return -ENOMEM; 703 return -ENOMEM;
708 } 704
709 mos_parport->msg_pending = false; 705 mos_parport->msg_pending = false;
710 kref_init(&mos_parport->ref_count); 706 kref_init(&mos_parport->ref_count);
711 spin_lock_init(&mos_parport->listlock); 707 spin_lock_init(&mos_parport->listlock);
@@ -1018,18 +1014,12 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port)
1018 for (j = 0; j < NUM_URBS; ++j) { 1014 for (j = 0; j < NUM_URBS; ++j) {
1019 urb = usb_alloc_urb(0, GFP_KERNEL); 1015 urb = usb_alloc_urb(0, GFP_KERNEL);
1020 mos7720_port->write_urb_pool[j] = urb; 1016 mos7720_port->write_urb_pool[j] = urb;
1021 1017 if (!urb)
1022 if (urb == NULL) {
1023 dev_err(&port->dev, "No more urbs???\n");
1024 continue; 1018 continue;
1025 }
1026 1019
1027 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 1020 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
1028 GFP_KERNEL); 1021 GFP_KERNEL);
1029 if (!urb->transfer_buffer) { 1022 if (!urb->transfer_buffer) {
1030 dev_err(&port->dev,
1031 "%s-out of memory for urb buffers.\n",
1032 __func__);
1033 usb_free_urb(mos7720_port->write_urb_pool[j]); 1023 usb_free_urb(mos7720_port->write_urb_pool[j]);
1034 mos7720_port->write_urb_pool[j] = NULL; 1024 mos7720_port->write_urb_pool[j] = NULL;
1035 continue; 1025 continue;
@@ -1250,11 +1240,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
1250 if (urb->transfer_buffer == NULL) { 1240 if (urb->transfer_buffer == NULL) {
1251 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 1241 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
1252 GFP_KERNEL); 1242 GFP_KERNEL);
1253 if (urb->transfer_buffer == NULL) { 1243 if (!urb->transfer_buffer)
1254 dev_err_console(port, "%s no more kernel memory...\n",
1255 __func__);
1256 goto exit; 1244 goto exit;
1257 }
1258 } 1245 }
1259 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); 1246 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1260 1247
@@ -1885,8 +1872,6 @@ static int mos7720_ioctl(struct tty_struct *tty,
1885 if (mos7720_port == NULL) 1872 if (mos7720_port == NULL)
1886 return -ENODEV; 1873 return -ENODEV;
1887 1874
1888 dev_dbg(&port->dev, "%s - cmd = 0x%x", __func__, cmd);
1889
1890 switch (cmd) { 1875 switch (cmd) {
1891 case TIOCSERGETLSR: 1876 case TIOCSERGETLSR:
1892 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__); 1877 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);