diff options
author | Alan Cox <alan@linux.intel.com> | 2010-09-16 13:21:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:20:05 -0400 |
commit | 0587102cf9f427c185bfdeb2cef41e13ee0264b1 (patch) | |
tree | 94c6dcc7ac230dee166d2f6aa1f9a54bffe5764b /drivers/char/mxser.c | |
parent | 0bca1b913affbd7e2fdaffee62a499659a466eb5 (diff) |
tty: icount changeover for other main devices
Again basically cut and paste
Convert the main driver set to use the hooks for GICOUNT
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r-- | drivers/char/mxser.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 9d243de795df..463df27494bd 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -1700,7 +1700,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1700 | return 0; | 1700 | return 0; |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT && | 1703 | if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && |
1704 | test_bit(TTY_IO_ERROR, &tty->flags)) | 1704 | test_bit(TTY_IO_ERROR, &tty->flags)) |
1705 | return -EIO; | 1705 | return -EIO; |
1706 | 1706 | ||
@@ -1730,32 +1730,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1730 | 1730 | ||
1731 | return wait_event_interruptible(info->port.delta_msr_wait, | 1731 | return wait_event_interruptible(info->port.delta_msr_wait, |
1732 | mxser_cflags_changed(info, arg, &cnow)); | 1732 | mxser_cflags_changed(info, arg, &cnow)); |
1733 | /* | ||
1734 | * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) | ||
1735 | * Return: write counters to the user passed counter struct | ||
1736 | * NB: both 1->0 and 0->1 transitions are counted except for | ||
1737 | * RI where only 0->1 is counted. | ||
1738 | */ | ||
1739 | case TIOCGICOUNT: { | ||
1740 | struct serial_icounter_struct icnt = { 0 }; | ||
1741 | spin_lock_irqsave(&info->slock, flags); | ||
1742 | cnow = info->icount; | ||
1743 | spin_unlock_irqrestore(&info->slock, flags); | ||
1744 | |||
1745 | icnt.frame = cnow.frame; | ||
1746 | icnt.brk = cnow.brk; | ||
1747 | icnt.overrun = cnow.overrun; | ||
1748 | icnt.buf_overrun = cnow.buf_overrun; | ||
1749 | icnt.parity = cnow.parity; | ||
1750 | icnt.rx = cnow.rx; | ||
1751 | icnt.tx = cnow.tx; | ||
1752 | icnt.cts = cnow.cts; | ||
1753 | icnt.dsr = cnow.dsr; | ||
1754 | icnt.rng = cnow.rng; | ||
1755 | icnt.dcd = cnow.dcd; | ||
1756 | |||
1757 | return copy_to_user(argp, &icnt, sizeof(icnt)) ? -EFAULT : 0; | ||
1758 | } | ||
1759 | case MOXA_HighSpeedOn: | 1733 | case MOXA_HighSpeedOn: |
1760 | return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); | 1734 | return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); |
1761 | case MOXA_SDS_RSTICOUNTER: | 1735 | case MOXA_SDS_RSTICOUNTER: |
@@ -1828,6 +1802,39 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, | |||
1828 | return 0; | 1802 | return 0; |
1829 | } | 1803 | } |
1830 | 1804 | ||
1805 | /* | ||
1806 | * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) | ||
1807 | * Return: write counters to the user passed counter struct | ||
1808 | * NB: both 1->0 and 0->1 transitions are counted except for | ||
1809 | * RI where only 0->1 is counted. | ||
1810 | */ | ||
1811 | |||
1812 | static int mxser_get_icount(struct tty_struct *tty, | ||
1813 | struct serial_icounter_struct *icount) | ||
1814 | |||
1815 | { | ||
1816 | struct mxser_port *info = tty->driver_data; | ||
1817 | struct async_icount cnow; | ||
1818 | unsigned long flags; | ||
1819 | |||
1820 | spin_lock_irqsave(&info->slock, flags); | ||
1821 | cnow = info->icount; | ||
1822 | spin_unlock_irqrestore(&info->slock, flags); | ||
1823 | |||
1824 | icount->frame = cnow.frame; | ||
1825 | icount->brk = cnow.brk; | ||
1826 | icount->overrun = cnow.overrun; | ||
1827 | icount->buf_overrun = cnow.buf_overrun; | ||
1828 | icount->parity = cnow.parity; | ||
1829 | icount->rx = cnow.rx; | ||
1830 | icount->tx = cnow.tx; | ||
1831 | icount->cts = cnow.cts; | ||
1832 | icount->dsr = cnow.dsr; | ||
1833 | icount->rng = cnow.rng; | ||
1834 | icount->dcd = cnow.dcd; | ||
1835 | return 0; | ||
1836 | } | ||
1837 | |||
1831 | static void mxser_stoprx(struct tty_struct *tty) | 1838 | static void mxser_stoprx(struct tty_struct *tty) |
1832 | { | 1839 | { |
1833 | struct mxser_port *info = tty->driver_data; | 1840 | struct mxser_port *info = tty->driver_data; |
@@ -2326,6 +2333,7 @@ static const struct tty_operations mxser_ops = { | |||
2326 | .wait_until_sent = mxser_wait_until_sent, | 2333 | .wait_until_sent = mxser_wait_until_sent, |
2327 | .tiocmget = mxser_tiocmget, | 2334 | .tiocmget = mxser_tiocmget, |
2328 | .tiocmset = mxser_tiocmset, | 2335 | .tiocmset = mxser_tiocmset, |
2336 | .get_icount = mxser_get_icount, | ||
2329 | }; | 2337 | }; |
2330 | 2338 | ||
2331 | struct tty_port_operations mxser_port_ops = { | 2339 | struct tty_port_operations mxser_port_ops = { |