Commit 979b6d89 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: simserial, use only one copy of async flags

The same as for amiserial. Use only one instance of the flags.

Also remove them from async_struct now. Nobody else uses them.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9e12dd5f
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define NR_PORTS 1 /* only one port for now */ #define NR_PORTS 1 /* only one port for now */
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED) #define IRQ_T(state) ((state->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
static char *serial_name = "SimSerial driver"; static char *serial_name = "SimSerial driver";
static char *serial_version = "0.6"; static char *serial_version = "0.6";
...@@ -455,12 +455,11 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) ...@@ -455,12 +455,11 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
static void shutdown(struct async_struct * info) static void shutdown(struct async_struct * info)
{ {
unsigned long flags; unsigned long flags;
struct serial_state *state; struct serial_state *state = info->state;
int retval; int retval;
if (!(info->flags & ASYNC_INITIALIZED)) return; if (!(state->flags & ASYNC_INITIALIZED))
return;
state = info->state;
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
printk("Shutting down serial port %d (irq %d)....", info->line, printk("Shutting down serial port %d (irq %d)....", info->line,
...@@ -487,7 +486,8 @@ static void shutdown(struct async_struct * info) ...@@ -487,7 +486,8 @@ static void shutdown(struct async_struct * info)
if (IRQ_ports[state->irq]) { if (IRQ_ports[state->irq]) {
free_irq(state->irq, NULL); free_irq(state->irq, NULL);
retval = request_irq(state->irq, rs_interrupt_single, retval = request_irq(state->irq, rs_interrupt_single,
IRQ_T(info), "serial", NULL); IRQ_T(state), "serial",
NULL);
if (retval) if (retval)
printk(KERN_ERR "serial shutdown: request_irq: error %d" printk(KERN_ERR "serial shutdown: request_irq: error %d"
...@@ -503,7 +503,7 @@ static void shutdown(struct async_struct * info) ...@@ -503,7 +503,7 @@ static void shutdown(struct async_struct * info)
if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
info->flags &= ~ASYNC_INITIALIZED; state->flags &= ~ASYNC_INITIALIZED;
} }
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -560,7 +560,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -560,7 +560,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
local_irq_restore(flags); local_irq_restore(flags);
return; return;
} }
info->flags |= ASYNC_CLOSING; state->flags |= ASYNC_CLOSING;
local_irq_restore(flags); local_irq_restore(flags);
/* /*
...@@ -576,7 +576,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -576,7 +576,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
schedule_timeout_interruptible(info->close_delay); schedule_timeout_interruptible(info->close_delay);
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait); wake_up_interruptible(&info->close_wait);
} }
...@@ -600,15 +600,13 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -600,15 +600,13 @@ static void rs_hangup(struct tty_struct *tty)
printk("rs_hangup: called\n"); printk("rs_hangup: called\n");
#endif #endif
state = info->state;
rs_flush_buffer(tty); rs_flush_buffer(tty);
if (info->flags & ASYNC_CLOSING) if (state->flags & ASYNC_CLOSING)
return; return;
shutdown(info); shutdown(info);
state->count = 0; state->count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE; state->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = NULL; info->tty = NULL;
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
...@@ -633,7 +631,6 @@ static int get_async_struct(int line, struct async_struct **ret_info) ...@@ -633,7 +631,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait); init_waitqueue_head(&info->close_wait);
info->port = sstate->port; info->port = sstate->port;
info->flags = sstate->flags;
info->xmit_fifo_size = sstate->xmit_fifo_size; info->xmit_fifo_size = sstate->xmit_fifo_size;
info->line = line; info->line = line;
info->state = sstate; info->state = sstate;
...@@ -661,7 +658,7 @@ startup(struct async_struct *info) ...@@ -661,7 +658,7 @@ startup(struct async_struct *info)
local_irq_save(flags); local_irq_save(flags);
if (info->flags & ASYNC_INITIALIZED) { if (state->flags & ASYNC_INITIALIZED) {
free_page(page); free_page(page);
goto errout; goto errout;
} }
...@@ -691,7 +688,8 @@ startup(struct async_struct *info) ...@@ -691,7 +688,8 @@ startup(struct async_struct *info)
} else } else
handler = rs_interrupt_single; handler = rs_interrupt_single;
retval = request_irq(state->irq, handler, IRQ_T(info), "simserial", NULL); retval = request_irq(state->irq, handler, IRQ_T(state),
"simserial", NULL);
if (retval) if (retval)
goto errout; goto errout;
} }
...@@ -721,17 +719,17 @@ startup(struct async_struct *info) ...@@ -721,17 +719,17 @@ startup(struct async_struct *info)
* Set up the tty->alt_speed kludge * Set up the tty->alt_speed kludge
*/ */
if (info->tty) { if (info->tty) {
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
info->tty->alt_speed = 57600; info->tty->alt_speed = 57600;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
info->tty->alt_speed = 115200; info->tty->alt_speed = 115200;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
info->tty->alt_speed = 230400; info->tty->alt_speed = 230400;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
info->tty->alt_speed = 460800; info->tty->alt_speed = 460800;
} }
info->flags |= ASYNC_INITIALIZED; state->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags); local_irq_restore(flags);
return 0; return 0;
...@@ -762,7 +760,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -762,7 +760,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
printk("rs_open %s, count = %d\n", tty->name, info->state->count); printk("rs_open %s, count = %d\n", tty->name, info->state->count);
#endif #endif
info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; info->tty->low_latency = (info->state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
if (!tmp_buf) { if (!tmp_buf) {
page = get_zeroed_page(GFP_KERNEL); page = get_zeroed_page(GFP_KERNEL);
...@@ -778,11 +776,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -778,11 +776,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
* If the port is the middle of closing, bail out now * If the port is the middle of closing, bail out now
*/ */
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
(info->flags & ASYNC_CLOSING)) { (info->state->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING) if (info->state->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait); interruptible_sleep_on(&info->close_wait);
#ifdef SERIAL_DO_RESTART #ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ? return ((info->state->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
#else #else
return -EAGAIN; return -EAGAIN;
......
...@@ -43,7 +43,6 @@ struct serial_state { ...@@ -43,7 +43,6 @@ struct serial_state {
struct async_struct { struct async_struct {
unsigned long port; unsigned long port;
int flags;
int xmit_fifo_size; int xmit_fifo_size;
struct serial_state *state; struct serial_state *state;
struct tty_struct *tty; struct tty_struct *tty;
......
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