Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95216
b: refs/heads/master
c: 978e595
h: refs/heads/master
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Apr 30, 2008
1 parent f7a56a7 commit 5a87dd5
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 235 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac0e4b7d319bf284bb64bc7e1c051417386b34a4
refs/heads/master: 978e595f88a1fba5869aa42a4af4fba36f33ecac
6 changes: 4 additions & 2 deletions trunk/drivers/char/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
rs_wait_until_sent(tty, info->timeout);
}
shutdown(info);
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
rs_flush_buffer(tty);

tty_ldisc_flush(tty);
tty->closing = 0;
Expand Down Expand Up @@ -1539,6 +1538,8 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
return; /* Just in case.... */

orig_jiffies = jiffies;

lock_kernel();
/*
* Set the check interval to be 1/5 of the estimated time to
* send a single character, and make it at least 1. The check
Expand Down Expand Up @@ -1579,6 +1580,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
break;
}
__set_current_state(TASK_RUNNING);
unlock_kernel();
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
#endif
Expand Down
76 changes: 40 additions & 36 deletions trunk/drivers/char/cyclades.c
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
return; /* Just in case.... */

orig_jiffies = jiffies;
lock_kernel();
/*
* Set the check interval to be 1/5 of the estimated time to
* send a single character, and make it at least 1. The check
Expand Down Expand Up @@ -2573,11 +2574,47 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
}
/* Run one more char cycle */
msleep_interruptible(jiffies_to_msecs(char_time * 5));
unlock_kernel();
#ifdef CY_DEBUG_WAIT_UNTIL_SENT
printk(KERN_DEBUG "Clean (jiff=%lu)...done\n", jiffies);
#endif
}

static void cy_flush_buffer(struct tty_struct *tty)
{
struct cyclades_port *info = tty->driver_data;
struct cyclades_card *card;
int channel, retval;
unsigned long flags;

#ifdef CY_DEBUG_IO
printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line);
#endif

if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
return;

card = info->card;
channel = info->line - card->first_line;

spin_lock_irqsave(&card->card_lock, flags);
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
spin_unlock_irqrestore(&card->card_lock, flags);

if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
buffers as well */
spin_lock_irqsave(&card->card_lock, flags);
retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
if (retval != 0) {
printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d "
"was %x\n", info->line, retval);
}
spin_unlock_irqrestore(&card->card_lock, flags);
}
tty_wakeup(tty);
} /* cy_flush_buffer */


/*
* This routine is called when a particular tty device is closed.
*/
Expand Down Expand Up @@ -2689,8 +2726,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)

spin_unlock_irqrestore(&card->card_lock, flags);
shutdown(info);
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
cy_flush_buffer(tty);
tty_ldisc_flush(tty);
spin_lock_irqsave(&card->card_lock, flags);

Expand Down Expand Up @@ -2881,6 +2917,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
int char_count;
__u32 tx_put, tx_get, tx_bufsize;

lock_kernel();
firm_id = card->base_addr + ID_ADDRESS;
zfw_ctrl = card->base_addr +
(readl(&firm_id->zfwctrl_addr) & 0xfffff);
Expand All @@ -2898,6 +2935,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n",
info->line, info->xmit_cnt + char_count);
#endif
unlock_kernel();
return info->xmit_cnt + char_count;
}
#endif /* Z_EXT_CHARS_IN_BUFFER */
Expand Down Expand Up @@ -4271,40 +4309,6 @@ static void cy_start(struct tty_struct *tty)
}
} /* cy_start */

static void cy_flush_buffer(struct tty_struct *tty)
{
struct cyclades_port *info = tty->driver_data;
struct cyclades_card *card;
int channel, retval;
unsigned long flags;

#ifdef CY_DEBUG_IO
printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line);
#endif

if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
return;

card = info->card;
channel = info->line - card->first_line;

spin_lock_irqsave(&card->card_lock, flags);
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
spin_unlock_irqrestore(&card->card_lock, flags);

if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
buffers as well */
spin_lock_irqsave(&card->card_lock, flags);
retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
if (retval != 0) {
printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d "
"was %x\n", info->line, retval);
}
spin_unlock_irqrestore(&card->card_lock, flags);
}
tty_wakeup(tty);
} /* cy_flush_buffer */

/*
* cy_hangup() --- called by tty_hangup() when a hangup is signaled.
*/
Expand Down
13 changes: 2 additions & 11 deletions trunk/drivers/char/epca.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ static void epca_error(int, char *);
static void pc_close(struct tty_struct *, struct file *);
static void shutdown(struct channel *);
static void pc_hangup(struct tty_struct *);
static void pc_put_char(struct tty_struct *, unsigned char);
static int pc_write_room(struct tty_struct *);
static int pc_chars_in_buffer(struct tty_struct *);
static void pc_flush_buffer(struct tty_struct *);
Expand Down Expand Up @@ -459,8 +458,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
setup_empty_event(tty, ch);
tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
}
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
pc_flush_buffer(tty);

