X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmacintosh%2Fmacserial.c;h=0be3ac6cc1699d431e7f9e9611b11d01bd6dd471;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=a3a5372f7aeb3723123a37d4eaf75d440b318b0a;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c index a3a5372f7..0be3ac6cc 100644 --- a/drivers/macintosh/macserial.c +++ b/drivers/macintosh/macserial.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +155,7 @@ static void dbdma_flush(volatile struct dbdma_regs *dma); static irqreturn_t rs_txdma_irq(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t rs_rxdma_irq(int irq, void *dev_id, struct pt_regs *regs); static void dma_init(struct mac_serial * info); -static void rxdma_start(struct mac_serial * info, int current); +static void rxdma_start(struct mac_serial * info, int curr); static void rxdma_to_tty(struct mac_serial * info); /* @@ -762,10 +762,10 @@ static int startup(struct mac_serial * info) return 0; } -static _INLINE_ void rxdma_start(struct mac_serial * info, int current) +static _INLINE_ void rxdma_start(struct mac_serial * info, int curr) { volatile struct dbdma_regs *rd = &info->rx->dma; - volatile struct dbdma_cmd *cd = info->rx_cmds[current]; + volatile struct dbdma_cmd *cd = info->rx_cmds[curr]; //printk(KERN_DEBUG "SCC: rxdma_start\n"); @@ -1461,7 +1461,7 @@ static void rs_flush_chars(struct tty_struct *tty) spin_unlock_irqrestore(&info->lock, flags); } -static int rs_write(struct tty_struct * tty, int from_user, +static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) { int c, ret = 0; @@ -1474,51 +1474,22 @@ static int rs_write(struct tty_struct * tty, int from_user, if (!tty || !info->xmit_buf || !tmp_buf) return 0; - if (from_user) { - down(&tmp_buf_sem); - while (1) { - c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - if (c <= 0) - break; - - c -= copy_from_user(tmp_buf, buf, c); - if (!c) { - if (!ret) - ret = -EFAULT; - break; - } - spin_lock_irqsave(&info->lock, flags); - c = min_t(int, c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c); - info->xmit_head = ((info->xmit_head + c) & - (SERIAL_XMIT_SIZE-1)); - info->xmit_cnt += c; - spin_unlock_irqrestore(&info->lock, flags); - buf += c; - count -= c; - ret += c; - } - up(&tmp_buf_sem); - } else { - while (1) { - spin_lock_irqsave(&info->lock, flags); - c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - if (c <= 0) { - spin_unlock_irqrestore(&info->lock, flags); - break; - } - memcpy(info->xmit_buf + info->xmit_head, buf, c); - info->xmit_head = ((info->xmit_head + c) & - (SERIAL_XMIT_SIZE-1)); - info->xmit_cnt += c; + while (1) { + spin_lock_irqsave(&info->lock, flags); + c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, + SERIAL_XMIT_SIZE - info->xmit_head)); + if (c <= 0) { spin_unlock_irqrestore(&info->lock, flags); - buf += c; - count -= c; - ret += c; + break; } + memcpy(info->xmit_buf + info->xmit_head, buf, c); + info->xmit_head = ((info->xmit_head + c) & + (SERIAL_XMIT_SIZE-1)); + info->xmit_cnt += c; + spin_unlock_irqrestore(&info->lock, flags); + buf += c; + count -= c; + ret += c; } spin_lock_irqsave(&info->lock, flags); if (info->xmit_cnt && !tty->stopped && !info->tx_stopped