X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fempeg.c;h=92beeb19795f15ae325b3599771832c7f851b759;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=9af8f5ca9a5f00fc7d95c9d7426debdba86b5066;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 9af8f5ca9..92beeb197 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -51,7 +51,6 @@ * */ -#include #include #include #include @@ -63,14 +62,9 @@ #include #include #include +#include -#ifdef CONFIG_USB_SERIAL_DEBUG - static int debug = 1; -#else - static int debug; -#endif - -#include "usb-serial.h" +static int debug; /* * Version Information @@ -86,7 +80,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp); static void empeg_close (struct usb_serial_port *port, struct file *filp); static int empeg_write (struct usb_serial_port *port, - int from_user, const unsigned char *buf, int count); static int empeg_write_room (struct usb_serial_port *port); @@ -99,9 +92,9 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); -static void empeg_set_termios (struct usb_serial_port *port, struct termios *old_termios); -static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs); -static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs); +static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); +static void empeg_write_bulk_callback (struct urb *urb); +static void empeg_read_bulk_callback (struct urb *urb); static struct usb_device_id id_table [] = { { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, @@ -111,16 +104,18 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver empeg_driver = { - .owner = THIS_MODULE, .name = "empeg", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; -static struct usb_serial_device_type empeg_device = { - .owner = THIS_MODULE, - .name = "Empeg", +static struct usb_serial_driver empeg_device = { + .driver = { + .owner = THIS_MODULE, + .name = "empeg", + }, .id_table = id_table, .num_interrupt_in = 0, .num_bulk_in = 1, @@ -157,9 +152,6 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) struct usb_serial *serial = port->serial; int result = 0; - if (port_paranoia_check (port, __FUNCTION__)) - return -ENODEV; - dbg("%s - port %d", __FUNCTION__, port->number); /* Force default termio settings */ @@ -190,27 +182,16 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) static void empeg_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; - - if (port_paranoia_check (port, __FUNCTION__)) - return; - dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - if (serial->dev) { - /* shutdown our bulk read */ - usb_unlink_urb (port->read_urb); - } + /* shutdown our bulk read */ + usb_kill_urb(port->read_urb); /* Uncomment the following line if you want to see some statistics in your syslog */ /* dev_info (&port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */ } -static int empeg_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) +static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct urb *urb; @@ -254,16 +235,9 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); - if (from_user) { - if (copy_from_user (urb->transfer_buffer, current_position, transfer_size)) { - bytes_sent = -EFAULT; - break; - } - } else { - memcpy (urb->transfer_buffer, current_position, transfer_size); - } + memcpy (urb->transfer_buffer, current_position, transfer_size); - usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size, urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, urb->transfer_buffer); /* build up our urb */ usb_fill_bulk_urb ( @@ -349,13 +323,10 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port) } -static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs) +static void empeg_write_bulk_callback (struct urb *urb) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - if (port_paranoia_check (port, __FUNCTION__)) - return; - dbg("%s - port %d", __FUNCTION__, port->number); if (urb->status) { @@ -363,52 +334,31 @@ static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs) return; } - schedule_work(&port->work); + usb_serial_port_softint(port); } -static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) +static void empeg_read_bulk_callback (struct urb *urb) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; - int i; int result; - if (port_paranoia_check (port, __FUNCTION__)) - return; - dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; } - usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); tty = port->tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { - /* gb - 2000/11/13 - * If we insert too many characters we'll overflow the buffer. - * This means we'll lose bytes - Decidedly bad. - */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - tty_insert_flip_char(tty, data[i], 0); - } - /* gb - 2000/11/13 - * Goes straight through instead of scheduling - if tty->low_latency is set. - */ + tty_buffer_request_room(tty, urb->actual_length); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); bytes_in += urb->actual_length; } @@ -416,8 +366,8 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) /* Continue trying to always read */ usb_fill_bulk_urb( port->read_urb, - serial->dev, - usb_rcvbulkpipe(serial->dev, + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, @@ -437,7 +387,7 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) static void empeg_throttle (struct usb_serial_port *port) { dbg("%s - port %d", __FUNCTION__, port->number); - usb_unlink_urb (port->read_urb); + usb_kill_urb(port->read_urb); } @@ -492,7 +442,7 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign } -static void empeg_set_termios (struct usb_serial_port *port, struct termios *old_termios) +static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s - port %d", __FUNCTION__, port->number); @@ -547,11 +497,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct termios *old */ port->tty->low_latency = 1; - /* Notify the tty driver that the termios have changed. */ - port->tty->ldisc.set_termios(port->tty, NULL); - return; - } @@ -593,8 +539,7 @@ failed_usb_register: failed_usb_serial_register: for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - if (write_urb_pool[i]->transfer_buffer) - kfree(write_urb_pool[i]->transfer_buffer); + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb(write_urb_pool[i]); } } @@ -614,12 +559,11 @@ static void __exit empeg_exit (void) for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - /* FIXME - uncomment the following usb_unlink_urb call when + /* FIXME - uncomment the following usb_kill_urb call when * the host controllers get fixed to set urb->dev = NULL after * the urb is finished. Otherwise this call oopses. */ - /* usb_unlink_urb(write_urb_pool[i]); */ - if (write_urb_pool[i]->transfer_buffer) - kfree(write_urb_pool[i]->transfer_buffer); + /* usb_kill_urb(write_urb_pool[i]); */ + kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb (write_urb_pool[i]); } } @@ -635,6 +579,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"); -