tty_ldisc_flush(tty);
shutdown(ch);
Expand Down Expand Up @@ -532,8 +530,7 @@ static void pc_hangup(struct tty_struct *tty)
if ((ch = verifyChannel(tty)) != NULL) {
unsigned long flags;

if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
pc_flush_buffer(tty);
tty_ldisc_flush(tty);
shutdown(ch);

Expand Down Expand Up @@ -645,11 +642,6 @@ static int pc_write(struct tty_struct *tty,
return amountCopied;
}

static void pc_put_char(struct tty_struct *tty, unsigned char c)
{
pc_write(tty, &c, 1);
}

static int pc_write_room(struct tty_struct *tty)
{
int remain;
Expand Down Expand Up @@ -1035,7 +1027,6 @@ static const struct tty_operations pc_ops = {
.flush_buffer = pc_flush_buffer,
.chars_in_buffer = pc_chars_in_buffer,
.flush_chars = pc_flush_chars,
.put_char = pc_put_char,
.ioctl = pc_ioctl,
.set_termios = pc_set_termios,
.stop = pc_stop,
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/char/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
rs_wait_until_sent(tty, info->timeout);
}
shutdown(info);
if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
tty->closing = 0;
info->tty = NULL;
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/char/generic_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ void gs_close(struct tty_struct * tty, struct file * filp)

port->flags &= ~GS_ACTIVE;

if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
gs_flush_buffer(tty);

tty_ldisc_flush(tty);
tty->closing = 0;
Expand Down
35 changes: 17 additions & 18 deletions trunk/drivers/char/isicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,22 @@ static void isicom_shutdown_port(struct isi_port *port)
}
}

static void isicom_flush_buffer(struct tty_struct *tty)
{
struct isi_port *port = tty->driver_data;
struct isi_board *card = port->card;
unsigned long flags;

if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer"))
return;

spin_lock_irqsave(&card->card_lock, flags);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
spin_unlock_irqrestore(&card->card_lock, flags);

tty_wakeup(tty);
}

static void isicom_close(struct tty_struct *tty, struct file *filp)
{
struct isi_port *port = tty->driver_data;
Expand Down Expand Up @@ -1065,8 +1081,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
isicom_shutdown_port(port);
spin_unlock_irqrestore(&card->card_lock, flags);

if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);
isicom_flush_buffer(tty);
tty_ldisc_flush(tty);

spin_lock_irqsave(&card->card_lock, flags);
Expand Down Expand Up @@ -1447,22 +1462,6 @@ static void isicom_hangup(struct tty_struct *tty)
wake_up_interruptible(&port->open_wait);
}

/* flush_buffer et all */
static void isicom_flush_buffer(struct tty_struct *tty)
{
struct isi_port *port = tty->driver_data;
struct isi_board *card = port->card;
unsigned long flags;

if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer"))
return;

spin_lock_irqsave(&card->card_lock, flags);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
spin_unlock_irqrestore(&card->card_lock, flags);

tty_wakeup(tty);
}

/*
* Driver init and deinit functions
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/char/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty)
*/
if (ch == NULL)
return 0;
lock_kernel();
chars = MoxaPortTxQueue(ch);
if (chars) {
/*
Expand All @@ -1289,6 +1290,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty)
if (!(ch->statusflags & EMPTYWAIT))
moxa_setup_empty_event(tty);
}
unlock_kernel();
return chars;
}

Expand Down
47 changes: 24 additions & 23 deletions trunk/drivers/char/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,27 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
return 0;
}

static void mxser_flush_buffer(struct tty_struct *tty)
{
struct mxser_port *info = tty->driver_data;
char fcr;
unsigned long flags;


spin_lock_irqsave(&info->slock, flags);
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

fcr = inb(info->ioaddr + UART_FCR);
outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
info->ioaddr + UART_FCR);
outb(fcr, info->ioaddr + UART_FCR);

spin_unlock_irqrestore(&info->slock, flags);

tty_wakeup(tty);
}


/*
* This routine is called when the serial port gets closed. First, we
* wait for the last remaining data to be sent. Then, we unlink its
Expand Down Expand Up @@ -1013,9 +1034,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
}
mxser_shutdown(info);

if (tty->driver->flush_buffer)
tty->driver->flush_buffer(tty);

mxser_flush_buffer(tty);
tty_ldisc_flush(tty);

tty->closing = 0;
Expand Down Expand Up @@ -1142,26 +1161,6 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
return info->xmit_cnt;
}

static void mxser_flush_buffer(struct tty_struct *tty)
{
struct mxser_port *info = tty->driver_data;
char fcr;
unsigned long flags;


spin_lock_irqsave(&info->slock, flags);
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

fcr = inb(info->ioaddr + UART_FCR);
outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
info->ioaddr + UART_FCR);
outb(fcr, info->ioaddr + UART_FCR);

spin_unlock_irqrestore(&info->slock, flags);

tty_wakeup(tty);
}

/*
* ------------------------------------------------------------
* friends of mxser_ioctl()
Expand Down Expand Up @@ -1992,6 +1991,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
timeout, char_time);
printk("jiff=%lu...", jiffies);
#endif
lock_kernel();
while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
Expand All @@ -2003,6 +2003,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
break;
}
set_current_state(TASK_RUNNING);
unlock_kernel();

#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
Expand Down
Loading

0 comments on commit 5a87dd5

Please sign in to comment.