Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: ark3116.c: Mixed fixups

o Don't parse the cflag for baud rates, its not valid to do so
any more and this driver got it wrong anyway
o Don't do clever termios change checks in drivers and get them
wrong (arguably we should do some smart ones in the tty core but
stty to change nothing is *not* a common or critical path

I don't have the hardware so if you can test this carefully please do. I
thought fixing it up this far was better than marking it and other bits of
USB serial && BROKEN

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
568c24ad 9e85c5f6

+25 -40
+25 -40
drivers/usb/serial/ark3116.c
··· 172 172 173 173 dbg("%s - port %d", __FUNCTION__, port->number); 174 174 175 - if ((!port->tty) || (!port->tty->termios)) { 175 + if (!port->tty || !port->tty->termios) { 176 176 dbg("%s - no tty structures", __FUNCTION__); 177 177 return; 178 178 } ··· 187 187 spin_unlock_irqrestore(&priv->lock, flags); 188 188 189 189 cflag = port->tty->termios->c_cflag; 190 - 191 - /* check that they really want us to change something: */ 192 - if (old_termios) { 193 - if ((cflag == old_termios->c_cflag) && 194 - (RELEVANT_IFLAG(port->tty->termios->c_iflag) == 195 - RELEVANT_IFLAG(old_termios->c_iflag))) { 196 - dbg("%s - nothing to change...", __FUNCTION__); 197 - return; 198 - } 199 - } 200 190 201 191 buf = kmalloc(1, GFP_KERNEL); 202 192 if (!buf) { ··· 210 220 dbg("setting CS7"); 211 221 break; 212 222 default: 213 - err("CSIZE was set but not CS5-CS8, using CS8!"); 223 + dbg("CSIZE was set but not CS5-CS8, using CS8!"); 214 224 /* fall through */ 215 225 case CS8: 216 226 config |= 0x03; ··· 241 251 } 242 252 243 253 /* set baudrate */ 244 - baud = 0; 245 - switch (cflag & CBAUD) { 246 - case B0: 247 - err("can't set 0 baud, using 9600 instead"); 248 - break; 249 - case B75: baud = 75; break; 250 - case B150: baud = 150; break; 251 - case B300: baud = 300; break; 252 - case B600: baud = 600; break; 253 - case B1200: baud = 1200; break; 254 - case B1800: baud = 1800; break; 255 - case B2400: baud = 2400; break; 256 - case B4800: baud = 4800; break; 257 - case B9600: baud = 9600; break; 258 - case B19200: baud = 19200; break; 259 - case B38400: baud = 38400; break; 260 - case B57600: baud = 57600; break; 261 - case B115200: baud = 115200; break; 262 - case B230400: baud = 230400; break; 263 - case B460800: baud = 460800; break; 264 - default: 265 - dbg("does not support the baudrate requested (fix it)"); 266 - break; 267 - } 254 + baud = tty_get_baud_rate(port->tty); 268 255 269 - /* set 9600 as default (if given baudrate is invalid for example) */ 270 - if (baud == 0) 271 - baud = 9600; 256 + switch (baud) { 257 + case 75: 258 + case 150: 259 + case 300: 260 + case 600: 261 + case 1200: 262 + case 1800: 263 + case 2400: 264 + case 4800: 265 + case 9600: 266 + case 19200: 267 + case 38400: 268 + case 57600: 269 + case 115200: 270 + case 230400: 271 + case 460800: 272 + break; 273 + /* set 9600 as default (if given baudrate is invalid for example) */ 274 + default: 275 + baud = 9600; 276 + } 272 277 273 278 /* 274 279 * found by try'n'error, be careful, maybe there are other options 275 - * for multiplicator etc! 280 + * for multiplicator etc! (3.5 for example) 276 281 */ 277 282 if (baud == 460800) 278 283 /* strange, for 460800 the formula is wrong