X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fkobil_sct.c;h=10d5cd1377a581b97c204147c5dc01036f295237;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=79cb22e31089bbec9382c3fe65f8e30d515d21ac;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 79cb22e31..10d5cd137 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -48,18 +48,10 @@ #include #include #include - - +#include "usb-serial.h" #include "kobil_sct.h" -//#include "../core/usb-debug.c" -#ifdef CONFIG_USB_SERIAL_DEBUG - static int debug = 1; -#else - static int debug; -#endif - -#include "usb-serial.h" +static int debug; /* Version Information */ #define DRIVER_VERSION "21/05/2004" @@ -81,7 +73,7 @@ static int kobil_startup (struct usb_serial *serial); static void kobil_shutdown (struct usb_serial *serial); static int kobil_open (struct usb_serial_port *port, struct file *filp); static void kobil_close (struct usb_serial_port *port, struct file *filp); -static int kobil_write (struct usb_serial_port *port, int from_user, +static int kobil_write (struct usb_serial_port *port, const unsigned char *buf, int count); static int kobil_write_room(struct usb_serial_port *port); static int kobil_ioctl(struct usb_serial_port *port, struct file *file, @@ -163,7 +155,7 @@ static int kobil_startup (struct usb_serial *serial) priv->filled = 0; priv->cur_pos = 0; - priv->device_type = serial->product; + priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); priv->line_state = 0; switch (priv->device_type){ @@ -358,14 +350,13 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __FUNCTION__, port->number); - if (port->write_urb){ - usb_unlink_urb( port->write_urb ); + if (port->write_urb) { + usb_kill_urb(port->write_urb); usb_free_urb( port->write_urb ); - port->write_urb = 0; - } - if (port->interrupt_in_urb){ - usb_unlink_urb (port->interrupt_in_urb); + port->write_urb = NULL; } + if (port->interrupt_in_urb) + usb_kill_urb(port->interrupt_in_urb); } @@ -427,7 +418,7 @@ static void kobil_write_callback( struct urb *purb, struct pt_regs *regs ) } -static int kobil_write (struct usb_serial_port *port, int from_user, +static int kobil_write (struct usb_serial_port *port, const unsigned char *buf, int count) { int length = 0; @@ -448,15 +439,9 @@ static int kobil_write (struct usb_serial_port *port, int from_user, } // Copy data to buffer - if (from_user) { - if (copy_from_user(priv->buf + priv->filled, buf, count)) { - return -EFAULT; - } - } else { - memcpy (priv->buf + priv->filled, buf, count); - } + memcpy (priv->buf + priv->filled, buf, count); - usb_serial_debug_data (__FILE__, __FUNCTION__, count, priv->buf + priv->filled); + usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled); priv->filled = priv->filled + count; @@ -466,9 +451,8 @@ static int kobil_write (struct usb_serial_port *port, int from_user, ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { // stop reading (except TWIN and KAAN SIM) - if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) { - usb_unlink_urb( port->interrupt_in_urb ); - } + if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) + usb_kill_urb(port->interrupt_in_urb); todo = priv->filled - priv->cur_pos; @@ -643,6 +627,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, unsigned char *transfer_buffer; int transfer_buffer_length = 8; char *settings; + void __user *user_arg = (void __user *)arg; priv = usb_get_serial_port_data(port); if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { @@ -652,12 +637,12 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, switch (cmd) { case TCGETS: // 0x5401 - result = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct termios)); + result = verify_area(VERIFY_WRITE, user_arg, sizeof(struct termios)); if (result) { dbg("%s - port %d Error in verify_area", __FUNCTION__, port->number); return(result); } - if (kernel_termios_to_user_termios((struct termios *)arg, + if (kernel_termios_to_user_termios((struct termios __user *)arg, &priv->internal_termios)) return -EFAULT; return 0; @@ -667,13 +652,13 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, dbg("%s - port %d Error: port->tty->termios is NULL", __FUNCTION__, port->number); return -ENOTTY; } - result = verify_area(VERIFY_READ, (void *)arg, sizeof(struct termios)); + result = verify_area(VERIFY_READ, user_arg, sizeof(struct termios)); if (result) { dbg("%s - port %d Error in verify_area", __FUNCTION__, port->number); return result; } if (user_termios_to_kernel_termios(&priv->internal_termios, - (struct termios *)arg)) + (struct termios __user *)arg)) return -EFAULT; settings = (unsigned char *) kmalloc(50, GFP_KERNEL); @@ -787,5 +772,5 @@ MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_LICENSE( "GPL" ); -MODULE_PARM(debug, "i"); +module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug enabled or not");