summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7720.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-05 03:03:51 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-05 03:03:51 +0200
commit8f28472a739e8e39adc6e64ee5b460df039f0e4f (patch)
tree979e35f3d1d2be94c06c942bcdc9ee68cbebaacb /drivers/usb/serial/mos7720.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (diff)
parentstaging: typec: Fairchild FUSB302 Type-c chip driver (diff)
downloadlinux-8f28472a739e8e39adc6e64ee5b460df039f0e4f.tar.xz
linux-8f28472a739e8e39adc6e64ee5b460df039f0e4f.zip
Merge tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH: "Here is the big USB patchset for 4.12-rc1. Lots of good stuff here, after many many many attempts, the kernel finally has a working typeC interface, many thanks to Heikki and Guenter and others who have taken the time to get this merged. It wasn't an easy path for them at all. There's also a staging driver that uses this new api, which is why it's coming in through this tree. Along with that, there's the usual huge number of changes for gadget drivers, xhci, and other stuff. Johan also finally refactored pretty much every driver that was looking at USB endpoints to do it in a common way, which will help prevent any "badly-formed" devices from causing problems in drivers. That too wasn't a simple task. All of these have been in linux-next for a while with no reported issues" * tag 'usb-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits) staging: typec: Fairchild FUSB302 Type-c chip driver staging: typec: Type-C Port Controller Interface driver (tcpci) staging: typec: USB Type-C Port Manager (tcpm) usb: host: xhci: remove #ifdef around PM functions usb: musb: don't mark of_dev_auxdata as initdata usb: misc: legousbtower: Fix buffers on stack USB: Revert "cdc-wdm: fix "out-of-sync" due to missing notifications" usb: Make sure usb/phy/of gets built-in USB: storage: e-mail update in drivers/usb/storage/unusual_devs.h usb: host: xhci: print correct command ring address usb: host: xhci: delete sp_dma_buffers for scratchpad usb: host: xhci: using correct specification chapter reference for DCBAAP xhci: switch to pci_alloc_irq_vectors usb: host: xhci-plat: set resume_quirk() for R-Car controllers usb: host: xhci-plat: add resume_quirk() usb: host: xhci-plat: enable clk in resume timing usb: host: plat: Enable xHCI plat runtime PM USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit USB: serial: constify static arrays usb: fix some references for /proc/bus/usb ...
Diffstat (limited to 'drivers/usb/serial/mos7720.c')
-rw-r--r--drivers/usb/serial/mos7720.c75
1 files changed, 25 insertions, 50 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index f075121c6e32..a453965f9e9a 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -973,11 +973,24 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
tty_port_tty_wakeup(&mos7720_port->port->port);
}
-static int mos77xx_calc_num_ports(struct usb_serial *serial)
+static int mos77xx_calc_num_ports(struct usb_serial *serial,
+ struct usb_serial_endpoints *epds)
{
u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
- if (product == MOSCHIP_DEVICE_ID_7715)
+
+ if (product == MOSCHIP_DEVICE_ID_7715) {
+ /*
+ * The 7715 uses the first bulk in/out endpoint pair for the
+ * parallel port, and the second for the serial port. We swap
+ * the endpoint descriptors here so that the the first and
+ * only registered port structure uses the serial-port
+ * endpoints.
+ */
+ swap(epds->bulk_in[0], epds->bulk_in[1]);
+ swap(epds->bulk_out[0], epds->bulk_out[1]);
+
return 1;
+ }
return 2;
}
@@ -1395,7 +1408,7 @@ struct divisor_table_entry {
/* Define table of divisors for moschip 7720 hardware *
* These assume a 3.6864MHz crystal, the standard /16, and *
* MCR.7 = 0. */
-static struct divisor_table_entry divisor_table[] = {
+static const struct divisor_table_entry divisor_table[] = {
{ 50, 2304},
{ 110, 1047}, /* 2094.545455 => 230450 => .0217 % over */
{ 134, 857}, /* 1713.011152 => 230398.5 => .00065% under */
@@ -1675,7 +1688,6 @@ static void mos7720_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{
int status;
- unsigned int cflag;
struct usb_serial *serial;
struct moschip_port *mos7720_port;
@@ -1691,16 +1703,6 @@ static void mos7720_set_termios(struct tty_struct *tty,
return;
}
- dev_dbg(&port->dev, "setting termios - ASPIRE\n");
-
- cflag = tty->termios.c_cflag;
-
- dev_dbg(&port->dev, "%s - cflag %08x iflag %08x\n", __func__,
- tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag));
-
- dev_dbg(&port->dev, "%s - old cflag %08x old iflag %08x\n", __func__,
- old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
-
/* change the port settings to the new ones specified */
change_port_settings(tty, mos7720_port, old_termios);
@@ -1900,54 +1902,24 @@ static int mos7720_startup(struct usb_serial *serial)
u16 product;
int ret_val;
- if (serial->num_bulk_in < 2 || serial->num_bulk_out < 2) {
- dev_err(&serial->interface->dev, "missing bulk endpoints\n");
- return -ENODEV;
- }
-
product = le16_to_cpu(serial->dev->descriptor.idProduct);
dev = serial->dev;
- /*
- * The 7715 uses the first bulk in/out endpoint pair for the parallel
- * port, and the second for the serial port. Because the usbserial core
- * assumes both pairs are serial ports, we must engage in a bit of
- * subterfuge and swap the pointers for ports 0 and 1 in order to make
- * port 0 point to the serial port. However, both moschip devices use a
- * single interrupt-in endpoint for both ports (as mentioned a little
- * further down), and this endpoint was assigned to port 0. So after
- * the swap, we must copy the interrupt endpoint elements from port 1
- * (as newly assigned) to port 0, and null out port 1 pointers.
- */
- if (product == MOSCHIP_DEVICE_ID_7715) {
- struct usb_serial_port *tmp = serial->port[0];
- serial->port[0] = serial->port[1];
- serial->port[1] = tmp;
- serial->port[0]->interrupt_in_urb = tmp->interrupt_in_urb;
- serial->port[0]->interrupt_in_buffer = tmp->interrupt_in_buffer;
- serial->port[0]->interrupt_in_endpointAddress =
- tmp->interrupt_in_endpointAddress;
- serial->port[1]->interrupt_in_urb = NULL;
- serial->port[1]->interrupt_in_buffer = NULL;
-
- if (serial->port[0]->interrupt_in_urb) {
- struct urb *urb = serial->port[0]->interrupt_in_urb;
-
- urb->complete = mos7715_interrupt_callback;
- }
- }
-
/* setting configuration feature to one */
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
(__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
-#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
if (product == MOSCHIP_DEVICE_ID_7715) {
+ struct urb *urb = serial->port[0]->interrupt_in_urb;
+
+ urb->complete = mos7715_interrupt_callback;
+
+#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
ret_val = mos7715_parport_init(serial);
if (ret_val < 0)
return ret_val;
- }
#endif
+ }
/* start the interrupt urb */
ret_val = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL);
if (ret_val) {
@@ -2039,6 +2011,9 @@ static struct usb_serial_driver moschip7720_2port_driver = {
},
.description = "Moschip 2 port adapter",
.id_table = id_table,
+ .num_bulk_in = 2,
+ .num_bulk_out = 2,
+ .num_interrupt_in = 1,
.calc_num_ports = mos77xx_calc_num_ports,
.open = mos7720_open,
.close = mos7720_close,