X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fchar%2Fn_hdlc.c;h=24ccc233b213998b011f19bd97454df626edc6d2;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=3e10c700d6858424751d92e1c5d2fc8188bfb6b5;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c index 3e10c700d..24ccc233b 100644 --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c @@ -103,9 +103,9 @@ #include /* used in new tty drivers */ #include /* used in new tty drivers */ #include +#include #include -#include #include #include @@ -177,14 +177,14 @@ static struct n_hdlc *n_hdlc_alloc (void); static int debuglevel; /* max frame size for memory allocations */ -static ssize_t maxframe = 4096; +static int maxframe = 4096; /* TTY callbacks */ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, __u8 __user *buf, size_t nr); static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, - const __u8 __user *buf, size_t nr); + const unsigned char *buf, size_t nr); static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp, @@ -402,7 +402,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) /* Send the next block of data to device */ tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); - actual = tty->driver->write(tty, 0, tbuf->buf, tbuf->count); + actual = tty->driver->write(tty, tbuf->buf, tbuf->count); /* if transmit error, throw frame away by */ /* pretending it was accepted by driver */ @@ -649,7 +649,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, * Returns the number of bytes written (or error code). */ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, - const __u8 __user *data, size_t count) + const unsigned char *data, size_t count) { struct n_hdlc *n_hdlc = tty2n_hdlc (tty); int error = 0; @@ -672,7 +672,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, if (debuglevel & DEBUG_LEVEL_INFO) printk (KERN_WARNING "n_hdlc_tty_write: truncating user packet " - "from %lu to %Zd\n", (unsigned long) count, + "from %lu to %d\n", (unsigned long) count, maxframe ); count = maxframe; } @@ -704,16 +704,12 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, if (!error) { /* Retrieve the user's buffer */ - if (copy_from_user(tbuf->buf, data, count)) { - /* return tx buffer to free list */ - n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,tbuf); - error = -EFAULT; - } else { - /* Send the data */ - tbuf->count = error = count; - n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); - n_hdlc_send_frames(n_hdlc,tty); - } + memcpy(tbuf->buf, data, count); + + /* Send the data */ + tbuf->count = error = count; + n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); + n_hdlc_send_frames(n_hdlc,tty); } return error; @@ -979,6 +975,6 @@ module_exit(n_hdlc_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com"); -MODULE_PARM(debuglevel, "i"); -MODULE_PARM(maxframe, "i"); +module_param(debuglevel, int, 0); +module_param(maxframe, int, 0); MODULE_ALIAS_LDISC(N_HDLC);