moxa: prepare for BKL pushdown
PATCH 1/1 moxa: prepare for BKL pushdown
Moxa needs a few routines wrapping with the BKL for now. It also snoops the TIOCG/SSOFTCAR function so needs its own implementation for now. That wants fixing by turning it into a termios set downcall into the drivers later.
drivers/char/moxa.c +26 -18
@@ -686,8 +686,8 @@int flag =0 , dtr, rts; port = tty->index; -if ((port !=MAX_PORTS ) && (!ch)) -return (-EINVAL ); +if (port !=MAX_PORTS && !ch) +return -EINVAL ;MoxaPortGetLineOut (ch->port, &dtr, &rts);if (dtr)
@@ -712,9 +712,10 @@int dtr, rts; port = tty->index; -if ((port !=MAX_PORTS ) && (!ch)) -return (-EINVAL ); +if (port !=MAX_PORTS && !ch) +return -EINVAL ; +lock_kernel ();MoxaPortGetLineOut (ch->port, &dtr, &rts);if (set &TIOCM_RTS ) rts =1 ;
@@ -725,6 +726,7 @@if (clear &TIOCM_DTR ) dtr =0 ;MoxaPortLineCtrl (ch->port, dtr, rts); +unlock_kernel ();return 0 ; }
@@ -734,52 +736,56 @@struct moxa_port *ch = (struct moxa_port *) tty->driver_data; registerint port;void __user *argp = (void __user *)arg; -int retval; - +int retval =0 ; + port = tty->index; -if ((port !=MAX_PORTS ) && (!ch)) -return (-EINVAL ); +if (port !=MAX_PORTS && !ch) +return -EINVAL ;switch (cmd) {case TCSBRK :/* SVID version: non-zero arg --> no break */ retval =tty_check_change (tty);if (retval) -return (retval); +break ;moxa_setup_empty_event (tty);tty_wait_until_sent (tty,0 );if (!arg)MoxaPortSendBreak (ch->port,0 ); -return (0 ); +break ;case TCSBRKP :/* support for POSIX tcsendbreak() */ retval =tty_check_change (tty);if (retval) -return (retval); +break ;moxa_setup_empty_event (tty);tty_wait_until_sent (tty,0 );MoxaPortSendBreak (ch->port, arg); -return (0 ); -case TIOCGSOFTCAR : -return put_user (C_CLOCAL (tty) ?1 :0 , (unsigned long __user *) argp); +break ;case TIOCSSOFTCAR :if (get_user (retval, (unsigned long __user *) argp))return -EFAULT ; arg = retval; +mutex_lock (&tty->termios_mutex); tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL ) | (arg ?CLOCAL :0 ));if (C_CLOCAL (tty)) ch->asyncflags &= ~ASYNC_CHECK_CD ;else ch->asyncflags |=ASYNC_CHECK_CD ; -return (0 ); +mutex_unlock (&tty->termios_mutex); +break ;case TIOCGSERIAL :return moxa_get_serial_info (ch, argp); -case TIOCSSERIAL : -return moxa_set_serial_info (ch, argp); +lock_kernel (); + retval =moxa_set_serial_info (ch, argp); +unlock_kernel (); +break ;default : +lock_kernel (); retval =MoxaDriverIoctl (cmd, arg, port); +unlock_kernel (); } -return (retval); +return retval; }static void moxa_throttle (struct tty_struct *tty)
@@ -2414,6 +2420,7 @@struct serial_struct tmp;memset (&tmp,0 ,sizeof (tmp)); +lock_kernel (); tmp.type = info->type; tmp.line = info->port; tmp.port =0 ;
@@ -2424,6 +2431,7 @@ tmp.closing_wait = info->closing_wait; tmp.custom_divisor =0 ; tmp.hub6 =0 ; +unlock_kernel ();if (copy_to_user (retinfo, &tmp,sizeof (*retinfo)))return -EFAULT ;return (0 );
Quoted 4 lines · Alan Cox
Moxa needs a few routines wrapping with the BKL for now. It also snoops the TIOCG/SSOFTCAR function so needs its own implementation for now. That wants fixing by turning it into a termios set downcall into the drivers later.
I'm taking care of this one. I'll apply it on the top of my changes, if it will be still needed (open/close/hangup/ioctl seems not).
Quoted 5 lines
Signed-off-by Alan Cox <[email protected]>diff -u --new-file --recursive --exclude-from
/usr/src/excludelinux.vanilla-2.6.25-rc2-mm1/drivers/char/moxa.clinux-2.6.25-rc2-mm1/drivers/char/moxa.cdrivers/char/moxa.c +0
-0