On Sat, 8 Apr 2006, Paul Fulghum wrote: > On Sat, 2006-04-08 at 21:34 +0200, Guennadi Liakhovetski wrote: > > On Fri, 7 Apr 2006, Paul Fulghum wrote: > > It hung exactly as with the previous big one. Don't think it is important, > > I am testing it on a SMP. > > OK, this one backs out my usb_console_setup change > that uses the temp tty structure for the device specific open. > > Included is: > * improved usb serial_open fix (fix ENODEV) > * improved usb_console_write fix (fix CR after LF) > * your original ftdi patch (fix oops on tty struct == NULL)
Yes, this one works. Guennadi > > > --- a/drivers/usb/serial/console.c 2006-03-19 23:53:29.000000000 -0600 > +++ b/drivers/usb/serial/console.c 2006-04-08 15:43:15.000000000 -0500 > @@ -213,17 +213,38 @@ static void usb_console_write(struct con > > if (!port->open_count) { > dbg ("%s - port not opened", __FUNCTION__); > - goto exit; > + return; > } > > - /* pass on to the driver specific version of this function if it is > available */ > - if (serial->type->write) > - retval = serial->type->write(port, buf, count); > - else > - retval = usb_serial_generic_write(port, buf, count); > - > -exit: > - dbg("%s - return value (if we had one): %d", __FUNCTION__, retval); > + while (count) { > + unsigned int i; > + unsigned int lf; > + /* search for LF so we can insert CR if necessary */ > + for (i=0, lf=0 ; i < count ; i++) { > + if (*(buf + i) == 10) { > + lf = 1; > + i++; > + break; > + } > + } > + /* pass on to the driver specific version of this function if > it is available */ > + if (serial->type->write) > + retval = serial->type->write(port, buf, i); > + else > + retval = usb_serial_generic_write(port, buf, i); > + dbg("%s - return value : %d", __FUNCTION__, retval); > + if (lf) { > + /* append CR after LF */ > + unsigned char cr = 13; > + if (serial->type->write) > + retval = serial->type->write(port, &cr, 1); > + else > + retval = usb_serial_generic_write(port, &cr, 1); > + dbg("%s - return value : %d", __FUNCTION__, retval); > + } > + buf += i; > + count -= i; > + } > } > > static struct console usbcons = { > --- a/drivers/usb/serial/usb-serial.c 2006-03-19 23:53:29.000000000 -0600 > +++ b/drivers/usb/serial/usb-serial.c 2006-04-08 15:34:11.000000000 -0500 > @@ -197,12 +197,12 @@ static int serial_open (struct tty_struc > > ++port->open_count; > > - if (port->open_count == 1) { > + /* set up our port structure making the tty driver > + * remember our port object, and us it */ > + tty->driver_data = port; > + port->tty = tty; > > - /* set up our port structure making the tty driver > - * remember our port object, and us it */ > - tty->driver_data = port; > - port->tty = tty; > + if (port->open_count == 1) { > > /* lock this module before we call it > * this may fail, which means we must bail out, > --- a/drivers/usb/serial/ftdi_sio.c 2006-03-19 23:53:29.000000000 -0600 > +++ b/drivers/usb/serial/ftdi_sio.c 2006-04-08 15:47:21.000000000 -0500 > @@ -1264,8 +1264,8 @@ static int ftdi_open (struct usb_serial > > dbg("%s", __FUNCTION__); > > - > - port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; > + if (port->tty) > + port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 > : 0; > > /* No error checking for this (will get errors later anyway) */ > /* See ftdi_sio.h for description of what is reset */ > @@ -1279,7 +1279,8 @@ static int ftdi_open (struct usb_serial > This is same behaviour as serial.c/rs_open() - Kuba */ > > /* ftdi_set_termios will send usb control messages */ > - ftdi_set_termios(port, &tmp_termios); > + if (port->tty) > + ftdi_set_termios(port, &tmp_termios); > > /* FIXME: Flow control might be enabled, so it should be checked - > we have no control of defaults! */ > @@ -1860,7 +1861,7 @@ static void ftdi_set_termios (struct usb > err("%s urb failed to set baudrate", __FUNCTION__); > } > /* Ensure RTS and DTR are raised when baudrate changed from 0 */ > - if ((old_termios->c_cflag & CBAUD) == B0) { > + if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) { > set_mctrl(port, TIOCM_DTR | TIOCM_RTS); > } > } > > --- Guennadi Liakhovetski ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel