mirror of
https://github.com/adulau/aha.git
synced 2024-12-31 21:26:18 +00:00
Char: mxser, remove special baudrate processing
Let the special baudrate processing on the tty layer. Also remove
set/get_special_rate ioctls introduced in commit
f64c84a166
, since it is no longer needed.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Reviewed-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
f29e37c076
commit
d7f549fa14
2 changed files with 23 additions and 101 deletions
|
@ -173,18 +173,6 @@ static struct pci_device_id mxser_pcibrds[] = {
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
|
MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
|
||||||
|
|
||||||
static int mxvar_baud_table[] = {
|
|
||||||
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
|
|
||||||
4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
|
|
||||||
};
|
|
||||||
static unsigned int mxvar_baud_table1[] = {
|
|
||||||
0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
|
|
||||||
B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
|
|
||||||
};
|
|
||||||
#define BAUD_TABLE_NO ARRAY_SIZE(mxvar_baud_table)
|
|
||||||
|
|
||||||
#define B_SPEC B2000000
|
|
||||||
|
|
||||||
static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
|
static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
|
||||||
static int ttymajor = MXSERMAJOR;
|
static int ttymajor = MXSERMAJOR;
|
||||||
static int calloutmajor = MXSERCUMAJOR;
|
static int calloutmajor = MXSERCUMAJOR;
|
||||||
|
@ -243,10 +231,8 @@ struct mxser_port {
|
||||||
int rx_trigger; /* Rx fifo trigger level */
|
int rx_trigger; /* Rx fifo trigger level */
|
||||||
int rx_low_water;
|
int rx_low_water;
|
||||||
int baud_base; /* max. speed */
|
int baud_base; /* max. speed */
|
||||||
long realbaud;
|
|
||||||
int type; /* UART type */
|
int type; /* UART type */
|
||||||
int flags; /* defined in tty.h */
|
int flags; /* defined in tty.h */
|
||||||
int speed;
|
|
||||||
|
|
||||||
int x_char; /* xon/xoff character */
|
int x_char; /* xon/xoff character */
|
||||||
int IER; /* Interrupt Enable Register */
|
int IER; /* Interrupt Enable Register */
|
||||||
|
@ -451,7 +437,6 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
|
||||||
|
|
||||||
static int mxser_set_baud(struct mxser_port *info, long newspd)
|
static int mxser_set_baud(struct mxser_port *info, long newspd)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
int quot = 0, baud;
|
int quot = 0, baud;
|
||||||
unsigned char cval;
|
unsigned char cval;
|
||||||
|
|
||||||
|
@ -464,27 +449,17 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
|
||||||
if (newspd > info->max_baud)
|
if (newspd > info->max_baud)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
info->realbaud = newspd;
|
if (newspd == 134) {
|
||||||
for (i = 0; i < BAUD_TABLE_NO; i++)
|
quot = 2 * info->baud_base / 269;
|
||||||
if (newspd == mxvar_baud_table[i])
|
tty_encode_baud_rate(info->tty, 134, 134);
|
||||||
break;
|
} else if (newspd) {
|
||||||
if (i == BAUD_TABLE_NO) {
|
quot = info->baud_base / newspd;
|
||||||
quot = info->baud_base / info->speed;
|
if (quot == 0)
|
||||||
if (info->speed <= 0 || info->speed > info->max_baud)
|
quot = 1;
|
||||||
quot = 0;
|
baud = info->baud_base/quot;
|
||||||
|
tty_encode_baud_rate(info->tty, baud, baud);
|
||||||
} else {
|
} else {
|
||||||
if (newspd == 134) {
|
quot = 0;
|
||||||
quot = (2 * info->baud_base / 269);
|
|
||||||
tty_encode_baud_rate(info->tty, 134, 134);
|
|
||||||
} else if (newspd) {
|
|
||||||
quot = info->baud_base / newspd;
|
|
||||||
if (quot == 0)
|
|
||||||
quot = 1;
|
|
||||||
baud = info->baud_base/quot;
|
|
||||||
tty_encode_baud_rate(info->tty, baud, baud);
|
|
||||||
} else {
|
|
||||||
quot = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
|
info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
|
||||||
|
@ -507,17 +482,19 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
|
||||||
outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */
|
outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */
|
||||||
outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */
|
outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */
|
||||||
|
|
||||||
if (i == BAUD_TABLE_NO) {
|
#ifdef BOTHER
|
||||||
quot = info->baud_base % info->speed;
|
if (C_BAUD(info->tty) == BOTHER) {
|
||||||
|
quot = info->baud_base % newspd;
|
||||||
quot *= 8;
|
quot *= 8;
|
||||||
if ((quot % info->speed) > (info->speed / 2)) {
|
if (quot % newspd > newspd / 2) {
|
||||||
quot /= info->speed;
|
quot /= newspd;
|
||||||
quot++;
|
quot++;
|
||||||
} else {
|
} else
|
||||||
quot /= info->speed;
|
quot /= newspd;
|
||||||
}
|
|
||||||
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot);
|
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot);
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
|
SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -533,7 +510,6 @@ static int mxser_change_speed(struct mxser_port *info,
|
||||||
unsigned cflag, cval, fcr;
|
unsigned cflag, cval, fcr;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned char status;
|
unsigned char status;
|
||||||
long baud;
|
|
||||||
|
|
||||||
if (!info->tty || !info->tty->termios)
|
if (!info->tty || !info->tty->termios)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -541,13 +517,8 @@ static int mxser_change_speed(struct mxser_port *info,
|
||||||
if (!(info->ioaddr))
|
if (!(info->ioaddr))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (mxser_set_baud_method[info->tty->index] == 0) {
|
if (mxser_set_baud_method[info->tty->index] == 0)
|
||||||
if ((cflag & CBAUD) == B_SPEC)
|
mxser_set_baud(info, tty_get_baud_rate(info->tty));
|
||||||
baud = info->speed;
|
|
||||||
else
|
|
||||||
baud = tty_get_baud_rate(info->tty);
|
|
||||||
mxser_set_baud(info, baud);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* byte size and parity */
|
/* byte size and parity */
|
||||||
switch (cflag & CSIZE) {
|
switch (cflag & CSIZE) {
|
||||||
|
@ -1587,7 +1558,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
|
||||||
port->mon_data.up_txcnt;
|
port->mon_data.up_txcnt;
|
||||||
mon_data_ext.modem_status[i] =
|
mon_data_ext.modem_status[i] =
|
||||||
port->mon_data.modem_status;
|
port->mon_data.modem_status;
|
||||||
mon_data_ext.baudrate[i] = port->realbaud;
|
mon_data_ext.baudrate[i] =
|
||||||
|
tty_get_baud_rate(port->tty);
|
||||||
|
|
||||||
if (!port->tty || !port->tty->termios) {
|
if (!port->tty || !port->tty->termios) {
|
||||||
cflag = port->normal_termios.c_cflag;
|
cflag = port->normal_termios.c_cflag;
|
||||||
|
@ -1645,7 +1617,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
struct serial_icounter_struct __user *p_cuser;
|
struct serial_icounter_struct __user *p_cuser;
|
||||||
unsigned long templ;
|
unsigned long templ;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned int i;
|
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
@ -1684,36 +1655,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == MOXA_SET_SPECIAL_BAUD_RATE) {
|
|
||||||
int speed;
|
|
||||||
|
|
||||||
if (get_user(speed, (int __user *)argp))
|
|
||||||
return -EFAULT;
|
|
||||||
if (speed <= 0 || speed > info->max_baud)
|
|
||||||
return -EFAULT;
|
|
||||||
if (!info->tty || !info->tty->termios || !info->ioaddr)
|
|
||||||
return 0;
|
|
||||||
info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX);
|
|
||||||
for (i = 0; i < BAUD_TABLE_NO; i++)
|
|
||||||
if (speed == mxvar_baud_table[i])
|
|
||||||
break;
|
|
||||||
if (i == BAUD_TABLE_NO) {
|
|
||||||
info->tty->termios->c_cflag |= B_SPEC;
|
|
||||||
} else if (speed != 0)
|
|
||||||
info->tty->termios->c_cflag |= mxvar_baud_table1[i];
|
|
||||||
|
|
||||||
info->speed = speed;
|
|
||||||
spin_lock_irqsave(&info->slock, flags);
|
|
||||||
mxser_change_speed(info, NULL);
|
|
||||||
spin_unlock_irqrestore(&info->slock, flags);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else if (cmd == MOXA_GET_SPECIAL_BAUD_RATE) {
|
|
||||||
if (copy_to_user(argp, &info->speed, sizeof(int)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
|
if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
|
||||||
test_bit(TTY_IO_ERROR, &tty->flags))
|
test_bit(TTY_IO_ERROR, &tty->flags))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -1807,20 +1748,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
info->mon_data.rxcnt = 0;
|
info->mon_data.rxcnt = 0;
|
||||||
info->mon_data.txcnt = 0;
|
info->mon_data.txcnt = 0;
|
||||||
return 0;
|
return 0;
|
||||||
case MOXA_ASPP_SETBAUD:{
|
|
||||||
long baud;
|
|
||||||
if (get_user(baud, (long __user *)argp))
|
|
||||||
return -EFAULT;
|
|
||||||
spin_lock_irqsave(&info->slock, flags);
|
|
||||||
mxser_set_baud(info, baud);
|
|
||||||
spin_unlock_irqrestore(&info->slock, flags);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case MOXA_ASPP_GETBAUD:
|
|
||||||
if (copy_to_user(argp, &info->realbaud, sizeof(long)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case MOXA_ASPP_OQUEUE:{
|
case MOXA_ASPP_OQUEUE:{
|
||||||
int len, lsr;
|
int len, lsr;
|
||||||
|
@ -2434,7 +2361,6 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
|
||||||
info->normal_termios = mxvar_sdriver->init_termios;
|
info->normal_termios = mxvar_sdriver->init_termios;
|
||||||
init_waitqueue_head(&info->open_wait);
|
init_waitqueue_head(&info->open_wait);
|
||||||
init_waitqueue_head(&info->delta_msr_wait);
|
init_waitqueue_head(&info->delta_msr_wait);
|
||||||
info->speed = 9600;
|
|
||||||
memset(&info->mon_data, 0, sizeof(struct mxser_mon));
|
memset(&info->mon_data, 0, sizeof(struct mxser_mon));
|
||||||
info->err_shadow = 0;
|
info->err_shadow = 0;
|
||||||
spin_lock_init(&info->slock);
|
spin_lock_init(&info->slock);
|
||||||
|
|
|
@ -29,14 +29,10 @@
|
||||||
|
|
||||||
#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
|
#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
|
||||||
#define MOXA_ASPP_OQUEUE (MOXA + 70)
|
#define MOXA_ASPP_OQUEUE (MOXA + 70)
|
||||||
#define MOXA_ASPP_SETBAUD (MOXA + 71)
|
|
||||||
#define MOXA_ASPP_GETBAUD (MOXA + 72)
|
|
||||||
#define MOXA_ASPP_MON (MOXA + 73)
|
#define MOXA_ASPP_MON (MOXA + 73)
|
||||||
#define MOXA_ASPP_LSTATUS (MOXA + 74)
|
#define MOXA_ASPP_LSTATUS (MOXA + 74)
|
||||||
#define MOXA_ASPP_MON_EXT (MOXA + 75)
|
#define MOXA_ASPP_MON_EXT (MOXA + 75)
|
||||||
#define MOXA_SET_BAUD_METHOD (MOXA + 76)
|
#define MOXA_SET_BAUD_METHOD (MOXA + 76)
|
||||||
#define MOXA_SET_SPECIAL_BAUD_RATE (MOXA + 77)
|
|
||||||
#define MOXA_GET_SPECIAL_BAUD_RATE (MOXA + 78)
|
|
||||||
|
|
||||||
/* --------------------------------------------------- */
|
/* --------------------------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue