X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fio_ti.c;h=6afee30a6a5ce03c1c1f5045c8f9546dc5667a2e;hb=dfa5ec79d28300b0d1fdeafbeebf0a6b721edc38;hp=b8670905bc3ac858d4e30aa91c2191e4c883c88e;hpb=0d090b6819e3559dabb05773c4a6dacc4fa94d0e;p=linux-2.6-omap-h63xx.git diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index b8670905bc3..6afee30a6a5 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -34,10 +34,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -133,7 +133,7 @@ struct edgeport_serial { struct product_info product_info; u8 TI_I2C_Type; // Type of I2C in UMP u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode - struct semaphore es_sem; + struct mutex es_lock; int num_ports_open; struct usb_serial *serial; }; @@ -654,7 +654,7 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f /* (TIIsTxActive doesn't seem to wait for the last byte) */ if ((baud_rate=port->baud_rate) == 0) baud_rate = 50; - msleep(max(1,(10000+baud_rate-1)/baud_rate)); + msleep(max(1, DIV_ROUND_UP(10000, baud_rate))); } static int TIChooseConfiguration (struct usb_device *dev) @@ -1086,12 +1086,11 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { struct ti_i2c_desc *rom_desc; - dbg ("%s - <<<<<<<<<<<<<<>>>>>>>>>", __FUNCTION__); + dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); status = TiValidateI2cImage (serial); if (status) { - dbg ("%s - <<<<<<<<<<<<<<>>>>>>>>>", - __FUNCTION__); + dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); return status; } @@ -1345,8 +1344,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) /********************************************************************/ /* Boot Mode */ /********************************************************************/ - dbg ("%s - <<<<<<<<<<<<<<>>>>>>>>>>>>>>", - __FUNCTION__); + dbg("%s - RUNNING IN BOOT MODE", __func__); // Configure the TI device so we can use the BULK pipes for download status = TIConfigureBootDevice (serial->serial->dev); @@ -1461,7 +1459,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) StayInBootMode: // Eprom is invalid or blank stay in boot mode - dbg ("%s - <<<<<<<<<<<<<<>>>>>>>>>>>", __FUNCTION__); + dbg("%s - STAYING IN BOOT MODE", __func__); serial->product_info.TiMode = TI_MODE_BOOT; return 0; @@ -1978,7 +1976,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) } /* set up the port settings */ - edge_set_termios (port, NULL); + edge_set_termios (port, port->tty->termios); /* open up the port */ @@ -2044,7 +2042,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); edge_serial = edge_port->edge_serial; - if (down_interruptible(&edge_serial->es_sem)) + if (mutex_lock_interruptible(&edge_serial->es_lock)) return -ERESTARTSYS; if (edge_serial->num_ports_open == 0) { /* we are the first port to be opened, let's post the interrupt urb */ @@ -2052,7 +2050,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) if (!urb) { dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__); status = -EINVAL; - goto up_es_sem; + goto release_es_lock; } urb->complete = edge_interrupt_callback; urb->context = edge_serial; @@ -2060,7 +2058,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) status = usb_submit_urb (urb, GFP_KERNEL); if (status) { dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status); - goto up_es_sem; + goto release_es_lock; } } @@ -2092,13 +2090,13 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) dbg("%s - exited", __FUNCTION__); - goto up_es_sem; + goto release_es_lock; unlink_int_urb: if (edge_port->edge_serial->num_ports_open == 0) usb_kill_urb(port->serial->port[0]->interrupt_in_urb); -up_es_sem: - up(&edge_serial->es_sem); +release_es_lock: + mutex_unlock(&edge_serial->es_lock); return status; } @@ -2137,14 +2135,14 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) 0, NULL, 0); - down(&edge_serial->es_sem); + mutex_lock(&edge_serial->es_lock); --edge_port->edge_serial->num_ports_open; if (edge_port->edge_serial->num_ports_open <= 0) { /* last port is now closed, let's shut down our interrupt urb */ usb_kill_urb(port->serial->port[0]->interrupt_in_urb); edge_port->edge_serial->num_ports_open = 0; } - up(&edge_serial->es_sem); + mutex_unlock(&edge_serial->es_lock); edge_port->close_pending = 0; dbg("%s - exited", __FUNCTION__); @@ -2393,11 +2391,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi dbg("%s - port %d", __FUNCTION__, edge_port->port->number); tty = edge_port->port->tty; - if ((!tty) || - (!tty->termios)) { - dbg("%s - no tty structures", __FUNCTION__); - return; - } config = kmalloc (sizeof (*config), GFP_KERNEL); if (!config) { @@ -2492,15 +2485,21 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi } } + tty->termios->c_cflag &= ~CMSPAR; + /* Round the baud rate */ baud = tty_get_baud_rate(tty); if (!baud) { /* pick a default, any default... */ baud = 9600; - } + } else + tty_encode_baud_rate(tty, baud, baud); + edge_port->baud_rate = baud; config->wBaudRate = (__u16)((461550L + baud/2) / baud); + /* FIXME: Recompute actual baud from divisor here */ + dbg ("%s - baud rate = %d, wBaudRate = %d", __FUNCTION__, baud, config->wBaudRate); dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); @@ -2538,19 +2537,12 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old struct tty_struct *tty = port->tty; unsigned int cflag; - if (!port->tty || !port->tty->termios) { - dbg ("%s - no tty or termios", __FUNCTION__); - return; - } - cflag = tty->termios->c_cflag; dbg("%s - clfag %08x iflag %08x", __FUNCTION__, tty->termios->c_cflag, tty->termios->c_iflag); - if (old_termios) { - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, - old_termios->c_cflag, old_termios->c_iflag); - } + dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + old_termios->c_cflag, old_termios->c_iflag); dbg("%s - port %d", __FUNCTION__, port->number); @@ -2567,9 +2559,11 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig { struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; + unsigned long flags; dbg("%s - port %d", __FUNCTION__, port->number); + spin_lock_irqsave(&edge_port->ep_lock, flags); mcr = edge_port->shadow_mcr; if (set & TIOCM_RTS) mcr |= MCR_RTS; @@ -2586,6 +2580,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig mcr &= ~MCR_LOOPBACK; edge_port->shadow_mcr = mcr; + spin_unlock_irqrestore(&edge_port->ep_lock, flags); TIRestoreMCR (edge_port, mcr); @@ -2598,9 +2593,12 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) unsigned int result = 0; unsigned int msr; unsigned int mcr; + unsigned long flags; dbg("%s - port %d", __FUNCTION__, port->number); + spin_lock_irqsave(&edge_port->ep_lock, flags); + msr = edge_port->shadow_msr; mcr = edge_port->shadow_mcr; result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ @@ -2612,6 +2610,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) dbg("%s -- %x", __FUNCTION__, result); + spin_unlock_irqrestore(&edge_port->ep_lock, flags); return result; } @@ -2743,7 +2742,7 @@ static int edge_startup (struct usb_serial *serial) dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__); return -ENOMEM; } - sema_init(&edge_serial->es_sem, 1); + mutex_init(&edge_serial->es_lock); edge_serial->serial = serial; usb_set_serial_data(serial, edge_serial);