Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41aee9a1 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds
Browse files

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: default avatarJiri Slaby <jirislaby@gmail.com>
Acked-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6ee8928d
Loading
Loading
Loading
Loading
+19 −23
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@
 *	Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
 *	Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox
 *	<alan@redhat.com>. The original 1.8 code is available on www.moxa.com.
 *	<alan@redhat.com>. The original 1.8 code is available on www.moxa.com.
 *	- Fixed x86_64 cleanness
 *	- Fixed x86_64 cleanness
 *	- Fixed sleep with spinlock held in mxser_send_break
 */
 */


#include <linux/module.h>
#include <linux/module.h>
@@ -1634,6 +1633,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)


	switch (cmd) {
	switch (cmd) {
	case MOXA_GET_MAJOR:
	case MOXA_GET_MAJOR:
		printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl %x, fix "
				"your userspace\n", current->comm, cmd);
		return put_user(ttymajor, (int __user *)argp);
		return put_user(ttymajor, (int __user *)argp);


	case MOXA_CHKPORTENABLE:
	case MOXA_CHKPORTENABLE:
@@ -1804,7 +1805,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
{
{
	struct mxser_port *info = tty->driver_data;
	struct mxser_port *info = tty->driver_data;
	struct async_icount cnow;
	struct async_icount cnow;
	struct serial_icounter_struct __user *p_cuser;
	unsigned long flags;
	unsigned long flags;
	void __user *argp = (void __user *)arg;
	void __user *argp = (void __user *)arg;
	int retval;
	int retval;
@@ -1884,30 +1884,26 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
	 * NB: both 1->0 and 0->1 transitions are counted except for
	 * NB: both 1->0 and 0->1 transitions are counted except for
	 *     RI where only 0->1 is counted.
	 *     RI where only 0->1 is counted.
	 */
	 */
	case TIOCGICOUNT:
	case TIOCGICOUNT: {
		struct serial_icounter_struct icnt = { 0 };
		spin_lock_irqsave(&info->slock, flags);
		spin_lock_irqsave(&info->slock, flags);
		cnow = info->icount;
		cnow = info->icount;
		spin_unlock_irqrestore(&info->slock, flags);
		spin_unlock_irqrestore(&info->slock, flags);
		p_cuser = argp;

		if (put_user(cnow.frame, &p_cuser->frame))
		icnt.frame = cnow.frame;
			return -EFAULT;
		icnt.brk = cnow.brk;
		if (put_user(cnow.brk, &p_cuser->brk))
		icnt.overrun = cnow.overrun;
			return -EFAULT;
		icnt.buf_overrun = cnow.buf_overrun;
		if (put_user(cnow.overrun, &p_cuser->overrun))
		icnt.parity = cnow.parity;
			return -EFAULT;
		icnt.rx = cnow.rx;
		if (put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
		icnt.tx = cnow.tx;
			return -EFAULT;
		icnt.cts = cnow.cts;
		if (put_user(cnow.parity, &p_cuser->parity))
		icnt.dsr = cnow.dsr;
			return -EFAULT;
		icnt.rng = cnow.rng;
		if (put_user(cnow.rx, &p_cuser->rx))
		icnt.dcd = cnow.dcd;
			return -EFAULT;

		if (put_user(cnow.tx, &p_cuser->tx))
		return copy_to_user(argp, &icnt, sizeof(icnt)) ? -EFAULT : 0;
			return -EFAULT;
	}
		put_user(cnow.cts, &p_cuser->cts);
		put_user(cnow.dsr, &p_cuser->dsr);
		put_user(cnow.rng, &p_cuser->rng);
		put_user(cnow.dcd, &p_cuser->dcd);
		return 0;
	case MOXA_HighSpeedOn:
	case MOXA_HighSpeedOn:
		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
		return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
	case MOXA_SDS_RSTICOUNTER:
	case MOXA_SDS_RSTICOUNTER: