Commit e4e95f51 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] callout removal: esp

callout removal: esp
parent 04da6b90
......@@ -109,12 +109,11 @@ static char serial_version[] __initdata = "2.2";
static DECLARE_TASK_QUEUE(tq_esp);
static struct tty_driver esp_driver, esp_callout_driver;
static struct tty_driver esp_driver;
static int serial_refcount;
/* serial subtype definitions */
#define SERIAL_TYPE_NORMAL 1
#define SERIAL_TYPE_CALLOUT 2
/*
* Serial driver configuration section. Here are the various options:
......@@ -638,8 +637,7 @@ static _INLINE_ void check_modem_status(struct esp_struct *info)
#endif
if (status & UART_MSR_DCD)
wake_up_interruptible(&info->open_wait);
else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) &&
(info->flags & ASYNC_CALLOUT_NOHUP))) {
else {
#ifdef SERIAL_DEBUG_OPEN
printk("scheduling hangup...");
#endif
......@@ -2077,8 +2075,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
*/
if (info->flags & ASYNC_NORMAL_ACTIVE)
info->normal_termios = *tty->termios;
if (info->flags & ASYNC_CALLOUT_ACTIVE)
info->callout_termios = *tty->termios;
/*
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
......@@ -2126,8 +2122,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
wake_up_interruptible(&info->open_wait);
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
ASYNC_CLOSING);
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
out:
restore_flags(flags);
......@@ -2185,7 +2180,7 @@ static void esp_hangup(struct tty_struct *tty)
shutdown(info);
info->event = 0;
info->count = 0;
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = 0;
wake_up_interruptible(&info->open_wait);
}
......@@ -2221,44 +2216,18 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif
}
/*
* If this is a callout device, then just make sure the normal
* device isn't being used.
*/
if (tty->driver->subtype == SERIAL_TYPE_CALLOUT) {
if (info->flags & ASYNC_NORMAL_ACTIVE)
return -EBUSY;
if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
(info->flags & ASYNC_SESSION_LOCKOUT) &&
(info->session != current->session))
return -EBUSY;
if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
(info->flags & ASYNC_PGRP_LOCKOUT) &&
(info->pgrp != current->pgrp))
return -EBUSY;
info->flags |= ASYNC_CALLOUT_ACTIVE;
return 0;
}
/*
* If non-blocking mode is set, or the port is not enabled,
* then make the check up front and then exit.
*/
if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
if (info->flags & ASYNC_CALLOUT_ACTIVE)
return -EBUSY;
info->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
if (info->flags & ASYNC_CALLOUT_ACTIVE) {
if (info->normal_termios.c_cflag & CLOCAL)
do_clocal = 1;
} else {
if (tty->termios->c_cflag & CLOCAL)
do_clocal = 1;
}
/*
* Block waiting for the carrier detect and the line to become
......@@ -2282,8 +2251,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
while (1) {
save_flags(flags);
cli();
if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
(tty->termios->c_cflag & CBAUD)) {
if ((tty->termios->c_cflag & CBAUD)) {
unsigned int scratch;
serial_out(info, UART_ESI_CMD1, ESI_READ_UART);
......@@ -2313,8 +2281,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD)
do_clocal = 1;
if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
!(info->flags & ASYNC_CLOSING) &&
if (!(info->flags & ASYNC_CLOSING) &&
(do_clocal))
break;
if (signal_pending(current)) {
......@@ -2399,16 +2366,10 @@ static int esp_open(struct tty_struct *tty, struct file * filp)
}
if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
*tty->termios = info->normal_termios;
else
*tty->termios = info->callout_termios;
change_speed(info);
}
info->session = current->session;
info->pgrp = current->pgrp;
#ifdef SERIAL_DEBUG_OPEN
printk("esp_open %s successful...", tty->name);
#endif
......@@ -2581,35 +2542,18 @@ int __init espserial_init(void)
esp_driver.break_ctl = esp_break;
esp_driver.wait_until_sent = rs_wait_until_sent;
/*
* The callout device is just like normal device except for
* major number and the subtype code.
*/
esp_callout_driver = esp_driver;
esp_callout_driver.name = "cup";
esp_callout_driver.major = ESP_OUT_MAJOR;
esp_callout_driver.subtype = SERIAL_TYPE_CALLOUT;
if (tty_register_driver(&esp_driver))
{
printk(KERN_ERR "Couldn't register esp serial driver");
return 1;
}
if (tty_register_driver(&esp_callout_driver))
{
printk(KERN_ERR "Couldn't register esp callout driver");
tty_unregister_driver(&esp_driver);
return 1;
}
info = kmalloc(sizeof(struct esp_struct), GFP_KERNEL);
if (!info)
{
printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
tty_unregister_driver(&esp_driver);
tty_unregister_driver(&esp_callout_driver);
return 1;
}
......@@ -2643,7 +2587,6 @@ int __init espserial_init(void)
info->tqueue.data = info;
info->tqueue_hangup.routine = do_serial_hangup;
info->tqueue_hangup.data = info;
info->callout_termios = esp_callout_driver.init_termios;
info->normal_termios = esp_driver.init_termios;
info->config.rx_timeout = rx_timeout;
info->config.flow_on = flow_on;
......@@ -2717,9 +2660,6 @@ static void __exit espserial_exit(void)
if ((e1 = tty_unregister_driver(&esp_driver)))
printk("SERIAL: failed to unregister serial driver (%d)\n",
e1);
if ((e2 = tty_unregister_driver(&esp_callout_driver)))
printk("SERIAL: failed to unregister callout driver (%d)\n",
e2);
restore_flags(flags);
while (ports) {
......
......@@ -96,8 +96,6 @@ struct esp_struct {
int line;
int count; /* # of fd on device */
int blocked_open; /* # of blocked opens */
long session; /* Session of opening process */
long pgrp; /* pgrp of opening process */
unsigned char *xmit_buf;
int xmit_head;
int xmit_tail;
......@@ -105,7 +103,6 @@ struct esp_struct {
struct work_struct tqueue;
struct work_struct tqueue_hangup;
struct termios normal_termios;
struct termios callout_termios;
wait_queue_head_t open_wait;
wait_queue_head_t close_wait;
wait_queue_head_t delta_msr_wait;
......
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