aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-07-25 04:48:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:43 -0400
commit41aee9a121fd0c31ae22dfe57e8f9ee9d6d85c25 (patch)
tree0b55efab61c97366b053e026ad31e711b69d4d82 /drivers/char
parent6ee8928d94841aa764aeaf645ad16daff811dc26 (diff)
Char: mxser, ioctl cleanup
- remove break ctl from ioctl handler, it's never reached, since tty_ops->break_ctl is defined (mxser break handling is done in software) - mark MOXA_GET_MAJOR as deprecated - fix TIOCGICOUNT (some retval non-checks of put_user). Use copy_to_user to whole structure instead. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Acked-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/mxser.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 4c756bbba948..e5029b149c5b 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -16,7 +16,6 @@
16 * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox 16 * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
17 * <alan@redhat.com>. The original 1.8 code is available on www.moxa.com. 17 * <alan@redhat.com>. The original 1.8 code is available on www.moxa.com.
18 * - Fixed x86_64 cleanness 18 * - Fixed x86_64 cleanness
19 * - Fixed sleep with spinlock held in mxser_send_break
20 */ 19 */
21 20
22#include <linux/module.h> 21#include <linux/module.h>
@@ -1634,6 +1633,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1634 1633
1635 switch (cmd) { 1634 switch (cmd) {
1636 case MOXA_GET_MAJOR: 1635 case MOXA_GET_MAJOR:
1636 printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl %x, fix "
1637 "your userspace\n", current->comm, cmd);
1637 return put_user(ttymajor, (int __user *)argp); 1638 return put_user(ttymajor, (int __user *)argp);
1638 1639
1639 case MOXA_CHKPORTENABLE: 1640 case MOXA_CHKPORTENABLE:
@@ -1804,7 +1805,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1804{ 1805{
1805 struct mxser_port *info = tty->driver_data; 1806 struct mxser_port *info = tty->driver_data;
1806 struct async_icount cnow; 1807 struct async_icount cnow;
1807 struct serial_icounter_struct __user *p_cuser;
1808 unsigned long flags; 1808 unsigned long flags;
1809 void __user *argp = (void __user *)arg; 1809 void __user *argp = (void __user *)arg;
1810 int retval; 1810 int retval;
@@ -1884,30 +1884,26 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1884 * NB: both 1->0 and 0->1 transitions are counted except for 1884 * NB: both 1->0 and 0->1 transitions are counted except for
1885 * RI where only 0->1 is counted. 1885 * RI where only 0->1 is counted.
1886 */ 1886 */
1887 case TIOCGICOUNT: 1887 case TIOCGICOUNT: {
1888 struct serial_icounter_struct icnt = { 0 };
1888 spin_lock_irqsave(&info->slock, flags); 1889 spin_lock_irqsave(&info->slock, flags);
1889 cnow = info->icount; 1890 cnow = info->icount;
1890 spin_unlock_irqrestore(&info->slock, flags); 1891 spin_unlock_irqrestore(&info->slock, flags);
1891 p_cuser = argp; 1892
1892 if (put_user(cnow.frame, &p_cuser->frame)) 1893 icnt.frame = cnow.frame;
1893 return -EFAULT; 1894 icnt.brk = cnow.brk;
1894 if (put_user(cnow.brk, &p_cuser->brk)) 1895 icnt.overrun = cnow.overrun;
1895 return -EFAULT; 1896 icnt.buf_overrun = cnow.buf_overrun;
1896 if (put_user(cnow.overrun, &p_cuser->overrun)) 1897 icnt.parity = cnow.parity;
1897 return -EFAULT; 1898 icnt.rx = cnow.rx;
1898 if (put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) 1899 icnt.tx = cnow.tx;
1899 return -EFAULT; 1900 icnt.cts = cnow.cts;
1900 if (put_user(cnow.parity, &p_cuser->parity)) 1901 icnt.dsr = cnow.dsr;
1901 return -EFAULT; 1902 icnt.rng = cnow.rng;
1902 if (put_user(cnow.rx, &p_cuser->rx)) 1903 icnt.dcd = cnow.dcd;
1903 return -EFAULT; 1904
1904 if (put_user(cnow.tx, &p_cuser->tx)) 1905 return copy_to_user(argp, &icnt, sizeof(icnt)) ? -EFAULT : 0;
1905 return -EFAULT; 1906 }
1906 put_user(cnow.cts, &p_cuser->cts);
1907 put_user(cnow.dsr, &p_cuser->dsr);
1908 put_user(cnow.rng, &p_cuser->rng);
1909 put_user(cnow.dcd, &p_cuser->dcd);
1910 return 0;
1911 case MOXA_HighSpeedOn: 1907 case MOXA_HighSpeedOn:
1912 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); 1908 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
1913 case MOXA_SDS_RSTICOUNTER: 1909 case MOXA_SDS_RSTICOUNTER: