aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/cdc-acm.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-04-18 15:52:50 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-04-18 15:52:50 -0400
commit681e4a5e13c1c8315694eb4f44e0cdd84c9082d2 (patch)
tree699f14527c118859026e8ce0214e689d0b9c88cb /drivers/usb/class/cdc-acm.c
parentb960d6c43a63ebd2d8518b328da3816b833ee8cc (diff)
parentc104f1fa1ecf4ee0fc06e31b1f77630b2551be81 (diff)
Merge commit 'c104f1fa1ecf4ee0fc06e31b1f77630b2551be81' into stable/for-linus-3.4
* commit 'c104f1fa1ecf4ee0fc06e31b1f77630b2551be81': (14566 commits) cpufreq: OMAP: fix build errors: depends on ARCH_OMAP2PLUS sparc64: Eliminate obsolete __handle_softirq() function sparc64: Fix bootup crash on sun4v. kconfig: delete last traces of __enabled_ from autoconf.h Revert "kconfig: fix __enabled_ macros definition for invisible and un-selected symbols" kconfig: fix IS_ENABLED to not require all options to be defined irq_domain: fix type mismatch in debugfs output format staging: android: fix mem leaks in __persistent_ram_init() staging: vt6656: Don't leak memory in drivers/staging/vt6656/ioctl.c::private_ioctl() staging: iio: hmc5843: Fix crash in probe function. panic: fix stack dump print on direct call to panic() drivers/rtc/rtc-pl031.c: enable clock on all ST variants Revert "mm: vmscan: fix misused nr_reclaimed in shrink_mem_cgroup_zone()" hugetlb: fix race condition in hugetlb_fault() drivers/rtc/rtc-twl.c: use static register while reading time drivers/rtc/rtc-s3c.c: add placeholder for driver private data drivers/rtc/rtc-s3c.c: fix compilation error MAINTAINERS: add PCDP console maintainer memcg: do not open code accesses to res_counter members drivers/rtc/rtc-efi.c: fix section mismatch warning ...
Diffstat (limited to 'drivers/usb/class/cdc-acm.c')
-rw-r--r--drivers/usb/class/cdc-acm.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 9543b19d410c..b32ccb461019 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -39,6 +39,7 @@
39#include <linux/serial.h> 39#include <linux/serial.h>
40#include <linux/tty_driver.h> 40#include <linux/tty_driver.h>
41#include <linux/tty_flip.h> 41#include <linux/tty_flip.h>
42#include <linux/serial.h>
42#include <linux/module.h> 43#include <linux/module.h>
43#include <linux/mutex.h> 44#include <linux/mutex.h>
44#include <linux/uaccess.h> 45#include <linux/uaccess.h>
@@ -508,17 +509,12 @@ static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
508 if (!acm) 509 if (!acm)
509 return -ENODEV; 510 return -ENODEV;
510 511
511 retval = tty_init_termios(tty); 512 retval = tty_standard_install(driver, tty);
512 if (retval) 513 if (retval)
513 goto error_init_termios; 514 goto error_init_termios;
514 515
515 tty->driver_data = acm; 516 tty->driver_data = acm;
516 517
517 /* Final install (we use the default method) */
518 tty_driver_kref_get(driver);
519 tty->count++;
520 driver->ttys[tty->index] = tty;
521
522 return 0; 518 return 0;
523 519
524error_init_termios: 520error_init_termios:
@@ -773,10 +769,37 @@ static int acm_tty_tiocmset(struct tty_struct *tty,
773 return acm_set_control(acm, acm->ctrlout = newctrl); 769 return acm_set_control(acm, acm->ctrlout = newctrl);
774} 770}
775 771
772static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
773{
774 struct serial_struct tmp;
775
776 if (!info)
777 return -EINVAL;
778
779 memset(&tmp, 0, sizeof(tmp));
780 tmp.flags = ASYNC_LOW_LATENCY;
781 tmp.xmit_fifo_size = acm->writesize;
782 tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
783
784 if (copy_to_user(info, &tmp, sizeof(tmp)))
785 return -EFAULT;
786 else
787 return 0;
788}
789
776static int acm_tty_ioctl(struct tty_struct *tty, 790static int acm_tty_ioctl(struct tty_struct *tty,
777 unsigned int cmd, unsigned long arg) 791 unsigned int cmd, unsigned long arg)
778{ 792{
779 return -ENOIOCTLCMD; 793 struct acm *acm = tty->driver_data;
794 int rv = -ENOIOCTLCMD;
795
796 switch (cmd) {
797 case TIOCGSERIAL: /* gets serial port data */
798 rv = get_serial_info(acm, (struct serial_struct __user *) arg);
799 break;
800 }
801
802 return rv;
780} 803}
781 804
782static const __u32 acm_tty_speed[] = { 805static const __u32 acm_tty_speed[] = {
@@ -1675,7 +1698,6 @@ static int __init acm_init(void)
1675 acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS); 1698 acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
1676 if (!acm_tty_driver) 1699 if (!acm_tty_driver)
1677 return -ENOMEM; 1700 return -ENOMEM;
1678 acm_tty_driver->owner = THIS_MODULE,
1679 acm_tty_driver->driver_name = "acm", 1701 acm_tty_driver->driver_name = "acm",
1680 acm_tty_driver->name = "ttyACM", 1702 acm_tty_driver->name = "ttyACM",
1681 acm_tty_driver->major = ACM_TTY_MAJOR, 1703 acm_tty_driver->major = ACM_TTY_MAJOR,