diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-06-22 09:36:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:34:37 -0400 |
commit | 568c24adeaa4d9ec2fd04c6ae226eeb673a385db (patch) | |
tree | a86aa556a093474530f8957d211c876a4c121c56 /drivers/usb/serial/ark3116.c | |
parent | 9e85c5f63268a5700860f53e52b090973652a5b2 (diff) |
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>
Diffstat (limited to 'drivers/usb/serial/ark3116.c')
-rw-r--r-- | drivers/usb/serial/ark3116.c | 61 |
1 files changed, 23 insertions, 38 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index fe437125f14b..c9fd486c1c7d 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -172,7 +172,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
172 | 172 | ||
173 | dbg("%s - port %d", __FUNCTION__, port->number); | 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 | dbg("%s - no tty structures", __FUNCTION__); | 176 | dbg("%s - no tty structures", __FUNCTION__); |
177 | return; | 177 | return; |
178 | } | 178 | } |
@@ -188,16 +188,6 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
188 | 188 | ||
189 | cflag = port->tty->termios->c_cflag; | 189 | cflag = port->tty->termios->c_cflag; |
190 | 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 | |||
201 | buf = kmalloc(1, GFP_KERNEL); | 191 | buf = kmalloc(1, GFP_KERNEL); |
202 | if (!buf) { | 192 | if (!buf) { |
203 | dbg("error kmalloc"); | 193 | dbg("error kmalloc"); |
@@ -220,7 +210,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
220 | dbg("setting CS7"); | 210 | dbg("setting CS7"); |
221 | break; | 211 | break; |
222 | default: | 212 | default: |
223 | err("CSIZE was set but not CS5-CS8, using CS8!"); | 213 | dbg("CSIZE was set but not CS5-CS8, using CS8!"); |
224 | /* fall through */ | 214 | /* fall through */ |
225 | case CS8: | 215 | case CS8: |
226 | config |= 0x03; | 216 | config |= 0x03; |
@@ -251,38 +241,33 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
251 | } | 241 | } |
252 | 242 | ||
253 | /* set baudrate */ | 243 | /* set baudrate */ |
254 | baud = 0; | 244 | baud = tty_get_baud_rate(port->tty); |
255 | switch (cflag & CBAUD) { | 245 | |
256 | case B0: | 246 | switch (baud) { |
257 | err("can't set 0 baud, using 9600 instead"); | 247 | case 75: |
248 | case 150: | ||
249 | case 300: | ||
250 | case 600: | ||
251 | case 1200: | ||
252 | case 1800: | ||
253 | case 2400: | ||
254 | case 4800: | ||
255 | case 9600: | ||
256 | case 19200: | ||
257 | case 38400: | ||
258 | case 57600: | ||
259 | case 115200: | ||
260 | case 230400: | ||
261 | case 460800: | ||
258 | break; | 262 | break; |
259 | case B75: baud = 75; break; | 263 | /* set 9600 as default (if given baudrate is invalid for example) */ |
260 | case B150: baud = 150; break; | ||
261 | case B300: baud = 300; break; | ||
262 | case B600: baud = 600; break; | ||
263 | case B1200: baud = 1200; break; | ||
264 | case B1800: baud = 1800; break; | ||
265 | case B2400: baud = 2400; break; | ||
266 | case B4800: baud = 4800; break; | ||
267 | case B9600: baud = 9600; break; | ||
268 | case B19200: baud = 19200; break; | ||
269 | case B38400: baud = 38400; break; | ||
270 | case B57600: baud = 57600; break; | ||
271 | case B115200: baud = 115200; break; | ||
272 | case B230400: baud = 230400; break; | ||
273 | case B460800: baud = 460800; break; | ||
274 | default: | 264 | default: |
275 | dbg("does not support the baudrate requested (fix it)"); | 265 | baud = 9600; |
276 | break; | ||
277 | } | 266 | } |
278 | 267 | ||
279 | /* set 9600 as default (if given baudrate is invalid for example) */ | ||
280 | if (baud == 0) | ||
281 | baud = 9600; | ||
282 | |||
283 | /* | 268 | /* |
284 | * found by try'n'error, be careful, maybe there are other options | 269 | * found by try'n'error, be careful, maybe there are other options |
285 | * for multiplicator etc! | 270 | * for multiplicator etc! (3.5 for example) |
286 | */ | 271 | */ |
287 | if (baud == 460800) | 272 | if (baud == 460800) |
288 | /* strange, for 460800 the formula is wrong | 273 | /* strange, for 460800 the formula is wrong |