X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fkobil_sct.c;h=693f00da7c038b0072d360b031479c0f1a30bea5;hb=dddec01eb8e2b56267b37a6f9f0997a64b4e0b2a;hp=6f224195bd25a6048efc65cc26f9b197d6f87a70;hpb=efefc6eb38d43b8e5daef482f575d767b002004e;p=linux-2.6-omap-h63xx.git diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 6f224195bd2..693f00da7c0 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -113,9 +113,6 @@ static struct usb_serial_driver kobil_device = { .description = "KOBIL USB smart card terminal", .usb_driver = &kobil_driver, .id_table = id_table, - .num_interrupt_in = NUM_DONT_CARE, - .num_bulk_in = 0, - .num_bulk_out = 0, .num_ports = 1, .attach = kobil_startup, .shutdown = kobil_shutdown, @@ -138,7 +135,6 @@ struct kobil_private { int filled; // index of the last char in buf int cur_pos; // index of the next char to send in buf __u16 device_type; - int line_state; }; @@ -160,7 +156,6 @@ static int kobil_startup (struct usb_serial *serial) priv->filled = 0; priv->cur_pos = 0; priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); - priv->line_state = 0; switch (priv->device_type){ case KOBIL_ADAPTER_B_PRODUCT_ID: @@ -188,11 +183,11 @@ static int kobil_startup (struct usb_serial *serial) for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { endpoint = &altsetting->endpoint[i]; if (usb_endpoint_is_int_out(&endpoint->desc)) { - dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); + dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; } if (usb_endpoint_is_int_in(&endpoint->desc)) { - dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); + dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; } } @@ -203,7 +198,7 @@ static int kobil_startup (struct usb_serial *serial) static void kobil_shutdown (struct usb_serial *serial) { int i; - dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); + dbg("%s - port %d", __func__, serial->port[0]->number); for (i=0; i < serial->num_ports; ++i) { while (serial->port[i]->open_count > 0) { @@ -223,9 +218,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) int transfer_buffer_length = 8; int write_urb_transfer_buffer_length = 8; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); priv = usb_get_serial_port_data(port); - priv->line_state = 0; // someone sets the dev to 0 if the close method has been called port->interrupt_in_urb->dev = port->serial->dev; @@ -251,10 +245,10 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) // allocate write_urb if (!port->write_urb) { - dbg("%s - port %d Allocating port->write_urb", __FUNCTION__, port->number); + dbg("%s - port %d Allocating port->write_urb", __func__, port->number); port->write_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->write_urb) { - dbg("%s - port %d usb_alloc_urb failed", __FUNCTION__, port->number); + dbg("%s - port %d usb_alloc_urb failed", __func__, port->number); kfree(transfer_buffer); return -ENOMEM; } @@ -280,7 +274,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) transfer_buffer_length, KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_HW_version URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result); dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); // get firmware version @@ -294,7 +288,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) transfer_buffer_length, KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_FW_version URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result); dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { @@ -309,7 +303,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) 0, KOBIL_TIMEOUT ); - dbg("%s - port %d Send set_baudrate URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result); // reset all queues result = usb_control_msg( port->serial->dev, @@ -322,13 +316,13 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) 0, KOBIL_TIMEOUT ); - dbg("%s - port %d Send reset_all_queues URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result); } if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { // start reading (Adapter B 'cause PNP string) result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } kfree(transfer_buffer); @@ -338,7 +332,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) static void kobil_close (struct usb_serial_port *port, struct file *filp) { - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (port->write_urb) { usb_kill_urb(port->write_urb); @@ -358,11 +352,11 @@ static void kobil_read_int_callback(struct urb *urb) int status = urb->status; // char *dbg_data; - dbg("%s - port %d", __FUNCTION__, port->number); + dbg("%s - port %d", __func__, port->number); if (status) { dbg("%s - port %d Read int status not zero: %d", - __FUNCTION__, port->number, status); + __func__, port->number, status); return; } @@ -392,7 +386,7 @@ static void kobil_read_int_callback(struct urb *urb) port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } @@ -410,21 +404,21 @@ static int kobil_write (struct usb_serial_port *port, struct kobil_private * priv; if (count == 0) { - dbg("%s - port %d write request of 0 bytes", __FUNCTION__, port->number); + dbg("%s - port %d write request of 0 bytes", __func__, port->number); return 0; } priv = usb_get_serial_port_data(port); if (count > (KOBIL_BUF_LENGTH - priv->filled)) { - dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); + dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number); return -ENOMEM; } // Copy data to buffer memcpy (priv->buf + priv->filled, buf, count); - usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled); + usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); priv->filled = priv->filled + count; @@ -456,7 +450,7 @@ static int kobil_write (struct usb_serial_port *port, priv->cur_pos = priv->cur_pos + length; result = usb_submit_urb( port->write_urb, GFP_NOIO ); - dbg("%s - port %d Send write URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result); todo = priv->filled - priv->cur_pos; if (todo > 0) { @@ -477,7 +471,7 @@ static int kobil_write (struct usb_serial_port *port, port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); - dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); } } return count; @@ -486,7 +480,7 @@ static int kobil_write (struct usb_serial_port *port, static int kobil_write_room (struct usb_serial_port *port) { - //dbg("%s - port %d", __FUNCTION__, port->number); + //dbg("%s - port %d", __func__, port->number); return 8; } @@ -521,16 +515,13 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) KOBIL_TIMEOUT); dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", - __FUNCTION__, port->number, result, transfer_buffer[0]); - - if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) { - priv->line_state |= TIOCM_DSR; - } else { - priv->line_state &= ~TIOCM_DSR; - } + __func__, port->number, result, transfer_buffer[0]); + result = 0; + if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) + result = TIOCM_DSR; kfree(transfer_buffer); - return priv->line_state; + return result; } static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, @@ -543,6 +534,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, unsigned char *transfer_buffer; int transfer_buffer_length = 8; + /* FIXME: locking ? */ priv = usb_get_serial_port_data(port); if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { // This device doesn't support ioctl calls @@ -566,9 +558,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { if (dtr != 0) - dbg("%s - port %d Setting DTR", __FUNCTION__, port->number); + dbg("%s - port %d Setting DTR", __func__, port->number); else - dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number); + dbg("%s - port %d Clearing DTR", __func__, port->number); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), SUSBCRequest_SetStatusLinesOrQueues, @@ -580,9 +572,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, KOBIL_TIMEOUT); } else { if (rts != 0) - dbg("%s - port %d Setting RTS", __FUNCTION__, port->number); + dbg("%s - port %d Setting RTS", __func__, port->number); else - dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number); + dbg("%s - port %d Clearing RTS", __func__, port->number); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), SUSBCRequest_SetStatusLinesOrQueues, @@ -593,7 +585,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 0, KOBIL_TIMEOUT); } - dbg("%s - port %d Send set_status_line URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? result : 0; } @@ -616,8 +608,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old case 1200: urb_val = SUSBCR_SBR_1200; break; - case 9600: default: + speed = 9600; + case 9600: urb_val = SUSBCR_SBR_9600; break; } @@ -641,6 +634,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old urb_val |= SUSBCR_SPASB_NoParity; strcat(settings, "No Parity"); } + port->tty->termios->c_cflag &= ~CMSPAR; + tty_encode_baud_rate(port->tty, speed, speed); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), @@ -683,7 +678,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne KOBIL_TIMEOUT ); - dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); + dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? -EFAULT : 0; default: