Commit 9d6d162d authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

mxser: prepare for BKL pushdown

Push the BKL down into various internal routines in the driver ready to
remove it from the break, ioctl and other call points.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 37361136
...@@ -1460,6 +1460,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1460,6 +1460,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
struct mxser_port *port; struct mxser_port *port;
int result, status; int result, status;
unsigned int i, j; unsigned int i, j;
int ret = 0;
switch (cmd) { switch (cmd) {
case MOXA_GET_MAJOR: case MOXA_GET_MAJOR:
...@@ -1467,18 +1468,21 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1467,18 +1468,21 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
case MOXA_CHKPORTENABLE: case MOXA_CHKPORTENABLE:
result = 0; result = 0;
lock_kernel();
for (i = 0; i < MXSER_BOARDS; i++) for (i = 0; i < MXSER_BOARDS; i++)
for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
if (mxser_boards[i].ports[j].ioaddr) if (mxser_boards[i].ports[j].ioaddr)
result |= (1 << i); result |= (1 << i);
unlock_kernel();
return put_user(result, (unsigned long __user *)argp); return put_user(result, (unsigned long __user *)argp);
case MOXA_GETDATACOUNT: case MOXA_GETDATACOUNT:
lock_kernel();
if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
return -EFAULT; ret = -EFAULT;
return 0; unlock_kernel();
return ret;
case MOXA_GETMSTATUS: case MOXA_GETMSTATUS:
lock_kernel();
for (i = 0; i < MXSER_BOARDS; i++) for (i = 0; i < MXSER_BOARDS; i++)
for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
port = &mxser_boards[i].ports[j]; port = &mxser_boards[i].ports[j];
...@@ -1515,6 +1519,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1515,6 +1519,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
else else
GMStatus[i].cts = 0; GMStatus[i].cts = 0;
} }
unlock_kernel();
if (copy_to_user(argp, GMStatus, if (copy_to_user(argp, GMStatus,
sizeof(struct mxser_mstatus) * MXSER_PORTS)) sizeof(struct mxser_mstatus) * MXSER_PORTS))
return -EFAULT; return -EFAULT;
...@@ -1524,7 +1529,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1524,7 +1529,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
unsigned long opmode; unsigned long opmode;
unsigned cflag, iflag; unsigned cflag, iflag;
for (i = 0; i < MXSER_BOARDS; i++) lock_kernel();
for (i = 0; i < MXSER_BOARDS; i++) {
for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
port = &mxser_boards[i].ports[j]; port = &mxser_boards[i].ports[j];
if (!port->ioaddr) if (!port->ioaddr)
...@@ -1589,13 +1595,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) ...@@ -1589,13 +1595,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
mon_data_ext.iftype[i] = opmode; mon_data_ext.iftype[i] = opmode;
} }
}
unlock_kernel();
if (copy_to_user(argp, &mon_data_ext, if (copy_to_user(argp, &mon_data_ext,
sizeof(mon_data_ext))) sizeof(mon_data_ext)))
return -EFAULT; return -EFAULT;
return 0; return 0;
}
} default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
return 0; return 0;
...@@ -1651,16 +1658,20 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1651,16 +1658,20 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
opmode != RS422_MODE && opmode != RS422_MODE &&
opmode != RS485_4WIRE_MODE) opmode != RS485_4WIRE_MODE)
return -EFAULT; return -EFAULT;
lock_kernel();
mask = ModeMask[p]; mask = ModeMask[p];
shiftbit = p * 2; shiftbit = p * 2;
val = inb(info->opmode_ioaddr); val = inb(info->opmode_ioaddr);
val &= mask; val &= mask;
val |= (opmode << shiftbit); val |= (opmode << shiftbit);
outb(val, info->opmode_ioaddr); outb(val, info->opmode_ioaddr);
unlock_kernel();
} else { } else {
lock_kernel();
shiftbit = p * 2; shiftbit = p * 2;
opmode = inb(info->opmode_ioaddr) >> shiftbit; opmode = inb(info->opmode_ioaddr) >> shiftbit;
opmode &= OP_MODE_MASK; opmode &= OP_MODE_MASK;
unlock_kernel();
if (put_user(opmode, (int __user *)argp)) if (put_user(opmode, (int __user *)argp))
return -EFAULT; return -EFAULT;
} }
...@@ -1687,17 +1698,16 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1687,17 +1698,16 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
tty_wait_until_sent(tty, 0); tty_wait_until_sent(tty, 0);
mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4); mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
return 0; return 0;
case TIOCGSOFTCAR:
return put_user(!!C_CLOCAL(tty), (unsigned long __user *)argp);
case TIOCSSOFTCAR:
if (get_user(arg, (unsigned long __user *)argp))
return -EFAULT;
tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
return 0;
case TIOCGSERIAL: case TIOCGSERIAL:
return mxser_get_serial_info(info, argp); lock_kernel();
retval = mxser_get_serial_info(info, argp);
unlock_kernel();
return retval;
case TIOCSSERIAL: case TIOCSSERIAL:
return mxser_set_serial_info(info, argp); lock_kernel();
retval = mxser_set_serial_info(info, argp);
unlock_kernel();
return retval;
case TIOCSERGETLSR: /* Get line status register */ case TIOCSERGETLSR: /* Get line status register */
return mxser_get_lsr_info(info, argp); return mxser_get_lsr_info(info, argp);
/* /*
...@@ -1746,24 +1756,27 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1746,24 +1756,27 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
case MOXA_HighSpeedOn: case MOXA_HighSpeedOn:
return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
case MOXA_SDS_RSTICOUNTER: case MOXA_SDS_RSTICOUNTER:
lock_kernel();
info->mon_data.rxcnt = 0; info->mon_data.rxcnt = 0;
info->mon_data.txcnt = 0; info->mon_data.txcnt = 0;
unlock_kernel();
return 0; return 0;
case MOXA_ASPP_OQUEUE:{ case MOXA_ASPP_OQUEUE:{
int len, lsr; int len, lsr;
lock_kernel();
len = mxser_chars_in_buffer(tty); len = mxser_chars_in_buffer(tty);
lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT; lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT;
len += (lsr ? 0 : 1); len += (lsr ? 0 : 1);
unlock_kernel();
return put_user(len, (int __user *)argp); return put_user(len, (int __user *)argp);
} }
case MOXA_ASPP_MON: { case MOXA_ASPP_MON: {
int mcr, status; int mcr, status;
lock_kernel();
status = mxser_get_msr(info->ioaddr, 1, tty->index); status = mxser_get_msr(info->ioaddr, 1, tty->index);
mxser_check_modem_status(info, status); mxser_check_modem_status(info, status);
...@@ -1782,7 +1795,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1782,7 +1795,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD; info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
else else
info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
unlock_kernel();
if (copy_to_user(argp, &info->mon_data, if (copy_to_user(argp, &info->mon_data,
sizeof(struct mxser_mon))) sizeof(struct mxser_mon)))
return -EFAULT; return -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment