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

USB: mos7840.c: turn this into a serial driver

The MOS driver is "interesting", in a bad kind of 'how the hell did this
get merged' kind of way

- Remove the bogus termios change check
- Remove the duplicate code for half the ioctls
- Remove the supporting code to duplicate the ioctl code

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
31473aae 70f458f6

-72
-72
drivers/usb/serial/mos7840.c
··· 2189 2189 return; 2190 2190 } 2191 2191 2192 - /* check that they really want us to change something */ 2193 - if (old_termios) { 2194 - if ((cflag == old_termios->c_cflag) && 2195 - (RELEVANT_IFLAG(tty->termios->c_iflag) == 2196 - RELEVANT_IFLAG(old_termios->c_iflag))) { 2197 - dbg("%s\n", "Nothing to change"); 2198 - return; 2199 - } 2200 - } 2201 - 2202 2192 dbg("%s - clfag %08x iflag %08x", __FUNCTION__, 2203 2193 tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); 2204 2194 ··· 2245 2255 if (copy_to_user(value, &result, sizeof(int))) 2246 2256 return -EFAULT; 2247 2257 return 0; 2248 - } 2249 - 2250 - /***************************************************************************** 2251 - * mos7840_get_bytes_avail - get number of bytes available 2252 - * 2253 - * Purpose: Let user call ioctl to get the count of number of bytes available. 2254 - *****************************************************************************/ 2255 - 2256 - static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port, 2257 - unsigned int __user *value) 2258 - { 2259 - unsigned int result = 0; 2260 - struct tty_struct *tty = mos7840_port->port->tty; 2261 - 2262 - if (!tty) 2263 - return -ENOIOCTLCMD; 2264 - 2265 - result = tty->read_cnt; 2266 - 2267 - dbg("%s(%d) = %d", __FUNCTION__, mos7840_port->port->number, result); 2268 - if (copy_to_user(value, &result, sizeof(int))) 2269 - return -EFAULT; 2270 - 2271 - return -ENOIOCTLCMD; 2272 2258 } 2273 2259 2274 2260 /***************************************************************************** ··· 2395 2429 struct async_icount cprev; 2396 2430 struct serial_icounter_struct icount; 2397 2431 int mosret = 0; 2398 - int retval; 2399 - struct tty_ldisc *ld; 2400 2432 2401 2433 if (mos7840_port_paranoia_check(port, __FUNCTION__)) { 2402 2434 dbg("%s", "Invalid port \n"); ··· 2412 2448 2413 2449 switch (cmd) { 2414 2450 /* return number of bytes available */ 2415 - 2416 - case TIOCINQ: 2417 - dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 2418 - return mos7840_get_bytes_avail(mos7840_port, argp); 2419 - 2420 - case TIOCOUTQ: 2421 - dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number); 2422 - return put_user(tty->driver->chars_in_buffer ? 2423 - tty->driver->chars_in_buffer(tty) : 0, 2424 - (int __user *)arg); 2425 - 2426 - case TCFLSH: 2427 - retval = tty_check_change(tty); 2428 - if (retval) 2429 - return retval; 2430 - 2431 - ld = tty_ldisc_ref(tty); 2432 - switch (arg) { 2433 - case TCIFLUSH: 2434 - if (ld && ld->flush_buffer) 2435 - ld->flush_buffer(tty); 2436 - break; 2437 - case TCIOFLUSH: 2438 - if (ld && ld->flush_buffer) 2439 - ld->flush_buffer(tty); 2440 - /* fall through */ 2441 - case TCOFLUSH: 2442 - if (tty->driver->flush_buffer) 2443 - tty->driver->flush_buffer(tty); 2444 - break; 2445 - default: 2446 - tty_ldisc_deref(ld); 2447 - return -EINVAL; 2448 - } 2449 - tty_ldisc_deref(ld); 2450 - return 0; 2451 2451 2452 2452 case TIOCSERGETLSR: 2453 2453 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);