From 7071a3ce0ca058ad2a9e3e8c33f30fb0bce62005 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 2 May 2008 06:02:41 +0200 Subject: USB: usb dev_name() instead of dev->bus_id The bus_id field is going away, use the dev_name() function instead. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 0cb0d77dc42..b4620c009d1 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -505,7 +505,7 @@ static void port_release(struct device *dev) { struct usb_serial_port *port = to_usb_serial_port(dev); - dbg ("%s - %s", __func__, dev->bus_id); + dbg ("%s - %s", __func__, dev_name(dev)); port_free(port); } @@ -939,7 +939,7 @@ int usb_serial_probe(struct usb_interface *interface, port->dev.release = &port_release; snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); - dbg ("%s - registering %s", __func__, port->dev.bus_id); + dbg ("%s - registering %s", __func__, dev_name(&port->dev)); retval = device_register(&port->dev); if (retval) dev_err(&port->dev, "Error registering port device, " -- cgit v1.2.3-70-g09d2 From 0031a06e2f07ab0d1bc98c31dbb6801f95f4bf01 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 2 May 2008 06:02:41 +0200 Subject: USB: usb dev_set_name() instead of dev->bus_id The bus_id field is going away, use the dev_set_name() function to set it properly. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/endpoint.c | 2 +- drivers/usb/core/message.c | 2 +- drivers/usb/core/usb.c | 5 ++--- drivers/usb/gadget/amd5536udc.c | 2 +- drivers/usb/gadget/dummy_hcd.c | 2 +- drivers/usb/gadget/file_storage.c | 4 ++-- drivers/usb/gadget/fsl_usb2_udc.c | 2 +- drivers/usb/gadget/goku_udc.c | 2 +- drivers/usb/gadget/m66592-udc.c | 2 +- drivers/usb/gadget/net2280.c | 2 +- drivers/usb/gadget/omap_udc.c | 2 +- drivers/usb/host/isp1760-hcd.c | 2 +- drivers/usb/serial/usb-serial.c | 2 +- 13 files changed, 15 insertions(+), 16 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index f600aec3fb3..22912136fc1 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c @@ -307,7 +307,7 @@ int usb_create_ep_files(struct device *parent, ep_dev->dev.class = ep_class->class; ep_dev->dev.parent = parent; ep_dev->dev.release = ep_device_release; - snprintf(ep_dev->dev.bus_id, BUS_ID_SIZE, "usbdev%d.%d_ep%02x", + dev_set_name(&ep_dev->dev, "usbdev%d.%d_ep%02x", udev->bus->busnum, udev->devnum, endpoint->desc.bEndpointAddress); diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 1141a4918e8..315363b744a 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1611,7 +1611,7 @@ free_interfaces: intf->dev.dma_mask = dev->dev.dma_mask; device_initialize(&intf->dev); mark_quiesced(intf); - sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", + dev_set_name(&intf->dev, "%d-%s:%d.%d", dev->bus->busnum, dev->devpath, configuration, alt->desc.bInterfaceNumber); } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 3aca6d5afcd..84fcaa6a21e 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -316,7 +316,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, dev->devpath[0] = '0'; dev->dev.parent = bus->controller; - sprintf(&dev->dev.bus_id[0], "usb%d", bus->busnum); + dev_set_name(&dev->dev, "usb%d", bus->busnum); root_hub = 1; } else { /* match any labeling on the hubs; it's one-based */ @@ -328,8 +328,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, "%s.%d", parent->devpath, port1); dev->dev.parent = &parent->dev; - sprintf(&dev->dev.bus_id[0], "%d-%s", - bus->busnum, dev->devpath); + dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath); /* hub driver sets up TT records */ } diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index f261d2a9a5f..1500e1b3c30 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c @@ -3342,7 +3342,7 @@ static int udc_probe(struct udc *dev) spin_lock_init(&dev->lock); dev->gadget.ops = &udc_ops; - strcpy(dev->gadget.dev.bus_id, "gadget"); + dev_set_name(&dev->gadget.dev, "gadget"); dev->gadget.dev.release = gadget_release; dev->gadget.name = name; dev->gadget.name = name; diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index b36ad240534..21d1406af9e 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -862,7 +862,7 @@ static int dummy_udc_probe (struct platform_device *pdev) /* maybe claim OTG support, though we won't complete HNP */ dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); - strcpy (dum->gadget.dev.bus_id, "gadget"); + dev_set_name(&dum->gadget.dev, "gadget"); dum->gadget.dev.parent = &pdev->dev; dum->gadget.dev.release = dummy_gadget_release; rc = device_register (&dum->gadget.dev); diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 638cee03a24..15c24edbb61 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -3867,8 +3867,8 @@ static int __init fsg_bind(struct usb_gadget *gadget) curlun->dev.parent = &gadget->dev; curlun->dev.driver = &fsg_driver.driver; dev_set_drvdata(&curlun->dev, fsg); - snprintf(curlun->dev.bus_id, BUS_ID_SIZE, - "%s-lun%d", dev_name(&gadget->dev), i); + dev_set_name(&curlun->dev,"%s-lun%d", + dev_name(&gadget->dev), i); if ((rc = device_register(&curlun->dev)) != 0) { INFO(fsg, "failed to register LUN%d: %d\n", i, rc); diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 18687543d7f..1695382f30f 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c @@ -2331,7 +2331,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) udc_controller->gadget.name = driver_name; /* Setup gadget.dev and register with kernel */ - strcpy(udc_controller->gadget.dev.bus_id, "gadget"); + dev_set_name(&udc_controller->gadget.dev, "gadget"); udc_controller->gadget.dev.release = fsl_udc_release; udc_controller->gadget.dev.parent = &pdev->dev; ret = device_register(&udc_controller->gadget.dev); diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index be6613afedb..48f1c63b701 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -1790,7 +1790,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev->gadget.ops = &goku_ops; /* the "gadget" abstracts/virtualizes the controller */ - strcpy(dev->gadget.dev.bus_id, "gadget"); + dev_set_name(&dev->gadget.dev, "gadget"); dev->gadget.dev.parent = &pdev->dev; dev->gadget.dev.dma_mask = pdev->dev.dma_mask; dev->gadget.dev.release = gadget_release; diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index ee6b35fa870..8da7535c0c7 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c @@ -1593,7 +1593,7 @@ static int __init m66592_probe(struct platform_device *pdev) m66592->gadget.ops = &m66592_gadget_ops; device_initialize(&m66592->gadget.dev); - strcpy(m66592->gadget.dev.bus_id, "gadget"); + dev_set_name(&m66592->gadget, "gadget"); m66592->gadget.is_dualspeed = 1; m66592->gadget.dev.parent = &pdev->dev; m66592->gadget.dev.dma_mask = pdev->dev.dma_mask; diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index e0186230016..b67ab677af7 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c @@ -2768,7 +2768,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) dev->gadget.is_dualspeed = 1; /* the "gadget" abstracts/virtualizes the controller */ - strcpy (dev->gadget.dev.bus_id, "gadget"); + dev_set_name(&dev->gadget.dev, "gadget"); dev->gadget.dev.parent = &pdev->dev; dev->gadget.dev.dma_mask = pdev->dev.dma_mask; dev->gadget.dev.release = gadget_release; diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 03a7f49d207..4b79a8509e8 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c @@ -2686,7 +2686,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv) udc->gadget.name = driver_name; device_initialize(&udc->gadget.dev); - strcpy (udc->gadget.dev.bus_id, "gadget"); + dev_set_name(&udc->gadget.dev, "gadget"); udc->gadget.dev.release = omap_udc_release; udc->gadget.dev.parent = &odev->dev; if (use_dma) diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 65aa5ecf569..0873168cded 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c @@ -2195,7 +2195,7 @@ struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq, /* prevent usb-core allocating DMA pages */ dev->dma_mask = NULL; - hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev->bus_id); + hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev)); if (!hcd) return ERR_PTR(-ENOMEM); diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index b4620c009d1..717e376795e 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -938,7 +938,7 @@ int usb_serial_probe(struct usb_interface *interface, port->dev.bus = &usb_serial_bus_type; port->dev.release = &port_release; - snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); + dev_set_name(&port->dev, "ttyUSB%d", port->number); dbg ("%s - registering %s", __func__, dev_name(&port->dev)); retval = device_register(&port->dev); if (retval) -- cgit v1.2.3-70-g09d2 From bd2c784595e3dd551c2b3aa4167657bcc802f598 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 1 May 2008 20:52:57 -0700 Subject: USB: use get_unaligned_* helpers for kl5kusb105 driver Signed-off-by: Harvey Harrison Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/kl5kusb105.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index f328948d74e..79787eda952 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -236,7 +236,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, if (rc < 0) err("Reading line status failed (error = %d)", rc); else { - status = le16_to_cpu(get_unaligned((__le16 *)status_buf)); + status = get_unaligned_le16(status_buf); info("%s - read status %x %x", __func__, status_buf[0], status_buf[1]); -- cgit v1.2.3-70-g09d2 From 2742fd8899328345d97a3443fb787b051b79ebae Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 29 Apr 2008 14:45:15 +0100 Subject: USB: io_ti: FIrst cut at a big clean up Sort out the insane naming like "OperationalFirmwareVersion" which seems designed to cause formatting problems and RSI Merge various common code together Clean up the pointlessly complex and spread about MCR handling This is really just the low hanging fruit. Needs lots of testing before it goes upstream so testers and reports appreciated Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/io_ti.c | 1860 ++++++++++++++++++++------------------------ 1 file changed, 852 insertions(+), 1008 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 61daea3f7b2..a58822a14a8 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -18,8 +18,8 @@ * * Version history: * - * July 11, 2002 Removed 4 port device structure since all TI UMP - * chips have only 2 ports + * July 11, 2002 Removed 4 port device structure since all TI UMP + * chips have only 2 ports * David Iacovelli (davidi@ionetworks.com) * */ @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -57,18 +57,19 @@ struct edgeport_uart_buf_desc { - __u32 count; // Number of bytes currently in buffer + __u32 count; /* Number of bytes currently in buffer */ }; /* different hardware types */ #define HARDWARE_TYPE_930 0 #define HARDWARE_TYPE_TIUMP 1 -// IOCTL_PRIVATE_TI_GET_MODE Definitions -#define TI_MODE_CONFIGURING 0 // Device has not entered start device -#define TI_MODE_BOOT 1 // Staying in boot mode -#define TI_MODE_DOWNLOAD 2 // Made it to download mode -#define TI_MODE_TRANSITIONING 3 // Currently in boot mode but transitioning to download mode +/* IOCTL_PRIVATE_TI_GET_MODE Definitions */ +#define TI_MODE_CONFIGURING 0 /* Device has not entered start device */ +#define TI_MODE_BOOT 1 /* Staying in boot mode */ +#define TI_MODE_DOWNLOAD 2 /* Made it to download mode */ +#define TI_MODE_TRANSITIONING 3 /* Currently in boot mode but + transitioning to download mode */ /* read urb state */ #define EDGE_READ_URB_RUNNING 0 @@ -82,10 +83,9 @@ struct edgeport_uart_buf_desc { /* Product information read from the Edgeport */ -struct product_info -{ - int TiMode; // Current TI Mode - __u8 hardware_type; // Type of hardware +struct product_info { + int TiMode; /* Current TI Mode */ + __u8 hardware_type; /* Type of hardware */ } __attribute__((packed)); /* circular buffer */ @@ -116,7 +116,7 @@ struct edgeport_port { happen */ struct edgeport_serial *edge_serial; struct usb_serial_port *port; - __u8 bUartMode; /* Port type, 0: RS232, etc. */ + __u8 bUartMode; /* Port type, 0: RS232, etc. */ spinlock_t ep_lock; int ep_read_urb_state; int ep_write_urb_in_use; @@ -125,8 +125,9 @@ struct edgeport_port { struct edgeport_serial { struct product_info product_info; - u8 TI_I2C_Type; // Type of I2C in UMP - u8 TiReadI2C; // Set to TRUE if we have read the I2c in Boot Mode + u8 TI_I2C_Type; /* Type of I2C in UMP */ + u8 TiReadI2C; /* Set to TRUE if we have read the + I2c in Boot Mode */ struct mutex es_lock; int num_ports_open; struct usb_serial *serial; @@ -214,7 +215,7 @@ static struct usb_device_id id_table_combined [] = { { } }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver io_driver = { .name = "io_ti", @@ -231,19 +232,19 @@ static unsigned short OperationalBuildNumber; static int debug; -static int TIStayInBootMode = 0; static int low_latency = EDGE_LOW_LATENCY; static int closing_wait = EDGE_CLOSING_WAIT; -static int ignore_cpu_rev = 0; -static int default_uart_mode = 0; /* RS232 */ - +static int ignore_cpu_rev; +static int default_uart_mode; /* RS232 */ -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length); +static void edge_tty_recv(struct device *dev, struct tty_struct *tty, + unsigned char *data, int length); static void stop_read(struct edgeport_port *edge_port); static int restart_read(struct edgeport_port *edge_port); -static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); +static void edge_set_termios(struct usb_serial_port *port, + struct ktermios *old_termios); static void edge_send(struct usb_serial_port *port); /* sysfs attributes */ @@ -262,87 +263,57 @@ static unsigned int edge_buf_get(struct edge_buf *eb, char *buf, unsigned int count); -static int TIReadVendorRequestSync (struct usb_device *dev, - __u8 request, - __u16 value, - __u16 index, - u8 *data, - int size) +static int ti_vread_sync(struct usb_device *dev, __u8 request, + __u16 value, __u16 index, u8 *data, int size) { int status; - status = usb_control_msg (dev, - usb_rcvctrlpipe(dev, 0), - request, - (USB_TYPE_VENDOR | - USB_RECIP_DEVICE | - USB_DIR_IN), - value, - index, - data, - size, - 1000); + status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, + (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN), + value, index, data, size, 1000); if (status < 0) return status; if (status != size) { - dbg ("%s - wanted to write %d, but only wrote %d", - __func__, size, status); + dbg("%s - wanted to write %d, but only wrote %d", + __func__, size, status); return -ECOMM; } return 0; } -static int TISendVendorRequestSync (struct usb_device *dev, - __u8 request, - __u16 value, - __u16 index, - u8 *data, - int size) +static int ti_vsend_sync(struct usb_device *dev, __u8 request, + __u16 value, __u16 index, u8 *data, int size) { int status; - status = usb_control_msg (dev, - usb_sndctrlpipe(dev, 0), - request, - (USB_TYPE_VENDOR | - USB_RECIP_DEVICE | - USB_DIR_OUT), - value, - index, - data, - size, - 1000); + status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, + (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), + value, index, data, size, 1000); if (status < 0) return status; if (status != size) { - dbg ("%s - wanted to write %d, but only wrote %d", + dbg("%s - wanted to write %d, but only wrote %d", __func__, size, status); return -ECOMM; } return 0; } -static int TIWriteCommandSync (struct usb_device *dev, __u8 command, +static int send_cmd(struct usb_device *dev, __u8 command, __u8 moduleid, __u16 value, u8 *data, int size) { - return TISendVendorRequestSync (dev, - command, // Request - value, // wValue - moduleid, // wIndex - data, // TransferBuffer - size); // TransferBufferLength - + return ti_vsend_sync(dev, command, value, moduleid, data, size); } /* clear tx/rx buffers and fifo in TI UMP */ -static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask) +static int purge_port(struct usb_serial_port *port, __u16 mask) { int port_number = port->number - port->serial->minor; - dbg ("%s - port %d, mask %x", __func__, port_number, mask); + dbg("%s - port %d, mask %x", __func__, port_number, mask); - return TIWriteCommandSync (port->serial->dev, + return send_cmd(port->serial->dev, UMPC_PURGE_PORT, (__u8)(UMPM_UART1_PORT + port_number), mask, @@ -351,92 +322,87 @@ static int TIPurgeDataSync (struct usb_serial_port *port, __u16 mask) } /** - * TIReadDownloadMemory - Read edgeport memory from TI chip + * read_download_mem - Read edgeport memory from TI chip * @dev: usb device pointer * @start_address: Device CPU address at which to read * @length: Length of above data * @address_type: Can read both XDATA and I2C * @buffer: pointer to input data buffer */ -static int TIReadDownloadMemory(struct usb_device *dev, int start_address, +static int read_download_mem(struct usb_device *dev, int start_address, int length, __u8 address_type, __u8 *buffer) { int status = 0; __u8 read_length; __be16 be_start_address; - - dbg ("%s - @ %x for %d", __func__, start_address, length); + + dbg("%s - @ %x for %d", __func__, start_address, length); /* Read in blocks of 64 bytes * (TI firmware can't handle more than 64 byte reads) */ while (length) { if (length > 64) - read_length= 64; + read_length = 64; else read_length = (__u8)length; if (read_length > 1) { - dbg ("%s - @ %x for %d", __func__, + dbg("%s - @ %x for %d", __func__, start_address, read_length); } - be_start_address = cpu_to_be16 (start_address); - status = TIReadVendorRequestSync (dev, - UMPC_MEMORY_READ, // Request - (__u16)address_type, // wValue (Address type) - (__force __u16)be_start_address, // wIndex (Address to read) - buffer, // TransferBuffer - read_length); // TransferBufferLength + be_start_address = cpu_to_be16(start_address); + status = ti_vread_sync(dev, UMPC_MEMORY_READ, + (__u16)address_type, + (__force __u16)be_start_address, + buffer, read_length); if (status) { - dbg ("%s - ERROR %x", __func__, status); + dbg("%s - ERROR %x", __func__, status); return status; } - if (read_length > 1) { + if (read_length > 1) usb_serial_debug_data(debug, &dev->dev, __func__, read_length, buffer); - } /* Update pointers/length */ start_address += read_length; buffer += read_length; length -= read_length; } - + return status; } -static int TIReadRam (struct usb_device *dev, int start_address, int length, __u8 *buffer) +static int read_ram(struct usb_device *dev, int start_address, + int length, __u8 *buffer) { - return TIReadDownloadMemory (dev, - start_address, - length, - DTK_ADDR_SPACE_XDATA, - buffer); + return read_download_mem(dev, start_address, length, + DTK_ADDR_SPACE_XDATA, buffer); } /* Read edgeport memory to a given block */ -static int TIReadBootMemory (struct edgeport_serial *serial, int start_address, int length, __u8 * buffer) +static int read_boot_mem(struct edgeport_serial *serial, + int start_address, int length, __u8 *buffer) { int status = 0; int i; - for (i=0; i< length; i++) { - status = TIReadVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_READ, // Request - serial->TI_I2C_Type, // wValue (Address type) - (__u16)(start_address+i), // wIndex - &buffer[i], // TransferBuffer - 0x01); // TransferBufferLength + for (i = 0; i < length; i++) { + status = ti_vread_sync(serial->serial->dev, + UMPC_MEMORY_READ, serial->TI_I2C_Type, + (__u16)(start_address+i), &buffer[i], 0x01); if (status) { - dbg ("%s - ERROR %x", __func__, status); + dbg("%s - ERROR %x", __func__, status); return status; } } - dbg ("%s - start_address = %x, length = %d", __func__, start_address, length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); + dbg("%s - start_address = %x, length = %d", + __func__, start_address, length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, + __func__, length, buffer); serial->TiReadI2C = 1; @@ -444,7 +410,8 @@ static int TIReadBootMemory (struct edgeport_serial *serial, int start_address, } /* Write given block to TI EPROM memory */ -static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) +static int write_boot_mem(struct edgeport_serial *serial, + int start_address, int length, __u8 *buffer) { int status = 0; int i; @@ -452,57 +419,58 @@ static int TIWriteBootMemory (struct edgeport_serial *serial, int start_address, /* Must do a read before write */ if (!serial->TiReadI2C) { - status = TIReadBootMemory(serial, 0, 1, &temp); + status = read_boot_mem(serial, 0, 1, &temp); if (status) return status; } - for (i=0; i < length; ++i) { - status = TISendVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_WRITE, // Request - buffer[i], // wValue - (__u16)(i+start_address), // wIndex - NULL, // TransferBuffer - 0); // TransferBufferLength + for (i = 0; i < length; ++i) { + status = ti_vsend_sync(serial->serial->dev, + UMPC_MEMORY_WRITE, buffer[i], + (__u16)(i + start_address), NULL, 0); if (status) return status; } - dbg ("%s - start_sddr = %x, length = %d", __func__, start_address, length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, length, buffer); + dbg("%s - start_sddr = %x, length = %d", + __func__, start_address, length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, + __func__, length, buffer); return status; } /* Write edgeport I2C memory to TI chip */ -static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address, int length, __u8 address_type, __u8 *buffer) +static int write_i2c_mem(struct edgeport_serial *serial, + int start_address, int length, __u8 address_type, __u8 *buffer) { int status = 0; int write_length; __be16 be_start_address; /* We can only send a maximum of 1 aligned byte page at a time */ - + /* calulate the number of bytes left in the first page */ - write_length = EPROM_PAGE_SIZE - (start_address & (EPROM_PAGE_SIZE - 1)); + write_length = EPROM_PAGE_SIZE - + (start_address & (EPROM_PAGE_SIZE - 1)); if (write_length > length) write_length = length; - dbg ("%s - BytesInFirstPage Addr = %x, length = %d", __func__, start_address, write_length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); + dbg("%s - BytesInFirstPage Addr = %x, length = %d", + __func__, start_address, write_length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, + __func__, write_length, buffer); /* Write first page */ - be_start_address = cpu_to_be16 (start_address); - status = TISendVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_WRITE, // Request - (__u16)address_type, // wValue - (__force __u16)be_start_address, // wIndex - buffer, // TransferBuffer - write_length); + be_start_address = cpu_to_be16(start_address); + status = ti_vsend_sync(serial->serial->dev, + UMPC_MEMORY_WRITE, (__u16)address_type, + (__force __u16)be_start_address, + buffer, write_length); if (status) { - dbg ("%s - ERROR %d", __func__, status); + dbg("%s - ERROR %d", __func__, status); return status; } @@ -510,29 +478,31 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address start_address += write_length; buffer += write_length; - /* We should be aligned now -- can write max page size bytes at a time */ + /* We should be aligned now -- can write + max page size bytes at a time */ while (length) { if (length > EPROM_PAGE_SIZE) write_length = EPROM_PAGE_SIZE; else write_length = length; - dbg ("%s - Page Write Addr = %x, length = %d", __func__, start_address, write_length); - usb_serial_debug_data(debug, &serial->serial->dev->dev, __func__, write_length, buffer); + dbg("%s - Page Write Addr = %x, length = %d", + __func__, start_address, write_length); + usb_serial_debug_data(debug, &serial->serial->dev->dev, + __func__, write_length, buffer); /* Write next page */ - be_start_address = cpu_to_be16 (start_address); - status = TISendVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_WRITE, // Request - (__u16)address_type, // wValue - (__force __u16)be_start_address, // wIndex - buffer, // TransferBuffer - write_length); // TransferBufferLength + be_start_address = cpu_to_be16(start_address); + status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, + (__u16)address_type, + (__force __u16)be_start_address, + buffer, write_length); if (status) { - dev_err (&serial->serial->dev->dev, "%s - ERROR %d\n", __func__, status); + dev_err(&serial->serial->dev->dev, "%s - ERROR %d\n", + __func__, status); return status; } - + length -= write_length; start_address += write_length; buffer += write_length; @@ -541,25 +511,25 @@ static int TIWriteDownloadI2C (struct edgeport_serial *serial, int start_address } /* Examine the UMP DMA registers and LSR - * + * * Check the MSBit of the X and Y DMA byte count registers. * A zero in this bit indicates that the TX DMA buffers are empty * then check the TX Empty bit in the UART. */ -static int TIIsTxActive (struct edgeport_port *port) +static int tx_active(struct edgeport_port *port) { int status; struct out_endpoint_desc_block *oedb; __u8 *lsr; int bytes_left = 0; - oedb = kmalloc (sizeof (* oedb), GFP_KERNEL); + oedb = kmalloc(sizeof(*oedb), GFP_KERNEL); if (!oedb) { - dev_err (&port->port->dev, "%s - out of memory\n", __func__); + dev_err(&port->port->dev, "%s - out of memory\n", __func__); return -ENOMEM; } - lsr = kmalloc (1, GFP_KERNEL); /* Sigh, that's right, just one byte, + lsr = kmalloc(1, GFP_KERNEL); /* Sigh, that's right, just one byte, as not all platforms can do DMA from stack */ if (!lsr) { @@ -567,43 +537,39 @@ static int TIIsTxActive (struct edgeport_port *port) return -ENOMEM; } /* Read the DMA Count Registers */ - status = TIReadRam (port->port->serial->dev, - port->dma_address, - sizeof( *oedb), - (void *)oedb); - + status = read_ram(port->port->serial->dev, port->dma_address, + sizeof(*oedb), (void *)oedb); if (status) goto exit_is_tx_active; - dbg ("%s - XByteCount 0x%X", __func__, oedb->XByteCount); + dbg("%s - XByteCount 0x%X", __func__, oedb->XByteCount); /* and the LSR */ - status = TIReadRam (port->port->serial->dev, - port->uart_base + UMPMEM_OFFS_UART_LSR, - 1, - lsr); + status = read_ram(port->port->serial->dev, + port->uart_base + UMPMEM_OFFS_UART_LSR, 1, lsr); if (status) goto exit_is_tx_active; - dbg ("%s - LSR = 0x%X", __func__, *lsr); - + dbg("%s - LSR = 0x%X", __func__, *lsr); + /* If either buffer has data or we are transmitting then return TRUE */ - if ((oedb->XByteCount & 0x80 ) != 0 ) + if ((oedb->XByteCount & 0x80) != 0) bytes_left += 64; - if ((*lsr & UMP_UART_LSR_TX_MASK ) == 0 ) + if ((*lsr & UMP_UART_LSR_TX_MASK) == 0) bytes_left += 1; /* We return Not Active if we get any kind of error */ exit_is_tx_active: - dbg ("%s - return %d", __func__, bytes_left ); + dbg("%s - return %d", __func__, bytes_left); kfree(lsr); kfree(oedb); return bytes_left; } -static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int flush) +static void chase_port(struct edgeport_port *port, unsigned long timeout, + int flush) { int baud_rate; struct tty_struct *tty = port->port->tty; @@ -611,7 +577,7 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f unsigned long flags; if (!timeout) - timeout = (HZ*EDGE_CLOSING_WAIT)/100; + timeout = (HZ * EDGE_CLOSING_WAIT)/100; /* wait for data to drain from the buffer */ spin_lock_irqsave(&port->ep_lock, flags); @@ -621,7 +587,8 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f set_current_state(TASK_INTERRUPTIBLE); if (edge_buf_data_avail(port->ep_out_buf) == 0 || timeout == 0 || signal_pending(current) - || !usb_get_intfdata(port->port->serial->interface)) /* disconnect */ + || !usb_get_intfdata(port->port->serial->interface)) + /* disconnect */ break; spin_unlock_irqrestore(&port->ep_lock, flags); timeout = schedule_timeout(timeout); @@ -636,8 +603,9 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f /* wait for data to drain from the device */ timeout += jiffies; while ((long)(jiffies - timeout) < 0 && !signal_pending(current) - && usb_get_intfdata(port->port->serial->interface)) { /* not disconnected */ - if (!TIIsTxActive(port)) + && usb_get_intfdata(port->port->serial->interface)) { + /* not disconnected */ + if (!tx_active(port)) break; msleep(10); } @@ -647,72 +615,72 @@ static void TIChasePort(struct edgeport_port *port, unsigned long timeout, int f return; /* wait one more character time, based on baud rate */ - /* (TIIsTxActive doesn't seem to wait for the last byte) */ - if ((baud_rate=port->baud_rate) == 0) + /* (tx_active doesn't seem to wait for the last byte) */ + baud_rate = port->baud_rate; + if (baud_rate == 0) baud_rate = 50; msleep(max(1, DIV_ROUND_UP(10000, baud_rate))); } -static int TIChooseConfiguration (struct usb_device *dev) +static int choose_config(struct usb_device *dev) { - // There may be multiple configurations on this device, in which case - // we would need to read and parse all of them to find out which one - // we want. However, we just support one config at this point, - // configuration # 1, which is Config Descriptor 0. + /* + * There may be multiple configurations on this device, in which case + * we would need to read and parse all of them to find out which one + * we want. However, we just support one config at this point, + * configuration # 1, which is Config Descriptor 0. + */ - dbg ("%s - Number of Interfaces = %d", __func__, dev->config->desc.bNumInterfaces); - dbg ("%s - MAX Power = %d", __func__, dev->config->desc.bMaxPower*2); + dbg("%s - Number of Interfaces = %d", + __func__, dev->config->desc.bNumInterfaces); + dbg("%s - MAX Power = %d", + __func__, dev->config->desc.bMaxPower * 2); if (dev->config->desc.bNumInterfaces != 1) { - dev_err (&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__); + dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", + __func__); return -ENODEV; } return 0; } -static int TIReadRom (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) +static int read_rom(struct edgeport_serial *serial, + int start_address, int length, __u8 *buffer) { int status; if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { - status = TIReadDownloadMemory (serial->serial->dev, + status = read_download_mem(serial->serial->dev, start_address, length, serial->TI_I2C_Type, buffer); } else { - status = TIReadBootMemory (serial, - start_address, - length, - buffer); + status = read_boot_mem(serial, start_address, length, + buffer); } - return status; } -static int TIWriteRom (struct edgeport_serial *serial, int start_address, int length, __u8 *buffer) +static int write_rom(struct edgeport_serial *serial, int start_address, + int length, __u8 *buffer) { if (serial->product_info.TiMode == TI_MODE_BOOT) - return TIWriteBootMemory (serial, - start_address, - length, - buffer); + return write_boot_mem(serial, start_address, length, + buffer); if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) - return TIWriteDownloadI2C (serial, - start_address, - length, - serial->TI_I2C_Type, - buffer); - + return write_i2c_mem(serial, start_address, length, + serial->TI_I2C_Type, buffer); return -EINVAL; } /* Read a descriptor header from I2C based on type */ -static int TIGetDescriptorAddress (struct edgeport_serial *serial, int desc_type, struct ti_i2c_desc *rom_desc) +static int get_descriptor_addr(struct edgeport_serial *serial, + int desc_type, struct ti_i2c_desc *rom_desc) { int start_address; int status; @@ -720,41 +688,42 @@ static int TIGetDescriptorAddress (struct edgeport_serial *serial, int desc_type /* Search for requested descriptor in I2C */ start_address = 2; do { - status = TIReadRom (serial, + status = read_rom(serial, start_address, sizeof(struct ti_i2c_desc), - (__u8 *)rom_desc ); + (__u8 *)rom_desc); if (status) return 0; if (rom_desc->Type == desc_type) return start_address; - start_address = start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size; + start_address = start_address + sizeof(struct ti_i2c_desc) + + rom_desc->Size; } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); - + return 0; } /* Validate descriptor checksum */ -static int ValidChecksum(struct ti_i2c_desc *rom_desc, __u8 *buffer) +static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer) { __u16 i; __u8 cs = 0; - for (i=0; i < rom_desc->Size; i++) { + for (i = 0; i < rom_desc->Size; i++) cs = (__u8)(cs + buffer[i]); - } + if (cs != rom_desc->CheckSum) { - dbg ("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); + dbg("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); return -EINVAL; } return 0; } /* Make sure that the I2C image is good */ -static int TiValidateI2cImage (struct edgeport_serial *serial) +static int check_i2c_image(struct edgeport_serial *serial) { struct device *dev = &serial->serial->dev->dev; int status = 0; @@ -763,120 +732,124 @@ static int TiValidateI2cImage (struct edgeport_serial *serial) __u8 *buffer; __u16 ttype; - rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); + rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (dev, "%s - out of memory\n", __func__); + dev_err(dev, "%s - out of memory\n", __func__); return -ENOMEM; } - buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL); + buffer = kmalloc(TI_MAX_I2C_SIZE, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory when allocating buffer\n", __func__); - kfree (rom_desc); + dev_err(dev, "%s - out of memory when allocating buffer\n", + __func__); + kfree(rom_desc); return -ENOMEM; } - // Read the first byte (Signature0) must be 0x52 or 0x10 - status = TIReadRom (serial, 0, 1, buffer); + /* Read the first byte (Signature0) must be 0x52 or 0x10 */ + status = read_rom(serial, 0, 1, buffer); if (status) - goto ExitTiValidateI2cImage; + goto out; if (*buffer != UMP5152 && *buffer != UMP3410) { - dev_err (dev, "%s - invalid buffer signature\n", __func__); + dev_err(dev, "%s - invalid buffer signature\n", __func__); status = -ENODEV; - goto ExitTiValidateI2cImage; + goto out; } do { - // Validate the I2C - status = TIReadRom (serial, + /* Validate the I2C */ + status = read_rom(serial, start_address, sizeof(struct ti_i2c_desc), (__u8 *)rom_desc); if (status) break; - if ((start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size) > TI_MAX_I2C_SIZE) { + if ((start_address + sizeof(struct ti_i2c_desc) + + rom_desc->Size) > TI_MAX_I2C_SIZE) { status = -ENODEV; - dbg ("%s - structure too big, erroring out.", __func__); + dbg("%s - structure too big, erroring out.", __func__); break; } - dbg ("%s Type = 0x%x", __func__, rom_desc->Type); + dbg("%s Type = 0x%x", __func__, rom_desc->Type); - // Skip type 2 record + /* Skip type 2 record */ ttype = rom_desc->Type & 0x0f; - if ( ttype != I2C_DESC_TYPE_FIRMWARE_BASIC - && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO ) { - // Read the descriptor data - status = TIReadRom(serial, - start_address+sizeof(struct ti_i2c_desc), - rom_desc->Size, - buffer); + if (ttype != I2C_DESC_TYPE_FIRMWARE_BASIC + && ttype != I2C_DESC_TYPE_FIRMWARE_AUTO) { + /* Read the descriptor data */ + status = read_rom(serial, start_address + + sizeof(struct ti_i2c_desc), + rom_desc->Size, buffer); if (status) break; - status = ValidChecksum(rom_desc, buffer); + status = valid_csum(rom_desc, buffer); if (status) break; } - start_address = start_address + sizeof(struct ti_i2c_desc) + rom_desc->Size; + start_address = start_address + sizeof(struct ti_i2c_desc) + + rom_desc->Size; - } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && (start_address < TI_MAX_I2C_SIZE)); + } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && + (start_address < TI_MAX_I2C_SIZE)); - if ((rom_desc->Type != I2C_DESC_TYPE_ION) || (start_address > TI_MAX_I2C_SIZE)) + if ((rom_desc->Type != I2C_DESC_TYPE_ION) || + (start_address > TI_MAX_I2C_SIZE)) status = -ENODEV; -ExitTiValidateI2cImage: - kfree (buffer); - kfree (rom_desc); +out: + kfree(buffer); + kfree(rom_desc); return status; } -static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer) +static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer) { int status; int start_address; struct ti_i2c_desc *rom_desc; struct edge_ti_manuf_descriptor *desc; - rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); + rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (&serial->serial->dev->dev, "%s - out of memory\n", __func__); + dev_err(&serial->serial->dev->dev, "%s - out of memory\n", + __func__); return -ENOMEM; } - start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc); + start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, + rom_desc); if (!start_address) { - dbg ("%s - Edge Descriptor not found in I2C", __func__); + dbg("%s - Edge Descriptor not found in I2C", __func__); status = -ENODEV; goto exit; } - // Read the descriptor data - status = TIReadRom (serial, - start_address+sizeof(struct ti_i2c_desc), - rom_desc->Size, - buffer); + /* Read the descriptor data */ + status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc), + rom_desc->Size, buffer); if (status) goto exit; - - status = ValidChecksum(rom_desc, buffer); - + + status = valid_csum(rom_desc, buffer); + desc = (struct edge_ti_manuf_descriptor *)buffer; - dbg ( "%s - IonConfig 0x%x", __func__, desc->IonConfig ); - dbg ( "%s - Version %d", __func__, desc->Version ); - dbg ( "%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev ); - dbg ( "%s - NumPorts %d", __func__, desc->NumPorts ); - dbg ( "%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts ); - dbg ( "%s - TotalPorts %d", __func__, desc->TotalPorts ); + dbg("%s - IonConfig 0x%x", __func__, desc->IonConfig); + dbg("%s - Version %d", __func__, desc->Version); + dbg("%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev); + dbg("%s - NumPorts %d", __func__, desc->NumPorts); + dbg("%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts); + dbg("%s - TotalPorts %d", __func__, desc->TotalPorts); exit: - kfree (rom_desc); + kfree(rom_desc); return status; } /* Build firmware header used for firmware update */ -static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) +static int build_i2c_fw_hdr(__u8 *header, struct device *dev) { __u8 *buffer; int buffer_size; @@ -889,24 +862,28 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) const struct firmware *fw; const char *fw_name = "edgeport/down3.bin"; - // In order to update the I2C firmware we must change the type 2 record to type 0xF2. - // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver - // will download the latest firmware (padded to 15.5k) into the UMP ram. - // And finally when the device comes back up in download mode the driver will cause - // the new firmware to be copied from the UMP Ram to I2C and the firmware will update - // the record type from 0xf2 to 0x02. - - // Allocate a 15.5k buffer + 2 bytes for version number (Firmware Record) - buffer_size = (((1024 * 16) - 512 )+ sizeof(struct ti_i2c_firmware_rec)); - - buffer = kmalloc (buffer_size, GFP_KERNEL); + /* In order to update the I2C firmware we must change the type 2 record + * to type 0xF2. This will force the UMP to come up in Boot Mode. + * Then while in boot mode, the driver will download the latest + * firmware (padded to 15.5k) into the UMP ram. And finally when the + * device comes back up in download mode the driver will cause the new + * firmware to be copied from the UMP Ram to I2C and the firmware will + * update the record type from 0xf2 to 0x02. + */ + + /* Allocate a 15.5k buffer + 2 bytes for version number + * (Firmware Record) */ + buffer_size = (((1024 * 16) - 512 ) + + sizeof(struct ti_i2c_firmware_rec)); + + buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory\n", __func__); + dev_err(dev, "%s - out of memory\n", __func__); return -ENOMEM; } - + // Set entire image of 0xffs - memset (buffer, 0xff, buffer_size); + memset(buffer, 0xff, buffer_size); err = request_firmware(&fw, fw_name, dev); if (err) { @@ -921,16 +898,16 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) OperationalMinorVersion = fw->data[1]; OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8); - // Copy version number into firmware record + /* Copy version number into firmware record */ firmware_rec = (struct ti_i2c_firmware_rec *)buffer; firmware_rec->Ver_Major = OperationalMajorVersion; firmware_rec->Ver_Minor = OperationalMinorVersion; - // Pointer to fw_down memory image + /* Pointer to fw_down memory image */ img_header = (struct ti_i2c_image_header *)&fw->data[4]; - memcpy (buffer + sizeof(struct ti_i2c_firmware_rec), + memcpy(buffer + sizeof(struct ti_i2c_firmware_rec), &fw->data[4 + sizeof(struct ti_i2c_image_header)], le16_to_cpu(img_header->Length)); @@ -940,12 +917,12 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) cs = (__u8)(cs + buffer[i]); } - kfree (buffer); + kfree(buffer); - // Build new header + /* Build new header */ i2c_header = (struct ti_i2c_desc *)header; firmware_rec = (struct ti_i2c_firmware_rec*)i2c_header->Data; - + i2c_header->Type = I2C_DESC_TYPE_FIRMWARE_BLANK; i2c_header->Size = (__u16)buffer_size; i2c_header->CheckSum = cs; @@ -956,103 +933,100 @@ static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev) } /* Try to figure out what type of I2c we have */ -static int TIGetI2cTypeInBootMode (struct edgeport_serial *serial) +static int i2c_type_bootmode(struct edgeport_serial *serial) { int status; __u8 data; - - // Try to read type 2 - status = TIReadVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_READ, // Request - DTK_ADDR_SPACE_I2C_TYPE_II, // wValue (Address type) - 0, // wIndex - &data, // TransferBuffer - 0x01); // TransferBufferLength + + /* Try to read type 2 */ + status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, + DTK_ADDR_SPACE_I2C_TYPE_II, 0, &data, 0x01); if (status) - dbg ("%s - read 2 status error = %d", __func__, status); + dbg("%s - read 2 status error = %d", __func__, status); else - dbg ("%s - read 2 data = 0x%x", __func__, data); + dbg("%s - read 2 data = 0x%x", __func__, data); if ((!status) && (data == UMP5152 || data == UMP3410)) { - dbg ("%s - ROM_TYPE_II", __func__); + dbg("%s - ROM_TYPE_II", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; return 0; } - // Try to read type 3 - status = TIReadVendorRequestSync (serial->serial->dev, - UMPC_MEMORY_READ, // Request - DTK_ADDR_SPACE_I2C_TYPE_III, // wValue (Address type) - 0, // wIndex - &data, // TransferBuffer - 0x01); // TransferBufferLength + /* Try to read type 3 */ + status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, + DTK_ADDR_SPACE_I2C_TYPE_III, 0, &data, 0x01); if (status) - dbg ("%s - read 3 status error = %d", __func__, status); + dbg("%s - read 3 status error = %d", __func__, status); else - dbg ("%s - read 2 data = 0x%x", __func__, data); + dbg("%s - read 2 data = 0x%x", __func__, data); if ((!status) && (data == UMP5152 || data == UMP3410)) { - dbg ("%s - ROM_TYPE_III", __func__); + dbg("%s - ROM_TYPE_III", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; return 0; } - dbg ("%s - Unknown", __func__); + dbg("%s - Unknown", __func__); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; return -ENODEV; } -static int TISendBulkTransferSync (struct usb_serial *serial, void *buffer, int length, int *num_sent) +static int bulk_xfer(struct usb_serial *serial, void *buffer, + int length, int *num_sent) { int status; - status = usb_bulk_msg (serial->dev, - usb_sndbulkpipe(serial->dev, - serial->port[0]->bulk_out_endpointAddress), - buffer, - length, - num_sent, - 1000); + status = usb_bulk_msg(serial->dev, + usb_sndbulkpipe(serial->dev, + serial->port[0]->bulk_out_endpointAddress), + buffer, length, num_sent, 1000); return status; } /* Download given firmware image to the device (IN BOOT MODE) */ -static int TIDownloadCodeImage (struct edgeport_serial *serial, __u8 *image, int image_length) +static int download_code(struct edgeport_serial *serial, __u8 *image, + int image_length) { int status = 0; int pos; int transfer; int done; - // Transfer firmware image + /* Transfer firmware image */ for (pos = 0; pos < image_length; ) { - // Read the next buffer from file + /* Read the next buffer from file */ transfer = image_length - pos; if (transfer > EDGE_FW_BULK_MAX_PACKET_SIZE) transfer = EDGE_FW_BULK_MAX_PACKET_SIZE; - // Transfer data - status = TISendBulkTransferSync (serial->serial, &image[pos], transfer, &done); + /* Transfer data */ + status = bulk_xfer(serial->serial, &image[pos], + transfer, &done); if (status) break; - // Advance buffer pointer + /* Advance buffer pointer */ pos += done; } return status; } -// FIXME!!! -static int TIConfigureBootDevice (struct usb_device *dev) +/* FIXME!!! */ +static int config_boot_dev(struct usb_device *dev) { return 0; } +static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc) +{ + return TI_GET_CPU_REVISION(desc->CpuRev_BoardRev); +} + /** * DownloadTIFirmware - Download run-time operating firmware to the TI5052 - * + * * This routine downloads the main operating code into the TI5052, using the * boot code already burned into E2PROM or ROM. */ -static int TIDownloadFirmware (struct edgeport_serial *serial) +static int download_fw(struct edgeport_serial *serial) { struct device *dev = &serial->serial->dev->dev; int status = 0; @@ -1071,22 +1045,25 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) /* Default to type 2 i2c */ serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; - status = TIChooseConfiguration (serial->serial->dev); + status = choose_config(serial->serial->dev); if (status) return status; interface = &serial->serial->interface->cur_altsetting->desc; if (!interface) { - dev_err (dev, "%s - no interface set, error!\n", __func__); + dev_err(dev, "%s - no interface set, error!\n", __func__); return -ENODEV; } - // Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING - // if we have more than one endpoint we are definitely in download mode + /* + * Setup initial mode -- the default mode 0 is TI_MODE_CONFIGURING + * if we have more than one endpoint we are definitely in download + * mode + */ if (interface->bNumEndpoints > 1) serial->product_info.TiMode = TI_MODE_DOWNLOAD; else - // Otherwise we will remain in configuring mode + /* Otherwise we will remain in configuring mode */ serial->product_info.TiMode = TI_MODE_CONFIGURING; /********************************************************************/ @@ -1097,256 +1074,273 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); - status = TiValidateI2cImage (serial); + status = check_i2c_image(serial); if (status) { dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); return status; } - + /* Validate Hardware version number * Read Manufacturing Descriptor from TI Based Edgeport */ - ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); + ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); if (!ti_manuf_desc) { - dev_err (dev, "%s - out of memory.\n", __func__); + dev_err(dev, "%s - out of memory.\n", __func__); return -ENOMEM; } - status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); + status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); if (status) { - kfree (ti_manuf_desc); + kfree(ti_manuf_desc); return status; } - // Check version number of ION descriptor - if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { - dbg ( "%s - Wrong CPU Rev %d (Must be 2)", __func__, - TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); - kfree (ti_manuf_desc); - return -EINVAL; - } + /* Check version number of ION descriptor */ + if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { + dbg("%s - Wrong CPU Rev %d (Must be 2)", + __func__, ti_cpu_rev(ti_manuf_desc)); + kfree(ti_manuf_desc); + return -EINVAL; + } - rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL); + rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); if (!rom_desc) { - dev_err (dev, "%s - out of memory.\n", __func__); - kfree (ti_manuf_desc); + dev_err(dev, "%s - out of memory.\n", __func__); + kfree(ti_manuf_desc); return -ENOMEM; } - // Search for type 2 record (firmware record) - if ((start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc)) != 0) { + /* Search for type 2 record (firmware record) */ + start_address = get_descriptor_addr(serial, + I2C_DESC_TYPE_FIRMWARE_BASIC, rom_desc); + if (start_address != 0) { struct ti_i2c_firmware_rec *firmware_version; __u8 record; - dbg ("%s - Found Type FIRMWARE (Type 2) record", __func__); + dbg("%s - Found Type FIRMWARE (Type 2) record", + __func__); - firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL); + firmware_version = kmalloc(sizeof(*firmware_version), + GFP_KERNEL); if (!firmware_version) { - dev_err (dev, "%s - out of memory.\n", __func__); - kfree (rom_desc); - kfree (ti_manuf_desc); + dev_err(dev, "%s - out of memory.\n", __func__); + kfree(rom_desc); + kfree(ti_manuf_desc); return -ENOMEM; } - // Validate version number - // Read the descriptor data - status = TIReadRom (serial, - start_address+sizeof(struct ti_i2c_desc), + /* Validate version number + * Read the descriptor data + */ + status = read_rom(serial, start_address + + sizeof(struct ti_i2c_desc), sizeof(struct ti_i2c_firmware_rec), (__u8 *)firmware_version); if (status) { - kfree (firmware_version); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(firmware_version); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } - // Check version number of download with current version in I2c - download_cur_ver = (firmware_version->Ver_Major << 8) + + /* Check version number of download with current + version in I2c */ + download_cur_ver = (firmware_version->Ver_Major << 8) + (firmware_version->Ver_Minor); download_new_ver = (OperationalMajorVersion << 8) + (OperationalMinorVersion); - dbg ("%s - >>>Firmware Versions Device %d.%d Driver %d.%d", - __func__, - firmware_version->Ver_Major, - firmware_version->Ver_Minor, - OperationalMajorVersion, - OperationalMinorVersion); + dbg("%s - >> FW Versions Device %d.%d Driver %d.%d", + __func__, + firmware_version->Ver_Major, + firmware_version->Ver_Minor, + OperationalMajorVersion, + OperationalMinorVersion); - // Check if we have an old version in the I2C and update if necessary + /* Check if we have an old version in the I2C and + update if necessary */ if (download_cur_ver != download_new_ver) { - dbg ("%s - Update I2C Download from %d.%d to %d.%d", - __func__, - firmware_version->Ver_Major, - firmware_version->Ver_Minor, - OperationalMajorVersion, - OperationalMinorVersion); - - // In order to update the I2C firmware we must change the type 2 record to type 0xF2. - // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver - // will download the latest firmware (padded to 15.5k) into the UMP ram. - // And finally when the device comes back up in download mode the driver will cause - // the new firmware to be copied from the UMP Ram to I2C and the firmware will update - // the record type from 0xf2 to 0x02. - + dbg("%s - Update I2C dld from %d.%d to %d.%d", + __func__, + firmware_version->Ver_Major, + firmware_version->Ver_Minor, + OperationalMajorVersion, + OperationalMinorVersion); + + /* In order to update the I2C firmware we must + * change the type 2 record to type 0xF2. This + * will force the UMP to come up in Boot Mode. + * Then while in boot mode, the driver will + * download the latest firmware (padded to + * 15.5k) into the UMP ram. Finally when the + * device comes back up in download mode the + * driver will cause the new firmware to be + * copied from the UMP Ram to I2C and the + * firmware will update the record type from + * 0xf2 to 0x02. + */ record = I2C_DESC_TYPE_FIRMWARE_BLANK; - // Change the I2C Firmware record type to 0xf2 to trigger an update - status = TIWriteRom (serial, - start_address, - sizeof(record), - &record); + /* Change the I2C Firmware record type to + 0xf2 to trigger an update */ + status = write_rom(serial, start_address, + sizeof(record), &record); if (status) { - kfree (firmware_version); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(firmware_version); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } - // verify the write -- must do this in order for write to - // complete before we do the hardware reset - status = TIReadRom (serial, + /* verify the write -- must do this in order + * for write to complete before we do the + * hardware reset + */ + status = read_rom(serial, start_address, sizeof(record), &record); - if (status) { - kfree (firmware_version); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(firmware_version); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) { - dev_err (dev, "%s - error resetting device\n", __func__); - kfree (firmware_version); - kfree (rom_desc); - kfree (ti_manuf_desc); + dev_err(dev, + "%s - error resetting device\n", + __func__); + kfree(firmware_version); + kfree(rom_desc); + kfree(ti_manuf_desc); return -ENODEV; } - dbg ("%s - HARDWARE RESET", __func__); + dbg("%s - HARDWARE RESET", __func__); - // Reset UMP -- Back to BOOT MODE - status = TISendVendorRequestSync (serial->serial->dev, - UMPC_HARDWARE_RESET, // Request - 0, // wValue - 0, // wIndex - NULL, // TransferBuffer - 0); // TransferBufferLength + /* Reset UMP -- Back to BOOT MODE */ + status = ti_vsend_sync(serial->serial->dev, + UMPC_HARDWARE_RESET, + 0, 0, NULL, 0); - dbg ( "%s - HARDWARE RESET return %d", __func__, status); + dbg("%s - HARDWARE RESET return %d", + __func__, status); /* return an error on purpose. */ - kfree (firmware_version); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(firmware_version); + kfree(rom_desc); + kfree(ti_manuf_desc); return -ENODEV; } - kfree (firmware_version); + kfree(firmware_version); } - // Search for type 0xF2 record (firmware blank record) - else if ((start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { - #define HEADER_SIZE (sizeof(struct ti_i2c_desc) + sizeof(struct ti_i2c_firmware_rec)) + /* Search for type 0xF2 record (firmware blank record) */ + else if ((start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_FIRMWARE_BLANK, rom_desc)) != 0) { +#define HEADER_SIZE (sizeof(struct ti_i2c_desc) + \ + sizeof(struct ti_i2c_firmware_rec)) __u8 *header; __u8 *vheader; - header = kmalloc (HEADER_SIZE, GFP_KERNEL); + header = kmalloc(HEADER_SIZE, GFP_KERNEL); if (!header) { - dev_err (dev, "%s - out of memory.\n", __func__); - kfree (rom_desc); - kfree (ti_manuf_desc); + dev_err(dev, "%s - out of memory.\n", __func__); + kfree(rom_desc); + kfree(ti_manuf_desc); return -ENOMEM; } - - vheader = kmalloc (HEADER_SIZE, GFP_KERNEL); + + vheader = kmalloc(HEADER_SIZE, GFP_KERNEL); if (!vheader) { - dev_err (dev, "%s - out of memory.\n", __func__); - kfree (header); - kfree (rom_desc); - kfree (ti_manuf_desc); + dev_err(dev, "%s - out of memory.\n", __func__); + kfree(header); + kfree(rom_desc); + kfree(ti_manuf_desc); return -ENOMEM; } - - dbg ("%s - Found Type BLANK FIRMWARE (Type F2) record", __func__); - - // In order to update the I2C firmware we must change the type 2 record to type 0xF2. - // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver - // will download the latest firmware (padded to 15.5k) into the UMP ram. - // And finally when the device comes back up in download mode the driver will cause - // the new firmware to be copied from the UMP Ram to I2C and the firmware will update - // the record type from 0xf2 to 0x02. - status = BuildI2CFirmwareHeader(header, dev); + + dbg("%s - Found Type BLANK FIRMWARE (Type F2) record", + __func__); + + /* + * In order to update the I2C firmware we must change + * the type 2 record to type 0xF2. This will force the + * UMP to come up in Boot Mode. Then while in boot + * mode, the driver will download the latest firmware + * (padded to 15.5k) into the UMP ram. Finally when the + * device comes back up in download mode the driver + * will cause the new firmware to be copied from the + * UMP Ram to I2C and the firmware will update the + * record type from 0xf2 to 0x02. + */ + status = build_i2c_fw_hdr(header, dev); if (status) { - kfree (vheader); - kfree (header); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(vheader); + kfree(header); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } - // Update I2C with type 0xf2 record with correct size and checksum - status = TIWriteRom (serial, + /* Update I2C with type 0xf2 record with correct + size and checksum */ + status = write_rom(serial, start_address, HEADER_SIZE, header); if (status) { - kfree (vheader); - kfree (header); - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(vheader); + kfree(header); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } - // verify the write -- must do this in order for write to - // complete before we do the hardware reset - status = TIReadRom (serial, - start_address, - HEADER_SIZE, - vheader); + /* verify the write -- must do this in order for + write to complete before we do the hardware reset */ + status = read_rom(serial, start_address, + HEADER_SIZE, vheader); if (status) { - dbg ("%s - can't read header back", __func__); - kfree (vheader); - kfree (header); - kfree (rom_desc); - kfree (ti_manuf_desc); + dbg("%s - can't read header back", __func__); + kfree(vheader); + kfree(header); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } if (memcmp(vheader, header, HEADER_SIZE)) { - dbg ("%s - write download record failed", __func__); - kfree (vheader); - kfree (header); - kfree (rom_desc); - kfree (ti_manuf_desc); + dbg("%s - write download record failed", + __func__); + kfree(vheader); + kfree(header); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } - kfree (vheader); - kfree (header); + kfree(vheader); + kfree(header); - dbg ("%s - Start firmware update", __func__); + dbg("%s - Start firmware update", __func__); - // Tell firmware to copy download image into I2C - status = TISendVendorRequestSync (serial->serial->dev, - UMPC_COPY_DNLD_TO_I2C, // Request - 0, // wValue - 0, // wIndex - NULL, // TransferBuffer - 0); // TransferBufferLength + /* Tell firmware to copy download image into I2C */ + status = ti_vsend_sync(serial->serial->dev, + UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); - dbg ("%s - Update complete 0x%x", __func__, status); + dbg("%s - Update complete 0x%x", __func__, status); if (status) { - dev_err (dev, "%s - UMPC_COPY_DNLD_TO_I2C failed\n", __func__); - kfree (rom_desc); - kfree (ti_manuf_desc); + dev_err(dev, + "%s - UMPC_COPY_DNLD_TO_I2C failed\n", + __func__); + kfree(rom_desc); + kfree(ti_manuf_desc); return status; } } // The device is running the download code - kfree (rom_desc); - kfree (ti_manuf_desc); + kfree(rom_desc); + kfree(ti_manuf_desc); return 0; } @@ -1355,32 +1349,26 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) /********************************************************************/ dbg("%s - RUNNING IN BOOT MODE", __func__); - // Configure the TI device so we can use the BULK pipes for download - status = TIConfigureBootDevice (serial->serial->dev); + /* Configure the TI device so we can use the BULK pipes for download */ + status = config_boot_dev(serial->serial->dev); if (status) return status; - if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) { - dbg ("%s - VID = 0x%x", __func__, + if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) + != USB_VENDOR_ID_ION) { + dbg("%s - VID = 0x%x", __func__, le16_to_cpu(serial->serial->dev->descriptor.idVendor)); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; - goto StayInBootMode; - } - - // We have an ION device (I2c Must be programmed) - // Determine I2C image type - if (TIGetI2cTypeInBootMode(serial)) { - goto StayInBootMode; + goto stayinbootmode; } - // Registry variable set? - if (TIStayInBootMode) { - dbg ("%s - TIStayInBootMode", __func__); - goto StayInBootMode; - } + /* We have an ION device (I2c Must be programmed) + Determine I2C image type */ + if (i2c_type_bootmode(serial)) + goto stayinbootmode; - // Check for ION Vendor ID and that the I2C is valid - if (!TiValidateI2cImage(serial)) { + /* Check for ION Vendor ID and that the I2C is valid */ + if (!check_i2c_image(serial)) { struct ti_i2c_image_header *header; int i; __u8 cs = 0; @@ -1393,49 +1381,52 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) /* Validate Hardware version number * Read Manufacturing Descriptor from TI Based Edgeport */ - ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL); + ti_manuf_desc = kmalloc(sizeof(*ti_manuf_desc), GFP_KERNEL); if (!ti_manuf_desc) { - dev_err (dev, "%s - out of memory.\n", __func__); + dev_err(dev, "%s - out of memory.\n", __func__); return -ENOMEM; } - status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc); + status = get_manuf_info(serial, (__u8 *)ti_manuf_desc); if (status) { - kfree (ti_manuf_desc); - goto StayInBootMode; + kfree(ti_manuf_desc); + goto stayinbootmode; } - // Check for version 2 - if (!ignore_cpu_rev && TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev) < 2) { - dbg ("%s - Wrong CPU Rev %d (Must be 2)", __func__, - TI_GET_CPU_REVISION(ti_manuf_desc->CpuRev_BoardRev)); - kfree (ti_manuf_desc); - goto StayInBootMode; + /* Check for version 2 */ + if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { + dbg("%s - Wrong CPU Rev %d (Must be 2)", + __func__, ti_cpu_rev(ti_manuf_desc)); + kfree(ti_manuf_desc); + goto stayinbootmode; } - kfree (ti_manuf_desc); + kfree(ti_manuf_desc); - // In order to update the I2C firmware we must change the type 2 record to type 0xF2. - // This will force the UMP to come up in Boot Mode. Then while in boot mode, the driver - // will download the latest firmware (padded to 15.5k) into the UMP ram. - // And finally when the device comes back up in download mode the driver will cause - // the new firmware to be copied from the UMP Ram to I2C and the firmware will update - // the record type from 0xf2 to 0x02. - /* + * In order to update the I2C firmware we must change the type + * 2 record to type 0xF2. This will force the UMP to come up + * in Boot Mode. Then while in boot mode, the driver will + * download the latest firmware (padded to 15.5k) into the + * UMP ram. Finally when the device comes back up in download + * mode the driver will cause the new firmware to be copied + * from the UMP Ram to I2C and the firmware will update the + * record type from 0xf2 to 0x02. + * * Do we really have to copy the whole firmware image, * or could we do this in place! */ - // Allocate a 15.5k buffer + 3 byte header - buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header)); - buffer = kmalloc (buffer_size, GFP_KERNEL); + /* Allocate a 15.5k buffer + 3 byte header */ + buffer_size = (((1024 * 16) - 512) + + sizeof(struct ti_i2c_image_header)); + buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (dev, "%s - out of memory\n", __func__); + dev_err(dev, "%s - out of memory\n", __func__); return -ENOMEM; } - - // Initialize the buffer to 0xff (pad the buffer) - memset (buffer, 0xff, buffer_size); + + /* Initialize the buffer to 0xff (pad the buffer) */ + memset(buffer, 0xff, buffer_size); err = request_firmware(&fw, fw_name, dev); if (err) { @@ -1447,38 +1438,43 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) memcpy(buffer, &fw->data[4], fw->size - 4); release_firmware(fw); - for(i = sizeof(struct ti_i2c_image_header); i < buffer_size; i++) { + for (i = sizeof(struct ti_i2c_image_header); + i < buffer_size; i++) { cs = (__u8)(cs + buffer[i]); } - + header = (struct ti_i2c_image_header *)buffer; - - // update length and checksum after padding - header->Length = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_i2c_image_header))); + + /* update length and checksum after padding */ + header->Length = cpu_to_le16((__u16)(buffer_size - + sizeof(struct ti_i2c_image_header))); header->CheckSum = cs; - // Download the operational code - dbg ("%s - Downloading operational code image (TI UMP)", __func__); - status = TIDownloadCodeImage (serial, buffer, buffer_size); + /* Download the operational code */ + dbg("%s - Downloading operational code image (TI UMP)", + __func__); + status = download_code(serial, buffer, buffer_size); - kfree (buffer); + kfree(buffer); if (status) { - dbg ("%s - Error downloading operational code image", __func__); + dbg("%s - Error downloading operational code image", + __func__); return status; } - // Device will reboot + /* Device will reboot */ serial->product_info.TiMode = TI_MODE_TRANSITIONING; - dbg ("%s - Download successful -- Device rebooting...", __func__); + dbg("%s - Download successful -- Device rebooting...", + __func__); /* return an error on purpose */ return -ENODEV; } -StayInBootMode: - // Eprom is invalid or blank stay in boot mode +stayinbootmode: + /* Eprom is invalid or blank stay in boot mode */ dbg("%s - STAYING IN BOOT MODE", __func__); serial->product_info.TiMode = TI_MODE_BOOT; @@ -1486,156 +1482,33 @@ StayInBootMode: } -static int TISetDtr (struct edgeport_port *port) +static int ti_do_config(struct edgeport_port *port, int feature, int on) { int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - port->shadow_mcr |= MCR_DTR; - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_DTR, - (__u8)(UMPM_UART1_PORT + port_number), - 1, /* set */ - NULL, - 0); + on = !!on; /* 1 or 0 not bitmask */ + return send_cmd(port->port->serial->dev, + feature, (__u8)(UMPM_UART1_PORT + port_number), + on, NULL, 0); } -static int TIClearDtr (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - port->shadow_mcr &= ~MCR_DTR; - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_DTR, - (__u8)(UMPM_UART1_PORT + port_number), - 0, /* clear */ - NULL, - 0); -} - -static int TISetRts (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - port->shadow_mcr |= MCR_RTS; - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_RTS, - (__u8)(UMPM_UART1_PORT + port_number), - 1, /* set */ - NULL, - 0); -} - -static int TIClearRts (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - port->shadow_mcr &= ~MCR_RTS; - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_RTS, - (__u8)(UMPM_UART1_PORT + port_number), - 0, /* clear */ - NULL, - 0); -} - -static int TISetLoopBack (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_LOOPBACK, - (__u8)(UMPM_UART1_PORT + port_number), - 1, /* set */ - NULL, - 0); -} - -static int TIClearLoopBack (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_LOOPBACK, - (__u8)(UMPM_UART1_PORT + port_number), - 0, /* clear */ - NULL, - 0); -} - -static int TISetBreak (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_BREAK, - (__u8)(UMPM_UART1_PORT + port_number), - 1, /* set */ - NULL, - 0); -} - -static int TIClearBreak (struct edgeport_port *port) -{ - int port_number = port->port->number - port->port->serial->minor; - - dbg ("%s", __func__); - - return TIWriteCommandSync (port->port->serial->dev, - UMPC_SET_CLR_BREAK, - (__u8)(UMPM_UART1_PORT + port_number), - 0, /* clear */ - NULL, - 0); -} - -static int TIRestoreMCR (struct edgeport_port *port, __u8 mcr) +static int restore_mcr(struct edgeport_port *port, __u8 mcr) { int status = 0; - dbg ("%s - %x", __func__, mcr); - - if (mcr & MCR_DTR) - status = TISetDtr (port); - else - status = TIClearDtr (port); + dbg("%s - %x", __func__, mcr); + status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); if (status) return status; - - if (mcr & MCR_RTS) - status = TISetRts (port); - else - status = TIClearRts (port); - + status = ti_do_config(port, UMPC_SET_CLR_RTS, mcr & MCR_RTS); if (status) return status; - - if (mcr & MCR_LOOPBACK) - status = TISetLoopBack (port); - else - status = TIClearLoopBack (port); - - return status; + return ti_do_config(port, UMPC_SET_CLR_LOOPBACK, mcr & MCR_LOOPBACK); } - - /* Convert TI LSR to standard UART flags */ -static __u8 MapLineStatus (__u8 ti_lsr) +static __u8 map_line_status(__u8 ti_lsr) { __u8 lsr = 0; @@ -1647,22 +1520,23 @@ static __u8 MapLineStatus (__u8 ti_lsr) MAP_FLAG(UMP_UART_LSR_PE_MASK, LSR_PAR_ERR) /* parity error */ MAP_FLAG(UMP_UART_LSR_FE_MASK, LSR_FRM_ERR) /* framing error */ MAP_FLAG(UMP_UART_LSR_BR_MASK, LSR_BREAK) /* break detected */ - MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* receive data available */ - MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* transmit holding register empty */ + MAP_FLAG(UMP_UART_LSR_RX_MASK, LSR_RX_AVAIL) /* rx data available */ + MAP_FLAG(UMP_UART_LSR_TX_MASK, LSR_TX_EMPTY) /* tx hold reg empty */ #undef MAP_FLAG return lsr; } -static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) +static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) { struct async_icount *icount; struct tty_struct *tty; - dbg ("%s - %02x", __func__, msr); + dbg("%s - %02x", __func__, msr); - if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { + if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | + EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { icount = &edge_port->icount; /* update input line counters */ @@ -1674,7 +1548,7 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) icount->dcd++; if (msr & EDGEPORT_MSR_DELTA_RI) icount->rng++; - wake_up_interruptible (&edge_port->delta_msr_wait); + wake_up_interruptible(&edge_port->delta_msr_wait); } /* Save the new modem status */ @@ -1694,26 +1568,28 @@ static void handle_new_msr (struct edgeport_port *edge_port, __u8 msr) return; } -static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 lsr, __u8 data) +static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, + __u8 lsr, __u8 data) { struct async_icount *icount; - __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); + __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | + LSR_FRM_ERR | LSR_BREAK)); - dbg ("%s - %02x", __func__, new_lsr); + dbg("%s - %02x", __func__, new_lsr); edge_port->shadow_lsr = lsr; - if (new_lsr & LSR_BREAK) { + if (new_lsr & LSR_BREAK) /* * Parity and Framing errors only count if they * occur exclusive of a break being received. */ new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); - } /* Place LSR data byte into Rx buffer */ if (lsr_data && edge_port->port->tty) - edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); + edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, + &data, 1); /* update input line counters */ icount = &edge_port->icount; @@ -1728,7 +1604,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8 } -static void edge_interrupt_callback (struct urb *urb) +static void edge_interrupt_callback(struct urb *urb) { struct edgeport_serial *edge_serial = urb->context; struct usb_serial_port *port; @@ -1762,66 +1638,71 @@ static void edge_interrupt_callback (struct urb *urb) } if (!length) { - dbg ("%s - no data in urb", __func__); + dbg("%s - no data in urb", __func__); goto exit; } - - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data); - + + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, + __func__, length, data); + if (length != 2) { - dbg ("%s - expecting packet of size 2, got %d", __func__, length); + dbg("%s - expecting packet of size 2, got %d", + __func__, length); goto exit; } - port_number = TIUMP_GET_PORT_FROM_CODE (data[0]); - function = TIUMP_GET_FUNC_FROM_CODE (data[0]); - dbg ("%s - port_number %d, function %d, info 0x%x", + port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); + function = TIUMP_GET_FUNC_FROM_CODE(data[0]); + dbg("%s - port_number %d, function %d, info 0x%x", __func__, port_number, function, data[1]); port = edge_serial->serial->port[port_number]; edge_port = usb_get_serial_port_data(port); if (!edge_port) { - dbg ("%s - edge_port not found", __func__); + dbg("%s - edge_port not found", __func__); return; } switch (function) { case TIUMP_INTERRUPT_CODE_LSR: - lsr = MapLineStatus(data[1]); + lsr = map_line_status(data[1]); if (lsr & UMP_UART_LSR_DATA_MASK) { - /* Save the LSR event for bulk read completion routine */ - dbg ("%s - LSR Event Port %u LSR Status = %02x", + /* Save the LSR event for bulk read + completion routine */ + dbg("%s - LSR Event Port %u LSR Status = %02x", __func__, port_number, lsr); edge_port->lsr_event = 1; edge_port->lsr_mask = lsr; } else { - dbg ("%s - ===== Port %d LSR Status = %02x ======", + dbg("%s - ===== Port %d LSR Status = %02x ======", __func__, port_number, lsr); - handle_new_lsr (edge_port, 0, lsr, 0); + handle_new_lsr(edge_port, 0, lsr, 0); } break; - case TIUMP_INTERRUPT_CODE_MSR: // MSR + case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ /* Copy MSR from UMP */ msr = data[1]; - dbg ("%s - ===== Port %u MSR Status = %02x ======\n", + dbg("%s - ===== Port %u MSR Status = %02x ======\n", __func__, port_number, msr); - handle_new_msr (edge_port, msr); + handle_new_msr(edge_port, msr); break; default: - dev_err (&urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n", - __func__, data[1]); + dev_err(&urb->dev->dev, + "%s - Unknown Interrupt code from UMP %x\n", + __func__, data[1]); break; - + } exit: - retval = usb_submit_urb (urb, GFP_ATOMIC); + retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) - dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", + dev_err(&urb->dev->dev, + "%s - usb_submit_urb failed with result %d\n", __func__, retval); } -static void edge_bulk_in_callback (struct urb *urb) +static void edge_bulk_in_callback(struct urb *urb) { struct edgeport_port *edge_port = urb->context; unsigned char *data = urb->transfer_buffer; @@ -1844,15 +1725,16 @@ static void edge_bulk_in_callback (struct urb *urb) __func__, status); return; default: - dev_err (&urb->dev->dev,"%s - nonzero read bulk status received: %d\n", - __func__, status); + dev_err(&urb->dev->dev, + "%s - nonzero read bulk status received: %d\n", + __func__, status); } if (status == -EPIPE) goto exit; if (status) { - dev_err(&urb->dev->dev,"%s - stopping read!\n", __func__); + dev_err(&urb->dev->dev, "%s - stopping read!\n", __func__); return; } @@ -1860,9 +1742,9 @@ static void edge_bulk_in_callback (struct urb *urb) if (edge_port->lsr_event) { edge_port->lsr_event = 0; - dbg ("%s ===== Port %u LSR Status = %02x, Data = %02x ======", + dbg("%s ===== Port %u LSR Status = %02x, Data = %02x ======", __func__, port_number, edge_port->lsr_mask, *data); - handle_new_lsr (edge_port, 1, edge_port->lsr_mask, *data); + handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); /* Adjust buffer length/pointer */ --urb->actual_length; ++data; @@ -1870,13 +1752,14 @@ static void edge_bulk_in_callback (struct urb *urb) tty = edge_port->port->tty; if (tty && urb->actual_length) { - usb_serial_debug_data(debug, &edge_port->port->dev, __func__, urb->actual_length, data); - - if (edge_port->close_pending) { - dbg ("%s - close is pending, dropping data on the floor.", __func__); - } else { - edge_tty_recv(&edge_port->port->dev, tty, data, urb->actual_length); - } + usb_serial_debug_data(debug, &edge_port->port->dev, + __func__, urb->actual_length, data); + if (edge_port->close_pending) + dbg("%s - close pending, dropping data on the floor", + __func__); + else + edge_tty_recv(&edge_port->port->dev, tty, data, + urb->actual_length); edge_port->icount.rx += urb->actual_length; } @@ -1891,37 +1774,31 @@ exit: } spin_unlock(&edge_port->ep_lock); if (retval) - dev_err (&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", + dev_err(&urb->dev->dev, + "%s - usb_submit_urb failed with result %d\n", __func__, retval); } -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length) +static void edge_tty_recv(struct device *dev, struct tty_struct *tty, + unsigned char *data, int length) { - int cnt; - - do { - cnt = tty_buffer_request_room(tty, length); - if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", - __func__, length - cnt); - if(cnt == 0) - break; - } - tty_insert_flip_string(tty, data, cnt); - data += cnt; - length -= cnt; - } while (length > 0); + int queued; + tty_buffer_request_room(tty, length); + queued = tty_insert_flip_string(tty, data, length); + if (queued < length) + dev_err(dev, "%s - dropping data, %d bytes lost\n", + __func__, length - queued); tty_flip_buffer_push(tty); } -static void edge_bulk_out_callback (struct urb *urb) +static void edge_bulk_out_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status = urb->status; - dbg ("%s - port %d", __func__, port->number); + dbg("%s - port %d", __func__, port->number); edge_port->ep_write_urb_in_use = 0; @@ -1945,7 +1822,7 @@ static void edge_bulk_out_callback (struct urb *urb) edge_send(port); } -static int edge_open (struct usb_serial_port *port, struct file * filp) +static int edge_open(struct usb_serial_port *port, struct file *filp) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_serial *edge_serial; @@ -1965,118 +1842,119 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) port_number = port->number - port->serial->minor; switch (port_number) { - case 0: - edge_port->uart_base = UMPMEM_BASE_UART1; - edge_port->dma_address = UMPD_OEDB1_ADDRESS; - break; - case 1: - edge_port->uart_base = UMPMEM_BASE_UART2; - edge_port->dma_address = UMPD_OEDB2_ADDRESS; - break; - default: - dev_err (&port->dev, "Unknown port number!!!\n"); - return -ENODEV; + case 0: + edge_port->uart_base = UMPMEM_BASE_UART1; + edge_port->dma_address = UMPD_OEDB1_ADDRESS; + break; + case 1: + edge_port->uart_base = UMPMEM_BASE_UART2; + edge_port->dma_address = UMPD_OEDB2_ADDRESS; + break; + default: + dev_err(&port->dev, "Unknown port number!!!\n"); + return -ENODEV; } - dbg ("%s - port_number = %d, uart_base = %04x, dma_address = %04x", - __func__, port_number, edge_port->uart_base, edge_port->dma_address); + dbg("%s - port_number = %d, uart_base = %04x, dma_address = %04x", + __func__, port_number, edge_port->uart_base, + edge_port->dma_address); dev = port->serial->dev; - memset (&(edge_port->icount), 0x00, sizeof(edge_port->icount)); - init_waitqueue_head (&edge_port->delta_msr_wait); + memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount)); + init_waitqueue_head(&edge_port->delta_msr_wait); /* turn off loopback */ - status = TIClearLoopBack (edge_port); + status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); if (status) { - dev_err(&port->dev,"%s - cannot send clear loopback command, %d\n", + dev_err(&port->dev, + "%s - cannot send clear loopback command, %d\n", __func__, status); return status; } - + /* set up the port settings */ - edge_set_termios (port, port->tty->termios); + edge_set_termios(port, port->tty->termios); /* open up the port */ /* milliseconds to timeout for DMA transfer */ transaction_timeout = 2; - edge_port->ump_read_timeout = max (20, ((transaction_timeout * 3) / 2) ); + edge_port->ump_read_timeout = + max(20, ((transaction_timeout * 3) / 2)); - // milliseconds to timeout for DMA transfer - open_settings = (u8)(UMP_DMA_MODE_CONTINOUS | - UMP_PIPE_TRANS_TIMEOUT_ENA | + /* milliseconds to timeout for DMA transfer */ + open_settings = (u8)(UMP_DMA_MODE_CONTINOUS | + UMP_PIPE_TRANS_TIMEOUT_ENA | (transaction_timeout << 2)); - dbg ("%s - Sending UMPC_OPEN_PORT", __func__); + dbg("%s - Sending UMPC_OPEN_PORT", __func__); /* Tell TI to open and start the port */ - status = TIWriteCommandSync (dev, - UMPC_OPEN_PORT, - (u8)(UMPM_UART1_PORT + port_number), - open_settings, - NULL, - 0); + status = send_cmd(dev, UMPC_OPEN_PORT, + (u8)(UMPM_UART1_PORT + port_number), open_settings, NULL, 0); if (status) { - dev_err(&port->dev,"%s - cannot send open command, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send open command, %d\n", + __func__, status); return status; } /* Start the DMA? */ - status = TIWriteCommandSync (dev, - UMPC_START_PORT, - (u8)(UMPM_UART1_PORT + port_number), - 0, - NULL, - 0); + status = send_cmd(dev, UMPC_START_PORT, + (u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0); if (status) { - dev_err(&port->dev,"%s - cannot send start DMA command, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send start DMA command, %d\n", + __func__, status); return status; } /* Clear TX and RX buffers in UMP */ - status = TIPurgeDataSync (port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); + status = purge_port(port, UMP_PORT_DIR_OUT | UMP_PORT_DIR_IN); if (status) { - dev_err(&port->dev,"%s - cannot send clear buffers command, %d\n", __func__, status); + dev_err(&port->dev, + "%s - cannot send clear buffers command, %d\n", + __func__, status); return status; } /* Read Initial MSR */ - status = TIReadVendorRequestSync (dev, - UMPC_READ_MSR, // Request - 0, // wValue - (__u16)(UMPM_UART1_PORT + port_number), // wIndex (Address) - &edge_port->shadow_msr, // TransferBuffer - 1); // TransferBufferLength + status = ti_vread_sync(dev, UMPC_READ_MSR, 0, + (__u16)(UMPM_UART1_PORT + port_number), + &edge_port->shadow_msr, 1); if (status) { - dev_err(&port->dev,"%s - cannot send read MSR command, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send read MSR command, %d\n", + __func__, status); return status; } - dbg ("ShadowMSR 0x%X", edge_port->shadow_msr); - + dbg("ShadowMSR 0x%X", edge_port->shadow_msr); + /* Set Initial MCR */ edge_port->shadow_mcr = MCR_RTS | MCR_DTR; - dbg ("ShadowMCR 0x%X", edge_port->shadow_mcr); + dbg("ShadowMCR 0x%X", edge_port->shadow_mcr); edge_serial = edge_port->edge_serial; if (mutex_lock_interruptible(&edge_serial->es_lock)) return -ERESTARTSYS; if (edge_serial->num_ports_open == 0) { - /* we are the first port to be opened, let's post the interrupt urb */ + /* we are the first port to open, post the interrupt urb */ urb = edge_serial->serial->port[0]->interrupt_in_urb; if (!urb) { - dev_err (&port->dev, "%s - no interrupt urb present, exiting\n", __func__); + dev_err(&port->dev, + "%s - no interrupt urb present, exiting\n", + __func__); status = -EINVAL; goto release_es_lock; } urb->complete = edge_interrupt_callback; urb->context = edge_serial; urb->dev = dev; - status = usb_submit_urb (urb, GFP_KERNEL); + status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err (&port->dev, "%s - usb_submit_urb failed with value %d\n", __func__, status); + dev_err(&port->dev, + "%s - usb_submit_urb failed with value %d\n", + __func__, status); goto release_es_lock; } } @@ -2085,13 +1963,14 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) * reset the data toggle on the bulk endpoints to work around bug in * host controllers where things get out of sync some times */ - usb_clear_halt (dev, port->write_urb->pipe); - usb_clear_halt (dev, port->read_urb->pipe); + usb_clear_halt(dev, port->write_urb->pipe); + usb_clear_halt(dev, port->read_urb->pipe); /* start up our bulk read urb */ urb = port->read_urb; if (!urb) { - dev_err (&port->dev, "%s - no read urb present, exiting\n", __func__); + dev_err(&port->dev, "%s - no read urb present, exiting\n", + __func__); status = -EINVAL; goto unlink_int_urb; } @@ -2099,9 +1978,11 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) urb->complete = edge_bulk_in_callback; urb->context = edge_port; urb->dev = dev; - status = usb_submit_urb (urb, GFP_KERNEL); + status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err (&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); + dev_err(&port->dev, + "%s - read bulk usb_submit_urb failed with value %d\n", + __func__, status); goto unlink_int_urb; } @@ -2119,7 +2000,7 @@ release_es_lock: return status; } -static void edge_close (struct usb_serial_port *port, struct file *filp) +static void edge_close(struct usb_serial_port *port, struct file *filp) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; @@ -2127,18 +2008,18 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) int status; dbg("%s - port %d", __func__, port->number); - + edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); - if ((edge_serial == NULL) || (edge_port == NULL)) + if (edge_serial == NULL || edge_port == NULL) return; - - /* The bulkreadcompletion routine will check + + /* The bulkreadcompletion routine will check * this flag and dump add read data */ edge_port->close_pending = 1; /* chase the port close and flush */ - TIChasePort (edge_port, (HZ*closing_wait)/100, 1); + chase_port(edge_port, (HZ * closing_wait) / 100, 1); usb_kill_urb(port->read_urb); usb_kill_urb(port->write_urb); @@ -2148,7 +2029,7 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) * send a close port command to it */ dbg("%s - send umpc_close_port", __func__); port_number = port->number - port->serial->minor; - status = TIWriteCommandSync (port->serial->dev, + status = send_cmd(port->serial->dev, UMPC_CLOSE_PORT, (__u8)(UMPM_UART1_PORT + port_number), 0, @@ -2167,7 +2048,8 @@ static void edge_close (struct usb_serial_port *port, struct file *filp) dbg("%s - exited", __func__); } -static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) +static int edge_write(struct usb_serial_port *port, const unsigned char *data, + int count) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned long flags; @@ -2223,11 +2105,12 @@ static void edge_send(struct usb_serial_port *port) spin_unlock_irqrestore(&edge_port->ep_lock, flags); - usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, + port->write_urb->transfer_buffer); /* set up our urb */ - usb_fill_bulk_urb (port->write_urb, port->serial->dev, - usb_sndbulkpipe (port->serial->dev, + usb_fill_bulk_urb(port->write_urb, port->serial->dev, + usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, count, edge_bulk_out_callback, @@ -2236,22 +2119,21 @@ static void edge_send(struct usb_serial_port *port) /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting write urb, error %d\n", + __func__, result); edge_port->ep_write_urb_in_use = 0; - // TODO: reschedule edge_send - } else { + /* TODO: reschedule edge_send */ + } else edge_port->icount.tx += count; - } /* wakeup any process waiting for writes to complete */ /* there is now more room in the buffer for new writes */ - if (tty) { - /* let the tty driver wakeup if it has a special write_wakeup function */ + if (tty) tty_wakeup(tty); - } } -static int edge_write_room (struct usb_serial_port *port) +static int edge_write_room(struct usb_serial_port *port) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); int room = 0; @@ -2260,9 +2142,9 @@ static int edge_write_room (struct usb_serial_port *port) dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) - return -ENODEV; + return 0; if (edge_port->close_pending == 1) - return -ENODEV; + return 0; spin_lock_irqsave(&edge_port->ep_lock, flags); room = edge_buf_space_avail(edge_port->ep_out_buf); @@ -2272,7 +2154,7 @@ static int edge_write_room (struct usb_serial_port *port) return room; } -static int edge_chars_in_buffer (struct usb_serial_port *port) +static int edge_chars_in_buffer(struct usb_serial_port *port) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); int chars = 0; @@ -2281,22 +2163,22 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) - return -ENODEV; + return 0; if (edge_port->close_pending == 1) - return -ENODEV; + return 0; spin_lock_irqsave(&edge_port->ep_lock, flags); chars = edge_buf_data_avail(edge_port->ep_out_buf); spin_unlock_irqrestore(&edge_port->ep_lock, flags); - dbg ("%s - returns %d", __func__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } -static void edge_throttle (struct usb_serial_port *port) +static void edge_throttle(struct usb_serial_port *port) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty; + struct tty_struct *tty = port->tty; int status; dbg("%s - port %d", __func__, port->number); @@ -2304,19 +2186,14 @@ static void edge_throttle (struct usb_serial_port *port) if (edge_port == NULL) return; - tty = port->tty; - if (!tty) { - dbg ("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = edge_write (port, &stop_char, 1); - if (status <= 0) { - dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); - } + status = edge_write(port, &stop_char, 1); + if (status <= 0) + dev_err(&port->dev, + "%s - failed to write stop character, %d\n", + __func__, status); } /* if we are implementing RTS/CTS, stop reads */ @@ -2326,10 +2203,10 @@ static void edge_throttle (struct usb_serial_port *port) } -static void edge_unthrottle (struct usb_serial_port *port) +static void edge_unthrottle(struct usb_serial_port *port) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty; + struct tty_struct *tty = port->tty; int status; dbg("%s - port %d", __func__, port->number); @@ -2337,27 +2214,23 @@ static void edge_unthrottle (struct usb_serial_port *port) if (edge_port == NULL) return; - tty = port->tty; - if (!tty) { - dbg ("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); - status = edge_write (port, &start_char, 1); - if (status <= 0) { - dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); - } + status = edge_write(port, &start_char, 1); + if (status <= 0) + dev_err(&port->dev, + "%s - failed to write start character, %d\n", + __func__, status); } - /* if we are implementing RTS/CTS, restart reads */ /* are the Edgeport will assert the RTS line */ if (C_CRTSCTS(tty)) { status = restart_read(edge_port); if (status) - dev_err(&port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __func__, status); + dev_err(&port->dev, + "%s - read bulk usb_submit_urb failed: %d\n", + __func__, status); } } @@ -2398,22 +2271,26 @@ static int restart_read(struct edgeport_port *edge_port) return status; } -static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios) +static void change_port_settings(struct edgeport_port *edge_port, + struct ktermios *old_termios) { struct ump_uart_config *config; struct tty_struct *tty; int baud; unsigned cflag; int status; - int port_number = edge_port->port->number - edge_port->port->serial->minor; + int port_number = edge_port->port->number - + edge_port->port->serial->minor; dbg("%s - port %d", __func__, edge_port->port->number); tty = edge_port->port->tty; - config = kmalloc (sizeof (*config), GFP_KERNEL); + config = kmalloc(sizeof(*config), GFP_KERNEL); if (!config) { - dev_err (&edge_port->port->dev, "%s - out of memory\n", __func__); + *tty->termios = *old_termios; + dev_err(&edge_port->port->dev, "%s - out of memory\n", + __func__); return; } @@ -2427,22 +2304,22 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi config->bUartMode = (__u8)(edge_port->bUartMode); switch (cflag & CSIZE) { - case CS5: - config->bDataBits = UMP_UART_CHAR5BITS; - dbg ("%s - data bits = 5", __func__); - break; - case CS6: - config->bDataBits = UMP_UART_CHAR6BITS; - dbg ("%s - data bits = 6", __func__); - break; - case CS7: - config->bDataBits = UMP_UART_CHAR7BITS; - dbg ("%s - data bits = 7", __func__); - break; - default: - case CS8: - config->bDataBits = UMP_UART_CHAR8BITS; - dbg ("%s - data bits = 8", __func__); + case CS5: + config->bDataBits = UMP_UART_CHAR5BITS; + dbg("%s - data bits = 5", __func__); + break; + case CS6: + config->bDataBits = UMP_UART_CHAR6BITS; + dbg("%s - data bits = 6", __func__); + break; + case CS7: + config->bDataBits = UMP_UART_CHAR7BITS; + dbg("%s - data bits = 7", __func__); + break; + default: + case CS8: + config->bDataBits = UMP_UART_CHAR8BITS; + dbg("%s - data bits = 8", __func__); break; } @@ -2457,7 +2334,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi dbg("%s - parity = even", __func__); } } else { - config->bParity = UMP_UART_NOPARITY; + config->bParity = UMP_UART_NOPARITY; dbg("%s - parity = none", __func__); } @@ -2480,29 +2357,26 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi restart_read(edge_port); } - /* if we are implementing XON/XOFF, set the start and stop character in the device */ - if (I_IXOFF(tty) || I_IXON(tty)) { - config->cXon = START_CHAR(tty); - config->cXoff = STOP_CHAR(tty); + /* if we are implementing XON/XOFF, set the start and stop + character in the device */ + config->cXon = START_CHAR(tty); + config->cXoff = STOP_CHAR(tty); - /* if we are implementing INBOUND XON/XOFF */ - if (I_IXOFF(tty)) { - config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; - dbg ("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", - __func__, config->cXon, config->cXoff); - } else { - dbg ("%s - INBOUND XON/XOFF is disabled", __func__); - } + /* if we are implementing INBOUND XON/XOFF */ + if (I_IXOFF(tty)) { + config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; + dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", + __func__, config->cXon, config->cXoff); + } else + dbg("%s - INBOUND XON/XOFF is disabled", __func__); - /* if we are implementing OUTBOUND XON/XOFF */ - if (I_IXON(tty)) { - config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; - dbg ("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", - __func__, config->cXon, config->cXoff); - } else { - dbg ("%s - OUTBOUND XON/XOFF is disabled", __func__); - } - } + /* if we are implementing OUTBOUND XON/XOFF */ + if (I_IXON(tty)) { + config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; + dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", + __func__, config->cXon, config->cXoff); + } else + dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); tty->termios->c_cflag &= ~CMSPAR; @@ -2519,62 +2393,52 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi /* FIXME: Recompute actual baud from divisor here */ - dbg ("%s - baud rate = %d, wBaudRate = %d", __func__, baud, config->wBaudRate); + dbg("%s - baud rate = %d, wBaudRate = %d", __func__, baud, + config->wBaudRate); - dbg ("wBaudRate: %d", (int)(461550L / config->wBaudRate)); - dbg ("wFlags: 0x%x", config->wFlags); - dbg ("bDataBits: %d", config->bDataBits); - dbg ("bParity: %d", config->bParity); - dbg ("bStopBits: %d", config->bStopBits); - dbg ("cXon: %d", config->cXon); - dbg ("cXoff: %d", config->cXoff); - dbg ("bUartMode: %d", config->bUartMode); + dbg("wBaudRate: %d", (int)(461550L / config->wBaudRate)); + dbg("wFlags: 0x%x", config->wFlags); + dbg("bDataBits: %d", config->bDataBits); + dbg("bParity: %d", config->bParity); + dbg("bStopBits: %d", config->bStopBits); + dbg("cXon: %d", config->cXon); + dbg("cXoff: %d", config->cXoff); + dbg("bUartMode: %d", config->bUartMode); /* move the word values into big endian mode */ - cpu_to_be16s (&config->wFlags); - cpu_to_be16s (&config->wBaudRate); + cpu_to_be16s(&config->wFlags); + cpu_to_be16s(&config->wBaudRate); - status = TIWriteCommandSync (edge_port->port->serial->dev, - UMPC_SET_CONFIG, + status = send_cmd(edge_port->port->serial->dev, UMPC_SET_CONFIG, (__u8)(UMPM_UART1_PORT + port_number), - 0, - (__u8 *)config, - sizeof(*config)); - if (status) { - dbg ("%s - error %d when trying to write config to device", + 0, (__u8 *)config, sizeof(*config)); + if (status) + dbg("%s - error %d when trying to write config to device", __func__, status); - } - - kfree (config); - + kfree(config); return; } -static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void edge_set_termios(struct usb_serial_port *port, + struct ktermios *old_termios) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; - unsigned int cflag; - - cflag = tty->termios->c_cflag; dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, tty->termios->c_iflag); dbg("%s - old clfag %08x old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); - dbg("%s - port %d", __func__, port->number); if (edge_port == NULL) return; - /* change the port settings to the new ones specified */ - change_port_settings (edge_port, old_termios); - - return; + change_port_settings(edge_port, old_termios); } -static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear) +static int edge_tiocmset(struct usb_serial_port *port, struct file *file, + unsigned int set, unsigned int clear) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; @@ -2601,8 +2465,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig edge_port->shadow_mcr = mcr; spin_unlock_irqrestore(&edge_port->ep_lock, flags); - TIRestoreMCR (edge_port, mcr); - + restore_mcr(edge_port, mcr); return 0; } @@ -2634,7 +2497,8 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file) return result; } -static int get_serial_info (struct edgeport_port *edge_port, struct serial_struct __user *retinfo) +static int get_serial_info(struct edgeport_port *edge_port, + struct serial_struct __user *retinfo) { struct serial_struct tmp; @@ -2652,17 +2516,14 @@ static int get_serial_info (struct edgeport_port *edge_port, struct serial_struc tmp.baud_base = 9600; tmp.close_delay = 5*HZ; tmp.closing_wait = closing_wait; -// tmp.custom_divisor = state->custom_divisor; -// tmp.hub6 = state->hub6; -// tmp.io_type = state->io_type; - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; return 0; } -static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) +static int edge_ioctl(struct usb_serial_port *port, struct file *file, + unsigned int cmd, unsigned long arg) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct async_icount cnow; @@ -2671,81 +2532,63 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { - case TIOCINQ: - dbg("%s - (%d) TIOCINQ", __func__, port->number); -// return get_number_bytes_avail(edge_port, (unsigned int *) arg); - break; - - case TIOCSERGETLSR: - dbg("%s - (%d) TIOCSERGETLSR", __func__, port->number); -// return get_lsr_info(edge_port, (unsigned int *) arg); - break; - - case TIOCGSERIAL: - dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); - return get_serial_info(edge_port, (struct serial_struct __user *) arg); - break; - - case TIOCSSERIAL: - dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); - break; - - case TIOCMIWAIT: - dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); - cprev = edge_port->icount; - while (1) { - interruptible_sleep_on(&edge_port->delta_msr_wait); - /* see if a signal did it */ - if (signal_pending(current)) - return -ERESTARTSYS; - cnow = edge_port->icount; - if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) - return -EIO; /* no change => error */ - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || - ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || - ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { - return 0; - } - cprev = cnow; + case TIOCGSERIAL: + dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); + return get_serial_info(edge_port, + (struct serial_struct __user *) arg); + case TIOCMIWAIT: + dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); + cprev = edge_port->icount; + while (1) { + interruptible_sleep_on(&edge_port->delta_msr_wait); + /* see if a signal did it */ + if (signal_pending(current)) + return -ERESTARTSYS; + cnow = edge_port->icount; + if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) + return -EIO; /* no change => error */ + if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || + ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || + ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { + return 0; } - /* not reached */ - break; - - case TIOCGICOUNT: - dbg ("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, - port->number, edge_port->icount.rx, edge_port->icount.tx); - if (copy_to_user((void __user *)arg, &edge_port->icount, sizeof(edge_port->icount))) - return -EFAULT; - return 0; + cprev = cnow; + } + /* not reached */ + break; + case TIOCGICOUNT: + dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, + port->number, edge_port->icount.rx, edge_port->icount.tx); + if (copy_to_user((void __user *)arg, &edge_port->icount, + sizeof(edge_port->icount))) + return -EFAULT; + return 0; } - return -ENOIOCTLCMD; } -static void edge_break (struct usb_serial_port *port, int break_state) +static void edge_break(struct usb_serial_port *port, int on) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status; + int bv = 0; /* Off */ - dbg ("%s - state = %d", __func__, break_state); + dbg("%s - state = %d", __func__, on); /* chase the port close */ - TIChasePort (edge_port, 0, 0); + chase_port(edge_port, 0, 0); - if (break_state == -1) { - status = TISetBreak (edge_port); - } else { - status = TIClearBreak (edge_port); - } - if (status) { - dbg ("%s - error %d sending break set/clear command.", + if (on == -1) + bv = 1; /* On */ + status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); + if (status) + dbg("%s - error %d sending break set/clear command.", __func__, status); - } } -static int edge_startup (struct usb_serial *serial) +static int edge_startup(struct usb_serial *serial) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; @@ -2765,9 +2608,9 @@ static int edge_startup (struct usb_serial *serial) edge_serial->serial = serial; usb_set_serial_data(serial, edge_serial); - status = TIDownloadFirmware (edge_serial); + status = download_fw(edge_serial); if (status) { - kfree (edge_serial); + kfree(edge_serial); return status; } @@ -2775,13 +2618,15 @@ static int edge_startup (struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", + __func__); goto cleanup; } spin_lock_init(&edge_port->ep_lock); edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE); if (edge_port->ep_out_buf == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", + __func__); kfree(edge_port); goto cleanup; } @@ -2790,27 +2635,27 @@ static int edge_startup (struct usb_serial *serial) usb_set_serial_port_data(serial->port[i], edge_port); edge_port->bUartMode = default_uart_mode; } - + return 0; cleanup: - for (--i; i>=0; --i) { + for (--i; i >= 0; --i) { edge_port = usb_get_serial_port_data(serial->port[i]); edge_buf_free(edge_port->ep_out_buf); kfree(edge_port); usb_set_serial_port_data(serial->port[i], NULL); } - kfree (edge_serial); + kfree(edge_serial); usb_set_serial_data(serial, NULL); return -ENOMEM; } -static void edge_shutdown (struct usb_serial *serial) +static void edge_shutdown(struct usb_serial *serial) { int i; struct edgeport_port *edge_port; - dbg ("%s", __func__); + dbg("%s", __func__); for (i = 0; i < serial->num_ports; ++i) { edge_port = usb_get_serial_port_data(serial->port[i]); @@ -2852,7 +2697,8 @@ static ssize_t store_uart_mode(struct device *dev, return count; } -static DEVICE_ATTR(uart_mode, S_IWUSR | S_IRUGO, show_uart_mode, store_uart_mode); +static DEVICE_ATTR(uart_mode, S_IWUSR | S_IRUGO, show_uart_mode, + store_uart_mode); static int edge_create_sysfs_attrs(struct usb_serial_port *port) { @@ -2922,9 +2768,9 @@ static void edge_buf_free(struct edge_buf *eb) static void edge_buf_clear(struct edge_buf *eb) { - if (eb != NULL) - eb->buf_get = eb->buf_put; - /* equivalent to a get of all data available */ + if (eb != NULL) + eb->buf_get = eb->buf_put; + /* equivalent to a get of all data available */ } @@ -2937,10 +2783,9 @@ static void edge_buf_clear(struct edge_buf *eb) static unsigned int edge_buf_data_avail(struct edge_buf *eb) { - if (eb != NULL) - return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size); - else + if (eb == NULL) return 0; + return ((eb->buf_size + eb->buf_put - eb->buf_get) % eb->buf_size); } @@ -2953,10 +2798,9 @@ static unsigned int edge_buf_data_avail(struct edge_buf *eb) static unsigned int edge_buf_space_avail(struct edge_buf *eb) { - if (eb != NULL) - return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size); - else + if (eb == NULL) return 0; + return ((eb->buf_size + eb->buf_get - eb->buf_put - 1) % eb->buf_size); } @@ -3113,7 +2957,7 @@ static int __init edgeport_init(void) if (retval) goto failed_2port_device_register; retval = usb_register(&io_driver); - if (retval) + if (retval) goto failed_usb_register; info(DRIVER_DESC " " DRIVER_VERSION); return 0; @@ -3125,11 +2969,11 @@ failed_1port_device_register: return retval; } -static void __exit edgeport_exit (void) +static void __exit edgeport_exit(void) { - usb_deregister (&io_driver); - usb_serial_deregister (&edgeport_1port_device); - usb_serial_deregister (&edgeport_2port_device); + usb_deregister(&io_driver); + usb_serial_deregister(&edgeport_1port_device); + usb_serial_deregister(&edgeport_2port_device); } module_init(edgeport_init); @@ -3151,8 +2995,8 @@ module_param(closing_wait, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); module_param(ignore_cpu_rev, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(ignore_cpu_rev, "Ignore the cpu revision when connecting to a device"); +MODULE_PARM_DESC(ignore_cpu_rev, + "Ignore the cpu revision when connecting to a device"); module_param(default_uart_mode, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(default_uart_mode, "Default uart_mode, 0=RS232, ..."); - -- cgit v1.2.3-70-g09d2 From ea05af61a874ffbc158d9cf06df8a9396f299f38 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 20 May 2008 01:00:46 +0300 Subject: USB: remove CVS keywords This patch removes CVS keywords that weren't updated for a long time from comments. Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/devices.c | 2 -- drivers/usb/core/devio.c | 2 -- drivers/usb/gadget/rndis.c | 2 -- drivers/usb/gadget/rndis.h | 2 -- drivers/usb/misc/emi62.c | 2 -- drivers/usb/serial/digi_acceleport.c | 2 -- drivers/usb/storage/datafab.c | 2 -- drivers/usb/storage/debug.c | 2 -- drivers/usb/storage/debug.h | 2 -- drivers/usb/storage/dpcm.c | 2 -- drivers/usb/storage/dpcm.h | 2 -- drivers/usb/storage/freecom.c | 2 -- drivers/usb/storage/freecom.h | 2 -- drivers/usb/storage/initializers.c | 2 -- drivers/usb/storage/initializers.h | 2 -- drivers/usb/storage/isd200.c | 2 -- drivers/usb/storage/jumpshot.c | 2 -- drivers/usb/storage/protocol.c | 2 -- drivers/usb/storage/protocol.h | 2 -- drivers/usb/storage/scsiglue.c | 2 -- drivers/usb/storage/scsiglue.h | 2 -- drivers/usb/storage/sddr09.c | 1 - drivers/usb/storage/sddr09.h | 2 -- drivers/usb/storage/sddr55.c | 2 -- drivers/usb/storage/sddr55.h | 2 -- drivers/usb/storage/shuttle_usbat.c | 2 -- drivers/usb/storage/shuttle_usbat.h | 2 -- drivers/usb/storage/transport.c | 2 -- drivers/usb/storage/transport.h | 2 -- drivers/usb/storage/unusual_devs.h | 2 -- drivers/usb/storage/usb.c | 2 -- drivers/usb/storage/usb.h | 2 -- include/linux/usbdevice_fs.h | 2 -- 33 files changed, 65 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 83d9dc379d9..a681d9b92bd 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -46,8 +46,6 @@ * 2000-07-05: Ashley Montanaro * Converted file reading routine to dump to buffer once * per device, not per bus - * - * $Id: devices.c,v 1.5 2000/01/11 13:58:21 tom Exp $ */ #include diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 9218cca2104..7bee9c18b3b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -19,8 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: devio.c,v 1.7 2000/02/01 17:28:48 fliegl Exp $ - * * This file implements the usbfs/x/y files, where * x is the bus number and y the device number. * diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index d0677f5d3cd..20b15fcc9d4 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -1,8 +1,6 @@ /* * RNDIS MSG parser * - * Version: $Id: rndis.c,v 1.19 2004/03/25 21:33:46 robert Exp $ - * * Authors: Benedikt Spranger, Pengutronix * Robert Schwebel, Pengutronix * diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h index 397b149f3ca..b917b4f34ea 100644 --- a/drivers/usb/gadget/rndis.h +++ b/drivers/usb/gadget/rndis.h @@ -1,8 +1,6 @@ /* * RNDIS Definitions for Remote NDIS * - * Version: $Id: rndis.h,v 1.15 2004/03/25 21:33:46 robert Exp $ - * * Authors: Benedikt Spranger, Pengutronix * Robert Schwebel, Pengutronix * diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 20886c21e73..5d859ded5bb 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -6,8 +6,6 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, as published by * the Free Software Foundation, version 2. - * - * $Id: emi62.c,v 1.15 2002/04/23 06:13:59 tapio Exp $ */ #include #include diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 04a56f300ea..d96302d0d96 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -229,8 +229,6 @@ * in case a wake up is lost. * - Following Documentation/DocBook/kernel-locking.pdf no spin locks * are held when calling copy_to/from_user or printk. -* -* $Id: digi_acceleport.c,v 1.80.1.2 2000/11/02 05:45:08 root Exp $ */ #include diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 579e9f52053..17f1ae23291 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -1,6 +1,4 @@ /* Driver for Datafab USB Compact Flash reader - * - * $Id: datafab.c,v 1.7 2002/02/25 00:40:13 mdharm Exp $ * * datafab driver v0.1: * diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c index 01e430654a1..a2b5526c9fa 100644 --- a/drivers/usb/storage/debug.c +++ b/drivers/usb/storage/debug.c @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Debugging Functions Source Code File * - * $Id: debug.c,v 1.9 2002/04/22 03:39:43 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h index 77e244a8c37..dbb985d5242 100644 --- a/drivers/usb/storage/debug.h +++ b/drivers/usb/storage/debug.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Debugging Functions Header File * - * $Id: debug.h,v 1.6 2001/01/12 23:51:04 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/dpcm.c b/drivers/usb/storage/dpcm.c index 9a410b5a6e5..939923471af 100644 --- a/drivers/usb/storage/dpcm.c +++ b/drivers/usb/storage/dpcm.c @@ -1,6 +1,4 @@ /* Driver for Microtech DPCM-USB CompactFlash/SmartMedia reader - * - * $Id: dpcm.c,v 1.4 2001/06/11 02:54:25 mdharm Exp $ * * DPCM driver v0.1: * diff --git a/drivers/usb/storage/dpcm.h b/drivers/usb/storage/dpcm.h index 81b464cfcc1..e7b7b0f120d 100644 --- a/drivers/usb/storage/dpcm.h +++ b/drivers/usb/storage/dpcm.h @@ -1,6 +1,4 @@ /* Driver for Microtech DPCM-USB CompactFlash/SmartMedia reader - * - * $Id: dpcm.h,v 1.2 2000/08/25 00:13:51 mdharm Exp $ * * DPCM driver v0.1: * diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index f5a4e8d6a3b..7a4d4567722 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c @@ -1,6 +1,4 @@ /* Driver for Freecom USB/IDE adaptor - * - * $Id: freecom.c,v 1.22 2002/04/22 03:39:43 mdharm Exp $ * * Freecom v0.1: * diff --git a/drivers/usb/storage/freecom.h b/drivers/usb/storage/freecom.h index 1b012d62d0a..20d0fe6ba0c 100644 --- a/drivers/usb/storage/freecom.h +++ b/drivers/usb/storage/freecom.h @@ -1,6 +1,4 @@ /* Driver for Freecom USB/IDE adaptor - * - * $Id: freecom.h,v 1.4 2000/08/29 14:49:15 dlbrown Exp $ * * Freecom v0.1: * diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c index 187dd1e0109..4995bb595ae 100644 --- a/drivers/usb/storage/initializers.c +++ b/drivers/usb/storage/initializers.c @@ -1,6 +1,4 @@ /* Special Initializers for certain USB Mass Storage devices - * - * $Id: initializers.c,v 1.2 2000/09/06 22:35:57 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h index ad3ffd4236c..529327fbb06 100644 --- a/drivers/usb/storage/initializers.h +++ b/drivers/usb/storage/initializers.h @@ -1,6 +1,4 @@ /* Header file for Special Initializers for certain USB Mass Storage devices - * - * $Id: initializers.h,v 1.1 2000/08/29 23:07:02 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index a153335f364..383abf2516a 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -1,6 +1,4 @@ /* Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC - * - * $Id: isd200.c,v 1.16 2002/04/22 03:39:43 mdharm Exp $ * * Current development and maintenance: * (C) 2001-2002 Björn Stenberg (bjorn@haxx.se) diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 61097cbb158..df67f13c9e7 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c @@ -1,6 +1,4 @@ /* Driver for Lexar "Jumpshot" Compact Flash reader - * - * $Id: jumpshot.c,v 1.7 2002/02/25 00:40:13 mdharm Exp $ * * jumpshot driver v0.1: * diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index b9b8ede61fb..3b3357e20ea 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c @@ -1,6 +1,4 @@ /* Driver for USB Mass Storage compliant devices - * - * $Id: protocol.c,v 1.14 2002/04/22 03:39:43 mdharm Exp $ * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h index 8737a36891c..487056ffb51 100644 --- a/drivers/usb/storage/protocol.h +++ b/drivers/usb/storage/protocol.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Protocol Functions Header File * - * $Id: protocol.h,v 1.4 2001/02/13 07:10:03 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 043b60b2ad1..b4c9e0f18a8 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * SCSI layer glue code * - * $Id: scsiglue.c,v 1.26 2002/04/22 03:39:43 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/scsiglue.h b/drivers/usb/storage/scsiglue.h index 737e4fa6045..ffa1cca93d2 100644 --- a/drivers/usb/storage/scsiglue.h +++ b/drivers/usb/storage/scsiglue.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * SCSI Connecting Glue Header File * - * $Id: scsiglue.h,v 1.4 2000/08/25 00:13:51 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 8972b17da84..c5a54b872c2 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -1,6 +1,5 @@ /* Driver for SanDisk SDDR-09 SmartMedia reader * - * $Id: sddr09.c,v 1.24 2002/04/22 03:39:43 mdharm Exp $ * (c) 2000, 2001 Robert Baruch (autophile@starband.net) * (c) 2002 Andries Brouwer (aeb@cwi.nl) * Developed with the assistance of: diff --git a/drivers/usb/storage/sddr09.h b/drivers/usb/storage/sddr09.h index c03089a9ec3..e50033ad7b1 100644 --- a/drivers/usb/storage/sddr09.h +++ b/drivers/usb/storage/sddr09.h @@ -1,8 +1,6 @@ /* Driver for SanDisk SDDR-09 SmartMedia reader * Header File * - * $Id: sddr09.h,v 1.5 2000/08/25 00:13:51 mdharm Exp $ - * * Current development and maintenance by: * (c) 2000 Robert Baruch (autophile@dol.net) * (c) 2002 Andries Brouwer (aeb@cwi.nl) diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 6d14327c921..0d8df757789 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -1,6 +1,4 @@ /* Driver for SanDisk SDDR-55 SmartMedia reader - * - * $Id:$ * * SDDR55 driver v0.1: * diff --git a/drivers/usb/storage/sddr55.h b/drivers/usb/storage/sddr55.h index d6bd32f6c9f..a815a0470c8 100644 --- a/drivers/usb/storage/sddr55.h +++ b/drivers/usb/storage/sddr55.h @@ -1,8 +1,6 @@ /* Driver for SanDisk SDDR-55 SmartMedia reader * Header File * - * $Id:$ - * * Current development and maintenance by: * (c) 2002 Simon Munton * diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 570c1250f6f..ae6d64810d2 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -1,6 +1,4 @@ /* Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable - * - * $Id: shuttle_usbat.c,v 1.17 2002/04/22 03:39:43 mdharm Exp $ * * Current development and maintenance by: * (c) 2000, 2001 Robert Baruch (autophile@starband.net) diff --git a/drivers/usb/storage/shuttle_usbat.h b/drivers/usb/storage/shuttle_usbat.h index 3ddf143a1de..d8bfc43e904 100644 --- a/drivers/usb/storage/shuttle_usbat.h +++ b/drivers/usb/storage/shuttle_usbat.h @@ -1,8 +1,6 @@ /* Driver for SCM Microsystems USB-ATAPI cable * Header File * - * $Id: shuttle_usbat.h,v 1.5 2000/09/17 14:44:52 groovyjava Exp $ - * * Current development and maintenance by: * (c) 2000 Robert Baruch (autophile@dol.net) * (c) 2004, 2005 Daniel Drake diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 94138df557b..08d3a13fec2 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -1,6 +1,4 @@ /* Driver for USB Mass Storage compliant devices - * - * $Id: transport.c,v 1.47 2002/04/22 03:39:43 mdharm Exp $ * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h index ada7c2f43f8..e70b88182f0 100644 --- a/drivers/usb/storage/transport.h +++ b/drivers/usb/storage/transport.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Transport Functions Header File * - * $Id: transport.h,v 1.18 2002/04/21 02:57:59 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 3ba972c20f3..7ae69f55aa9 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Unusual Devices File * - * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $ - * * Current development and maintenance by: * (c) 2000-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 6bfd99dd57a..bfea851be98 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -1,6 +1,4 @@ /* Driver for USB Mass Storage compliant devices - * - * $Id: usb.c,v 1.75 2002/04/22 03:39:43 mdharm Exp $ * * Current development and maintenance by: * (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net) diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 47906dc620d..a4ad73bd832 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -1,8 +1,6 @@ /* Driver for USB Mass Storage compliant devices * Main Header File * - * $Id: usb.h,v 1.21 2002/04/21 02:57:59 mdharm Exp $ - * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h index 3118ede2c67..0044d9b4cb8 100644 --- a/include/linux/usbdevice_fs.h +++ b/include/linux/usbdevice_fs.h @@ -22,8 +22,6 @@ * * History: * 0.1 04.01.2000 Created - * - * $Id: usbdevice_fs.h,v 1.1 2000/01/06 18:40:41 tom Exp $ */ /*****************************************************************************/ -- cgit v1.2.3-70-g09d2 From 5a33956a300dcb48a3b125cae437ad6f5c718282 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 30 May 2008 10:18:53 -0700 Subject: USB: digi_accelport.c trivial sparse lock annotation Signed-off-by: Harvey Harrison Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/digi_acceleport.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index d96302d0d96..28bc6fcf44f 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -571,6 +571,7 @@ static struct usb_serial_driver digi_acceleport_4_device = { static long cond_wait_interruptible_timeout_irqrestore( wait_queue_head_t *q, long timeout, spinlock_t *lock, unsigned long flags) +__releases(lock) { DEFINE_WAIT(wait); -- cgit v1.2.3-70-g09d2 From b2bdd1f5041db6f2d172417b5ceea20abc7a6eb6 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 30 May 2008 10:29:55 -0700 Subject: USB: cp2101.c fix sparse signedness mismatch warnings The get/set 2101_config helpers take an unsigned int rather than an int. It is safe to change these in each case and may even produce better code as it will be an unsigned divide rather than a signed divide in places. All other manipulation was setting/masking bits which will not be affected by the sign change. Fixes the following sparse warnings: drivers/usb/serial/cp2101.c:378:44: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:378:44: expected unsigned int *data drivers/usb/serial/cp2101.c:378:44: got int * drivers/usb/serial/cp2101.c:388:40: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:388:40: expected unsigned int *data drivers/usb/serial/cp2101.c:388:40: got int * drivers/usb/serial/cp2101.c:413:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:413:42: expected unsigned int *data drivers/usb/serial/cp2101.c:413:42: got int * drivers/usb/serial/cp2101.c:421:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:421:42: expected unsigned int *data drivers/usb/serial/cp2101.c:421:42: got int * drivers/usb/serial/cp2101.c:444:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:444:42: expected unsigned int *data drivers/usb/serial/cp2101.c:444:42: got int * drivers/usb/serial/cp2101.c:451:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:451:42: expected unsigned int *data drivers/usb/serial/cp2101.c:451:42: got int * drivers/usb/serial/cp2101.c:458:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:458:42: expected unsigned int *data drivers/usb/serial/cp2101.c:458:42: got int * drivers/usb/serial/cp2101.c:471:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:471:42: expected unsigned int *data drivers/usb/serial/cp2101.c:471:42: got int * drivers/usb/serial/cp2101.c:481:42: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:481:42: expected unsigned int *data drivers/usb/serial/cp2101.c:481:42: got int * drivers/usb/serial/cp2101.c:561:41: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:561:41: expected unsigned int *data drivers/usb/serial/cp2101.c:561:41: got int * drivers/usb/serial/cp2101.c:591:45: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:591:45: expected unsigned int *data drivers/usb/serial/cp2101.c:591:45: got int * drivers/usb/serial/cp2101.c:597:41: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:597:41: expected unsigned int *data drivers/usb/serial/cp2101.c:597:41: got int * drivers/usb/serial/cp2101.c:608:45: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:608:45: expected unsigned int *data drivers/usb/serial/cp2101.c:608:45: got int * drivers/usb/serial/cp2101.c:614:41: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:614:41: expected unsigned int *data drivers/usb/serial/cp2101.c:614:41: got int * drivers/usb/serial/cp2101.c:623:45: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:623:45: expected unsigned int *data drivers/usb/serial/cp2101.c:623:45: got int * drivers/usb/serial/cp2101.c:680:50: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:680:50: expected unsigned int *data drivers/usb/serial/cp2101.c:680:50: got int * drivers/usb/serial/cp2101.c:690:43: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:690:43: expected unsigned int *data drivers/usb/serial/cp2101.c:690:43: got int * drivers/usb/serial/cp2101.c:715:41: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/cp2101.c:715:41: expected unsigned int *data drivers/usb/serial/cp2101.c:715:41: got int * Signed-off-by: Harvey Harrison Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/cp2101.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index f5b57b196c5..2bc5576c443 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -365,8 +365,8 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) static void cp2101_get_termios (struct usb_serial_port *port) { unsigned int cflag, modem_ctl[4]; - int baud; - int bits; + unsigned int baud; + unsigned int bits; dbg("%s - port %d", __func__, port->number); @@ -498,7 +498,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { unsigned int cflag, old_cflag; - int baud=0, bits; + unsigned int baud = 0, bits; unsigned int modem_ctl[4]; dbg("%s - port %d", __func__, port->number); @@ -654,7 +654,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear) { - int control = 0; + unsigned int control = 0; dbg("%s - port %d", __func__, port->number); @@ -683,7 +683,8 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) { - int control, result; + unsigned int control; + int result; dbg("%s - port %d", __func__, port->number); @@ -703,7 +704,7 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) { - int state; + unsigned int state; dbg("%s - port %d", __func__, port->number); if (break_state == 0) -- cgit v1.2.3-70-g09d2 From e0d795e4f36c2d8949c1355b497fc5425dbb9437 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 3 Jun 2008 14:47:52 +0300 Subject: usb: irda: cleanup on ir-usb module General cleanup on ir-usb module. Introduced a common header that could be used also on usb gadget framework. Lot's of cleanups and now using macros from the header file. Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ir-usb.c | 490 ++++++++++++++++++++++++-------------------- include/linux/usb/irda.h | 151 ++++++++++++++ 2 files changed, 421 insertions(+), 220 deletions(-) create mode 100644 include/linux/usb/irda.h (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 004d57385a7..0063c11c808 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -19,7 +19,12 @@ * was written by Roman Weissgaerber , Dag Brattli * , and Jean Tourrilhes * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver + * + * 2008_Jun_02 Felipe Balbi + * Introduced common header to be used also in USB Gadget Framework. + * Still needs some other style fixes. * * 2007_Jun_21 Alan Cox * Minimal cleanups for some of the driver problens and tty layer abuse. @@ -59,9 +64,10 @@ #include #include #include -#include +#include #include #include +#include /* * Version Information @@ -70,100 +76,75 @@ #define DRIVER_AUTHOR "Greg Kroah-Hartman " #define DRIVER_DESC "USB IR Dongle driver" -/* USB IrDA class spec information */ -#define USB_CLASS_IRDA 0x02 -#define USB_DT_IRDA 0x21 -#define IU_REQ_GET_CLASS_DESC 0x06 -#define SPEED_2400 0x01 -#define SPEED_9600 0x02 -#define SPEED_19200 0x03 -#define SPEED_38400 0x04 -#define SPEED_57600 0x05 -#define SPEED_115200 0x06 -#define SPEED_576000 0x07 -#define SPEED_1152000 0x08 -#define SPEED_4000000 0x09 - -struct irda_class_desc { - u8 bLength; - u8 bDescriptorType; - u16 bcdSpecRevision; - u8 bmDataSize; - u8 bmWindowSize; - u8 bmMinTurnaroundTime; - u16 wBaudRate; - u8 bmAdditionalBOFs; - u8 bIrdaRateSniff; - u8 bMaxUnicastList; -} __attribute__ ((packed)); - static int debug; /* if overridden by the user, then use their value for the size of the read and * write urbs */ static int buffer_size; + /* if overridden by the user, then use the specified number of XBOFs */ static int xbof = -1; -static int ir_startup (struct usb_serial *serial); -static int ir_open (struct usb_serial_port *port, struct file *filep); -static void ir_close (struct usb_serial_port *port, struct file *filep); -static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static void ir_write_bulk_callback (struct urb *urb); -static void ir_read_bulk_callback (struct urb *urb); -static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); +static int ir_startup(struct usb_serial *serial); +static int ir_open(struct usb_serial_port *port, struct file *filep); +static void ir_close(struct usb_serial_port *port, struct file *filep); +static int ir_write(struct usb_serial_port *port, + const unsigned char *buf, int count); +static void ir_write_bulk_callback(struct urb *urb); +static void ir_read_bulk_callback(struct urb *urb); +static void ir_set_termios(struct usb_serial_port *port, + struct ktermios *old_termios); /* Not that this lot means you can only have one per system */ -static u8 ir_baud = 0; -static u8 ir_xbof = 0; -static u8 ir_add_bof = 0; +static u8 ir_baud; +static u8 ir_xbof; +static u8 ir_add_bof; -static struct usb_device_id id_table [] = { +static struct usb_device_id ir_id_table[] = { { USB_DEVICE(0x050f, 0x0180) }, /* KC Technology, KC-180 */ { USB_DEVICE(0x08e9, 0x0100) }, /* XTNDAccess */ { USB_DEVICE(0x09c4, 0x0011) }, /* ACTiSys ACT-IR2000U */ - { USB_INTERFACE_INFO (USB_CLASS_APP_SPEC, USB_CLASS_IRDA, 0) }, + { USB_INTERFACE_INFO(USB_CLASS_APP_SPEC, USB_SUBCLASS_IRDA, 0) }, { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, ir_id_table); static struct usb_driver ir_driver = { - .name = "ir-usb", - .probe = usb_serial_probe, - .disconnect = usb_serial_disconnect, - .id_table = id_table, - .no_dynamic_id = 1, + .name = "ir-usb", + .probe = usb_serial_probe, + .disconnect = usb_serial_disconnect, + .id_table = ir_id_table, + .no_dynamic_id = 1, }; - static struct usb_serial_driver ir_device = { - .driver = { - .owner = THIS_MODULE, - .name = "ir-usb", + .driver = { + .owner = THIS_MODULE, + .name = "ir-usb", }, - .description = "IR Dongle", - .usb_driver = &ir_driver, - .id_table = id_table, - .num_ports = 1, - .set_termios = ir_set_termios, - .attach = ir_startup, - .open = ir_open, - .close = ir_close, - .write = ir_write, - .write_bulk_callback = ir_write_bulk_callback, - .read_bulk_callback = ir_read_bulk_callback, + .description = "IR Dongle", + .usb_driver = &ir_driver, + .id_table = ir_id_table, + .num_ports = 1, + .set_termios = ir_set_termios, + .attach = ir_startup, + .open = ir_open, + .close = ir_close, + .write = ir_write, + .write_bulk_callback = ir_write_bulk_callback, + .read_bulk_callback = ir_read_bulk_callback, }; -static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc) +static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) { dbg("bLength=%x", desc->bLength); dbg("bDescriptorType=%x", desc->bDescriptorType); - dbg("bcdSpecRevision=%x", desc->bcdSpecRevision); + dbg("bcdSpecRevision=%x", __le16_to_cpu(desc->bcdSpecRevision)); dbg("bmDataSize=%x", desc->bmDataSize); dbg("bmWindowSize=%x", desc->bmWindowSize); dbg("bmMinTurnaroundTime=%d", desc->bmMinTurnaroundTime); - dbg("wBaudRate=%x", desc->wBaudRate); + dbg("wBaudRate=%x", __le16_to_cpu(desc->wBaudRate)); dbg("bmAdditionalBOFs=%x", desc->bmAdditionalBOFs); dbg("bIrdaRateSniff=%x", desc->bIrdaRateSniff); dbg("bMaxUnicastList=%x", desc->bMaxUnicastList); @@ -181,35 +162,37 @@ static inline void irda_usb_dump_class_desc(struct irda_class_desc *desc) * * Based on the same function in drivers/net/irda/irda-usb.c */ -static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) +static struct usb_irda_cs_descriptor * +irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) { - struct irda_class_desc *desc; + struct usb_irda_cs_descriptor *desc; int ret; - - desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL); - if (desc == NULL) + + desc = kzalloc(sizeof(*desc), GFP_KERNEL); + if (!desc) return NULL; - - ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0), - IU_REQ_GET_CLASS_DESC, + + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), + USB_REQ_CS_IRDA_GET_CLASS_DESC, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, ifnum, desc, sizeof(*desc), 1000); - + dbg("%s - ret=%d", __func__, ret); if (ret < sizeof(*desc)) { dbg("%s - class descriptor read %s (%d)", __func__, - (ret<0) ? "failed" : "too short", + (ret < 0) ? "failed" : "too short", ret); goto error; } - if (desc->bDescriptorType != USB_DT_IRDA) { + if (desc->bDescriptorType != USB_DT_CS_IRDA) { dbg("%s - bad class descriptor type", __func__); goto error; } - + irda_usb_dump_class_desc(desc); return desc; + error: kfree(desc); return NULL; @@ -219,64 +202,100 @@ error: static u8 ir_xbof_change(u8 xbof) { u8 result; + /* reference irda-usb.c */ - switch(xbof) { - case 48: result = 0x10; break; - case 28: - case 24: result = 0x20; break; - default: - case 12: result = 0x30; break; - case 5: - case 6: result = 0x40; break; - case 3: result = 0x50; break; - case 2: result = 0x60; break; - case 1: result = 0x70; break; - case 0: result = 0x80; break; + switch (xbof) { + case 48: + result = 0x10; + break; + case 28: + case 24: + result = 0x20; + break; + default: + case 12: + result = 0x30; + break; + case 5: + case 6: + result = 0x40; + break; + case 3: + result = 0x50; + break; + case 2: + result = 0x60; + break; + case 1: + result = 0x70; + break; + case 0: + result = 0x80; + break; } + return(result); } -static int ir_startup (struct usb_serial *serial) +static int ir_startup(struct usb_serial *serial) { - struct irda_class_desc *irda_desc; + struct usb_irda_cs_descriptor *irda_desc; - irda_desc = irda_usb_find_class_desc (serial->dev, 0); - if (irda_desc == NULL) { - dev_err (&serial->dev->dev, "IRDA class descriptor not found, device not bound\n"); + irda_desc = irda_usb_find_class_desc(serial->dev, 0); + if (!irda_desc) { + dev_err(&serial->dev->dev, + "IRDA class descriptor not found, device not bound\n"); return -ENODEV; } - dbg ("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", + dbg("%s - Baud rates supported:%s%s%s%s%s%s%s%s%s", __func__, - (irda_desc->wBaudRate & 0x0001) ? " 2400" : "", - (irda_desc->wBaudRate & 0x0002) ? " 9600" : "", - (irda_desc->wBaudRate & 0x0004) ? " 19200" : "", - (irda_desc->wBaudRate & 0x0008) ? " 38400" : "", - (irda_desc->wBaudRate & 0x0010) ? " 57600" : "", - (irda_desc->wBaudRate & 0x0020) ? " 115200" : "", - (irda_desc->wBaudRate & 0x0040) ? " 576000" : "", - (irda_desc->wBaudRate & 0x0080) ? " 1152000" : "", - (irda_desc->wBaudRate & 0x0100) ? " 4000000" : ""); - - switch( irda_desc->bmAdditionalBOFs ) { - case 0x01: ir_add_bof = 48; break; - case 0x02: ir_add_bof = 24; break; - case 0x04: ir_add_bof = 12; break; - case 0x08: ir_add_bof = 6; break; - case 0x10: ir_add_bof = 3; break; - case 0x20: ir_add_bof = 2; break; - case 0x40: ir_add_bof = 1; break; - case 0x80: ir_add_bof = 0; break; - default:; + (irda_desc->wBaudRate & USB_IRDA_BR_2400) ? " 2400" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_9600) ? " 9600" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_19200) ? " 19200" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_38400) ? " 38400" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_57600) ? " 57600" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_115200) ? " 115200" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_576000) ? " 576000" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_1152000) ? " 1152000" : "", + (irda_desc->wBaudRate & USB_IRDA_BR_4000000) ? " 4000000" : ""); + + switch (irda_desc->bmAdditionalBOFs) { + case USB_IRDA_AB_48: + ir_add_bof = 48; + break; + case USB_IRDA_AB_24: + ir_add_bof = 24; + break; + case USB_IRDA_AB_12: + ir_add_bof = 12; + break; + case USB_IRDA_AB_6: + ir_add_bof = 6; + break; + case USB_IRDA_AB_3: + ir_add_bof = 3; + break; + case USB_IRDA_AB_2: + ir_add_bof = 2; + break; + case USB_IRDA_AB_1: + ir_add_bof = 1; + break; + case USB_IRDA_AB_0: + ir_add_bof = 0; + break; + default: + break; } - kfree (irda_desc); + kfree(irda_desc); - return 0; + return 0; } -static int ir_open (struct usb_serial_port *port, struct file *filp) +static int ir_open(struct usb_serial_port *port, struct file *filp) { char *buffer; int result = 0; @@ -285,51 +304,55 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) if (buffer_size) { /* override the default buffer sizes */ - buffer = kmalloc (buffer_size, GFP_KERNEL); + buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (&port->dev, "%s - out of memory.\n", __func__); + dev_err(&port->dev, "%s - out of memory.\n", __func__); return -ENOMEM; } - kfree (port->read_urb->transfer_buffer); + kfree(port->read_urb->transfer_buffer); port->read_urb->transfer_buffer = buffer; port->read_urb->transfer_buffer_length = buffer_size; - buffer = kmalloc (buffer_size, GFP_KERNEL); + buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) { - dev_err (&port->dev, "%s - out of memory.\n", __func__); + dev_err(&port->dev, "%s - out of memory.\n", __func__); return -ENOMEM; } - kfree (port->write_urb->transfer_buffer); + kfree(port->write_urb->transfer_buffer); port->write_urb->transfer_buffer = buffer; port->write_urb->transfer_buffer_length = buffer_size; port->bulk_out_size = buffer_size; } /* Start reading from the device */ - usb_fill_bulk_urb ( + usb_fill_bulk_urb( port->read_urb, - port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ir_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); return result; } -static void ir_close (struct usb_serial_port *port, struct file * filp) +static void ir_close(struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); - + /* shutdown our bulk read */ usb_kill_urb(port->read_urb); } -static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int ir_write(struct usb_serial_port *port, + const unsigned char *buf, int count) { unsigned char *transfer_buffer; int result; @@ -338,7 +361,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int dbg("%s - port = %d, count = %d", __func__, port->number, count); if (!port->tty) { - dev_err (&port->dev, "%s - no tty???\n", __func__); + dev_err(&port->dev, "%s - no tty???\n", __func__); return 0; } @@ -359,7 +382,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int /* * The first byte of the packet we send to the device contains an - * inband header which indicates an additional number of BOFs and + * inbound header which indicates an additional number of BOFs and * a baud rate change. * * See section 5.4.2.2 of the USB IrDA spec. @@ -367,9 +390,9 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int *transfer_buffer = ir_xbof | ir_baud; ++transfer_buffer; - memcpy (transfer_buffer, buf, transfer_size); + memcpy(transfer_buffer, buf, transfer_size); - usb_fill_bulk_urb ( + usb_fill_bulk_urb( port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, @@ -381,17 +404,19 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int port->write_urb->transfer_flags = URB_ZERO_PACKET; - result = usb_submit_urb (port->write_urb, GFP_ATOMIC); + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { port->write_urb_busy = 0; - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting write urb, error %d\n", + __func__, result); } else result = transfer_size; return result; } -static void ir_write_bulk_callback (struct urb *urb) +static void ir_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; int status = urb->status; @@ -405,7 +430,7 @@ static void ir_write_bulk_callback (struct urb *urb) return; } - usb_serial_debug_data ( + usb_serial_debug_data( debug, &port->dev, __func__, @@ -415,7 +440,7 @@ static void ir_write_bulk_callback (struct urb *urb) usb_serial_port_softint(port); } -static void ir_read_bulk_callback (struct urb *urb) +static void ir_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct tty_struct *tty; @@ -431,68 +456,69 @@ static void ir_read_bulk_callback (struct urb *urb) } switch (status) { - case 0: /* Successful */ - - /* - * The first byte of the packet we get from the device - * contains a busy indicator and baud rate change. - * See section 5.4.1.2 of the USB IrDA spec. - */ - if ((*data & 0x0f) > 0) - ir_baud = *data & 0x0f; - - usb_serial_debug_data ( - debug, - &port->dev, - __func__, - urb->actual_length, - data); - - tty = port->tty; - - if (tty_buffer_request_room(tty, urb->actual_length - 1)) { - tty_insert_flip_string(tty, data+1, urb->actual_length - 1); - tty_flip_buffer_push(tty); - } - - /* - * No break here. - * We want to resubmit the urb so we can read - * again. - */ - - case -EPROTO: /* taking inspiration from pl2303.c */ - - /* Continue trying to always read */ - usb_fill_bulk_urb ( - port->read_urb, - port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, - port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, - port->read_urb->transfer_buffer_length, - ir_read_bulk_callback, - port); - - result = usb_submit_urb(port->read_urb, GFP_ATOMIC); - if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", - __func__, result); - - break ; - - default: - dbg("%s - nonzero read bulk status received: %d", - __func__, - status); - break ; + case 0: /* Successful */ + + /* + * The first byte of the packet we get from the device + * contains a busy indicator and baud rate change. + * See section 5.4.1.2 of the USB IrDA spec. + */ + if ((*data & 0x0f) > 0) + ir_baud = *data & 0x0f; + + usb_serial_debug_data( + debug, + &port->dev, + __func__, + urb->actual_length, + data); + + tty = port->tty; + + if (tty_buffer_request_room(tty, urb->actual_length - 1)) { + tty_insert_flip_string(tty, data + 1, + urb->actual_length - 1); + tty_flip_buffer_push(tty); + } + /* + * No break here. + * We want to resubmit the urb so we can read + * again. + */ + + case -EPROTO: /* taking inspiration from pl2303.c */ + + /* Continue trying to always read */ + usb_fill_bulk_urb( + port->read_urb, + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ir_read_bulk_callback, + port); + + result = usb_submit_urb(port->read_urb, GFP_ATOMIC); + if (result) + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); + break; + + default: + dbg("%s - nonzero read bulk status received: %d", + __func__, + status); + break; } return; } -static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void ir_set_termios(struct usb_serial_port *port, + struct ktermios *old_termios) { unsigned char *transfer_buffer; int result; @@ -510,19 +536,36 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t */ switch (baud) { - case 2400: ir_baud = SPEED_2400; break; - case 9600: ir_baud = SPEED_9600; break; - case 19200: ir_baud = SPEED_19200; break; - case 38400: ir_baud = SPEED_38400; break; - case 57600: ir_baud = SPEED_57600; break; - case 115200: ir_baud = SPEED_115200; break; - case 576000: ir_baud = SPEED_576000; break; - case 1152000: ir_baud = SPEED_1152000; break; - case 4000000: ir_baud = SPEED_4000000; break; - break; - default: - ir_baud = SPEED_9600; - baud = 9600; + case 2400: + ir_baud = USB_IRDA_BR_2400; + break; + case 9600: + ir_baud = USB_IRDA_BR_9600; + break; + case 19200: + ir_baud = USB_IRDA_BR_19200; + break; + case 38400: + ir_baud = USB_IRDA_BR_38400; + break; + case 57600: + ir_baud = USB_IRDA_BR_57600; + break; + case 115200: + ir_baud = USB_IRDA_BR_115200; + break; + case 576000: + ir_baud = USB_IRDA_BR_576000; + break; + case 1152000: + ir_baud = USB_IRDA_BR_1152000; + break; + case 4000000: + ir_baud = USB_IRDA_BR_4000000; + break; + default: + ir_baud = USB_IRDA_BR_9600; + baud = 9600; } if (xbof == -1) @@ -538,10 +581,11 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t transfer_buffer = port->write_urb->transfer_buffer; *transfer_buffer = ir_xbof | ir_baud; - usb_fill_bulk_urb ( + usb_fill_bulk_urb( port->write_urb, port->serial->dev, - usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), + usb_sndbulkpipe(port->serial->dev, + port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, 1, ir_write_bulk_callback, @@ -549,38 +593,44 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t port->write_urb->transfer_flags = URB_ZERO_PACKET; - result = usb_submit_urb (port->write_urb, GFP_KERNEL); + result = usb_submit_urb(port->write_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting write urb, error %d\n", + __func__, result); /* Only speed changes are supported */ tty_termios_copy_hw(port->tty->termios, old_termios); tty_encode_baud_rate(port->tty, baud, baud); } - -static int __init ir_init (void) +static int __init ir_init(void) { int retval; + retval = usb_serial_register(&ir_device); if (retval) goto failed_usb_serial_register; + retval = usb_register(&ir_driver); - if (retval) + if (retval) goto failed_usb_register; + info(DRIVER_DESC " " DRIVER_VERSION); + return 0; + failed_usb_register: usb_serial_deregister(&ir_device); + failed_usb_serial_register: return retval; } - -static void __exit ir_exit (void) +static void __exit ir_exit(void) { - usb_deregister (&ir_driver); - usb_serial_deregister (&ir_device); + usb_deregister(&ir_driver); + usb_serial_deregister(&ir_device); } diff --git a/include/linux/usb/irda.h b/include/linux/usb/irda.h new file mode 100644 index 00000000000..e345ceaf72d --- /dev/null +++ b/include/linux/usb/irda.h @@ -0,0 +1,151 @@ +/* + * USB IrDA Bridge Device Definition + */ + +#ifndef __LINUX_USB_IRDA_H +#define __LINUX_USB_IRDA_H + +/* This device should use Application-specific class */ + +#define USB_SUBCLASS_IRDA 0x02 + +/*-------------------------------------------------------------------------*/ + +/* Class-Specific requests (bRequest field) */ + +#define USB_REQ_CS_IRDA_RECEIVING 1 +#define USB_REQ_CS_IRDA_CHECK_MEDIA_BUSY 3 +#define USB_REQ_CS_IRDA_RATE_SNIFF 4 +#define USB_REQ_CS_IRDA_UNICAST_LIST 5 +#define USB_REQ_CS_IRDA_GET_CLASS_DESC 6 + +/*-------------------------------------------------------------------------*/ + +/* Class-Specific descriptor */ + +#define USB_DT_CS_IRDA 0x21 + +/*-------------------------------------------------------------------------*/ + +/* Data sizes */ + +#define USB_IRDA_DS_2048 (1 << 5) +#define USB_IRDA_DS_1024 (1 << 4) +#define USB_IRDA_DS_512 (1 << 3) +#define USB_IRDA_DS_256 (1 << 2) +#define USB_IRDA_DS_128 (1 << 1) +#define USB_IRDA_DS_64 (1 << 0) + +/* Window sizes */ + +#define USB_IRDA_WS_7 (1 << 6) +#define USB_IRDA_WS_6 (1 << 5) +#define USB_IRDA_WS_5 (1 << 4) +#define USB_IRDA_WS_4 (1 << 3) +#define USB_IRDA_WS_3 (1 << 2) +#define USB_IRDA_WS_2 (1 << 1) +#define USB_IRDA_WS_1 (1 << 0) + +/* Min turnaround times in usecs */ + +#define USB_IRDA_MTT_0 (1 << 7) +#define USB_IRDA_MTT_10 (1 << 6) +#define USB_IRDA_MTT_50 (1 << 5) +#define USB_IRDA_MTT_100 (1 << 4) +#define USB_IRDA_MTT_500 (1 << 3) +#define USB_IRDA_MTT_1000 (1 << 2) +#define USB_IRDA_MTT_5000 (1 << 1) +#define USB_IRDA_MTT_10000 (1 << 0) + +/* Baud rates */ + +#define USB_IRDA_BR_4000000 (1 << 8) +#define USB_IRDA_BR_1152000 (1 << 7) +#define USB_IRDA_BR_576000 (1 << 6) +#define USB_IRDA_BR_115200 (1 << 5) +#define USB_IRDA_BR_57600 (1 << 4) +#define USB_IRDA_BR_38400 (1 << 3) +#define USB_IRDA_BR_19200 (1 << 2) +#define USB_IRDA_BR_9600 (1 << 1) +#define USB_IRDA_BR_2400 (1 << 0) + +/* Additional BOFs */ + +#define USB_IRDA_AB_0 (1 << 7) +#define USB_IRDA_AB_1 (1 << 6) +#define USB_IRDA_AB_2 (1 << 5) +#define USB_IRDA_AB_3 (1 << 4) +#define USB_IRDA_AB_6 (1 << 3) +#define USB_IRDA_AB_12 (1 << 2) +#define USB_IRDA_AB_24 (1 << 1) +#define USB_IRDA_AB_48 (1 << 0) + +/* IRDA Rate Sniff */ + +#define USB_IRDA_RATE_SNIFF 1 + +/*-------------------------------------------------------------------------*/ + +struct usb_irda_cs_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __le16 bcdSpecRevision; + __u8 bmDataSize; + __u8 bmWindowSize; + __u8 bmMinTurnaroundTime; + __le16 wBaudRate; + __u8 bmAdditionalBOFs; + __u8 bIrdaRateSniff; + __u8 bMaxUnicastList; +} __attribute__ ((packed)); + +/*-------------------------------------------------------------------------*/ + +/* Data Format */ + +#define USB_IRDA_STATUS_MEDIA_BUSY (1 << 7) + +/* The following is a 4-bit value used for both + * inbound and outbound headers: + * + * 0 - speed ignored + * 1 - 2400 bps + * 2 - 9600 bps + * 3 - 19200 bps + * 4 - 38400 bps + * 5 - 57600 bps + * 6 - 115200 bps + * 7 - 576000 bps + * 8 - 1.152 Mbps + * 9 - 5 mbps + * 10..15 - Reserved + */ +#define USB_IRDA_STATUS_LINK_SPEED 0x0f + +/* The following is a 4-bit value used only for + * outbound header: + * + * 0 - No change (BOF ignored) + * 1 - 48 BOFs + * 2 - 24 BOFs + * 3 - 12 BOFs + * 4 - 6 BOFs + * 5 - 3 BOFs + * 6 - 2 BOFs + * 7 - 1 BOFs + * 8 - 0 BOFs + * 9..15 - Reserved + */ +#define USB_IRDA_EXTRA_BOFS 0xf0 + +struct usb_irda_inbound_header { + __u8 bmStatus; +}; + +struct usb_irda_outbound_header { + __u8 bmChange; +}; + +#endif /* __LINUX_USB_IRDA_H */ + -- cgit v1.2.3-70-g09d2 From 640c1bce86d1e11ee6a1263fdf6170d3210b1684 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 19 Jun 2008 11:21:16 -0700 Subject: USB: delete airprime driver This driver is only for one device id, and the option driver should be used instead for it. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/Kconfig | 8 - drivers/usb/serial/Makefile | 1 - drivers/usb/serial/airprime.c | 353 ------------------------------------------ drivers/usb/serial/option.c | 2 + 4 files changed, 2 insertions(+), 362 deletions(-) delete mode 100644 drivers/usb/serial/airprime.c (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 9a7681b5526..8878c1767fc 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -64,14 +64,6 @@ config USB_SERIAL_AIRCABLE To compile this driver as a module, choose M here: the module will be called aircable. -config USB_SERIAL_AIRPRIME - tristate "USB AirPrime CDMA Wireless Driver" - help - Say Y here if you want to use a AirPrime CDMA Wireless PC card. - - To compile this driver as a module, choose M here: the - module will be called airprime. - config USB_SERIAL_ARK3116 tristate "USB ARK Micro 3116 USB Serial Driver" help diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 17a762ab676..6047f818adf 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -12,7 +12,6 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o -obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c deleted file mode 100644 index 0798c14ce78..00000000000 --- a/drivers/usb/serial/airprime.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * AirPrime CDMA Wireless Serial USB driver - * - * Copyright (C) 2005-2006 Greg Kroah-Hartman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include - -static struct usb_device_id id_table [] = { - { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ - { }, -}; -MODULE_DEVICE_TABLE(usb, id_table); - -#define URB_TRANSFER_BUFFER_SIZE 4096 -#define NUM_READ_URBS 4 -#define NUM_WRITE_URBS 4 -#define NUM_BULK_EPS 3 -#define MAX_BULK_EPS 6 - -/* if overridden by the user, then use their value for the size of the - * read and write urbs, and the number of endpoints */ -static int buffer_size = URB_TRANSFER_BUFFER_SIZE; -static int endpoints = NUM_BULK_EPS; -static int debug; -struct airprime_private { - spinlock_t lock; - int outstanding_urbs; - int throttled; - struct urb *read_urbp[NUM_READ_URBS]; - - /* Settings for the port */ - int rts_state; /* Handshaking pins (outputs) */ - int dtr_state; - int cts_state; /* Handshaking pins (inputs) */ - int dsr_state; - int dcd_state; - int ri_state; -}; - -static int airprime_send_setup(struct usb_serial_port *port) -{ - struct usb_serial *serial = port->serial; - struct airprime_private *priv; - - dbg("%s", __func__); - - if (port->number != 0) - return 0; - - priv = usb_get_serial_port_data(port); - - if (port->tty) { - int val = 0; - if (priv->dtr_state) - val |= 0x01; - if (priv->rts_state) - val |= 0x02; - - return usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - 0x22, 0x21, val, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - } - - return 0; -} - -static void airprime_read_bulk_callback(struct urb *urb) -{ - struct usb_serial_port *port = urb->context; - unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; - int result; - int status = urb->status; - - dbg("%s - port %d", __func__, port->number); - - if (status) { - dbg("%s - nonzero read bulk status received: %d", - __func__, status); - return; - } - usb_serial_debug_data(debug, &port->dev, __func__, - urb->actual_length, data); - - tty = port->tty; - if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); - tty_flip_buffer_push(tty); - } - - result = usb_submit_urb(urb, GFP_ATOMIC); - if (result) - dev_err(&port->dev, - "%s - failed resubmitting read urb, error %d\n", - __func__, result); - return; -} - -static void airprime_write_bulk_callback(struct urb *urb) -{ - struct usb_serial_port *port = urb->context; - struct airprime_private *priv = usb_get_serial_port_data(port); - int status = urb->status; - unsigned long flags; - - dbg("%s - port %d", __func__, port->number); - - /* free up the transfer buffer, as usb_free_urb() does not do this */ - kfree(urb->transfer_buffer); - - if (status) - dbg("%s - nonzero write bulk status received: %d", - __func__, status); - spin_lock_irqsave(&priv->lock, flags); - --priv->outstanding_urbs; - spin_unlock_irqrestore(&priv->lock, flags); - - usb_serial_port_softint(port); -} - -static int airprime_open(struct usb_serial_port *port, struct file *filp) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - struct urb *urb; - char *buffer = NULL; - int i; - int result = 0; - - dbg("%s - port %d", __func__, port->number); - - /* initialize our private data structure if it isn't already created */ - if (!priv) { - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) { - result = -ENOMEM; - goto out; - } - spin_lock_init(&priv->lock); - usb_set_serial_port_data(port, priv); - } - - /* Set some sane defaults */ - priv->rts_state = 1; - priv->dtr_state = 1; - - for (i = 0; i < NUM_READ_URBS; ++i) { - buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!buffer) { - dev_err(&port->dev, "%s - out of memory.\n", - __func__); - result = -ENOMEM; - goto errout; - } - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) { - kfree(buffer); - dev_err(&port->dev, "%s - no more urbs?\n", - __func__); - result = -ENOMEM; - goto errout; - } - usb_fill_bulk_urb(urb, serial->dev, - usb_rcvbulkpipe(serial->dev, - port->bulk_out_endpointAddress), - buffer, buffer_size, - airprime_read_bulk_callback, port); - result = usb_submit_urb(urb, GFP_KERNEL); - if (result) { - usb_free_urb(urb); - kfree(buffer); - dev_err(&port->dev, - "%s - failed submitting read urb %d for port %d, error %d\n", - __func__, i, port->number, result); - goto errout; - } - /* remember this urb so we can kill it when the - port is closed */ - priv->read_urbp[i] = urb; - } - - airprime_send_setup(port); - - goto out; - - errout: - /* some error happened, cancel any submitted urbs and clean up - anything that got allocated successfully */ - - while (i-- != 0) { - urb = priv->read_urbp[i]; - buffer = urb->transfer_buffer; - usb_kill_urb(urb); - usb_free_urb(urb); - kfree(buffer); - } - - out: - return result; -} - -static void airprime_close(struct usb_serial_port *port, struct file *filp) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - int i; - - dbg("%s - port %d", __func__, port->number); - - priv->rts_state = 0; - priv->dtr_state = 0; - - mutex_lock(&port->serial->disc_mutex); - if (!port->serial->disconnected) - airprime_send_setup(port); - mutex_unlock(&port->serial->disc_mutex); - - for (i = 0; i < NUM_READ_URBS; ++i) { - usb_kill_urb(priv->read_urbp[i]); - kfree(priv->read_urbp[i]->transfer_buffer); - usb_free_urb(priv->read_urbp[i]); - } - - /* free up private structure */ - kfree(priv); - usb_set_serial_port_data(port, NULL); -} - -static int airprime_write(struct usb_serial_port *port, - const unsigned char *buf, int count) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - struct urb *urb; - unsigned char *buffer; - unsigned long flags; - int status; - dbg("%s - port %d", __func__, port->number); - - spin_lock_irqsave(&priv->lock, flags); - if (priv->outstanding_urbs > NUM_WRITE_URBS) { - spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - write limit hit\n", __func__); - return 0; - } - spin_unlock_irqrestore(&priv->lock, flags); - buffer = kmalloc(count, GFP_ATOMIC); - if (!buffer) { - dev_err(&port->dev, "out of memory\n"); - return -ENOMEM; - } - urb = usb_alloc_urb(0, GFP_ATOMIC); - if (!urb) { - dev_err(&port->dev, "no more free urbs\n"); - kfree(buffer); - return -ENOMEM; - } - memcpy(buffer, buf, count); - - usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); - - usb_fill_bulk_urb(urb, serial->dev, - usb_sndbulkpipe(serial->dev, - port->bulk_out_endpointAddress), - buffer, count, - airprime_write_bulk_callback, port); - - /* send it down the pipe */ - status = usb_submit_urb(urb, GFP_ATOMIC); - if (status) { - dev_err(&port->dev, - "%s - usb_submit_urb(write bulk) failed with status = %d\n", - __func__, status); - count = status; - kfree(buffer); - } else { - spin_lock_irqsave(&priv->lock, flags); - ++priv->outstanding_urbs; - spin_unlock_irqrestore(&priv->lock, flags); - } - /* we are done with this urb, so let the host driver - * really free it when it is finished with it */ - usb_free_urb(urb); - return count; -} - -static struct usb_driver airprime_driver = { - .name = "airprime", - .probe = usb_serial_probe, - .disconnect = usb_serial_disconnect, - .id_table = id_table, - .no_dynamic_id = 1, -}; - -static struct usb_serial_driver airprime_device = { - .driver = { - .owner = THIS_MODULE, - .name = "airprime", - }, - .usb_driver = &airprime_driver, - .id_table = id_table, - .open = airprime_open, - .close = airprime_close, - .write = airprime_write, -}; - -static int __init airprime_init(void) -{ - int retval; - - airprime_device.num_ports = endpoints; - if (endpoints < 0 || endpoints >= MAX_BULK_EPS) - airprime_device.num_ports = NUM_BULK_EPS; - - retval = usb_serial_register(&airprime_device); - if (retval) - return retval; - retval = usb_register(&airprime_driver); - if (retval) - usb_serial_deregister(&airprime_device); - return retval; -} - -static void __exit airprime_exit(void) -{ - dbg("%s", __func__); - - usb_deregister(&airprime_driver); - usb_serial_deregister(&airprime_device); -} - -module_init(airprime_init); -module_exit(airprime_exit); -MODULE_LICENSE("GPL"); - -module_param(debug, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "Debug enabled"); -module_param(buffer_size, int, 0); -MODULE_PARM_DESC(buffer_size, - "Size of the transfer buffers in bytes (default 4096)"); -module_param(endpoints, int, 0); -MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a73420dd052..1e936a1cbe0 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -173,6 +173,7 @@ static int option_send_setup(struct usb_serial_port *port); #define DELL_VENDOR_ID 0x413C #define KYOCERA_VENDOR_ID 0x0c88 +#define KYOCERA_PRODUCT_KPC650 0x17da #define KYOCERA_PRODUCT_KPC680 0x180a #define ANYDATA_VENDOR_ID 0x16d5 @@ -305,6 +306,7 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, + { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ -- cgit v1.2.3-70-g09d2 From dd9ca5d9be7eba99d685d733e23d5be7110e9556 Mon Sep 17 00:00:00 2001 From: Andre Haupt Date: Wed, 18 Jun 2008 15:56:00 +0200 Subject: USB: usb-serial: fix a sparse warning about different signedness fix the following sparse warning: drivers/usb/serial/usb-serial.c:927:43: warning: incorrect type in argument 3 (different signedness) drivers/usb/serial/usb-serial.c:927:43: expected unsigned int *minor drivers/usb/serial/usb-serial.c:927:43: got int * CHECK drivers/usb/serial/generic.c Signed-off-by: Andre Haupt Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 717e376795e..3bcf3346658 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -625,7 +625,7 @@ int usb_serial_probe(struct usb_interface *interface, struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; struct usb_serial_driver *type = NULL; int retval; - int minor; + unsigned int minor; int buffer_size; int i; int num_interrupt_in = 0; -- cgit v1.2.3-70-g09d2 From 3b36a8fd67774867536f138035823ea9fb1b9566 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Fri, 27 Jun 2008 12:22:32 +0300 Subject: usb: fix uninitialized variable warning in keyspan_pda This fixes the compiler warning. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan_pda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 644a1eaaa37..60b3e22bd63 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -408,7 +408,7 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial, 3, /* get pins */ USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, 0, 0, &data, 1, 2000); - if (rc > 0) + if (rc >= 0) *value = data; return rc; } -- cgit v1.2.3-70-g09d2 From 188d63602756bfd4aa1fb61d531dbd59bddac962 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Thu, 26 Jun 2008 20:08:16 -0400 Subject: USB: keyspan: Remove duplicate device entries The 28xb, as documented in comments, has the same ID's as the 28x. Remove the duplicated ID's from the device tables, and expand the comment to document this. Signed-off-by: Ben Collins Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index b52fb657a24..8bf72639b14 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h @@ -138,7 +138,8 @@ static int keyspan_usa67_send_setup (struct usb_serial *serial, /* Product IDs post-renumeration. Note that the 28x and 28xb have the same id's post-renumeration but behave identically - so it's not an issue. */ + so it's not an issue. As such, the 28xb is not listed in any + of the device tables. */ #define keyspan_usa18x_product_id 0x0112 #define keyspan_usa19_product_id 0x0107 #define keyspan_usa19qi_product_id 0x010c @@ -482,7 +483,6 @@ static struct usb_device_id keyspan_ids_combined[] = { { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, - { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)}, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, @@ -532,7 +532,6 @@ static struct usb_device_id keyspan_2port_ids[] = { { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, - { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_product_id) }, { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, { } /* Terminating entry */ }; -- cgit v1.2.3-70-g09d2 From 62ad296b6ca78bd123864c138814c0a597873693 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Wed, 25 Jun 2008 13:32:49 +0200 Subject: USB: fix usb serial pm counter decrement for disconnected interfaces usb serial decrements the pm counter even if an interface has been disconnected. If it was a logical disconnect the interface may belong already to another driver. This patch introduces a check for disconnected interfaces. Signed-off-by: Oliver Neukum Cc: Stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 3bcf3346658..35379863190 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -283,7 +283,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp) } if (port->open_count == 0) { - usb_autopm_put_interface(port->serial->interface); + mutex_lock(&port->serial->disc_mutex); + if (!port->serial->disconnected) + usb_autopm_put_interface(port->serial->interface); + mutex_unlock(&port->serial->disc_mutex); module_put(port->serial->type->driver.owner); } -- cgit v1.2.3-70-g09d2 From 71be4f81e97fe1f42c48a6dfc411dc6d3c18687f Mon Sep 17 00:00:00 2001 From: Aleksey Gorelov Date: Thu, 19 Jun 2008 15:22:17 -0700 Subject: USB: debug port converter does not accept more than 8 byte packets USB debug port only supports 8 byte rx/tx packets. Although spec implies that "if a packet larger than eight bytes is received from the remote computer, the device must break the larger packet into eight-byte packets before sending the data to the Debug Port", the real PLX NET20DC device does not handle it right - data is corrupted on debug port end if serial interface sends >8 byte urbs. Patch below fixes the issue by limiting tx urb to 8 byte. Signed off by: Aleks Gorelov Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_debug.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index f9fc926b56d..9ca4d4db1dd 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c @@ -15,6 +15,8 @@ #include #include +#define USB_DEBUG_MAX_PACKET_SIZE 8 + static struct usb_device_id id_table [] = { { USB_DEVICE(0x0525, 0x127a) }, { }, @@ -29,6 +31,12 @@ static struct usb_driver debug_driver = { .no_dynamic_id = 1, }; +int usb_debug_open(struct usb_serial_port *port, struct file *filp) +{ + port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; + return usb_serial_generic_open(port, filp); +} + static struct usb_serial_driver debug_device = { .driver = { .owner = THIS_MODULE, @@ -36,6 +44,7 @@ static struct usb_serial_driver debug_device = { }, .id_table = id_table, .num_ports = 1, + .open = usb_debug_open, }; static int __init debug_init(void) -- cgit v1.2.3-70-g09d2 From df3e1ab7334279bc744344bcf05272dc8b985d3d Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Mon, 30 Jun 2008 14:33:57 +0200 Subject: USB: fix double kfree in ipaq in error case in the error case the ipaq driver leaves a dangling pointer to already freed memory that will be freed again. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ipaq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index d9fb3768a2d..80d9ec5570d 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -646,12 +646,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) */ kfree(port->bulk_in_buffer); - kfree(port->bulk_out_buffer); port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); if (port->bulk_in_buffer == NULL) { port->bulk_out_buffer = NULL; /* prevent double free */ goto enomem; } + + kfree(port->bulk_out_buffer); port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); if (port->bulk_out_buffer == NULL) { kfree(port->bulk_in_buffer); -- cgit v1.2.3-70-g09d2 From 95da310e66ee8090119596c70ca8432e57f9a97f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:07 +0100 Subject: usb_serial: API all change USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/aircable.c | 19 +- drivers/usb/serial/airprime.c | 355 ++++++++++++++++++++++++++++++++++ drivers/usb/serial/ark3116.c | 32 +-- drivers/usb/serial/belkin_sa.c | 69 +++---- drivers/usb/serial/ch341.c | 10 +- drivers/usb/serial/console.c | 34 ++-- drivers/usb/serial/cp2101.c | 74 +++---- drivers/usb/serial/cyberjack.c | 47 +++-- drivers/usb/serial/cypress_m8.c | 117 ++++++----- drivers/usb/serial/digi_acceleport.c | 127 ++++++------ drivers/usb/serial/empeg.c | 78 +++----- drivers/usb/serial/ftdi_sio.c | 211 ++++++++++---------- drivers/usb/serial/garmin_gps.c | 58 ++---- drivers/usb/serial/generic.c | 39 ++-- drivers/usb/serial/io_edgeport.c | 175 ++++++----------- drivers/usb/serial/io_ti.c | 109 ++++++----- drivers/usb/serial/ipaq.c | 48 +++-- drivers/usb/serial/ipw.c | 15 +- drivers/usb/serial/ir-usb.c | 81 ++++---- drivers/usb/serial/iuu_phoenix.c | 43 ++-- drivers/usb/serial/keyspan.c | 138 ++++++------- drivers/usb/serial/keyspan.h | 39 ++-- drivers/usb/serial/keyspan_pda.c | 69 +++---- drivers/usb/serial/kl5kusb105.c | 74 ++++--- drivers/usb/serial/kobil_sct.c | 80 ++++---- drivers/usb/serial/mct_u232.c | 121 +++++------- drivers/usb/serial/mos7720.c | 87 ++++----- drivers/usb/serial/mos7840.c | 165 +++++++--------- drivers/usb/serial/navman.c | 10 +- drivers/usb/serial/omninet.c | 26 +-- drivers/usb/serial/option.c | 105 ++++------ drivers/usb/serial/oti6858.c | 119 +++++------- drivers/usb/serial/pl2303.c | 76 ++++---- drivers/usb/serial/safe_serial.c | 14 +- drivers/usb/serial/sierra.c | 93 +++------ drivers/usb/serial/spcp8x5.c | 69 ++++--- drivers/usb/serial/ti_usb_3410_5052.c | 203 ++++++++++--------- drivers/usb/serial/usb-serial.c | 82 ++++---- drivers/usb/serial/usb_debug.c | 5 +- drivers/usb/serial/visor.c | 66 ++----- drivers/usb/serial/whiteheat.c | 102 +++++----- include/linux/usb/serial.h | 56 +++--- 42 files changed, 1820 insertions(+), 1720 deletions(-) create mode 100644 drivers/usb/serial/airprime.c (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index db6f97a93c0..79ea98c66fa 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c @@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work) * 64 bytes, to ensure I do not get throttled. * Ask USB mailing list for better aproach. */ - tty = port->tty; + tty = port->port.tty; if (!tty) { schedule_work(&priv->rx_work); @@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial) } } -static int aircable_write_room(struct usb_serial_port *port) +static int aircable_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct aircable_private *priv = usb_get_serial_port_data(port); return serial_buf_data_avail(priv->tx_buf); } -static int aircable_write(struct usb_serial_port *port, +static int aircable_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *source, int count) { struct aircable_private *priv = usb_get_serial_port_data(port); @@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb) if (status) { dbg("%s - urb status = %d", __func__, status); - if (!port->open_count) { + if (!port->port.count) { dbg("%s - port is closed, exiting.", __func__); return; } @@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, urb->transfer_buffer); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { if (urb->actual_length <= 2) { /* This is an incomplete package */ @@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb) } /* Schedule the next read _if_ we are still open */ - if (port->open_count) { + if (port->port.count) { usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), @@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb) } /* Based on ftdi_sio.c throttle */ -static void aircable_throttle(struct usb_serial_port *port) +static void aircable_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct aircable_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port) } /* Based on ftdi_sio.c unthrottle */ -static void aircable_unthrottle(struct usb_serial_port *port) +static void aircable_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct aircable_private *priv = usb_get_serial_port_data(port); int actually_throttled; unsigned long flags; diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c new file mode 100644 index 00000000000..b3f1d1e8246 --- /dev/null +++ b/drivers/usb/serial/airprime.c @@ -0,0 +1,355 @@ +/* + * AirPrime CDMA Wireless Serial USB driver + * + * Copyright (C) 2005-2006 Greg Kroah-Hartman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include + +static struct usb_device_id id_table [] = { + { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ + { }, +}; +MODULE_DEVICE_TABLE(usb, id_table); + +#define URB_TRANSFER_BUFFER_SIZE 4096 +#define NUM_READ_URBS 4 +#define NUM_WRITE_URBS 4 +#define NUM_BULK_EPS 3 +#define MAX_BULK_EPS 6 + +/* if overridden by the user, then use their value for the size of the + * read and write urbs, and the number of endpoints */ +static int buffer_size = URB_TRANSFER_BUFFER_SIZE; +static int endpoints = NUM_BULK_EPS; +static int debug; +struct airprime_private { + spinlock_t lock; + int outstanding_urbs; + int throttled; + struct urb *read_urbp[NUM_READ_URBS]; + + /* Settings for the port */ + int rts_state; /* Handshaking pins (outputs) */ + int dtr_state; + int cts_state; /* Handshaking pins (inputs) */ + int dsr_state; + int dcd_state; + int ri_state; +}; + +static int airprime_send_setup(struct usb_serial_port *port) +{ + struct usb_serial *serial = port->serial; + struct airprime_private *priv; + + dbg("%s", __func__); + + if (port->number != 0) + return 0; + + priv = usb_get_serial_port_data(port); + + if (port->port.tty) { + int val = 0; + if (priv->dtr_state) + val |= 0x01; + if (priv->rts_state) + val |= 0x02; + + return usb_control_msg(serial->dev, + usb_rcvctrlpipe(serial->dev, 0), + 0x22, 0x21, val, 0, NULL, 0, + USB_CTRL_SET_TIMEOUT); + } + + return 0; +} + +static void airprime_read_bulk_callback(struct urb *urb) +{ + struct usb_serial_port *port = urb->context; + unsigned char *data = urb->transfer_buffer; + struct tty_struct *tty; + int result; + int status = urb->status; + + dbg("%s - port %d", __func__, port->number); + + if (status) { + dbg("%s - nonzero read bulk status received: %d", + __func__, status); + return; + } + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); + + tty = port->port.tty; + if (tty && urb->actual_length) { + tty_insert_flip_string(tty, data, urb->actual_length); + tty_flip_buffer_push(tty); + } + + result = usb_submit_urb(urb, GFP_ATOMIC); + if (result) + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); + return; +} + +static void airprime_write_bulk_callback(struct urb *urb) +{ + struct usb_serial_port *port = urb->context; + struct airprime_private *priv = usb_get_serial_port_data(port); + int status = urb->status; + unsigned long flags; + + dbg("%s - port %d", __func__, port->number); + + /* free up the transfer buffer, as usb_free_urb() does not do this */ + kfree(urb->transfer_buffer); + + if (status) + dbg("%s - nonzero write bulk status received: %d", + __func__, status); + spin_lock_irqsave(&priv->lock, flags); + --priv->outstanding_urbs; + spin_unlock_irqrestore(&priv->lock, flags); + + usb_serial_port_softint(port); +} + +static int airprime_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) +{ + struct airprime_private *priv = usb_get_serial_port_data(port); + struct usb_serial *serial = port->serial; + struct urb *urb; + char *buffer = NULL; + int i; + int result = 0; + + dbg("%s - port %d", __func__, port->number); + + /* initialize our private data structure if it isn't already created */ + if (!priv) { + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) { + result = -ENOMEM; + goto out; + } + spin_lock_init(&priv->lock); + usb_set_serial_port_data(port, priv); + } + + /* Set some sane defaults */ + priv->rts_state = 1; + priv->dtr_state = 1; + + for (i = 0; i < NUM_READ_URBS; ++i) { + buffer = kmalloc(buffer_size, GFP_KERNEL); + if (!buffer) { + dev_err(&port->dev, "%s - out of memory.\n", + __func__); + result = -ENOMEM; + goto errout; + } + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) { + kfree(buffer); + dev_err(&port->dev, "%s - no more urbs?\n", + __func__); + result = -ENOMEM; + goto errout; + } + usb_fill_bulk_urb(urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_out_endpointAddress), + buffer, buffer_size, + airprime_read_bulk_callback, port); + result = usb_submit_urb(urb, GFP_KERNEL); + if (result) { + usb_free_urb(urb); + kfree(buffer); + dev_err(&port->dev, + "%s - failed submitting read urb %d for port %d, error %d\n", + __func__, i, port->number, result); + goto errout; + } + /* remember this urb so we can kill it when the + port is closed */ + priv->read_urbp[i] = urb; + } + + airprime_send_setup(port); + + goto out; + + errout: + /* some error happened, cancel any submitted urbs and clean up + anything that got allocated successfully */ + + while (i-- != 0) { + urb = priv->read_urbp[i]; + buffer = urb->transfer_buffer; + usb_kill_urb(urb); + usb_free_urb(urb); + kfree(buffer); + } + + out: + return result; +} + +static void airprime_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) +{ + struct airprime_private *priv = usb_get_serial_port_data(port); + int i; + + dbg("%s - port %d", __func__, port->number); + + priv->rts_state = 0; + priv->dtr_state = 0; + + mutex_lock(&port->serial->disc_mutex); + if (!port->serial->disconnected) + airprime_send_setup(port); + mutex_unlock(&port->serial->disc_mutex); + + for (i = 0; i < NUM_READ_URBS; ++i) { + usb_kill_urb(priv->read_urbp[i]); + kfree(priv->read_urbp[i]->transfer_buffer); + usb_free_urb(priv->read_urbp[i]); + } + + /* free up private structure */ + kfree(priv); + usb_set_serial_port_data(port, NULL); +} + +static int airprime_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) +{ + struct airprime_private *priv = usb_get_serial_port_data(port); + struct usb_serial *serial = port->serial; + struct urb *urb; + unsigned char *buffer; + unsigned long flags; + int status; + dbg("%s - port %d", __func__, port->number); + + spin_lock_irqsave(&priv->lock, flags); + if (priv->outstanding_urbs > NUM_WRITE_URBS) { + spin_unlock_irqrestore(&priv->lock, flags); + dbg("%s - write limit hit\n", __func__); + return 0; + } + spin_unlock_irqrestore(&priv->lock, flags); + buffer = kmalloc(count, GFP_ATOMIC); + if (!buffer) { + dev_err(&port->dev, "out of memory\n"); + return -ENOMEM; + } + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + dev_err(&port->dev, "no more free urbs\n"); + kfree(buffer); + return -ENOMEM; + } + memcpy(buffer, buf, count); + + usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); + + usb_fill_bulk_urb(urb, serial->dev, + usb_sndbulkpipe(serial->dev, + port->bulk_out_endpointAddress), + buffer, count, + airprime_write_bulk_callback, port); + + /* send it down the pipe */ + status = usb_submit_urb(urb, GFP_ATOMIC); + if (status) { + dev_err(&port->dev, + "%s - usb_submit_urb(write bulk) failed with status = %d\n", + __func__, status); + count = status; + kfree(buffer); + } else { + spin_lock_irqsave(&priv->lock, flags); + ++priv->outstanding_urbs; + spin_unlock_irqrestore(&priv->lock, flags); + } + /* we are done with this urb, so let the host driver + * really free it when it is finished with it */ + usb_free_urb(urb); + return count; +} + +static struct usb_driver airprime_driver = { + .name = "airprime", + .probe = usb_serial_probe, + .disconnect = usb_serial_disconnect, + .id_table = id_table, + .no_dynamic_id = 1, +}; + +static struct usb_serial_driver airprime_device = { + .driver = { + .owner = THIS_MODULE, + .name = "airprime", + }, + .usb_driver = &airprime_driver, + .id_table = id_table, + .open = airprime_open, + .close = airprime_close, + .write = airprime_write, +}; + +static int __init airprime_init(void) +{ + int retval; + + airprime_device.num_ports = endpoints; + if (endpoints < 0 || endpoints >= MAX_BULK_EPS) + airprime_device.num_ports = NUM_BULK_EPS; + + retval = usb_serial_register(&airprime_device); + if (retval) + return retval; + retval = usb_register(&airprime_driver); + if (retval) + usb_serial_deregister(&airprime_device); + return retval; +} + +static void __exit airprime_exit(void) +{ + dbg("%s", __func__); + + usb_deregister(&airprime_driver); + usb_serial_deregister(&airprime_device); +} + +module_init(airprime_init); +module_exit(airprime_exit); +MODULE_LICENSE("GPL"); + +module_param(debug, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "Debug enabled"); +module_param(buffer_size, int, 0); +MODULE_PARM_DESC(buffer_size, + "Size of the transfer buffers in bytes (default 4096)"); +module_param(endpoints, int, 0); +MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 77895c8f8f3..aec61880f36 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -158,12 +158,13 @@ cleanup: return -ENOMEM; } -static void ark3116_set_termios(struct usb_serial_port *port, +static void ark3116_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct ark3116_private *priv = usb_get_serial_port_data(port); - struct ktermios *termios = port->tty->termios; + struct ktermios *termios = tty->termios; unsigned int cflag = termios->c_cflag; unsigned long flags; int baud; @@ -177,8 +178,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { - *(port->tty->termios) = tty_std_termios; - port->tty->termios->c_cflag = B9600 | CS8 + *termios = tty_std_termios; + termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; termios->c_ispeed = 9600; termios->c_ospeed = 9600; @@ -192,7 +193,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, buf = kmalloc(1, GFP_KERNEL); if (!buf) { dbg("error kmalloc"); - *port->tty->termios = *old_termios; + *termios = *old_termios; return; } @@ -243,7 +244,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, } /* set baudrate */ - baud = tty_get_baud_rate(port->tty); + baud = tty_get_baud_rate(tty); switch (baud) { case 75: @@ -262,11 +263,11 @@ static void ark3116_set_termios(struct usb_serial_port *port, case 230400: case 460800: /* Report the resulting rate back to the caller */ - tty_encode_baud_rate(port->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); break; /* set 9600 as default (if given baudrate is invalid for example) */ default: - tty_encode_baud_rate(port->tty, 9600, 9600); + tty_encode_baud_rate(tty, 9600, 9600); case 0: baud = 9600; } @@ -317,7 +318,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, return; } -static int ark3116_open(struct usb_serial_port *port, struct file *filp) +static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { struct ktermios tmp_termios; struct usb_serial *serial = port->serial; @@ -332,7 +334,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) return -ENOMEM; } - result = usb_serial_generic_open(port, filp); + result = usb_serial_generic_open(tty, port, filp); if (result) goto err_out; @@ -362,8 +364,8 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf); /* initialise termios */ - if (port->tty) - ark3116_set_termios(port, &tmp_termios); + if (tty) + ark3116_set_termios(tty, port, &tmp_termios); err_out: kfree(buf); @@ -371,9 +373,10 @@ err_out: return result; } -static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, +static int ark3116_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct serial_struct serstruct; void __user *user_arg = (void __user *)arg; @@ -403,8 +406,9 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file) +static int ark3116_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; char *buf; char temp; diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 0a322fc53d6..1a762692c73 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -89,14 +89,13 @@ static int debug; /* function prototypes for a Belkin USB Serial Adapter F5U103 */ static int belkin_sa_startup (struct usb_serial *serial); static void belkin_sa_shutdown (struct usb_serial *serial); -static int belkin_sa_open (struct usb_serial_port *port, struct file *filp); -static void belkin_sa_close (struct usb_serial_port *port, struct file *filp); +static int belkin_sa_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void belkin_sa_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); static void belkin_sa_read_int_callback (struct urb *urb); -static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios * old); -static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); -static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state ); -static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file); -static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); +static void belkin_sa_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); +static void belkin_sa_break_ctl (struct tty_struct *tty, int break_state ); +static int belkin_sa_tiocmget (struct tty_struct *tty, struct file *file); +static int belkin_sa_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static struct usb_device_id id_table_combined [] = { @@ -132,7 +131,6 @@ static struct usb_serial_driver belkin_device = { .open = belkin_sa_open, .close = belkin_sa_close, .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ - .ioctl = belkin_sa_ioctl, .set_termios = belkin_sa_set_termios, .break_ctl = belkin_sa_break_ctl, .tiocmget = belkin_sa_tiocmget, @@ -190,7 +188,7 @@ static int belkin_sa_startup (struct usb_serial *serial) } -static void belkin_sa_shutdown (struct usb_serial *serial) +static void belkin_sa_shutdown(struct usb_serial *serial) { struct belkin_sa_private *priv; int i; @@ -206,7 +204,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial) } -static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) +static int belkin_sa_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { int retval = 0; @@ -235,7 +233,8 @@ exit: } /* belkin_sa_open */ -static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) +static void belkin_sa_close (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { dbg("%s port %d", __func__, port->number); @@ -246,7 +245,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) } /* belkin_sa_close */ -static void belkin_sa_read_int_callback (struct urb *urb) +static void belkin_sa_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct belkin_sa_private *priv; @@ -311,7 +310,7 @@ static void belkin_sa_read_int_callback (struct urb *urb) * to look in to this before committing any code. */ if (priv->last_lsr & BELKIN_SA_LSR_ERR) { - tty = port->tty; + tty = port->port.tty; /* Overrun Error */ if (priv->last_lsr & BELKIN_SA_LSR_OE) { } @@ -334,7 +333,8 @@ exit: __func__, retval); } -static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void belkin_sa_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct belkin_sa_private *priv = usb_get_serial_port_data(port); @@ -347,7 +347,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios unsigned long control_state; int bad_flow_control; speed_t baud; - struct ktermios *termios = port->tty->termios; + struct ktermios *termios = tty->termios; iflag = termios->c_iflag; cflag = termios->c_cflag; @@ -377,7 +377,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios } } - baud = tty_get_baud_rate(port->tty); + baud = tty_get_baud_rate(tty); if (baud) { urb_value = BELKIN_SA_BAUD(baud); /* Clip to maximum speed */ @@ -387,7 +387,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios baud = BELKIN_SA_BAUD(urb_value); /* Report the actual baud rate back to the caller */ - tty_encode_baud_rate(port->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) err("Set baudrate error"); } else { @@ -463,8 +463,9 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios } /* belkin_sa_set_termios */ -static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state ) +static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) @@ -472,8 +473,9 @@ static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state ) } -static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) +static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct belkin_sa_private *priv = usb_get_serial_port_data(port); unsigned long control_state; unsigned long flags; @@ -488,9 +490,10 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) } -static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, +static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct belkin_sa_private *priv = usb_get_serial_port_data(port); unsigned long control_state; @@ -540,29 +543,7 @@ exit: } -static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) -{ - switch (cmd) { - case TIOCMIWAIT: - /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ - /* TODO */ - return( 0 ); - - case TIOCGICOUNT: - /* return count of modemline transitions */ - /* TODO */ - return 0; - - default: - dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd); - return(-ENOIOCTLCMD); - break; - } - return 0; -} /* belkin_sa_ioctl */ - - -static int __init belkin_sa_init (void) +static int __init belkin_sa_init(void) { int retval; retval = usb_serial_register(&belkin_device); @@ -583,7 +564,7 @@ failed_usb_serial_register: static void __exit belkin_sa_exit (void) { usb_deregister (&belkin_driver); - usb_serial_deregister (&belkin_device); + usb_serial_deregister(&belkin_device); } diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 1f7c86bd829..f61e3ca6430 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -232,7 +232,8 @@ error: kfree(priv); } /* open this device, set default parameters */ -static int ch341_open(struct usb_serial_port *port, struct file *filp) +static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { struct usb_serial *serial = port->serial; struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); @@ -256,7 +257,7 @@ static int ch341_open(struct usb_serial_port *port, struct file *filp) if (r) goto out; - r = usb_serial_generic_open(port, filp); + r = usb_serial_generic_open(tty, port, filp); out: return r; } @@ -264,11 +265,10 @@ out: return r; /* Old_termios contains the original termios settings and * tty->termios contains the new setting to be used. */ -static void ch341_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void ch341_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct ch341_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; unsigned baud_rate; dbg("ch341_set_termios()"); diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 201184c3fb8..940f5de6898 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -145,12 +145,12 @@ static int usb_console_setup(struct console *co, char *options) } port = serial->port[0]; - port->tty = NULL; + port->port.tty = NULL; info->port = port; - ++port->open_count; - if (port->open_count == 1) { + ++port->port.count; + if (port->port.count == 1) { if (serial->type->set_termios) { /* * allocate a fake tty so the driver can initialize @@ -171,15 +171,15 @@ static int usb_console_setup(struct console *co, char *options) } memset(&dummy, 0, sizeof(struct ktermios)); tty->termios = termios; - port->tty = tty; + port->port.tty = tty; } /* only call the device specific open if this * is the first time the port is opened */ if (serial->type->open) - retval = serial->type->open(port, NULL); + retval = serial->type->open(NULL, port, NULL); else - retval = usb_serial_generic_open(port, NULL); + retval = usb_serial_generic_open(NULL, port, NULL); if (retval) { err("could not open USB console port"); @@ -188,9 +188,9 @@ static int usb_console_setup(struct console *co, char *options) if (serial->type->set_termios) { termios->c_cflag = cflag; - serial->type->set_termios(port, &dummy); + serial->type->set_termios(NULL, port, &dummy); - port->tty = NULL; + port->port.tty = NULL; kfree(termios); kfree(tty); } @@ -203,11 +203,11 @@ out: return retval; free_termios: kfree(termios); - port->tty = NULL; + port->port.tty = NULL; free_tty: kfree(tty); reset_open_count: - port->open_count = 0; + port->port.count = 0; goto out; } @@ -227,7 +227,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun dbg("%s - port %d, %d byte(s)", __func__, port->number, count); - if (!port->open_count) { + if (!port->port.count) { dbg ("%s - port not opened", __func__); return; } @@ -245,17 +245,17 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun } /* pass on to the driver specific version of this function if it is available */ if (serial->type->write) - retval = serial->type->write(port, buf, i); + retval = serial->type->write(NULL, port, buf, i); else - retval = usb_serial_generic_write(port, buf, i); + retval = usb_serial_generic_write(NULL, port, buf, i); dbg("%s - return value : %d", __func__, retval); if (lf) { /* append CR after LF */ unsigned char cr = 13; if (serial->type->write) - retval = serial->type->write(port, &cr, 1); + retval = serial->type->write(NULL, port, &cr, 1); else - retval = usb_serial_generic_write(port, &cr, 1); + retval = usb_serial_generic_write(NULL, port, &cr, 1); dbg("%s - return value : %d", __func__, retval); } buf += i; @@ -306,8 +306,8 @@ void usb_serial_console_exit (void) { if (usbcons_info.port) { unregister_console(&usbcons); - if (usbcons_info.port->open_count) - usbcons_info.port->open_count--; + if (usbcons_info.port->port.count) + usbcons_info.port->port.count--; usbcons_info.port = NULL; } } diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 2bc5576c443..46c33fc9f6c 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -37,15 +37,18 @@ /* * Function Prototypes */ -static int cp2101_open(struct usb_serial_port*, struct file*); -static void cp2101_cleanup(struct usb_serial_port*); -static void cp2101_close(struct usb_serial_port*, struct file*); -static void cp2101_get_termios(struct usb_serial_port*); -static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*); -static int cp2101_tiocmget (struct usb_serial_port *, struct file *); -static int cp2101_tiocmset (struct usb_serial_port *, struct file *, +static int cp2101_open(struct tty_struct *, struct usb_serial_port *, + struct file *); +static void cp2101_cleanup(struct usb_serial_port *); +static void cp2101_close(struct tty_struct *, struct usb_serial_port *, + struct file*); +static void cp2101_get_termios(struct tty_struct *); +static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *, + struct ktermios*); +static int cp2101_tiocmget (struct tty_struct *, struct file *); +static int cp2101_tiocmset (struct tty_struct *, struct file *, unsigned int, unsigned int); -static void cp2101_break_ctl(struct usb_serial_port*, int); +static void cp2101_break_ctl(struct tty_struct *, int); static int cp2101_startup (struct usb_serial *); static void cp2101_shutdown(struct usb_serial*); @@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = { * 'data' is a pointer to a pre-allocated array of integers large * enough to hold 'size' bytes (with 4 bytes to each integer) */ -static int cp2101_get_config(struct usb_serial_port* port, u8 request, +static int cp2101_get_config(struct usb_serial_port *port, u8 request, unsigned int *data, int size) { struct usb_serial *serial = port->serial; @@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, * Values less than 16 bits wide are sent directly * 'size' is specified in bytes. */ -static int cp2101_set_config(struct usb_serial_port* port, u8 request, +static int cp2101_set_config(struct usb_serial_port *port, u8 request, unsigned int *data, int size) { struct usb_serial *serial = port->serial; @@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, * Convenience function for calling cp2101_set_config on single data values * without requiring an integer pointer */ -static inline int cp2101_set_config_single(struct usb_serial_port* port, +static inline int cp2101_set_config_single(struct usb_serial_port *port, u8 request, unsigned int data) { return cp2101_set_config(port, request, &data, 2); } -static int cp2101_open (struct usb_serial_port *port, struct file *filp) +static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { struct usb_serial *serial = port->serial; int result; @@ -318,10 +322,10 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) } /* Configure the termios structure */ - cp2101_get_termios(port); + cp2101_get_termios(tty); /* Set the DTR and RTS pins low */ - cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); + cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0); return 0; } @@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port) } } -static void cp2101_close (struct usb_serial_port *port, struct file * filp) +static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file * filp) { dbg("%s - port %d", __func__, port->number); @@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) * from the device, corrects any unsupported values, and configures the * termios structure to reflect the state of the device */ -static void cp2101_get_termios (struct usb_serial_port *port) +static void cp2101_get_termios (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; unsigned int cflag, modem_ctl[4]; unsigned int baud; unsigned int bits; dbg("%s - port %d", __func__, port->number); - if (!port->tty || !port->tty->termios) { - dbg("%s - no tty structures", __func__); - return; - } - cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); /* Convert to baudrate */ if (baud) @@ -382,8 +383,8 @@ static void cp2101_get_termios (struct usb_serial_port *port) dbg("%s - baud rate = %d", __func__, baud); - tty_encode_baud_rate(port->tty, baud, baud); - cflag = port->tty->termios->c_cflag; + tty_encode_baud_rate(tty, baud, baud); + cflag = tty->termios->c_cflag; cp2101_get_config(port, CP2101_BITS, &bits, 2); cflag &= ~CSIZE; @@ -491,11 +492,11 @@ static void cp2101_get_termios (struct usb_serial_port *port) cflag &= ~CRTSCTS; } - port->tty->termios->c_cflag = cflag; + tty->termios->c_cflag = cflag; } -static void cp2101_set_termios (struct usb_serial_port *port, - struct ktermios *old_termios) +static void cp2101_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { unsigned int cflag, old_cflag; unsigned int baud = 0, bits; @@ -503,15 +504,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, dbg("%s - port %d", __func__, port->number); - if (!port->tty || !port->tty->termios) { - dbg("%s - no tty structures", __func__); + if (!tty) return; - } - port->tty->termios->c_cflag &= ~CMSPAR; - cflag = port->tty->termios->c_cflag; + tty->termios->c_cflag &= ~CMSPAR; + cflag = tty->termios->c_cflag; old_cflag = old_termios->c_cflag; - baud = tty_get_baud_rate(port->tty); + baud = tty_get_baud_rate(tty); /* If the baud rate is to be updated*/ if (baud != tty_termios_baud_rate(old_termios)) { @@ -554,7 +553,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, } } /* Report back the resulting baud rate */ - tty_encode_baud_rate(port->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); /* If the number of data bits is to be updated */ if ((cflag & CSIZE) != (old_cflag & CSIZE)) { @@ -651,9 +650,10 @@ static void cp2101_set_termios (struct usb_serial_port *port, } -static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, +static int cp2101_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; unsigned int control = 0; dbg("%s - port %d", __func__, port->number); @@ -681,8 +681,9 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, } -static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) +static int cp2101_tiocmget (struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; unsigned int control; int result; @@ -702,8 +703,9 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) return result; } -static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) +static void cp2101_break_ctl (struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; unsigned int state; dbg("%s - port %d", __func__, port->number); diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index c164e2cf275..546178ea6f2 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -57,15 +57,18 @@ static int debug; #define CYBERJACK_PRODUCT_ID 0x0100 /* Function prototypes */ -static int cyberjack_startup (struct usb_serial *serial); -static void cyberjack_shutdown (struct usb_serial *serial); -static int cyberjack_open (struct usb_serial_port *port, struct file *filp); -static void cyberjack_close (struct usb_serial_port *port, struct file *filp); -static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int cyberjack_write_room( struct usb_serial_port *port ); -static void cyberjack_read_int_callback (struct urb *urb); -static void cyberjack_read_bulk_callback (struct urb *urb); -static void cyberjack_write_bulk_callback (struct urb *urb); +static int cyberjack_startup(struct usb_serial *serial); +static void cyberjack_shutdown(struct usb_serial *serial); +static int cyberjack_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void cyberjack_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int cyberjack_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count); +static int cyberjack_write_room( struct tty_struct *tty); +static void cyberjack_read_int_callback(struct urb *urb); +static void cyberjack_read_bulk_callback(struct urb *urb); +static void cyberjack_write_bulk_callback(struct urb *urb); static struct usb_device_id id_table [] = { { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, @@ -111,7 +114,7 @@ struct cyberjack_private { }; /* do some startup allocations not currently performed by usb_serial_probe() */ -static int cyberjack_startup (struct usb_serial *serial) +static int cyberjack_startup(struct usb_serial *serial) { struct cyberjack_private *priv; int i; @@ -145,7 +148,7 @@ static int cyberjack_startup (struct usb_serial *serial) return( 0 ); } -static void cyberjack_shutdown (struct usb_serial *serial) +static void cyberjack_shutdown(struct usb_serial *serial) { int i; @@ -159,7 +162,8 @@ static void cyberjack_shutdown (struct usb_serial *serial) } } -static int cyberjack_open (struct usb_serial_port *port, struct file *filp) +static int cyberjack_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct cyberjack_private *priv; unsigned long flags; @@ -174,7 +178,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) * the data through, otherwise it is scheduled, and with high * data rates (like with OHCI) data can get lost. */ - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; priv = usb_get_serial_port_data(port); spin_lock_irqsave(&priv->lock, flags); @@ -186,7 +191,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) return result; } -static void cyberjack_close (struct usb_serial_port *port, struct file *filp) +static void cyberjack_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); @@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp) } } -static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int cyberjack_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct cyberjack_private *priv = usb_get_serial_port_data(port); @@ -292,13 +299,13 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b return (count); } -static int cyberjack_write_room( struct usb_serial_port *port ) +static int cyberjack_write_room(struct tty_struct *tty) { /* FIXME: .... */ return CYBERJACK_LOCAL_BUF_SIZE; } -static void cyberjack_read_int_callback( struct urb *urb ) +static void cyberjack_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); @@ -355,7 +362,7 @@ resubmit: dbg("%s - usb_submit_urb(int urb)", __func__); } -static void cyberjack_read_bulk_callback (struct urb *urb) +static void cyberjack_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); @@ -374,7 +381,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb) return; } - tty = port->tty; + tty = port->port.tty; if (!tty) { dbg("%s - ignoring since device not open\n", __func__); return; @@ -407,7 +414,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb) } } -static void cyberjack_write_bulk_callback (struct urb *urb) +static void cyberjack_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 0230d3c0888..6999d3372d8 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -167,18 +167,18 @@ static int cypress_earthmate_startup (struct usb_serial *serial); static int cypress_hidcom_startup (struct usb_serial *serial); static int cypress_ca42v2_startup (struct usb_serial *serial); static void cypress_shutdown (struct usb_serial *serial); -static int cypress_open (struct usb_serial_port *port, struct file *filp); -static void cypress_close (struct usb_serial_port *port, struct file *filp); -static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count); +static int cypress_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void cypress_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int cypress_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); static void cypress_send (struct usb_serial_port *port); -static int cypress_write_room (struct usb_serial_port *port); -static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); -static void cypress_set_termios (struct usb_serial_port *port, struct ktermios * old); -static int cypress_tiocmget (struct usb_serial_port *port, struct file *file); -static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); -static int cypress_chars_in_buffer (struct usb_serial_port *port); -static void cypress_throttle (struct usb_serial_port *port); -static void cypress_unthrottle (struct usb_serial_port *port); +static int cypress_write_room (struct tty_struct *tty); +static int cypress_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); +static void cypress_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); +static int cypress_tiocmget (struct tty_struct *tty, struct file *file); +static int cypress_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); +static int cypress_chars_in_buffer (struct tty_struct *tty); +static void cypress_throttle (struct tty_struct *tty); +static void cypress_unthrottle (struct tty_struct *tty); static void cypress_set_dead (struct usb_serial_port *port); static void cypress_read_int_callback (struct urb *urb); static void cypress_write_int_callback (struct urb *urb); @@ -322,8 +322,10 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) /* This function can either set or retrieve the current serial line settings */ -static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits, - int parity_enable, int parity_type, int reset, int cypress_request_type) +static int cypress_serial_control (struct tty_struct *tty, + struct usb_serial_port *port, speed_t baud_rate, int data_bits, + int stop_bits, int parity_enable, int parity_type, int reset, + int cypress_request_type) { int new_baudrate = 0, retval = 0, tries = 0; struct cypress_private *priv; @@ -395,7 +397,7 @@ static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_ra spin_unlock_irqrestore(&priv->lock, flags); /* If we asked for a speed change encode it */ if (baud_rate) - tty_encode_baud_rate(port->tty, + tty_encode_baud_rate(tty, new_baudrate, new_baudrate); } break; @@ -611,7 +613,8 @@ static void cypress_shutdown (struct usb_serial *serial) } -static int cypress_open (struct usb_serial_port *port, struct file *filp) +static int cypress_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct cypress_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; @@ -636,14 +639,15 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) spin_unlock_irqrestore(&priv->lock, flags); /* setting to zero could cause data loss */ - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* raise both lines and set termios */ spin_lock_irqsave(&priv->lock, flags); priv->line_control = CONTROL_DTR | CONTROL_RTS; priv->cmd_ctrl = 1; spin_unlock_irqrestore(&priv->lock, flags); - result = cypress_write(port, NULL, 0); + result = cypress_write(tty, port, NULL, 0); if (result) { dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result); @@ -651,7 +655,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) } else dbg("%s - success setting the control lines", __func__); - cypress_set_termios(port, &priv->tmp_termios); + if (tty) + cypress_set_termios(tty, port, &priv->tmp_termios); /* setup the port and start reading from the device */ if(!port->interrupt_in_urb){ @@ -674,7 +679,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) } /* cypress_open */ -static void cypress_close(struct usb_serial_port *port, struct file * filp) +static void cypress_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct cypress_private *priv = usb_get_serial_port_data(port); unsigned int c_cflag; @@ -688,7 +694,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) spin_lock_irq(&priv->lock); timeout = CYPRESS_CLOSING_WAIT; init_waitqueue_entry(&wait, current); - add_wait_queue(&port->tty->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (cypress_buf_data_avail(priv->buf) == 0 @@ -701,7 +707,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) spin_lock_irq(&priv->lock); } set_current_state(TASK_RUNNING); - remove_wait_queue(&port->tty->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); /* clear out any remaining data in the buffer */ cypress_buf_clear(priv->buf); spin_unlock_irq(&priv->lock); @@ -713,19 +719,21 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) return; } /* wait for characters to drain from device */ - bps = tty_get_baud_rate(port->tty); - if (bps > 1200) - timeout = max((HZ*2560)/bps,HZ/10); - else - timeout = 2*HZ; - schedule_timeout_interruptible(timeout); + if (tty) { + bps = tty_get_baud_rate(tty); + if (bps > 1200) + timeout = max((HZ*2560)/bps,HZ/10); + else + timeout = 2*HZ; + schedule_timeout_interruptible(timeout); + } dbg("%s - stopping urbs", __func__); usb_kill_urb (port->interrupt_in_urb); usb_kill_urb (port->interrupt_out_urb); - if (port->tty) { - c_cflag = port->tty->termios->c_cflag; + if (tty) { + c_cflag = tty->termios->c_cflag; if (c_cflag & HUPCL) { /* drop dtr and rts */ priv = usb_get_serial_port_data(port); @@ -733,7 +741,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) priv->line_control = 0; priv->cmd_ctrl = 1; spin_unlock_irq(&priv->lock); - cypress_write(port, NULL, 0); + cypress_write(tty, port, NULL, 0); } } @@ -744,7 +752,8 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) } /* cypress_close */ -static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count) +static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -878,8 +887,9 @@ send: /* returns how much space is available in the soft buffer */ -static int cypress_write_room(struct usb_serial_port *port) +static int cypress_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -895,8 +905,9 @@ static int cypress_write_room(struct usb_serial_port *port) } -static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) +static int cypress_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); __u8 status, control; unsigned int result = 0; @@ -922,9 +933,10 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) } -static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, +static int cypress_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -942,12 +954,14 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, priv->cmd_ctrl = 1; spin_unlock_irqrestore(&priv->lock, flags); - return cypress_write(port, NULL, 0); + return cypress_write(tty, port, NULL, 0); } -static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) +static int cypress_ioctl(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); @@ -983,22 +997,18 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi } } return 0; - break; default: break; } - dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); - return -ENOIOCTLCMD; } /* cypress_ioctl */ -static void cypress_set_termios (struct usb_serial_port *port, - struct ktermios *old_termios) +static void cypress_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct cypress_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty; int data_bits, stop_bits, parity_type, parity_enable; unsigned cflag, iflag; unsigned long flags; @@ -1007,8 +1017,6 @@ static void cypress_set_termios (struct usb_serial_port *port, dbg("%s - port %d", __func__, port->number); - tty = port->tty; - spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { if (priv->chiptype == CT_EARTHMATE) { @@ -1096,13 +1104,13 @@ static void cypress_set_termios (struct usb_serial_port *port, "%d data_bits (+5)", __func__, stop_bits, parity_enable, parity_type, data_bits); - cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits, + cypress_serial_control(tty, port, tty_get_baud_rate(tty), data_bits, stop_bits, parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); /* we perform a CYPRESS_GET_CONFIG so that the current settings are * filled into the private structure this should confirm that all is * working if it returns what we just set */ - cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); + cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); /* Here we can define custom tty settings for devices; the main tty * termios flag base comes from empeg.c */ @@ -1142,14 +1150,15 @@ static void cypress_set_termios (struct usb_serial_port *port, /* if necessary, set lines */ if (linechange) { priv->cmd_ctrl = 1; - cypress_write(port, NULL, 0); + cypress_write(tty, port, NULL, 0); } } /* cypress_set_termios */ /* returns amount of data still left in soft buffer */ -static int cypress_chars_in_buffer(struct usb_serial_port *port) +static int cypress_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; @@ -1165,8 +1174,9 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port) } -static void cypress_throttle (struct usb_serial_port *port) +static void cypress_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -1178,8 +1188,9 @@ static void cypress_throttle (struct usb_serial_port *port) } -static void cypress_unthrottle (struct usb_serial_port *port) +static void cypress_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); int actually_throttled, result; unsigned long flags; @@ -1251,7 +1262,7 @@ static void cypress_read_int_callback(struct urb *urb) } spin_unlock_irqrestore(&priv->lock, flags); - tty = port->tty; + tty = port->port.tty; if (!tty) { dbg("%s - bad tty pointer - exiting", __func__); return; @@ -1327,7 +1338,7 @@ static void cypress_read_int_callback(struct urb *urb) data[i]); tty_insert_flip_char(tty, data[i], tty_flag); } - tty_flip_buffer_push(port->tty); + tty_flip_buffer_push(port->port.tty); } spin_lock_irqsave(&priv->lock, flags); @@ -1339,7 +1350,7 @@ continue_read: /* Continue trying to always read... unless the port has closed. */ - if (port->open_count > 0 && priv->comm_is_ok) { + if (port->port.count > 0 && priv->comm_is_ok) { usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress), diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 28bc6fcf44f..dc92dbfc962 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -15,7 +15,7 @@ * Al Borchers (borchers@steinerpoint.com) * * (12/03/2001) gkh -* switched to using port->open_count instead of private version. +* switched to using port->port.count instead of private version. * Removed port->active * * (04/08/2001) gb @@ -441,22 +441,23 @@ static int digi_set_modem_signals(struct usb_serial_port *port, unsigned int modem_signals, int interruptible); static int digi_transmit_idle(struct usb_serial_port *port, unsigned long timeout); -static void digi_rx_throttle (struct usb_serial_port *port); -static void digi_rx_unthrottle (struct usb_serial_port *port); -static void digi_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios); -static void digi_break_ctl(struct usb_serial_port *port, int break_state); -static int digi_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg); -static int digi_tiocmget(struct usb_serial_port *port, struct file *file); -static int digi_tiocmset(struct usb_serial_port *port, struct file *file, +static void digi_rx_throttle (struct tty_struct *tty); +static void digi_rx_unthrottle (struct tty_struct *tty); +static void digi_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); +static void digi_break_ctl(struct tty_struct *tty, int break_state); +static int digi_tiocmget(struct tty_struct *tty, struct file *file); +static int digi_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count); +static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); static void digi_write_bulk_callback(struct urb *urb); -static int digi_write_room(struct usb_serial_port *port); -static int digi_chars_in_buffer(struct usb_serial_port *port); -static int digi_open(struct usb_serial_port *port, struct file *filp); -static void digi_close(struct usb_serial_port *port, struct file *filp); +static int digi_write_room(struct tty_struct *tty); +static int digi_chars_in_buffer(struct tty_struct *tty); +static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void digi_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); static int digi_startup_device(struct usb_serial *serial); static int digi_startup(struct usb_serial *serial); static void digi_shutdown(struct usb_serial *serial); @@ -516,7 +517,6 @@ static struct usb_serial_driver digi_acceleport_2_device = { .chars_in_buffer = digi_chars_in_buffer, .throttle = digi_rx_throttle, .unthrottle = digi_rx_unthrottle, - .ioctl = digi_ioctl, .set_termios = digi_set_termios, .break_ctl = digi_break_ctl, .tiocmget = digi_tiocmget, @@ -543,7 +543,6 @@ static struct usb_serial_driver digi_acceleport_4_device = { .chars_in_buffer = digi_chars_in_buffer, .throttle = digi_rx_throttle, .unthrottle = digi_rx_unthrottle, - .ioctl = digi_ioctl, .set_termios = digi_set_termios, .break_ctl = digi_break_ctl, .tiocmget = digi_tiocmget, @@ -604,7 +603,7 @@ static void digi_wakeup_write_lock(struct work_struct *work) static void digi_wakeup_write(struct usb_serial_port *port) { - tty_wakeup(port->tty); + tty_wakeup(port->port.tty); } @@ -856,9 +855,10 @@ static int digi_transmit_idle(struct usb_serial_port *port, } -static void digi_rx_throttle(struct usb_serial_port *port) +static void digi_rx_throttle(struct tty_struct *tty) { unsigned long flags; + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); @@ -872,10 +872,11 @@ static void digi_rx_throttle(struct usb_serial_port *port) } -static void digi_rx_unthrottle(struct usb_serial_port *port) +static void digi_rx_unthrottle(struct tty_struct *tty) { int ret = 0; unsigned long flags; + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num); @@ -900,12 +901,10 @@ static void digi_rx_unthrottle(struct usb_serial_port *port) } -static void digi_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void digi_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { - struct digi_port *priv = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; unsigned int iflag = tty->termios->c_iflag; unsigned int cflag = tty->termios->c_cflag; unsigned int old_iflag = old_termios->c_iflag; @@ -1088,8 +1087,9 @@ static void digi_set_termios(struct usb_serial_port *port, } -static void digi_break_ctl(struct usb_serial_port *port, int break_state) +static void digi_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; unsigned char buf[4]; buf[0] = DIGI_CMD_BREAK_CONTROL; @@ -1100,8 +1100,9 @@ static void digi_break_ctl(struct usb_serial_port *port, int break_state) } -static int digi_tiocmget(struct usb_serial_port *port, struct file *file) +static int digi_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); unsigned int val; unsigned long flags; @@ -1115,9 +1116,10 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file) } -static int digi_tiocmset(struct usb_serial_port *port, struct file *file, +static int digi_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); unsigned int val; unsigned long flags; @@ -1131,27 +1133,8 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file, } -static int digi_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct digi_port *priv = usb_get_serial_port_data(port); - dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd); - - switch (cmd) { - case TIOCMIWAIT: - /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ - /* TODO */ - return 0; - case TIOCGICOUNT: - /* return count of modemline transitions */ - /* TODO */ - return 0; - } - return -ENOIOCTLCMD; - -} - -static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count) +static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { int ret,data_len,new_len; @@ -1261,7 +1244,7 @@ static void digi_write_bulk_callback(struct urb *urb) /* try to send any buffered data on this port, if it is open */ spin_lock(&priv->dp_port_lock); priv->dp_write_urb_in_use = 0; - if (port->open_count && port->write_urb->status != -EINPROGRESS + if (port->port.count && port->write_urb->status != -EINPROGRESS && priv->dp_out_buf_len > 0) { *((unsigned char *)(port->write_urb->transfer_buffer)) = (unsigned char)DIGI_CMD_SEND_DATA; @@ -1288,11 +1271,11 @@ static void digi_write_bulk_callback(struct urb *urb) __func__, ret, priv->dp_port_num); } -static int digi_write_room(struct usb_serial_port *port) +static int digi_write_room(struct tty_struct *tty) { - - int room; + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); + int room; unsigned long flags = 0; spin_lock_irqsave(&priv->dp_port_lock, flags); @@ -1308,12 +1291,11 @@ static int digi_write_room(struct usb_serial_port *port) } -static int digi_chars_in_buffer(struct usb_serial_port *port) +static int digi_chars_in_buffer(struct tty_struct *tty) { - + struct usb_serial_port *port = tty->driver_data; struct digi_port *priv = usb_get_serial_port_data(port); - if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) { dbg("digi_chars_in_buffer: port=%d, chars=%d", @@ -1329,7 +1311,8 @@ static int digi_chars_in_buffer(struct usb_serial_port *port) } -static int digi_open(struct usb_serial_port *port, struct file *filp) +static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { int ret; unsigned char buf[32]; @@ -1338,7 +1321,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) unsigned long flags = 0; dbg("digi_open: TOP: port=%d, open_count=%d", - priv->dp_port_num, port->open_count); + priv->dp_port_num, port->port.count); /* be sure the device is started up */ if (digi_startup_device(port->serial) != 0) @@ -1380,9 +1363,11 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) dbg("digi_open: write oob failed, ret=%d", ret); /* set termios settings */ - not_termios.c_cflag = ~port->tty->termios->c_cflag; - not_termios.c_iflag = ~port->tty->termios->c_iflag; - digi_set_termios(port, ¬_termios); + if (tty) { + not_termios.c_cflag = ~tty->termios->c_cflag; + not_termios.c_iflag = ~tty->termios->c_iflag; + digi_set_termios(tty, port, ¬_termios); + } /* set DTR and RTS */ digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1); @@ -1391,16 +1376,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) } -static void digi_close(struct usb_serial_port *port, struct file *filp) +static void digi_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { DEFINE_WAIT(wait); int ret; unsigned char buf[32]; - struct tty_struct *tty = port->tty; struct digi_port *priv = usb_get_serial_port_data(port); dbg("digi_close: TOP: port=%d, open_count=%d", - priv->dp_port_num, port->open_count); + priv->dp_port_num, port->port.count); mutex_lock(&port->serial->disc_mutex); /* if disconnected, just clear flags */ @@ -1663,7 +1648,7 @@ static int digi_read_inb_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; struct digi_port *priv = usb_get_serial_port_data(port); int opcode = ((unsigned char *)urb->transfer_buffer)[0]; int len = ((unsigned char *)urb->transfer_buffer)[1]; @@ -1675,7 +1660,7 @@ static int digi_read_inb_callback(struct urb *urb) /* do not process callbacks on closed ports */ /* but do continue the read chain */ - if (port->open_count == 0) + if (port->port.count == 0) return 0; /* short/multiple packet check */ @@ -1785,17 +1770,17 @@ static int digi_read_oob_callback(struct urb *urb) if (val & DIGI_READ_INPUT_SIGNALS_CTS) { priv->dp_modem_signals |= TIOCM_CTS; /* port must be open to use tty struct */ - if (port->open_count - && port->tty->termios->c_cflag & CRTSCTS) { - port->tty->hw_stopped = 0; + if (port->port.count + && port->port.tty->termios->c_cflag & CRTSCTS) { + port->port.tty->hw_stopped = 0; digi_wakeup_write(port); } } else { priv->dp_modem_signals &= ~TIOCM_CTS; /* port must be open to use tty struct */ - if (port->open_count - && port->tty->termios->c_cflag & CRTSCTS) { - port->tty->hw_stopped = 1; + if (port->port.count + && port->port.tty->termios->c_cflag & CRTSCTS) { + port->port.tty->hw_stopped = 1; } } if (val & DIGI_READ_INPUT_SIGNALS_DSR) diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index c5ec309a3cb..47ebdf5fad8 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -31,7 +31,7 @@ * Moved MOD_DEC_USE_COUNT to end of empeg_close(). * * (12/03/2000) gb - * Added port->tty->ldisc.set_termios(port->tty, NULL) to empeg_open() + * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open() * This notifies the tty driver that the termios have changed. * * (11/13/2000) gb @@ -77,22 +77,18 @@ static int debug; #define EMPEG_PRODUCT_ID 0x0001 /* function prototypes for an empeg-car player */ -static int empeg_open (struct usb_serial_port *port, struct file *filp); -static void empeg_close (struct usb_serial_port *port, struct file *filp); -static int empeg_write (struct usb_serial_port *port, +static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int empeg_write_room (struct usb_serial_port *port); -static int empeg_chars_in_buffer (struct usb_serial_port *port); -static void empeg_throttle (struct usb_serial_port *port); -static void empeg_unthrottle (struct usb_serial_port *port); +static int empeg_write_room (struct tty_struct *tty); +static int empeg_chars_in_buffer (struct tty_struct *tty); +static void empeg_throttle (struct tty_struct *tty); +static void empeg_unthrottle (struct tty_struct *tty); static int empeg_startup (struct usb_serial *serial); static void empeg_shutdown (struct usb_serial *serial); -static int empeg_ioctl (struct usb_serial_port *port, - struct file * file, - unsigned int cmd, - unsigned long arg); -static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); +static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); static void empeg_write_bulk_callback (struct urb *urb); static void empeg_read_bulk_callback (struct urb *urb); @@ -125,7 +121,6 @@ static struct usb_serial_driver empeg_device = { .unthrottle = empeg_unthrottle, .attach = empeg_startup, .shutdown = empeg_shutdown, - .ioctl = empeg_ioctl, .set_termios = empeg_set_termios, .write = empeg_write, .write_room = empeg_write_room, @@ -145,7 +140,8 @@ static int bytes_out; /****************************************************************************** * Empeg specific driver functions ******************************************************************************/ -static int empeg_open (struct usb_serial_port *port, struct file *filp) +static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { struct usb_serial *serial = port->serial; int result = 0; @@ -153,7 +149,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) dbg("%s - port %d", __func__, port->number); /* Force default termio settings */ - empeg_set_termios (port, NULL) ; + empeg_set_termios (tty, port, NULL) ; bytes_in = 0; bytes_out = 0; @@ -178,7 +174,8 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) } -static void empeg_close (struct usb_serial_port *port, struct file * filp) +static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file * filp) { dbg("%s - port %d", __func__, port->number); @@ -189,7 +186,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) } -static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct urb *urb; @@ -203,7 +200,6 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, dbg("%s - port %d", __func__, port->number); while (count > 0) { - /* try to find a free urb in our list of them */ urb = NULL; @@ -262,15 +258,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, bytes_out += transfer_size; } - exit: return bytes_sent; - } -static int empeg_write_room (struct usb_serial_port *port) +static int empeg_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; unsigned long flags; int i; int room = 0; @@ -278,25 +273,22 @@ static int empeg_write_room (struct usb_serial_port *port) dbg("%s - port %d", __func__, port->number); spin_lock_irqsave (&write_urb_pool_lock, flags); - /* tally up the number of bytes available */ for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]->status != -EINPROGRESS) { room += URB_TRANSFER_BUFFER_SIZE; } } - spin_unlock_irqrestore (&write_urb_pool_lock, flags); - dbg("%s - returns %d", __func__, room); - - return (room); + return room; } -static int empeg_chars_in_buffer (struct usb_serial_port *port) +static int empeg_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; unsigned long flags; int i; int chars = 0; @@ -356,7 +348,7 @@ static void empeg_read_bulk_callback (struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); @@ -386,27 +378,24 @@ static void empeg_read_bulk_callback (struct urb *urb) } -static void empeg_throttle (struct usb_serial_port *port) +static void empeg_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } -static void empeg_unthrottle (struct usb_serial_port *port) +static void empeg_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int result; - dbg("%s - port %d", __func__, port->number); port->read_urb->dev = port->serial->dev; - result = usb_submit_urb(port->read_urb, GFP_ATOMIC); - if (result) dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); - - return; } @@ -436,17 +425,10 @@ static void empeg_shutdown (struct usb_serial *serial) } -static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) -{ - dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); - - return -ENOIOCTLCMD; -} - - -static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void empeg_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { - struct ktermios *termios = port->tty->termios; + struct ktermios *termios = tty->termios; dbg("%s - port %d", __func__, port->number); /* @@ -491,8 +473,8 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol * this is bad as it opens up the possibility of dropping bytes * on the floor. We don't want to drop bytes on the floor. :) */ - port->tty->low_latency = 1; - tty_encode_baud_rate(port->tty, 115200, 115200); + tty->low_latency = 1; + tty_encode_baud_rate(tty, 115200, 115200); } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 0ff4a3971e4..abbb447e537 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -682,21 +682,21 @@ static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_i static void ftdi_shutdown (struct usb_serial *serial); static int ftdi_sio_port_probe (struct usb_serial_port *port); static int ftdi_sio_port_remove (struct usb_serial_port *port); -static int ftdi_open (struct usb_serial_port *port, struct file *filp); -static void ftdi_close (struct usb_serial_port *port, struct file *filp); -static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int ftdi_write_room (struct usb_serial_port *port); -static int ftdi_chars_in_buffer (struct usb_serial_port *port); +static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); +static int ftdi_write_room (struct tty_struct *tty); +static int ftdi_chars_in_buffer (struct tty_struct *tty); static void ftdi_write_bulk_callback (struct urb *urb); static void ftdi_read_bulk_callback (struct urb *urb); static void ftdi_process_read (struct work_struct *work); -static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios * old); -static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); -static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); -static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); -static void ftdi_break_ctl (struct usb_serial_port *port, int break_state ); -static void ftdi_throttle (struct usb_serial_port *port); -static void ftdi_unthrottle (struct usb_serial_port *port); +static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); +static int ftdi_tiocmget (struct tty_struct *tty, struct file *file); +static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear); +static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); +static void ftdi_break_ctl (struct tty_struct *tty, int break_state ); +static void ftdi_throttle (struct tty_struct *tty); +static void ftdi_unthrottle (struct tty_struct *tty); static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); static unsigned short int ftdi_232am_baud_to_divisor (int baud); @@ -843,42 +843,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned } -static __u32 get_ftdi_divisor(struct usb_serial_port * port); - - -static int change_speed(struct usb_serial_port *port) -{ - struct ftdi_private *priv = usb_get_serial_port_data(port); - char *buf; - __u16 urb_value; - __u16 urb_index; - __u32 urb_index_value; - int rv; - - buf = kmalloc(1, GFP_NOIO); - if (!buf) - return -ENOMEM; - - urb_index_value = get_ftdi_divisor(port); - urb_value = (__u16)urb_index_value; - urb_index = (__u16)(urb_index_value >> 16); - if (priv->interface) { /* FT2232C */ - urb_index = (__u16)((urb_index << 8) | priv->interface); - } - - rv = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_BAUDRATE_REQUEST, - FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, - urb_value, urb_index, - buf, 0, WDR_SHORT_TIMEOUT); - - kfree(buf); - return rv; -} - - -static __u32 get_ftdi_divisor(struct usb_serial_port * port) +static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port) { /* get_ftdi_divisor */ struct ftdi_private *priv = usb_get_serial_port_data(port); __u32 div_value = 0; @@ -910,7 +875,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ - baud = tty_get_baud_rate(port->tty); + baud = tty_get_baud_rate(tty); dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ @@ -976,10 +941,42 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) ftdi_chip_name[priv->chip_type]); } - tty_encode_baud_rate(port->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); return(div_value); } +static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) +{ + struct ftdi_private *priv = usb_get_serial_port_data(port); + char *buf; + __u16 urb_value; + __u16 urb_index; + __u32 urb_index_value; + int rv; + + buf = kmalloc(1, GFP_NOIO); + if (!buf) + return -ENOMEM; + + urb_index_value = get_ftdi_divisor(tty, port); + urb_value = (__u16)urb_index_value; + urb_index = (__u16)(urb_index_value >> 16); + if (priv->interface) { /* FT2232C */ + urb_index = (__u16)((urb_index << 8) | priv->interface); + } + + rv = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + FTDI_SIO_SET_BAUDRATE_REQUEST, + FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, + urb_value, urb_index, + buf, 0, WDR_SHORT_TIMEOUT); + + kfree(buf); + return rv; +} + + static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) { @@ -998,7 +995,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _ } /* get_serial_info */ -static int set_serial_info(struct usb_serial_port * port, struct serial_struct __user * newinfo) +static int set_serial_info(struct tty_struct *tty, + struct usb_serial_port * port, struct serial_struct __user * newinfo) { /* set_serial_info */ struct ftdi_private *priv = usb_get_serial_port_data(port); struct serial_struct new_serial; @@ -1030,30 +1028,29 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _ (new_serial.flags & ASYNC_FLAGS)); priv->custom_divisor = new_serial.custom_divisor; - port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; check_and_exit: if ((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) { if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) - port->tty->alt_speed = 57600; + tty->alt_speed = 57600; else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) - port->tty->alt_speed = 115200; + tty->alt_speed = 115200; else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) - port->tty->alt_speed = 230400; + tty->alt_speed = 230400; else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) - port->tty->alt_speed = 460800; + tty->alt_speed = 460800; else - port->tty->alt_speed = 0; + tty->alt_speed = 0; } if (((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) || (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && (old_priv.custom_divisor != priv->custom_divisor))) { - change_speed(port); + change_speed(tty, port); } - - return (0); + return 0; } /* set_serial_info */ @@ -1415,7 +1412,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) return 0; } -static int ftdi_open (struct usb_serial_port *port, struct file *filp) +static int ftdi_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { /* ftdi_open */ struct usb_device *dev = port->serial->dev; struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -1433,8 +1431,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) priv->rx_bytes = 0; spin_unlock_irqrestore(&priv->rx_lock, flags); - if (port->tty) - port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + if (tty) + tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; /* No error checking for this (will get errors later anyway) */ /* See ftdi_sio.h for description of what is reset */ @@ -1448,8 +1446,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) This is same behaviour as serial.c/rs_open() - Kuba */ /* ftdi_set_termios will send usb control messages */ - if (port->tty) - ftdi_set_termios(port, port->tty->termios); + if (tty) + ftdi_set_termios(tty, port, tty->termios); /* FIXME: Flow control might be enabled, so it should be checked - we have no control of defaults! */ @@ -1485,9 +1483,10 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) * */ -static void ftdi_close (struct usb_serial_port *port, struct file *filp) +static void ftdi_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { /* ftdi_close */ - unsigned int c_cflag = port->tty->termios->c_cflag; + unsigned int c_cflag = tty->termios->c_cflag; struct ftdi_private *priv = usb_get_serial_port_data(port); char buf[1]; @@ -1527,7 +1526,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) * * The new devices do not require this byte */ -static int ftdi_write (struct usb_serial_port *port, +static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { /* ftdi_write */ struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -1686,8 +1685,9 @@ static void ftdi_write_bulk_callback (struct urb *urb) } /* ftdi_write_bulk_callback */ -static int ftdi_write_room( struct usb_serial_port *port ) +static int ftdi_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); int room; unsigned long flags; @@ -1707,11 +1707,11 @@ static int ftdi_write_room( struct usb_serial_port *port ) } spin_unlock_irqrestore(&priv->tx_lock, flags); return room; -} /* ftdi_write_room */ - +} -static int ftdi_chars_in_buffer (struct usb_serial_port *port) -{ /* ftdi_chars_in_buffer */ +static int ftdi_chars_in_buffer(struct tty_struct *tty) +{ + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); int buffered; unsigned long flags; @@ -1726,12 +1726,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port) buffered = 0; } return buffered; -} /* ftdi_chars_in_buffer */ - - +} -static void ftdi_read_bulk_callback (struct urb *urb) -{ /* ftdi_read_bulk_callback */ +static void ftdi_read_bulk_callback(struct urb *urb) +{ struct usb_serial_port *port = urb->context; struct tty_struct *tty; struct ftdi_private *priv; @@ -1747,10 +1745,10 @@ static void ftdi_read_bulk_callback (struct urb *urb) dbg("%s - port %d", __func__, port->number); - if (port->open_count <= 0) + if (port->port.count <= 0) return; - tty = port->tty; + tty = port->port.tty; if (!tty) { dbg("%s - bad tty pointer - exiting",__func__); return; @@ -1803,10 +1801,10 @@ static void ftdi_process_read (struct work_struct *work) dbg("%s - port %d", __func__, port->number); - if (port->open_count <= 0) + if (port->port.count <= 0) return; - tty = port->tty; + tty = port->port.tty; if (!tty) { dbg("%s - bad tty pointer - exiting",__func__); return; @@ -1954,7 +1952,7 @@ static void ftdi_process_read (struct work_struct *work) } spin_unlock_irqrestore(&priv->rx_lock, flags); /* if the port is closed stop trying to read */ - if (port->open_count > 0){ + if (port->port.count > 0){ /* delay processing of remainder */ schedule_delayed_work(&priv->rx_work, 1); } else { @@ -1967,7 +1965,7 @@ static void ftdi_process_read (struct work_struct *work) priv->rx_processed = 0; /* if the port is closed stop trying to read */ - if (port->open_count > 0){ + if (port->port.count > 0){ /* Continue trying to always read */ usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), @@ -1983,8 +1981,9 @@ static void ftdi_process_read (struct work_struct *work) } /* ftdi_process_read */ -static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) +static void ftdi_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value = 0; char buf[1]; @@ -2018,11 +2017,12 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) * WARNING: set_termios calls this with old_termios in kernel space */ -static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void ftdi_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { /* ftdi_termios */ struct usb_device *dev = port->serial->dev; struct ftdi_private *priv = usb_get_serial_port_data(port); - struct ktermios *termios = port->tty->termios; + struct ktermios *termios = tty->termios; unsigned int cflag = termios->c_cflag; __u16 urb_value; /* will hold the new flags */ char buf[1]; /* Perhaps I should dynamically alloc this? */ @@ -2037,7 +2037,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old /* Force baud rate if this device requires it, unless it is set to B0. */ if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { dbg("%s: forcing baud rate for this device", __func__); - tty_encode_baud_rate(port->tty, priv->force_baud, + tty_encode_baud_rate(tty, priv->force_baud, priv->force_baud); } @@ -2104,7 +2104,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); } else { /* set the baudrate determined before */ - if (change_speed(port)) { + if (change_speed(tty, port)) { err("%s urb failed to set baudrate", __func__); } /* Ensure RTS and DTR are raised when baudrate changed from 0 */ @@ -2168,11 +2168,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old } return; -} /* ftdi_termios */ - +} -static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) +static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); unsigned char buf[2]; int ret; @@ -2221,15 +2221,18 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) priv->last_dtr_rts; } -static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) +static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, + unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; dbg("%s TIOCMSET", __func__); return update_mctrl(port, set, clear); } -static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) +static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); dbg("%s cmd 0x%04x", __func__, cmd); @@ -2241,7 +2244,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne return get_serial_info(port, (struct serial_struct __user *) arg); case TIOCSSERIAL: /* sets serial port data */ - return set_serial_info(port, (struct serial_struct __user *) arg); + return set_serial_info(tty, port, (struct serial_struct __user *) arg); /* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change @@ -2280,25 +2283,20 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne */ } } - return(0); - break; + return 0; default: break; - } - - /* This is not necessarily an error - turns out the higher layers will do * some ioctls itself (see comment above) */ dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); + return -ENOIOCTLCMD; +} - return(-ENOIOCTLCMD); -} /* ftdi_ioctl */ - - -static void ftdi_throttle (struct usb_serial_port *port) +static void ftdi_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -2310,8 +2308,9 @@ static void ftdi_throttle (struct usb_serial_port *port) } -static void ftdi_unthrottle (struct usb_serial_port *port) +static void ftdi_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); int actually_throttled; unsigned long flags; diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 8ce5a56a48e..06cfa43c6f0 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -275,7 +275,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf) static void send_to_tty(struct usb_serial_port *port, char *data, unsigned int actual_length) { - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; if (tty && actual_length) { @@ -970,7 +970,8 @@ static int garmin_init_session(struct usb_serial_port *port) -static int garmin_open (struct usb_serial_port *port, struct file *filp) +static int garmin_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { unsigned long flags; int status = 0; @@ -983,8 +984,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) * through, otherwise it is scheduled, and with high data rates (like * with OHCI) data can get lost. */ - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->mode = initial_mode; @@ -998,17 +999,16 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) usb_kill_urb (port->write_urb); usb_kill_urb (port->read_urb); - if (garmin_data_p->state == STATE_RESET) { + if (garmin_data_p->state == STATE_RESET) status = garmin_init_session(port); - } garmin_data_p->state = STATE_ACTIVE; - return status; } -static void garmin_close (struct usb_serial_port *port, struct file * filp) +static void garmin_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct usb_serial *serial = port->serial; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); @@ -1042,7 +1042,6 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) mutex_unlock(&port->serial->disc_mutex); } - static void garmin_write_bulk_callback (struct urb *urb) { unsigned long flags; @@ -1145,10 +1144,8 @@ static int garmin_write_bulk (struct usb_serial_port *port, return count; } - - -static int garmin_write (struct usb_serial_port *port, - const unsigned char *buf, int count) +static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { int pktid, pktsiz, len; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); @@ -1158,7 +1155,6 @@ static int garmin_write (struct usb_serial_port *port, /* check for our private packets */ if (count >= GARMIN_PKTHDR_LENGTH) { - len = PRIVPKTSIZ; if (count < len) len = count; @@ -1226,8 +1222,9 @@ static int garmin_write (struct usb_serial_port *port, } -static int garmin_write_room (struct usb_serial_port *port) +static int garmin_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; /* * Report back the bytes currently available in the output buffer. */ @@ -1236,20 +1233,6 @@ static int garmin_write_room (struct usb_serial_port *port) } -static int garmin_chars_in_buffer (struct usb_serial_port *port) -{ - /* - * Report back the number of bytes currently in our input buffer. - * Will this lock up the driver - the buffer contains an incomplete - * package which will not be written to the device until it - * has been completed ? - */ - //struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); - //return garmin_data_p->insize; - return 0; -} - - static void garmin_read_process(struct garmin_data * garmin_data_p, unsigned char *data, unsigned data_length) { @@ -1468,10 +1451,11 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p) } -static void garmin_throttle (struct usb_serial_port *port) +static void garmin_throttle(struct tty_struct *tty) { - unsigned long flags; + struct usb_serial_port *port = tty->driver_data; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + unsigned long flags; dbg("%s - port %d", __func__, port->number); /* set flag, data received will be put into a queue @@ -1482,10 +1466,11 @@ static void garmin_throttle (struct usb_serial_port *port) } -static void garmin_unthrottle (struct usb_serial_port *port) +static void garmin_unthrottle (struct tty_struct *tty) { - unsigned long flags; + struct usb_serial_port *port = tty->driver_data; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + unsigned long flags; int status; dbg("%s - port %d", __func__, port->number); @@ -1507,8 +1492,6 @@ static void garmin_unthrottle (struct usb_serial_port *port) } } - - /* * The timer is currently only used to send queued packets to * the tty in cases where the protocol provides no own handshaking @@ -1526,7 +1509,7 @@ static void timeout_handler(unsigned long data) -static int garmin_attach (struct usb_serial *serial) +static int garmin_attach(struct usb_serial *serial) { int status = 0; struct usb_serial_port *port = serial->port[0]; @@ -1556,7 +1539,7 @@ static int garmin_attach (struct usb_serial *serial) } -static void garmin_shutdown (struct usb_serial *serial) +static void garmin_shutdown(struct usb_serial *serial) { struct usb_serial_port *port = serial->port[0]; struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); @@ -1588,7 +1571,6 @@ static struct usb_serial_driver garmin_device = { .shutdown = garmin_shutdown, .write = garmin_write, .write_room = garmin_write_room, - .chars_in_buffer = garmin_chars_in_buffer, .write_bulk_callback = garmin_write_bulk_callback, .read_bulk_callback = garmin_read_bulk_callback, .read_int_callback = garmin_read_int_callback, diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 537f12a027c..5128018c276 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -112,7 +112,8 @@ void usb_serial_generic_deregister (void) #endif } -int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) +int usb_serial_generic_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; int result = 0; @@ -123,8 +124,8 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) /* force low_latency on so that our tty_push actually forces the data through, otherwise it is scheduled, and with high data rates (like with OHCI) data can get lost. */ - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* clear the throttle flags */ spin_lock_irqsave(&port->lock, flags); @@ -152,7 +153,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) } EXPORT_SYMBOL_GPL(usb_serial_generic_open); -static void generic_cleanup (struct usb_serial_port *port) +static void generic_cleanup(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; @@ -182,7 +183,7 @@ int usb_serial_generic_resume(struct usb_serial *serial) #endif for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - if (port->open_count && port->read_urb) { + if (port->port.count && port->read_urb) { r = usb_submit_urb(port->read_urb, GFP_NOIO); if (r < 0) c++; @@ -192,13 +193,15 @@ int usb_serial_generic_resume(struct usb_serial *serial) return c ? -EIO : 0; } -void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) +void usb_serial_generic_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { dbg("%s - port %d", __func__, port->number); generic_cleanup (port); } -int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count) +int usb_serial_generic_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; int result; @@ -255,8 +258,9 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * return 0; } -int usb_serial_generic_write_room (struct usb_serial_port *port) +int usb_serial_generic_write_room (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; int room = 0; @@ -272,8 +276,9 @@ int usb_serial_generic_write_room (struct usb_serial_port *port) return room; } -int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) +int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; int chars = 0; @@ -286,7 +291,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) } dbg("%s - returns %d", __func__, chars); - return (chars); + return chars; } @@ -311,10 +316,10 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) } /* Push data to tty layer and resubmit the bulk read URB */ -static void flush_and_resubmit_read_urb (struct usb_serial_port *port) +static void flush_and_resubmit_read_urb(struct usb_serial_port *port) { struct urb *urb = port->read_urb; - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; int room; /* Push data to tty */ @@ -329,7 +334,7 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port) resubmit_read_urb(port, GFP_ATOMIC); } -void usb_serial_generic_read_bulk_callback (struct urb *urb) +void usb_serial_generic_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; @@ -357,7 +362,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb) } EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); -void usb_serial_generic_write_bulk_callback (struct urb *urb) +void usb_serial_generic_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; int status = urb->status; @@ -374,8 +379,9 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb) } EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); -void usb_serial_generic_throttle (struct usb_serial_port *port) +void usb_serial_generic_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; unsigned long flags; dbg("%s - port %d", __func__, port->number); @@ -387,8 +393,9 @@ void usb_serial_generic_throttle (struct usb_serial_port *port) spin_unlock_irqrestore(&port->lock, flags); } -void usb_serial_generic_unthrottle (struct usb_serial_port *port) +void usb_serial_generic_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int was_throttled; unsigned long flags; diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 2fd449bcfa3..29346d79df7 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -206,18 +206,18 @@ static void edge_bulk_out_data_callback (struct urb *urb); static void edge_bulk_out_cmd_callback (struct urb *urb); /* function prototypes for the usbserial callbacks */ -static int edge_open (struct usb_serial_port *port, struct file *filp); -static void edge_close (struct usb_serial_port *port, struct file *filp); -static int edge_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int edge_write_room (struct usb_serial_port *port); -static int edge_chars_in_buffer (struct usb_serial_port *port); -static void edge_throttle (struct usb_serial_port *port); -static void edge_unthrottle (struct usb_serial_port *port); -static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); -static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); -static void edge_break (struct usb_serial_port *port, int break_state); -static int edge_tiocmget (struct usb_serial_port *port, struct file *file); -static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); +static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); +static int edge_write_room (struct tty_struct *tty); +static int edge_chars_in_buffer (struct tty_struct *tty); +static void edge_throttle (struct tty_struct *tty); +static void edge_unthrottle (struct tty_struct *tty); +static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); +static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static void edge_break (struct tty_struct *tty, int break_state); +static int edge_tiocmget (struct tty_struct *tty, struct file *file); +static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static int edge_startup (struct usb_serial *serial); static void edge_shutdown (struct usb_serial *serial); @@ -233,7 +233,8 @@ static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8 static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param); static int calc_baud_rate_divisor (int baud_rate, int *divisor); static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate); -static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios); +static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port, + struct ktermios *old_termios); static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue); static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength); static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); @@ -639,8 +640,8 @@ static void edge_interrupt_callback (struct urb *urb) dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); /* tell the tty driver that something has changed */ - if (edge_port->port->tty) - tty_wakeup(edge_port->port->tty); + if (edge_port->port->port.tty) + tty_wakeup(edge_port->port->port.tty); // Since we have more credit, check if more data can be sent send_more_port_data(edge_serial, edge_port); @@ -737,7 +738,7 @@ static void edge_bulk_out_data_callback (struct urb *urb) __func__, status); } - tty = edge_port->port->tty; + tty = edge_port->port->port.tty; if (tty && edge_port->open) { /* let the tty driver wakeup if it has a special write_wakeup function */ @@ -781,7 +782,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) } /* Get pointer to tty */ - tty = edge_port->port->tty; + tty = edge_port->port->port.tty; /* tell the tty driver that something has changed */ if (tty && edge_port->open) @@ -803,7 +804,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) * If successful, we return 0 * Otherwise we return a negative error number. *****************************************************************************/ -static int edge_open (struct usb_serial_port *port, struct file * filp) +static int edge_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct usb_serial *serial; @@ -815,16 +817,15 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) if (edge_port == NULL) return -ENODEV; - if (port->tty) - port->tty->low_latency = low_latency; + if (tty) + tty->low_latency = low_latency; /* see if we've set up our endpoint info yet (can't set it up in edge_startup as the structures were not set up at that time.) */ serial = port->serial; edge_serial = usb_get_serial_data(serial); - if (edge_serial == NULL) { + if (edge_serial == NULL) return -ENODEV; - } if (edge_serial->interrupt_in_buffer == NULL) { struct usb_serial_port *port0 = serial->port[0]; @@ -908,7 +909,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) if (!edge_port->txfifo.fifo) { dbg("%s - no memory", __func__); - edge_close (port, filp); + edge_close (tty, port, filp); return -ENOMEM; } @@ -918,7 +919,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) if (!edge_port->write_urb) { dbg("%s - no memory", __func__); - edge_close (port, filp); + edge_close (tty, port, filp); return -ENOMEM; } @@ -1038,7 +1039,8 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) * edge_close * this function is called by the tty driver when a port is closed *****************************************************************************/ -static void edge_close (struct usb_serial_port *port, struct file * filp) +static void edge_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; @@ -1106,7 +1108,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) * If successful, we return the number of bytes written, otherwise we return * a negative error number. *****************************************************************************/ -static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) +static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *data, int count) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct TxFifo *fifo; @@ -1308,8 +1311,9 @@ exit_send: * (the txCredits), * Otherwise we return a negative error number. *****************************************************************************/ -static int edge_write_room (struct usb_serial_port *port) +static int edge_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int room; unsigned long flags; @@ -1347,8 +1351,9 @@ static int edge_write_room (struct usb_serial_port *port) * system, * Otherwise we return a negative error number. *****************************************************************************/ -static int edge_chars_in_buffer (struct usb_serial_port *port) +static int edge_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int num_chars; unsigned long flags; @@ -1381,10 +1386,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) * this function is called by the tty driver when it wants to stop the data * being read from the port. *****************************************************************************/ -static void edge_throttle (struct usb_serial_port *port) +static void edge_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty; int status; dbg("%s - port %d", __func__, port->number); @@ -1397,16 +1402,10 @@ static void edge_throttle (struct usb_serial_port *port) return; } - tty = port->tty; - if (!tty) { - dbg ("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = edge_write (port, &stop_char, 1); + status = edge_write (tty, port, &stop_char, 1); if (status <= 0) { return; } @@ -1430,10 +1429,10 @@ static void edge_throttle (struct usb_serial_port *port) * this function is called by the tty driver when it wants to resume the data * being read from the port (called after SerialThrottle is called) *****************************************************************************/ -static void edge_unthrottle (struct usb_serial_port *port) +static void edge_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty; int status; dbg("%s - port %d", __func__, port->number); @@ -1446,31 +1445,18 @@ static void edge_unthrottle (struct usb_serial_port *port) return; } - tty = port->tty; - if (!tty) { - dbg ("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); - status = edge_write (port, &start_char, 1); - if (status <= 0) { + status = edge_write(tty, port, &start_char, 1); + if (status <= 0) return; - } } - /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { edge_port->shadowMCR |= MCR_RTS; - status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); - if (status != 0) { - return; - } + send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); } - - return; } @@ -1478,11 +1464,10 @@ static void edge_unthrottle (struct usb_serial_port *port) * SerialSetTermios * this function is called by the tty driver when it wants to change the termios structure *****************************************************************************/ -static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) +static void edge_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { - /* FIXME: This function appears unused ?? */ struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; unsigned int cflag; cflag = tty->termios->c_cflag; @@ -1502,9 +1487,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old } /* change the port settings to the new ones specified */ - change_port_settings (edge_port, old_termios); - - return; + change_port_settings(tty, edge_port, old_termios); } @@ -1536,25 +1519,9 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va return 0; } -static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int __user *value) -{ - unsigned int result = 0; - struct tty_struct *tty = edge_port->port->tty; - - if (!tty) - return -ENOIOCTLCMD; - - result = tty->read_cnt; - - dbg("%s(%d) = %d", __func__, edge_port->port->number, result); - if (copy_to_user(value, &result, sizeof(int))) - return -EFAULT; - //return 0; - return -ENOIOCTLCMD; -} - -static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear) +static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; @@ -1582,8 +1549,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig return 0; } -static int edge_tiocmget(struct usb_serial_port *port, struct file *file) +static int edge_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int result = 0; unsigned int msr; @@ -1624,9 +1592,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct tmp.baud_base = 9600; tmp.close_delay = 5*HZ; tmp.closing_wait = 30*HZ; -// tmp.custom_divisor = state->custom_divisor; -// tmp.hub6 = state->hub6; -// tmp.io_type = state->io_type; if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; @@ -1639,8 +1604,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct * SerialIoctl * this function handles any ioctl calls to the driver *****************************************************************************/ -static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) +static int edge_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; DEFINE_WAIT(wait); struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct async_icount cnow; @@ -1650,25 +1617,14 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { - // return number of bytes available - case TIOCINQ: - dbg("%s (%d) TIOCINQ", __func__, port->number); - return get_number_bytes_avail(edge_port, (unsigned int __user *) arg); - break; - case TIOCSERGETLSR: dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); return get_lsr_info(edge_port, (unsigned int __user *) arg); - return 0; case TIOCGSERIAL: dbg("%s (%d) TIOCGSERIAL", __func__, port->number); return get_serial_info(edge_port, (struct serial_struct __user *) arg); - case TIOCSSERIAL: - dbg("%s (%d) TIOCSSERIAL", __func__, port->number); - break; - case TIOCMIWAIT: dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = edge_port->icount; @@ -1723,8 +1679,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned * SerialBreak * this function sends a break to the port *****************************************************************************/ -static void edge_break (struct usb_serial_port *port, int break_state) +static void edge_break (struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); int status; @@ -1866,7 +1823,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha port = edge_serial->serial->port[edge_serial->rxPort]; edge_port = usb_get_serial_port_data(port); if (edge_port->open) { - tty = edge_port->port->tty; + tty = edge_port->port->port.tty; if (tty) { dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); @@ -1941,8 +1898,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 handle_new_msr (edge_port, byte2); /* send the current line settings to the port so we are in sync with any further termios calls */ - if (edge_port->port->tty) - change_port_settings (edge_port, edge_port->port->tty->termios); + /* FIXME: locking on tty */ + if (edge_port->port->port.tty) + change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios); /* we have completed the open */ edge_port->openPending = false; @@ -2078,8 +2036,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l } /* Place LSR data byte into Rx buffer */ - if (lsrData && edge_port->port->tty) - edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); + if (lsrData && edge_port->port->port.tty) + edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1); /* update input line counters */ icount = &edge_port->icount; @@ -2473,13 +2431,11 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r * This routine is called to set the UART on the device to match the specified * new settings. *****************************************************************************/ -#ifndef CMSPAR -#define CMSPAR 0 -#endif -static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios) + +static void change_port_settings(struct tty_struct *tty, + struct edgeport_port *edge_port, struct ktermios *old_termios) { struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); - struct tty_struct *tty; int baud; unsigned cflag; __u8 mask = 0xff; @@ -2498,13 +2454,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi return; } - tty = edge_port->port->tty; - if ((!tty) || - (!tty->termios)) { - dbg("%s - no tty structures", __func__); - return; - } - cflag = tty->termios->c_cflag; switch (cflag & CSIZE) { diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index a58822a14a8..7cf383a2a55 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -243,9 +243,9 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, static void stop_read(struct edgeport_port *edge_port); static int restart_read(struct edgeport_port *edge_port); -static void edge_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios); -static void edge_send(struct usb_serial_port *port); +static void edge_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); +static void edge_send(struct tty_struct *tty); /* sysfs attributes */ static int edge_create_sysfs_attrs(struct usb_serial_port *port); @@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, int flush) { int baud_rate; - struct tty_struct *tty = port->port->tty; + struct tty_struct *tty = port->port->port.tty; wait_queue_t wait; unsigned long flags; @@ -1554,7 +1554,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) /* Save the new modem status */ edge_port->shadow_msr = msr & 0xf0; - tty = edge_port->port->tty; + tty = edge_port->port->port.tty; /* handle CTS flow control */ if (tty && C_CRTSCTS(tty)) { if (msr & EDGEPORT_MSR_CTS) { @@ -1587,9 +1587,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); /* Place LSR data byte into Rx buffer */ - if (lsr_data && edge_port->port->tty) - edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, - &data, 1); + if (lsr_data && edge_port->port->port.tty) + edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1); /* update input line counters */ icount = &edge_port->icount; @@ -1750,7 +1749,7 @@ static void edge_bulk_in_callback(struct urb *urb) ++data; } - tty = edge_port->port->tty; + tty = edge_port->port->port.tty; if (tty && urb->actual_length) { usb_serial_debug_data(debug, &edge_port->port->dev, __func__, urb->actual_length, data); @@ -1819,10 +1818,11 @@ static void edge_bulk_out_callback(struct urb *urb) } /* send any buffered data */ - edge_send(port); + edge_send(port->port.tty); } -static int edge_open(struct usb_serial_port *port, struct file *filp) +static int edge_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_serial *edge_serial; @@ -1838,7 +1838,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp) if (edge_port == NULL) return -ENODEV; - port->tty->low_latency = low_latency; + if (tty) + tty->low_latency = low_latency; port_number = port->number - port->serial->minor; switch (port_number) { @@ -1874,7 +1875,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp) } /* set up the port settings */ - edge_set_termios(port, port->tty->termios); + if (tty) + edge_set_termios(tty, port, port->port.tty->termios); /* open up the port */ @@ -2000,7 +2002,8 @@ release_es_lock: return status; } -static void edge_close(struct usb_serial_port *port, struct file *filp) +static void edge_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; @@ -2048,8 +2051,8 @@ static void edge_close(struct usb_serial_port *port, struct file *filp) dbg("%s - exited", __func__); } -static int edge_write(struct usb_serial_port *port, const unsigned char *data, - int count) +static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *data, int count) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned long flags; @@ -2070,16 +2073,16 @@ static int edge_write(struct usb_serial_port *port, const unsigned char *data, count = edge_buf_put(edge_port->ep_out_buf, data, count); spin_unlock_irqrestore(&edge_port->ep_lock, flags); - edge_send(port); + edge_send(tty); return count; } -static void edge_send(struct usb_serial_port *port) +static void edge_send(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int count, result; struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; unsigned long flags; @@ -2133,8 +2136,9 @@ static void edge_send(struct usb_serial_port *port) tty_wakeup(tty); } -static int edge_write_room(struct usb_serial_port *port) +static int edge_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -2154,8 +2158,9 @@ static int edge_write_room(struct usb_serial_port *port) return room; } -static int edge_chars_in_buffer(struct usb_serial_port *port) +static int edge_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; @@ -2175,10 +2180,10 @@ static int edge_chars_in_buffer(struct usb_serial_port *port) return chars; } -static void edge_throttle(struct usb_serial_port *port) +static void edge_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; int status; dbg("%s - port %d", __func__, port->number); @@ -2189,11 +2194,10 @@ static void edge_throttle(struct usb_serial_port *port) /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = edge_write(port, &stop_char, 1); - if (status <= 0) - dev_err(&port->dev, - "%s - failed to write stop character, %d\n", - __func__, status); + status = edge_write(tty, port, &stop_char, 1); + if (status <= 0) { + dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status); + } } /* if we are implementing RTS/CTS, stop reads */ @@ -2203,10 +2207,10 @@ static void edge_throttle(struct usb_serial_port *port) } -static void edge_unthrottle(struct usb_serial_port *port) +static void edge_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; int status; dbg("%s - port %d", __func__, port->number); @@ -2217,11 +2221,10 @@ static void edge_unthrottle(struct usb_serial_port *port) /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); - status = edge_write(port, &start_char, 1); - if (status <= 0) - dev_err(&port->dev, - "%s - failed to write start character, %d\n", - __func__, status); + status = edge_write(tty, port, &start_char, 1); + if (status <= 0) { + dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status); + } } /* if we are implementing RTS/CTS, restart reads */ /* are the Edgeport will assert the RTS line */ @@ -2271,11 +2274,10 @@ static int restart_read(struct edgeport_port *edge_port) return status; } -static void change_port_settings(struct edgeport_port *edge_port, - struct ktermios *old_termios) +static void change_port_settings(struct tty_struct *tty, + struct edgeport_port *edge_port, struct ktermios *old_termios) { struct ump_uart_config *config; - struct tty_struct *tty; int baud; unsigned cflag; int status; @@ -2284,9 +2286,7 @@ static void change_port_settings(struct edgeport_port *edge_port, dbg("%s - port %d", __func__, edge_port->port->number); - tty = edge_port->port->tty; - - config = kmalloc(sizeof(*config), GFP_KERNEL); + config = kmalloc (sizeof (*config), GFP_KERNEL); if (!config) { *tty->termios = *old_termios; dev_err(&edge_port->port->dev, "%s - out of memory\n", @@ -2419,11 +2419,13 @@ static void change_port_settings(struct edgeport_port *edge_port, return; } -static void edge_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void edge_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; + unsigned int cflag; + + cflag = tty->termios->c_cflag; dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, tty->termios->c_iflag); @@ -2434,12 +2436,14 @@ static void edge_set_termios(struct usb_serial_port *port, if (edge_port == NULL) return; /* change the port settings to the new ones specified */ - change_port_settings(edge_port, old_termios); + change_port_settings(tty, edge_port, old_termios); + return; } -static int edge_tiocmset(struct usb_serial_port *port, struct file *file, +static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int mcr; unsigned long flags; @@ -2469,8 +2473,9 @@ static int edge_tiocmset(struct usb_serial_port *port, struct file *file, return 0; } -static int edge_tiocmget(struct usb_serial_port *port, struct file *file) +static int edge_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); unsigned int result = 0; unsigned int msr; @@ -2522,9 +2527,10 @@ static int get_serial_info(struct edgeport_port *edge_port, return 0; } -static int edge_ioctl(struct usb_serial_port *port, struct file *file, +static int edge_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct async_icount cnow; struct async_icount cprev; @@ -2569,18 +2575,19 @@ static int edge_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static void edge_break(struct usb_serial_port *port, int on) +static void edge_break(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status; int bv = 0; /* Off */ - dbg("%s - state = %d", __func__, on); + dbg("%s - state = %d", __func__, break_state); /* chase the port close */ chase_port(edge_port, 0, 0); - if (on == -1) + if (break_state == -1) bv = 1; /* On */ status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); if (status) diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 80d9ec5570d..a7784642d6a 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -74,19 +74,21 @@ static int connect_retries = KP_RETRIES; static int initial_wait; /* Function prototypes for an ipaq */ -static int ipaq_open (struct usb_serial_port *port, struct file *filp); -static void ipaq_close (struct usb_serial_port *port, struct file *filp); -static int ipaq_startup (struct usb_serial *serial); -static void ipaq_shutdown (struct usb_serial *serial); -static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, - int count); +static int ipaq_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void ipaq_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int ipaq_startup(struct usb_serial *serial); +static void ipaq_shutdown(struct usb_serial *serial); +static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, - int count); + int count); static void ipaq_write_gather(struct usb_serial_port *port); static void ipaq_read_bulk_callback (struct urb *urb); static void ipaq_write_bulk_callback(struct urb *urb); -static int ipaq_write_room(struct usb_serial_port *port); -static int ipaq_chars_in_buffer(struct usb_serial_port *port); +static int ipaq_write_room(struct tty_struct *tty); +static int ipaq_chars_in_buffer(struct tty_struct *tty); static void ipaq_destroy_lists(struct usb_serial_port *port); @@ -591,7 +593,8 @@ static spinlock_t write_list_lock; static int bytes_in; static int bytes_out; -static int ipaq_open(struct usb_serial_port *port, struct file *filp) +static int ipaq_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; struct ipaq_private *priv; @@ -637,10 +640,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) * discipline instead of queueing. */ - port->tty->low_latency = 1; - port->tty->raw = 1; - port->tty->real_raw = 1; - + if (tty) { + tty->low_latency = 1; + /* FIXME: These two are bogus */ + tty->raw = 1; + tty->real_raw = 1; + } /* * Lose the small buffers usbserial provides. Make larger ones. */ @@ -714,7 +719,8 @@ error: } -static void ipaq_close(struct usb_serial_port *port, struct file *filp) +static void ipaq_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct ipaq_private *priv = usb_get_serial_port_data(port); @@ -751,7 +757,7 @@ static void ipaq_read_bulk_callback(struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -770,8 +776,8 @@ static void ipaq_read_bulk_callback(struct urb *urb) return; } -static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, - int count) +static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { const unsigned char *current_position = buf; int bytes_sent = 0; @@ -905,16 +911,18 @@ static void ipaq_write_bulk_callback(struct urb *urb) usb_serial_port_softint(port); } -static int ipaq_write_room(struct usb_serial_port *port) +static int ipaq_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - freelen %d", __func__, priv->free_len); return priv->free_len; } -static int ipaq_chars_in_buffer(struct usb_serial_port *port) +static int ipaq_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - queuelen %d", __func__, priv->queue_len); diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index bc85ca5c1c3..a89ebfe9e91 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -179,7 +179,7 @@ static void ipw_read_bulk_callback(struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -199,7 +199,8 @@ static void ipw_read_bulk_callback(struct urb *urb) return; } -static int ipw_open(struct usb_serial_port *port, struct file *filp) +static int ipw_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_device *dev = port->serial->dev; u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; @@ -212,8 +213,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) if (!buf_flow_init) return -ENOMEM; - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* --1: Tell the modem to initialize (we think) From sniffs this is always the * first thing that gets sent to the modem during opening of the device */ @@ -301,7 +302,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) return 0; } -static void ipw_close(struct usb_serial_port *port, struct file * filp) +static void ipw_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct usb_device *dev = port->serial->dev; int result; @@ -384,7 +386,8 @@ static void ipw_write_bulk_callback(struct urb *urb) usb_serial_port_softint(port); } -static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count) +static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct usb_device *dev = port->serial->dev; int ret; diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 0063c11c808..e59155c6607 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -85,15 +85,17 @@ static int buffer_size; /* if overridden by the user, then use the specified number of XBOFs */ static int xbof = -1; -static int ir_startup(struct usb_serial *serial); -static int ir_open(struct usb_serial_port *port, struct file *filep); -static void ir_close(struct usb_serial_port *port, struct file *filep); -static int ir_write(struct usb_serial_port *port, - const unsigned char *buf, int count); -static void ir_write_bulk_callback(struct urb *urb); -static void ir_read_bulk_callback(struct urb *urb); -static void ir_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios); +static int ir_startup (struct usb_serial *serial); +static int ir_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filep); +static void ir_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filep); +static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static void ir_write_bulk_callback (struct urb *urb); +static void ir_read_bulk_callback (struct urb *urb); +static void ir_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); /* Not that this lot means you can only have one per system */ static u8 ir_baud; @@ -295,7 +297,8 @@ static int ir_startup(struct usb_serial *serial) return 0; } -static int ir_open(struct usb_serial_port *port, struct file *filp) +static int ir_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { char *buffer; int result = 0; @@ -343,7 +346,8 @@ static int ir_open(struct usb_serial_port *port, struct file *filp) return result; } -static void ir_close(struct usb_serial_port *port, struct file *filp) +static void ir_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { dbg("%s - port %d", __func__, port->number); @@ -351,8 +355,8 @@ static void ir_close(struct usb_serial_port *port, struct file *filp) usb_kill_urb(port->read_urb); } -static int ir_write(struct usb_serial_port *port, - const unsigned char *buf, int count) +static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { unsigned char *transfer_buffer; int result; @@ -360,11 +364,6 @@ static int ir_write(struct usb_serial_port *port, dbg("%s - port = %d, count = %d", __func__, port->number, count); - if (!port->tty) { - dev_err(&port->dev, "%s - no tty???\n", __func__); - return 0; - } - if (count == 0) return 0; @@ -450,14 +449,13 @@ static void ir_read_bulk_callback(struct urb *urb) dbg("%s - port %d", __func__, port->number); - if (!port->open_count) { + if (!port->port.count) { dbg("%s - port closed.", __func__); return; } switch (status) { case 0: /* Successful */ - /* * The first byte of the packet we get from the device * contains a busy indicator and baud rate change. @@ -465,19 +463,11 @@ static void ir_read_bulk_callback(struct urb *urb) */ if ((*data & 0x0f) > 0) ir_baud = *data & 0x0f; - - usb_serial_debug_data( - debug, - &port->dev, - __func__, - urb->actual_length, - data); - - tty = port->tty; - + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); + tty = port->port.tty; if (tty_buffer_request_room(tty, urb->actual_length - 1)) { - tty_insert_flip_string(tty, data + 1, - urb->actual_length - 1); + tty_insert_flip_string(tty, data+1, urb->actual_length - 1); tty_flip_buffer_push(tty); } @@ -488,11 +478,10 @@ static void ir_read_bulk_callback(struct urb *urb) */ case -EPROTO: /* taking inspiration from pl2303.c */ - - /* Continue trying to always read */ + /* Continue trying to always read */ usb_fill_bulk_urb( port->read_urb, - port->serial->dev, + port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -502,23 +491,19 @@ static void ir_read_bulk_callback(struct urb *urb) result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, - "%s - failed resubmitting read urb, error %d\n", + dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); - break; - + break ; default: dbg("%s - nonzero read bulk status received: %d", - __func__, - status); - break; + __func__, status); + break ; } - return; } -static void ir_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void ir_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { unsigned char *transfer_buffer; int result; @@ -527,7 +512,7 @@ static void ir_set_termios(struct usb_serial_port *port, dbg("%s - port %d", __func__, port->number); - baud = tty_get_baud_rate(port->tty); + baud = tty_get_baud_rate(tty); /* * FIXME, we should compare the baud request against the @@ -600,8 +585,8 @@ static void ir_set_termios(struct usb_serial_port *port, __func__, result); /* Only speed changes are supported */ - tty_termios_copy_hw(port->tty->termios, old_termios); - tty_encode_baud_rate(port->tty, baud, baud); + tty_termios_copy_hw(tty->termios, old_termios); + tty_encode_baud_rate(tty, baud, baud); } static int __init ir_init(void) diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index a01e987c7d3..d6541488834 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -144,9 +144,10 @@ static void iuu_shutdown(struct usb_serial *serial) } } -static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, +static int iuu_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct iuu_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, * When no card , the reader respond with TIOCM_CD * This is known as CD autodetect mechanism */ -static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) +static int iuu_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct iuu_private *priv = usb_get_serial_port_data(port); unsigned long flags; int rc; @@ -630,7 +632,7 @@ static void read_buf_callback(struct urb *urb) } dbg("%s - %i chars to write", __func__, urb->actual_length); - tty = port->tty; + tty = port->port.tty; if (data == NULL) dbg("%s - data is NULL !!!", __func__); if (tty && urb->actual_length && data) { @@ -752,11 +754,10 @@ static void iuu_uart_read_callback(struct urb *urb) /* if nothing to write call again rxcmd */ dbg("%s - rxcmd recall", __func__); iuu_led_activity_off(urb); - return; } -static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, - int count) +static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, + const u8 *buf, int count) { struct iuu_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -948,7 +949,8 @@ static int set_control_lines(struct usb_device *dev, u8 value) return 0; } -static void iuu_close(struct usb_serial_port *port, struct file *filp) +static void iuu_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { /* iuu_led (port,255,0,0,0); */ struct usb_serial *serial; @@ -964,8 +966,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) iuu_uart_off(port); if (serial->dev) { - if (port->tty) { - c_cflag = port->tty->termios->c_cflag; + if (tty) { + c_cflag = tty->termios->c_cflag; if (c_cflag & HUPCL) { /* drop DTR and RTS */ priv = usb_get_serial_port_data(port); @@ -989,7 +991,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) } } -static int iuu_open(struct usb_serial_port *port, struct file *filp) +static int iuu_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; u8 *buf; @@ -1036,15 +1039,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) /* set the termios structure */ spin_lock_irqsave(&priv->lock, flags); - if (!priv->termios_initialized) { - *(port->tty->termios) = tty_std_termios; - port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 - | TIOCM_CTS | CSTOPB | PARENB; - port->tty->termios->c_lflag = 0; - port->tty->termios->c_oflag = 0; - port->tty->termios->c_iflag = 0; + if (tty && !priv->termios_initialized) { + *(tty->termios) = tty_std_termios; + tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 + | TIOCM_CTS | CSTOPB | PARENB; + tty->termios->c_ispeed = 9600; + tty->termios->c_ospeed = 9600; + tty->termios->c_lflag = 0; + tty->termios->c_oflag = 0; + tty->termios->c_iflag = 0; priv->termios_initialized = 1; - port->tty->low_latency = 1; + tty->low_latency = 1; priv->poll = 0; } spin_unlock_irqrestore(&priv->lock, flags); @@ -1148,7 +1153,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) if (result) { dev_err(&port->dev, "%s - failed submitting read urb," " error %d\n", __func__, result); - iuu_close(port, NULL); + iuu_close(tty, port, NULL); return -EPROTO; } else { dbg("%s - rxcmd OK", __func__); diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 11e439b90ea..a371c41bb3a 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -244,20 +244,9 @@ static void __exit keyspan_exit (void) module_init(keyspan_init); module_exit(keyspan_exit); -static void keyspan_rx_throttle (struct usb_serial_port *port) -{ - dbg("%s - port %d", __func__, port->number); -} - - -static void keyspan_rx_unthrottle (struct usb_serial_port *port) -{ - dbg("%s - port %d", __func__, port->number); -} - - -static void keyspan_break_ctl (struct usb_serial_port *port, int break_state) +static void keyspan_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct keyspan_port_private *p_priv; dbg("%s", __func__); @@ -273,14 +262,13 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state) } -static void keyspan_set_termios (struct usb_serial_port *port, - struct ktermios *old_termios) +static void keyspan_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { int baud_rate, device_port; struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; unsigned int cflag; - struct tty_struct *tty = port->tty; dbg("%s", __func__); @@ -312,12 +300,11 @@ static void keyspan_set_termios (struct usb_serial_port *port, keyspan_send_setup(port, 0); } -static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file) +static int keyspan_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; + struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); unsigned int value; - struct keyspan_port_private *p_priv; - - p_priv = usb_get_serial_port_data(port); value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | ((p_priv->dtr_state) ? TIOCM_DTR : 0) | @@ -329,18 +316,16 @@ static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file) return value; } -static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file, +static int keyspan_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { - struct keyspan_port_private *p_priv; - - p_priv = usb_get_serial_port_data(port); + struct usb_serial_port *port = tty->driver_data; + struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); if (set & TIOCM_RTS) p_priv->rts_state = 1; if (set & TIOCM_DTR) p_priv->dtr_state = 1; - if (clear & TIOCM_RTS) p_priv->rts_state = 0; if (clear & TIOCM_DTR) @@ -349,16 +334,10 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file, return 0; } -static int keyspan_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) -{ - return -ENOIOCTLCMD; -} - - /* Write function is similar for the four protocols used - with only a minor change for usa90 (usa19hs) required */ -static int keyspan_write(struct usb_serial_port *port, - const unsigned char *buf, int count) +/* Write function is similar for the four protocols used + with only a minor change for usa90 (usa19hs) required */ +static int keyspan_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; @@ -448,7 +427,7 @@ static void usa26_indat_callback(struct urb *urb) } port = urb->context; - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { @@ -479,7 +458,7 @@ static void usa26_indat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->open_count) + if (port->port.count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { dbg("%s - resubmit read urb failed. (%d)", __func__, err); } @@ -496,7 +475,7 @@ static void usa2x_outdat_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); - if (port->open_count) + if (port->port.count) usb_serial_port_softint(port); } @@ -567,10 +546,10 @@ static void usa26_instat_callback(struct urb *urb) p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state != p_priv->dcd_state) { if (old_dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } @@ -619,7 +598,7 @@ static void usa28_indat_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { for (i = 0; i < urb->actual_length ; ++i) { tty_insert_flip_char(tty, data[i], 0); @@ -629,7 +608,7 @@ static void usa28_indat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->open_count) + if (port->port.count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { dbg("%s - resubmit read urb failed. (%d)", __func__, err); } @@ -704,10 +683,10 @@ static void usa28_instat_callback(struct urb *urb) p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state != p_priv->dcd_state) { if (old_dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } @@ -797,10 +776,10 @@ static void usa49_instat_callback(struct urb *urb) p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state != p_priv->dcd_state) { if (old_dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } @@ -839,7 +818,7 @@ static void usa49_indat_callback(struct urb *urb) } port = urb->context; - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { @@ -866,7 +845,7 @@ static void usa49_indat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->open_count) + if (port->port.count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { dbg("%s - resubmit read urb failed. (%d)", __func__, err); } @@ -904,7 +883,7 @@ static void usa49wg_indat_callback(struct urb *urb) return; } port = serial->port[data[i++]]; - tty = port->tty; + tty = port->port.tty; len = data[i++]; /* 0x80 bit is error flag */ @@ -912,7 +891,7 @@ static void usa49wg_indat_callback(struct urb *urb) /* no error on any byte */ i++; for (x = 1; x < len ; ++x) - if (port->open_count) + if (port->port.count) tty_insert_flip_char(tty, data[i++], 0); else @@ -930,13 +909,13 @@ static void usa49wg_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - if (port->open_count) + if (port->port.count) tty_insert_flip_char(tty, data[i+1], flag); i += 2; } } - if (port->open_count) + if (port->port.count) tty_flip_buffer_push(tty); } } @@ -978,7 +957,7 @@ static void usa90_indat_callback(struct urb *urb) port = urb->context; p_priv = usb_get_serial_port_data(port); - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { /* if current mode is DMA, looks like usa28 format @@ -1021,7 +1000,7 @@ static void usa90_indat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->open_count) + if (port->port.count) if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { dbg("%s - resubmit read urb failed. (%d)", __func__, err); } @@ -1064,10 +1043,10 @@ static void usa90_instat_callback(struct urb *urb) p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state != p_priv->dcd_state) { if (old_dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } @@ -1139,10 +1118,10 @@ static void usa67_instat_callback(struct urb *urb) p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state != p_priv->dcd_state) { if (old_dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } @@ -1177,8 +1156,9 @@ static void usa67_glocont_callback(struct urb *urb) } } -static int keyspan_write_room (struct usb_serial_port *port) +static int keyspan_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; int flip; @@ -1210,13 +1190,8 @@ static int keyspan_write_room (struct usb_serial_port *port) } -static int keyspan_chars_in_buffer (struct usb_serial_port *port) -{ - return 0; -} - - -static int keyspan_open (struct usb_serial_port *port, struct file *filp) +static int keyspan_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct keyspan_port_private *p_priv; struct keyspan_serial_private *s_priv; @@ -1225,7 +1200,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) int i, err; int baud_rate, device_port; struct urb *urb; - unsigned int cflag; + unsigned int cflag = 0; s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1271,19 +1246,19 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) /* get the terminal config for the setup message now so we don't * need to send 2 of them */ - cflag = port->tty->termios->c_cflag; device_port = port->number - port->serial->minor; - - /* Baud rate calculation takes baud rate as an integer - so other rates can be generated if desired. */ - baud_rate = tty_get_baud_rate(port->tty); - /* If no match or invalid, leave as default */ - if (baud_rate >= 0 - && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, - NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { - p_priv->baud = baud_rate; + if (tty) { + cflag = tty->termios->c_cflag; + /* Baud rate calculation takes baud rate as an integer + so other rates can be generated if desired. */ + baud_rate = tty_get_baud_rate(tty); + /* If no match or invalid, leave as default */ + if (baud_rate >= 0 + && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, + NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { + p_priv->baud = baud_rate; + } } - /* set CTS/RTS handshake etc. */ p_priv->cflag = cflag; p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; @@ -1301,7 +1276,8 @@ static inline void stop_urb(struct urb *urb) usb_kill_urb(urb); } -static void keyspan_close(struct usb_serial_port *port, struct file *filp) +static void keyspan_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int i; struct usb_serial *serial = port->serial; @@ -1338,7 +1314,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) stop_urb(p_priv->out_urbs[i]); } } - port->tty = NULL; + port->port.tty = NULL; } /* download the firmware to a pre-renumeration device */ @@ -2427,7 +2403,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, } /* Sending intermediate configs */ else { - if (port->open_count) + if (port->port.count) msg.portEnabled = 1; msg.txBreak = (p_priv->break_on); } diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 8bf72639b14..38b4582e073 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h @@ -35,17 +35,18 @@ /* Function prototypes for Keyspan serial converter */ -static int keyspan_open (struct usb_serial_port *port, +static int keyspan_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); -static void keyspan_close (struct usb_serial_port *port, +static void keyspan_close (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); static int keyspan_startup (struct usb_serial *serial); static void keyspan_shutdown (struct usb_serial *serial); -static void keyspan_rx_throttle (struct usb_serial_port *port); -static void keyspan_rx_unthrottle (struct usb_serial_port *port); -static int keyspan_write_room (struct usb_serial_port *port); +static int keyspan_write_room (struct tty_struct *tty); -static int keyspan_write (struct usb_serial_port *port, +static int keyspan_write (struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count); @@ -53,18 +54,14 @@ static void keyspan_send_setup (struct usb_serial_port *port, int reset_port); -static int keyspan_chars_in_buffer (struct usb_serial_port *port); -static int keyspan_ioctl (struct usb_serial_port *port, - struct file *file, - unsigned int cmd, - unsigned long arg); -static void keyspan_set_termios (struct usb_serial_port *port, +static void keyspan_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); -static void keyspan_break_ctl (struct usb_serial_port *port, +static void keyspan_break_ctl (struct tty_struct *tty, int break_state); -static int keyspan_tiocmget (struct usb_serial_port *port, +static int keyspan_tiocmget (struct tty_struct *tty, struct file *file); -static int keyspan_tiocmset (struct usb_serial_port *port, +static int keyspan_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static int keyspan_fake_startup (struct usb_serial *serial); @@ -567,10 +564,6 @@ static struct usb_serial_driver keyspan_1port_device = { .close = keyspan_close, .write = keyspan_write, .write_room = keyspan_write_room, - .chars_in_buffer = keyspan_chars_in_buffer, - .throttle = keyspan_rx_throttle, - .unthrottle = keyspan_rx_unthrottle, - .ioctl = keyspan_ioctl, .set_termios = keyspan_set_termios, .break_ctl = keyspan_break_ctl, .tiocmget = keyspan_tiocmget, @@ -591,10 +584,6 @@ static struct usb_serial_driver keyspan_2port_device = { .close = keyspan_close, .write = keyspan_write, .write_room = keyspan_write_room, - .chars_in_buffer = keyspan_chars_in_buffer, - .throttle = keyspan_rx_throttle, - .unthrottle = keyspan_rx_unthrottle, - .ioctl = keyspan_ioctl, .set_termios = keyspan_set_termios, .break_ctl = keyspan_break_ctl, .tiocmget = keyspan_tiocmget, @@ -615,10 +604,6 @@ static struct usb_serial_driver keyspan_4port_device = { .close = keyspan_close, .write = keyspan_write, .write_room = keyspan_write_room, - .chars_in_buffer = keyspan_chars_in_buffer, - .throttle = keyspan_rx_throttle, - .unthrottle = keyspan_rx_unthrottle, - .ioctl = keyspan_ioctl, .set_termios = keyspan_set_termios, .break_ctl = keyspan_break_ctl, .tiocmget = keyspan_tiocmget, diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 60b3e22bd63..24a08ac2e4e 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -171,7 +171,7 @@ static void keyspan_pda_wakeup_write(struct work_struct *work) container_of(work, struct keyspan_pda_private, wakeup_work); struct usb_serial_port *port = priv->port; - tty_wakeup(port->tty); + tty_wakeup(port->port.tty); } static void keyspan_pda_request_unthrottle(struct work_struct *work) @@ -203,7 +203,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) static void keyspan_pda_rx_interrupt (struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; unsigned char *data = urb->transfer_buffer; int i; int retval; @@ -266,7 +266,7 @@ exit: } -static void keyspan_pda_rx_throttle (struct usb_serial_port *port) +static void keyspan_pda_rx_throttle(struct tty_struct *tty) { /* stop receiving characters. We just turn off the URB request, and let chars pile up in the device. If we're doing hardware @@ -274,14 +274,15 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port) fills up. If we're doing XON/XOFF, this would be a good time to send an XOFF, although it might make sense to foist that off upon the device too. */ - + struct usb_serial_port *port = tty->driver_data; dbg("keyspan_pda_rx_throttle port %d", port->number); usb_kill_urb(port->interrupt_in_urb); } -static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port) +static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; /* just restart the receive interrupt URB */ dbg("keyspan_pda_rx_unthrottle port %d", port->number); port->interrupt_in_urb->dev = port->serial->dev; @@ -330,8 +331,9 @@ static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) } -static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state) +static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; int value; int result; @@ -354,8 +356,8 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state } -static void keyspan_pda_set_termios (struct usb_serial_port *port, - struct ktermios *old_termios) +static void keyspan_pda_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; speed_t speed; @@ -380,7 +382,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, For now, just do baud. */ - speed = tty_get_baud_rate(port->tty); + speed = tty_get_baud_rate(tty); speed = keyspan_pda_setbaud(serial, speed); if (speed == 0) { @@ -390,8 +392,8 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, } /* Only speed can change so copy the old h/w parameters then encode the new speed */ - tty_termios_copy_hw(port->tty->termios, old_termios); - tty_encode_baud_rate(port->tty, speed, speed); + tty_termios_copy_hw(tty->termios, old_termios); + tty_encode_baud_rate(tty, speed, speed); } @@ -425,8 +427,9 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial, return rc; } -static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file) +static int keyspan_pda_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; int rc; unsigned char status; @@ -445,9 +448,10 @@ static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file) return value; } -static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file, +static int keyspan_pda_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; int rc; unsigned char status; @@ -469,23 +473,8 @@ static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file, return rc; } -static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) -{ - switch (cmd) { - case TIOCMIWAIT: - /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ - /* TODO */ - case TIOCGICOUNT: - /* return count of modemline transitions */ - return 0; /* TODO */ - } - - return -ENOIOCTLCMD; -} - -static int keyspan_pda_write(struct usb_serial_port *port, - const unsigned char *buf, int count) +static int keyspan_pda_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; int request_unthrottle = 0; @@ -607,22 +596,21 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb) } -static int keyspan_pda_write_room (struct usb_serial_port *port) +static int keyspan_pda_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct keyspan_pda_private *priv; - priv = usb_get_serial_port_data(port); - /* used by n_tty.c for processing of tabs and such. Giving it our conservative guess is probably good enough, but needs testing by running a console through the device. */ - return (priv->tx_room); } -static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) +static int keyspan_pda_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct keyspan_pda_private *priv; unsigned long flags; int ret = 0; @@ -640,7 +628,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) } -static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) +static int keyspan_pda_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; unsigned char room; @@ -672,7 +661,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) /* the normal serial device seems to always turn on DTR and RTS here, so do the same */ - if (port->tty->termios->c_cflag & CBAUD) + if (tty && (tty->termios->c_cflag & CBAUD)) keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) ); else keyspan_pda_set_modem_info(serial, 0); @@ -690,13 +679,14 @@ error: } -static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) +static void keyspan_pda_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; if (serial->dev) { /* the normal serial device seems to always shut off DTR and RTS now */ - if (port->tty->termios->c_cflag & HUPCL) + if (tty->termios->c_cflag & HUPCL) keyspan_pda_set_modem_info(serial, 0); /* shutdown our bulk reads and writes */ @@ -832,7 +822,6 @@ static struct usb_serial_driver keyspan_pda_device = { .chars_in_buffer = keyspan_pda_chars_in_buffer, .throttle = keyspan_pda_rx_throttle, .unthrottle = keyspan_pda_rx_unthrottle, - .ioctl = keyspan_pda_ioctl, .set_termios = keyspan_pda_set_termios, .break_ctl = keyspan_pda_break_ctl, .tiocmget = keyspan_pda_tiocmget, diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 79787eda952..4a38ec8f5fe 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -74,29 +74,33 @@ static int debug; */ static int klsi_105_startup (struct usb_serial *serial); static void klsi_105_shutdown (struct usb_serial *serial); -static int klsi_105_open (struct usb_serial_port *port, +static int klsi_105_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); -static void klsi_105_close (struct usb_serial_port *port, +static void klsi_105_close (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); -static int klsi_105_write (struct usb_serial_port *port, +static int klsi_105_write (struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count); static void klsi_105_write_bulk_callback (struct urb *urb); -static int klsi_105_chars_in_buffer (struct usb_serial_port *port); -static int klsi_105_write_room (struct usb_serial_port *port); +static int klsi_105_chars_in_buffer (struct tty_struct *tty); +static int klsi_105_write_room (struct tty_struct *tty); static void klsi_105_read_bulk_callback (struct urb *urb); -static void klsi_105_set_termios (struct usb_serial_port *port, +static void klsi_105_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); -static void klsi_105_throttle (struct usb_serial_port *port); -static void klsi_105_unthrottle (struct usb_serial_port *port); +static void klsi_105_throttle (struct tty_struct *tty); +static void klsi_105_unthrottle (struct tty_struct *tty); /* -static void klsi_105_break_ctl (struct usb_serial_port *port, +static void klsi_105_break_ctl (struct tty_struct *tty, int break_state ); */ -static int klsi_105_tiocmget (struct usb_serial_port *port, +static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file); -static int klsi_105_tiocmset (struct usb_serial_port *port, +static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); @@ -361,7 +365,8 @@ static void klsi_105_shutdown (struct usb_serial *serial) } } /* klsi_105_shutdown */ -static int klsi_105_open (struct usb_serial_port *port, struct file *filp) +static int klsi_105_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct klsi_105_private *priv = usb_get_serial_port_data(port); int retval = 0; @@ -375,7 +380,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) /* force low_latency on so that our tty_push actually forces * the data through - * port->tty->low_latency = 1; */ + * tty->low_latency = 1; */ /* Do a defined restart: * Set up sane default baud rate and send the 'READ_ON' @@ -393,12 +398,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) /* set up termios structure */ spin_lock_irqsave (&priv->lock, flags); - priv->termios.c_iflag = port->tty->termios->c_iflag; - priv->termios.c_oflag = port->tty->termios->c_oflag; - priv->termios.c_cflag = port->tty->termios->c_cflag; - priv->termios.c_lflag = port->tty->termios->c_lflag; + priv->termios.c_iflag = tty->termios->c_iflag; + priv->termios.c_oflag = tty->termios->c_oflag; + priv->termios.c_cflag = tty->termios->c_cflag; + priv->termios.c_lflag = tty->termios->c_lflag; for (i=0; itermios.c_cc[i] = port->tty->termios->c_cc[i]; + priv->termios.c_cc[i] = tty->termios->c_cc[i]; priv->cfg.pktlen = cfg.pktlen; priv->cfg.baudrate = cfg.baudrate; priv->cfg.databits = cfg.databits; @@ -452,7 +457,8 @@ exit: } /* klsi_105_open */ -static void klsi_105_close (struct usb_serial_port *port, struct file *filp) +static void klsi_105_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct klsi_105_private *priv = usb_get_serial_port_data(port); int rc; @@ -493,8 +499,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ -static int klsi_105_write (struct usb_serial_port *port, - const unsigned char *buf, int count) +static int klsi_105_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct klsi_105_private *priv = usb_get_serial_port_data(port); int result, size; @@ -584,8 +590,9 @@ static void klsi_105_write_bulk_callback ( struct urb *urb) /* return number of characters currently in the writing process */ -static int klsi_105_chars_in_buffer (struct usb_serial_port *port) +static int klsi_105_chars_in_buffer (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int chars = 0; int i; unsigned long flags; @@ -605,8 +612,9 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port) return (chars); } -static int klsi_105_write_room (struct usb_serial_port *port) +static int klsi_105_write_room (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; unsigned long flags; int i; int room = 0; @@ -660,7 +668,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) } else { int bytes_sent = ((__u8 *) data)[0] + ((unsigned int) ((__u8 *) data)[1] << 8); - tty = port->tty; + tty = port->port.tty; /* we should immediately resubmit the URB, before attempting * to pass the data on to the tty layer. But that needs locking * against re-entry an then mixed-up data because of @@ -699,11 +707,11 @@ static void klsi_105_read_bulk_callback (struct urb *urb) } /* klsi_105_read_bulk_callback */ -static void klsi_105_set_termios (struct usb_serial_port *port, +static void klsi_105_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct klsi_105_private *priv = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; unsigned int iflag = tty->termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag; unsigned int cflag = tty->termios->c_cflag; @@ -863,8 +871,9 @@ static void klsi_105_set_termios (struct usb_serial_port *port, #if 0 -static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) +static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct mct_u232_private *priv = (struct mct_u232_private *)port->private; unsigned char lcr = priv->last_lcr; @@ -878,8 +887,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) } /* mct_u232_break_ctl */ #endif -static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) +static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct klsi_105_private *priv = usb_get_serial_port_data(port); unsigned long flags; int rc; @@ -900,7 +910,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) return (int)line_state; } -static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, +static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { int retval = -EINVAL; @@ -929,14 +939,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, return retval; } -static void klsi_105_throttle (struct usb_serial_port *port) +static void klsi_105_throttle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } -static void klsi_105_unthrottle (struct usb_serial_port *port) +static void klsi_105_unthrottle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int result; dbg("%s - port %d", __func__, port->number); diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 693f00da7c0..40c67f0096b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -70,19 +70,22 @@ static int debug; /* Function prototypes */ static int kobil_startup (struct usb_serial *serial); static void kobil_shutdown (struct usb_serial *serial); -static int kobil_open (struct usb_serial_port *port, struct file *filp); -static void kobil_close (struct usb_serial_port *port, struct file *filp); -static int kobil_write (struct usb_serial_port *port, +static int kobil_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int kobil_write_room(struct usb_serial_port *port); -static int kobil_ioctl(struct usb_serial_port *port, struct file *file, +static int kobil_write_room(struct tty_struct *tty); +static int kobil_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); -static int kobil_tiocmget(struct usb_serial_port *port, struct file *file); -static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, +static int kobil_tiocmget(struct tty_struct *tty, struct file *file); +static int kobil_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static void kobil_read_int_callback( struct urb *urb ); static void kobil_write_callback( struct urb *purb ); -static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old); +static void kobil_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); static struct usb_device_id id_table [] = { @@ -201,8 +204,8 @@ static void kobil_shutdown (struct usb_serial *serial) dbg("%s - port %d", __func__, serial->port[0]->number); for (i=0; i < serial->num_ports; ++i) { - while (serial->port[i]->open_count > 0) { - kobil_close (serial->port[i], NULL); + while (serial->port[i]->port.count > 0) { + kobil_close (NULL, serial->port[i], NULL); } kfree(usb_get_serial_port_data(serial->port[i])); usb_set_serial_port_data(serial->port[i], NULL); @@ -210,7 +213,8 @@ static void kobil_shutdown (struct usb_serial *serial) } -static int kobil_open (struct usb_serial_port *port, struct file *filp) +static int kobil_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int result = 0; struct kobil_private *priv; @@ -229,14 +233,15 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) * the data through, otherwise it is scheduled, and with high * data rates (like with OHCI) data can get lost. */ - port->tty->low_latency = 1; - - // without this, every push_tty_char is echoed :-( - port->tty->termios->c_lflag = 0; - port->tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); - port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; - port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) - + if (tty) { + tty->low_latency = 1; + + /* Default to echo off and other sane device settings */ + tty->termios->c_lflag = 0; + tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); + tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; + tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) + } // allocate memory for transfer buffer transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); if (! transfer_buffer) { @@ -330,7 +335,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) } -static void kobil_close (struct usb_serial_port *port, struct file *filp) +static void kobil_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); @@ -360,7 +366,7 @@ static void kobil_read_int_callback(struct urb *urb) return; } - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { // BEGIN DEBUG @@ -395,7 +401,7 @@ static void kobil_write_callback( struct urb *purb ) } -static int kobil_write (struct usb_serial_port *port, +static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { int length = 0; @@ -417,12 +423,9 @@ static int kobil_write (struct usb_serial_port *port, // Copy data to buffer memcpy (priv->buf + priv->filled, buf, count); - usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); - priv->filled = priv->filled + count; - // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { @@ -478,15 +481,17 @@ static int kobil_write (struct usb_serial_port *port, } -static int kobil_write_room (struct usb_serial_port *port) +static int kobil_write_room (struct tty_struct *tty) { //dbg("%s - port %d", __func__, port->number); + /* FIXME */ return 8; } -static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) +static int kobil_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct kobil_private * priv; int result; unsigned char *transfer_buffer; @@ -524,9 +529,10 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) return result; } -static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, +static int kobil_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct kobil_private * priv; int result; int dtr = 0; @@ -590,12 +596,13 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, return (result < 0) ? result : 0; } -static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old) +static void kobil_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old) { struct kobil_private * priv; int result; unsigned short urb_val = 0; - int c_cflag = port->tty->termios->c_cflag; + int c_cflag = tty->termios->c_cflag; speed_t speed; void * settings; @@ -604,7 +611,7 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old // This device doesn't support ioctl calls return; - switch (speed = tty_get_baud_rate(port->tty)) { + switch (speed = tty_get_baud_rate(tty)) { case 1200: urb_val = SUSBCR_SBR_1200; break; @@ -634,8 +641,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old urb_val |= SUSBCR_SPASB_NoParity; strcat(settings, "No Parity"); } - port->tty->termios->c_cflag &= ~CMSPAR; - tty_encode_baud_rate(port->tty, speed, speed); + tty->termios->c_cflag &= ~CMSPAR; + tty_encode_baud_rate(tty, speed, speed); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), @@ -650,8 +657,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old kfree(settings); } -static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) +static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct kobil_private * priv = usb_get_serial_port_data(port); unsigned char *transfer_buffer; int transfer_buffer_length = 8; @@ -662,7 +670,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne return 0; switch (cmd) { - case TCFLSH: // 0x540B + case TCFLSH: transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); if (! transfer_buffer) return -ENOBUFS; @@ -680,7 +688,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); - return (result < 0) ? -EFAULT : 0; + return (result < 0) ? -EIO: 0; default: return -ENOIOCTLCMD; } diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 5fc2cef30e3..7bce4302a5f 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -92,26 +92,25 @@ static int debug; */ static int mct_u232_startup (struct usb_serial *serial); static void mct_u232_shutdown (struct usb_serial *serial); -static int mct_u232_open (struct usb_serial_port *port, +static int mct_u232_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); -static void mct_u232_close (struct usb_serial_port *port, +static void mct_u232_close (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); static void mct_u232_read_int_callback (struct urb *urb); -static void mct_u232_set_termios (struct usb_serial_port *port, +static void mct_u232_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios * old); -static int mct_u232_ioctl (struct usb_serial_port *port, - struct file * file, - unsigned int cmd, - unsigned long arg); -static void mct_u232_break_ctl (struct usb_serial_port *port, +static void mct_u232_break_ctl (struct tty_struct *tty, int break_state ); -static int mct_u232_tiocmget (struct usb_serial_port *port, +static int mct_u232_tiocmget (struct tty_struct *tty, struct file *file); -static int mct_u232_tiocmset (struct usb_serial_port *port, +static int mct_u232_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void mct_u232_throttle (struct usb_serial_port *port); -static void mct_u232_unthrottle (struct usb_serial_port *port); +static void mct_u232_throttle (struct tty_struct *tty); +static void mct_u232_unthrottle (struct tty_struct *tty); /* @@ -149,7 +148,6 @@ static struct usb_serial_driver mct_u232_device = { .throttle = mct_u232_throttle, .unthrottle = mct_u232_unthrottle, .read_int_callback = mct_u232_read_int_callback, - .ioctl = mct_u232_ioctl, .set_termios = mct_u232_set_termios, .break_ctl = mct_u232_break_ctl, .tiocmget = mct_u232_tiocmget, @@ -224,8 +222,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value } } -static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, - speed_t value) +static int mct_u232_set_baud_rate(struct tty_struct *tty, + struct usb_serial *serial, struct usb_serial_port *port, speed_t value) { __le32 divisor; int rc; @@ -243,7 +241,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p if (rc < 0) /*FIXME: What value speed results */ err("Set BAUD RATE %d failed (error = %d)", value, rc); else - tty_encode_baud_rate(port->tty, speed, speed); + tty_encode_baud_rate(tty, speed, speed); dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which @@ -272,7 +270,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p err("Sending USB device request code %d failed (error = %d)", MCT_U232_SET_UNKNOWN1_REQUEST, rc); - if (port && C_CRTSCTS(port->tty)) { + if (port && C_CRTSCTS(tty)) { cts_enable_byte = 1; } @@ -411,7 +409,8 @@ static void mct_u232_shutdown (struct usb_serial *serial) } } /* mct_u232_shutdown */ -static int mct_u232_open (struct usb_serial_port *port, struct file *filp) +static int mct_u232_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; struct mct_u232_private *priv = usb_get_serial_port_data(port); @@ -437,7 +436,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) * either. */ spin_lock_irqsave(&priv->lock, flags); - if (port->tty->termios->c_cflag & CBAUD) + if (tty && (tty->termios->c_cflag & CBAUD)) priv->control_state = TIOCM_DTR | TIOCM_RTS; else priv->control_state = 0; @@ -481,15 +480,16 @@ error: } /* mct_u232_open */ -static void mct_u232_close (struct usb_serial_port *port, struct file *filp) +static void mct_u232_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { unsigned int c_cflag; unsigned int control_state; struct mct_u232_private *priv = usb_get_serial_port_data(port); dbg("%s port %d", __func__, port->number); - if (port->tty) { - c_cflag = port->tty->termios->c_cflag; + if (tty) { + c_cflag = tty->termios->c_cflag; mutex_lock(&port->serial->disc_mutex); if (c_cflag & HUPCL && !port->serial->disconnected) { /* drop DTR and RTS */ @@ -553,7 +553,7 @@ static void mct_u232_read_int_callback (struct urb *urb) */ if (urb->transfer_buffer_length > 2) { int i; - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { for (i = 0; i < urb->actual_length ; ++i) { tty_insert_flip_char(tty, data[i], 0); @@ -583,7 +583,7 @@ static void mct_u232_read_int_callback (struct urb *urb) * to look in to this before committing any code. */ if (priv->last_lsr & MCT_U232_LSR_ERR) { - tty = port->tty; + tty = port->port.tty; /* Overrun Error */ if (priv->last_lsr & MCT_U232_LSR_OE) { } @@ -606,12 +606,13 @@ exit: __func__, retval); } /* mct_u232_read_int_callback */ -static void mct_u232_set_termios (struct usb_serial_port *port, +static void mct_u232_set_termios (struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct mct_u232_private *priv = usb_get_serial_port_data(port); - struct ktermios *termios = port->tty->termios; + struct ktermios *termios = tty->termios; unsigned int cflag = termios->c_cflag; unsigned int old_cflag = old_termios->c_cflag; unsigned long flags; @@ -638,7 +639,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, mct_u232_set_modem_ctrl(serial, control_state); } - mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); + mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); if ((cflag & CBAUD) == B0 ) { dbg("%s: baud is B0", __func__); @@ -689,8 +690,9 @@ static void mct_u232_set_termios (struct usb_serial_port *port, spin_unlock_irqrestore(&priv->lock, flags); } /* mct_u232_set_termios */ -static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) +static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned char lcr; @@ -709,8 +711,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) } /* mct_u232_break_ctl */ -static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) +static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned int control_state; unsigned long flags; @@ -724,9 +727,10 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) return control_state; } -static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, +static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned int control_state; @@ -751,73 +755,46 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, return mct_u232_set_modem_ctrl(serial, control_state); } -static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, - unsigned int cmd, unsigned long arg) -{ - dbg("%scmd=0x%x", __func__, cmd); - - /* Based on code from acm.c and others */ - switch (cmd) { - case TIOCMIWAIT: - /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ - /* TODO */ - return( 0 ); - - case TIOCGICOUNT: - /* return count of modemline transitions */ - /* TODO */ - return 0; - - default: - dbg("%s: arg not supported - 0x%04x", __func__,cmd); - return(-ENOIOCTLCMD); - break; - } - return 0; -} /* mct_u232_ioctl */ - -static void mct_u232_throttle (struct usb_serial_port *port) +static void mct_u232_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned long flags; unsigned int control_state; - struct tty_struct *tty; - tty = port->tty; dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->rx_flags |= THROTTLED; if (C_CRTSCTS(tty)) { - priv->control_state &= ~TIOCM_RTS; - control_state = priv->control_state; - spin_unlock_irqrestore(&priv->lock, flags); - (void) mct_u232_set_modem_ctrl(port->serial, control_state); + priv->control_state &= ~TIOCM_RTS; + control_state = priv->control_state; + spin_unlock_irqrestore(&priv->lock, flags); + (void) mct_u232_set_modem_ctrl(port->serial, control_state); } else { - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } } -static void mct_u232_unthrottle (struct usb_serial_port *port) +static void mct_u232_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned long flags; unsigned int control_state; - struct tty_struct *tty; dbg("%s - port %d", __func__, port->number); - tty = port->tty; spin_lock_irqsave(&priv->lock, flags); if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) { - priv->rx_flags &= ~THROTTLED; - priv->control_state |= TIOCM_RTS; - control_state = priv->control_state; - spin_unlock_irqrestore(&priv->lock, flags); - (void) mct_u232_set_modem_ctrl(port->serial, control_state); + priv->rx_flags &= ~THROTTLED; + priv->control_state |= TIOCM_RTS; + control_state = priv->control_state; + spin_unlock_irqrestore(&priv->lock, flags); + (void) mct_u232_set_modem_ctrl(port->serial, control_state); } else { - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } } diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 50f1fe26333..d47f0814ce2 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -218,7 +218,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) data = urb->transfer_buffer; - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -264,7 +264,7 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) dbg("Entering ........."); - tty = mos7720_port->port->tty; + tty = mos7720_port->port->port.tty; if (tty && mos7720_port->open) tty_wakeup(tty); @@ -320,7 +320,8 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, return status; } -static int mos7720_open(struct usb_serial_port *port, struct file * filp) +static int mos7720_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct usb_serial *serial; struct usb_serial_port *port0; @@ -443,14 +444,12 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) data = 0x0c; send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); -//Matrix - /* force low_latency on so that our tty_push actually forces * * the data through,otherwise it is scheduled, and with * * high data rates (like with OHCI) data can get lost. */ - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* see if we've set up our endpoint info yet * * (can't set it up in mos7720_startup as the * @@ -515,8 +514,9 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) * system, * Otherwise we return a negative error number. */ -static int mos7720_chars_in_buffer(struct usb_serial_port *port) +static int mos7720_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int i; int chars = 0; struct moschip_port *mos7720_port; @@ -537,7 +537,8 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port) return chars; } -static void mos7720_close(struct usb_serial_port *port, struct file *filp) +static void mos7720_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; struct moschip_port *mos7720_port; @@ -588,8 +589,9 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp) dbg("Leaving %s", __func__); } -static void mos7720_break(struct usb_serial_port *port, int break_state) +static void mos7720_break(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; unsigned char data; struct usb_serial *serial; struct moschip_port *mos7720_port; @@ -621,8 +623,9 @@ static void mos7720_break(struct usb_serial_port *port, int break_state) * If successful, we return the amount of room that we have for this port * Otherwise we return a negative error number. */ -static int mos7720_write_room(struct usb_serial_port *port) +static int mos7720_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7720_port; int room = 0; int i; @@ -645,8 +648,8 @@ static int mos7720_write_room(struct usb_serial_port *port) return room; } -static int mos7720_write(struct usb_serial_port *port, - const unsigned char *data, int count) +static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *data, int count) { int status; int i; @@ -719,10 +722,10 @@ exit: return bytes_sent; } -static void mos7720_throttle(struct usb_serial_port *port) +static void mos7720_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7720_port; - struct tty_struct *tty; int status; dbg("%s- port %d\n", __func__, port->number); @@ -739,16 +742,10 @@ static void mos7720_throttle(struct usb_serial_port *port) dbg("%s: Entering ..........", __func__); - tty = port->tty; - if (!tty) { - dbg("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = mos7720_write(port, &stop_char, 1); + status = mos7720_write(tty, port, &stop_char, 1); if (status <= 0) return; } @@ -764,11 +761,11 @@ static void mos7720_throttle(struct usb_serial_port *port) } } -static void mos7720_unthrottle(struct usb_serial_port *port) +static void mos7720_unthrottle(struct tty_struct *tty) { - struct tty_struct *tty; - int status; + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7720_port = usb_get_serial_port_data(port); + int status; if (mos7720_port == NULL) return; @@ -780,16 +777,10 @@ static void mos7720_unthrottle(struct usb_serial_port *port) dbg("%s: Entering ..........", __func__); - tty = port->tty; - if (!tty) { - dbg("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); - status = mos7720_write(port, &start_char, 1); + status = mos7720_write(tty, port, &start_char, 1); if (status <= 0) return; } @@ -1011,12 +1002,12 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, * This routine is called to set the UART on the device to match * the specified new settings. */ -static void change_port_settings(struct moschip_port *mos7720_port, +static void change_port_settings(struct tty_struct *tty, + struct moschip_port *mos7720_port, struct ktermios *old_termios) { struct usb_serial_port *port; struct usb_serial *serial; - struct tty_struct *tty; int baud; unsigned cflag; unsigned iflag; @@ -1042,8 +1033,6 @@ static void change_port_settings(struct moschip_port *mos7720_port, return; } - tty = mos7720_port->port->tty; - dbg("%s: Entering ..........", __func__); lData = UART_LCR_WLEN8; @@ -1198,14 +1187,13 @@ static void change_port_settings(struct moschip_port *mos7720_port, * this function is called by the tty driver when it wants to change the * termios structure. */ -static void mos7720_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +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; - struct tty_struct *tty; serial = port->serial; @@ -1214,9 +1202,6 @@ static void mos7720_set_termios(struct usb_serial_port *port, if (mos7720_port == NULL) return; - tty = port->tty; - - if (!mos7720_port->open) { dbg("%s - port not opened", __func__); return; @@ -1237,7 +1222,7 @@ static void mos7720_set_termios(struct usb_serial_port *port, dbg("%s - port %d", __func__, port->number); /* change the port settings to the new ones specified */ - change_port_settings(mos7720_port, old_termios); + change_port_settings(tty, mos7720_port, old_termios); if(!port->read_urb) { dbg("%s","URB KILLED !!!!!\n"); @@ -1264,13 +1249,13 @@ static void mos7720_set_termios(struct usb_serial_port *port, * transmit holding register is empty. This functionality * allows an RS485 driver to be written in user space. */ -static int get_lsr_info(struct moschip_port *mos7720_port, +static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port, unsigned int __user *value) { int count; unsigned int result = 0; - count = mos7720_chars_in_buffer(mos7720_port->port); + count = mos7720_chars_in_buffer(tty); if (count == 0) { dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; @@ -1290,7 +1275,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port, unsigned int __user *value) { unsigned int result = 0; - struct tty_struct *tty = mos7720_port->port->tty; + struct tty_struct *tty = mos7720_port->port->port.tty; if (!tty) return -ENOIOCTLCMD; @@ -1407,9 +1392,10 @@ static int get_serial_info(struct moschip_port *mos7720_port, return 0; } -static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, +static int mos7720_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7720_port; struct async_icount cnow; struct async_icount cprev; @@ -1431,9 +1417,10 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, case TIOCSERGETLSR: dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); - return get_lsr_info(mos7720_port, (unsigned int __user *)arg); + return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg); return 0; + /* FIXME: These should be using the mode methods */ case TIOCMBIS: case TIOCMBIC: case TIOCMSET: @@ -1452,10 +1439,6 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, return get_serial_info(mos7720_port, (struct serial_struct __user *)arg); - case TIOCSSERIAL: - dbg("%s (%d) TIOCSSERIAL", __func__, port->number); - break; - case TIOCMIWAIT: dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = mos7720_port->icount; diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 78f2f6db494..2b1fded6619 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -710,7 +710,7 @@ static void mos7840_bulk_in_callback(struct urb *urb) dbg("%s", "Entering ........... \n"); if (urb->actual_length) { - tty = mos7840_port->port->tty; + tty = mos7840_port->port->port.tty; if (tty) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -774,7 +774,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) dbg("%s \n", "Entering ........."); - tty = mos7840_port->port->tty; + tty = mos7840_port->port->port.tty; if (tty && mos7840_port->open) tty_wakeup(tty); @@ -804,7 +804,8 @@ static int mos7840_serial_probe(struct usb_serial *serial, * Otherwise we return a negative error number. *****************************************************************************/ -static int mos7840_open(struct usb_serial_port *port, struct file *filp) +static int mos7840_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int response; int j; @@ -1008,8 +1009,8 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) * the data through,otherwise it is scheduled, and with * * high data rates (like with OHCI) data can get lost. */ - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* Check to see if we've set up our endpoint info yet * * (can't set it up in mos7840_startup as the structures * * were not set up at that time.) */ @@ -1104,11 +1105,12 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp) * been written, but hasn't made it out the port yet) * If successful, we return the number of bytes left to be written in the * system, - * Otherwise we return a negative error number. + * Otherwise we return zero. *****************************************************************************/ -static int mos7840_chars_in_buffer(struct usb_serial_port *port) +static int mos7840_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int i; int chars = 0; unsigned long flags; @@ -1118,21 +1120,19 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port) if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); - return -1; + return 0; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) { dbg("%s \n", "mos7840_break:leaving ..........."); - return -1; + return 0; } spin_lock_irqsave(&mos7840_port->pool_lock,flags); - for (i = 0; i < NUM_URBS; ++i) { - if (mos7840_port->busy[i]) { + for (i = 0; i < NUM_URBS; ++i) + if (mos7840_port->busy[i]) chars += URB_TRANSFER_BUFFER_SIZE; - } - } spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); dbg("%s - returns %d", __func__, chars); return chars; @@ -1149,7 +1149,8 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port) * 3. A timeout of 3 seconds without activity has expired * ************************************************************************/ -static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) +static void mos7840_block_until_tx_empty(struct tty_struct *tty, + struct moschip_port *mos7840_port) { int timeout = HZ / 10; int wait = 30; @@ -1157,7 +1158,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) while (1) { - count = mos7840_chars_in_buffer(mos7840_port->port); + count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ if (count <= 0) { @@ -1185,7 +1186,8 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) * this function is called by the tty driver when a port is closed *****************************************************************************/ -static void mos7840_close(struct usb_serial_port *port, struct file *filp) +static void mos7840_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; struct moschip_port *mos7840_port; @@ -1226,20 +1228,17 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp) } } - if (serial->dev) { + if (serial->dev) /* flush and block until tx is empty */ - mos7840_block_until_tx_empty(mos7840_port); - } + mos7840_block_until_tx_empty(tty, mos7840_port); /* While closing port, shutdown all bulk read, write * * and interrupt read if they exists */ if (serial->dev) { - if (mos7840_port->write_urb) { dbg("%s", "Shutdown bulk write\n"); usb_kill_urb(mos7840_port->write_urb); } - if (mos7840_port->read_urb) { dbg("%s", "Shutdown bulk read\n"); usb_kill_urb(mos7840_port->read_urb); @@ -1247,11 +1246,10 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp) if ((&mos7840_port->control_urb)) { dbg("%s", "Shutdown control read\n"); // usb_kill_urb (mos7840_port->control_urb); - } } -// if(mos7840_port->ctrl_buf != NULL) -// kfree(mos7840_port->ctrl_buf); +// if(mos7840_port->ctrl_buf != NULL) +// kfree(mos7840_port->ctrl_buf); port0->open_ports--; dbg("mos7840_num_open_ports in close%d:in port%d\n", port0->open_ports, port->number); @@ -1293,15 +1291,15 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp) * ************************************************************************/ -static void mos7840_block_until_chase_response(struct moschip_port - *mos7840_port) +static void mos7840_block_until_chase_response(struct tty_struct *tty, + struct moschip_port *mos7840_port) { int timeout = 1 * HZ; int wait = 10; int count; while (1) { - count = mos7840_chars_in_buffer(mos7840_port->port); + count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ if (count <= 0) { @@ -1328,8 +1326,9 @@ static void mos7840_block_until_chase_response(struct moschip_port * mos7840_break * this function sends a break to the port *****************************************************************************/ -static void mos7840_break(struct usb_serial_port *port, int break_state) +static void mos7840_break(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; unsigned char data; struct usb_serial *serial; struct moschip_port *mos7840_port; @@ -1354,17 +1353,14 @@ static void mos7840_break(struct usb_serial_port *port, int break_state) return; } - if (serial->dev) { - + if (serial->dev) /* flush and block until tx is empty */ - mos7840_block_until_chase_response(mos7840_port); - } + mos7840_block_until_chase_response(tty, mos7840_port); - if (break_state == -1) { + if (break_state == -1) data = mos7840_port->shadowLCR | LCR_SET_BREAK; - } else { + else data = mos7840_port->shadowLCR & ~LCR_SET_BREAK; - } mos7840_port->shadowLCR = data; dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", @@ -1383,8 +1379,9 @@ static void mos7840_break(struct usb_serial_port *port, int break_state) * Otherwise we return a negative error number. *****************************************************************************/ -static int mos7840_write_room(struct usb_serial_port *port) +static int mos7840_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int i; int room = 0; unsigned long flags; @@ -1426,7 +1423,7 @@ static int mos7840_write_room(struct usb_serial_port *port) * return a negative error number. *****************************************************************************/ -static int mos7840_write(struct usb_serial_port *port, +static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *data, int count) { int status; @@ -1555,8 +1552,7 @@ static int mos7840_write(struct usb_serial_port *port, mos7840_port->icount.tx += transfer_size; smp_wmb(); dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); - exit: - +exit: return bytes_sent; } @@ -1567,10 +1563,10 @@ static int mos7840_write(struct usb_serial_port *port, * being read from the port. *****************************************************************************/ -static void mos7840_throttle(struct usb_serial_port *port) +static void mos7840_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; - struct tty_struct *tty; int status; if (mos7840_port_paranoia_check(port, __func__)) { @@ -1592,32 +1588,21 @@ static void mos7840_throttle(struct usb_serial_port *port) dbg("%s", "Entering .......... \n"); - tty = port->tty; - if (!tty) { - dbg("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = mos7840_write(port, &stop_char, 1); - if (status <= 0) { + status = mos7840_write(tty, port, &stop_char, 1); + if (status <= 0) return; - } } - /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR &= ~MCR_RTS; status = 0; - status = - mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, + status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); - - if (status < 0) { + if (status < 0) return; - } } return; @@ -1628,9 +1613,9 @@ static void mos7840_throttle(struct usb_serial_port *port) * this function is called by the tty driver when it wants to resume the data * being read from the port (called after SerialThrottle is called) *****************************************************************************/ -static void mos7840_unthrottle(struct usb_serial_port *port) +static void mos7840_unthrottle(struct tty_struct *tty) { - struct tty_struct *tty; + struct usb_serial_port *port = tty->driver_data; int status; struct moschip_port *mos7840_port = mos7840_get_port_private(port); @@ -1649,38 +1634,28 @@ static void mos7840_unthrottle(struct usb_serial_port *port) dbg("%s", "Entering .......... \n"); - tty = port->tty; - if (!tty) { - dbg("%s - no tty available", __func__); - return; - } - /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); - status = mos7840_write(port, &start_char, 1); - if (status <= 0) { + status = mos7840_write(tty, port, &start_char, 1); + if (status <= 0) return; - } } /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR |= MCR_RTS; status = 0; - status = - mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, + status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); - if (status < 0) { + if (status < 0) return; - } } - - return; } -static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) +static int mos7840_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; unsigned int result; __u16 msr; @@ -1708,9 +1683,10 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) return result; } -static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, +static int mos7840_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; unsigned int mcr; int status; @@ -1949,10 +1925,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, * the specified new settings. *****************************************************************************/ -static void mos7840_change_port_settings(struct moschip_port *mos7840_port, - struct ktermios *old_termios) +static void mos7840_change_port_settings(struct tty_struct *tty, + struct moschip_port *mos7840_port, struct ktermios *old_termios) { - struct tty_struct *tty; int baud; unsigned cflag; unsigned iflag; @@ -1988,8 +1963,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, return; } - tty = mos7840_port->port->tty; - dbg("%s", "Entering .......... \n"); lData = LCR_BITS_8; @@ -2131,14 +2104,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, * the termios structure *****************************************************************************/ -static void mos7840_set_termios(struct usb_serial_port *port, +static void mos7840_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 *mos7840_port; - struct tty_struct *tty; dbg("mos7840_set_termios: START\n"); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); @@ -2157,8 +2130,6 @@ static void mos7840_set_termios(struct usb_serial_port *port, if (mos7840_port == NULL) return; - tty = port->tty; - if (!mos7840_port->open) { dbg("%s - port not opened", __func__); return; @@ -2176,7 +2147,7 @@ static void mos7840_set_termios(struct usb_serial_port *port, /* change the port settings to the new ones specified */ - mos7840_change_port_settings(mos7840_port, old_termios); + mos7840_change_port_settings(tty, mos7840_port, old_termios); if (!mos7840_port->read_urb) { dbg("%s", "URB KILLED !!!!!\n"); @@ -2205,13 +2176,13 @@ static void mos7840_set_termios(struct usb_serial_port *port, * allows an RS485 driver to be written in user space. *****************************************************************************/ -static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, +static int mos7840_get_lsr_info(struct tty_struct *tty, unsigned int __user *value) { int count; unsigned int result = 0; - count = mos7840_chars_in_buffer(mos7840_port->port); + count = mos7840_chars_in_buffer(tty); if (count == 0) { dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; @@ -2227,6 +2198,8 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, * function to set modem info *****************************************************************************/ +/* FIXME: Should be using the model control hooks */ + static int mos7840_set_modem_info(struct moschip_port *mos7840_port, unsigned int cmd, unsigned int __user *value) { @@ -2304,9 +2277,8 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port, __u16 msr; unsigned int mcr = mos7840_port->shadowMCR; int status = 0; - status = - mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER, - &msr); + status = mos7840_get_uart_reg(mos7840_port->port, + MODEM_STATUS_REGISTER, &msr); result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */ @@ -2359,12 +2331,12 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port, * this function handles any ioctl calls to the driver *****************************************************************************/ -static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, +static int mos7840_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; void __user *argp = (void __user *)arg; struct moschip_port *mos7840_port; - struct tty_struct *tty; struct async_icount cnow; struct async_icount cprev; @@ -2381,8 +2353,6 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, if (mos7840_port == NULL) return -1; - tty = mos7840_port->port->tty; - dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { @@ -2390,9 +2360,10 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, case TIOCSERGETLSR: dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); - return mos7840_get_lsr_info(mos7840_port, argp); + return mos7840_get_lsr_info(tty, argp); return 0; + /* FIXME: use the modem hooks and remove this */ case TIOCMBIS: case TIOCMBIC: case TIOCMSET: @@ -2463,13 +2434,9 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, if (copy_to_user(argp, &icount, sizeof(icount))) return -EFAULT; return 0; - - case TIOCEXBAUD: - return 0; default: break; } - return -ENOIOCTLCMD; } diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index 43c8894353b..d6736531a0f 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c @@ -64,7 +64,7 @@ static void navman_read_int_callback(struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -79,7 +79,8 @@ exit: __func__, result); } -static int navman_open(struct usb_serial_port *port, struct file *filp) +static int navman_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int result = 0; @@ -96,14 +97,15 @@ static int navman_open(struct usb_serial_port *port, struct file *filp) return result; } -static void navman_close(struct usb_serial_port *port, struct file *filp) +static void navman_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->interrupt_in_urb); } -static int navman_write(struct usb_serial_port *port, +static int navman_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { dbg("%s - port %d", __func__, port->number); diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 7b7422f4947..5a2d045562f 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -61,12 +61,12 @@ static int debug; #define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */ /* function prototypes */ -static int omninet_open (struct usb_serial_port *port, struct file *filp); -static void omninet_close (struct usb_serial_port *port, struct file *filp); +static int omninet_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void omninet_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); static void omninet_read_bulk_callback (struct urb *urb); static void omninet_write_bulk_callback (struct urb *urb); -static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int omninet_write_room (struct usb_serial_port *port); +static int omninet_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); +static int omninet_write_room (struct tty_struct *tty); static void omninet_shutdown (struct usb_serial *serial); static int omninet_attach (struct usb_serial *serial); @@ -157,7 +157,8 @@ static int omninet_attach (struct usb_serial *serial) return 0; } -static int omninet_open (struct usb_serial_port *port, struct file *filp) +static int omninet_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; struct usb_serial_port *wport; @@ -166,7 +167,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) dbg("%s - port %d", __func__, port->number); wport = serial->port[1]; - wport->tty = port->tty; + wport->port.tty = tty; /* FIXME */ /* Start reading from the device */ usb_fill_bulk_urb(port->read_urb, serial->dev, @@ -181,7 +182,8 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) return result; } -static void omninet_close (struct usb_serial_port *port, struct file * filp) +static void omninet_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); @@ -221,9 +223,9 @@ static void omninet_read_bulk_callback (struct urb *urb) if (urb->actual_length && header->oh_len) { for (i = 0; i < header->oh_len; i++) { - tty_insert_flip_char(port->tty, data[OMNINET_DATAOFFSET + i], 0); + tty_insert_flip_char(port->port.tty, data[OMNINET_DATAOFFSET + i], 0); } - tty_flip_buffer_push(port->tty); + tty_flip_buffer_push(port->port.tty); } /* Continue trying to always read */ @@ -238,7 +240,8 @@ static void omninet_read_bulk_callback (struct urb *urb) return; } -static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct usb_serial_port *wport = serial->port[1]; @@ -290,8 +293,9 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf } -static int omninet_write_room (struct usb_serial_port *port) +static int omninet_write_room (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; struct usb_serial_port *wport = serial->port[1]; diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 1e936a1cbe0..4350990abf1 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -43,29 +43,23 @@ #include /* Function prototypes */ -static int option_open(struct usb_serial_port *port, struct file *filp); -static void option_close(struct usb_serial_port *port, struct file *filp); +static int option_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void option_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); static int option_startup(struct usb_serial *serial); static void option_shutdown(struct usb_serial *serial); -static void option_rx_throttle(struct usb_serial_port *port); -static void option_rx_unthrottle(struct usb_serial_port *port); -static int option_write_room(struct usb_serial_port *port); +static int option_write_room(struct tty_struct *tty); static void option_instat_callback(struct urb *urb); -static int option_write(struct usb_serial_port *port, +static int option_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); - -static int option_chars_in_buffer(struct usb_serial_port *port); -static int option_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg); -static void option_set_termios(struct usb_serial_port *port, - struct ktermios *old); -static void option_break_ctl(struct usb_serial_port *port, int break_state); -static int option_tiocmget(struct usb_serial_port *port, struct file *file); -static int option_tiocmset(struct usb_serial_port *port, struct file *file, +static int option_chars_in_buffer(struct tty_struct *tty); +static void option_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static int option_tiocmget(struct tty_struct *tty, struct file *file); +static int option_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static int option_send_setup(struct usb_serial_port *port); +static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port); /* Vendor and product IDs */ #define OPTION_VENDOR_ID 0x0AF0 @@ -342,11 +336,7 @@ static struct usb_serial_driver option_1port_device = { .write = option_write, .write_room = option_write_room, .chars_in_buffer = option_chars_in_buffer, - .throttle = option_rx_throttle, - .unthrottle = option_rx_unthrottle, - .ioctl = option_ioctl, .set_termios = option_set_termios, - .break_ctl = option_break_ctl, .tiocmget = option_tiocmget, .tiocmset = option_tiocmset, .attach = option_startup, @@ -417,33 +407,18 @@ static void __exit option_exit(void) module_init(option_init); module_exit(option_exit); -static void option_rx_throttle(struct usb_serial_port *port) -{ - dbg("%s", __func__); -} - -static void option_rx_unthrottle(struct usb_serial_port *port) -{ - dbg("%s", __func__); -} - -static void option_break_ctl(struct usb_serial_port *port, int break_state) -{ - /* Unfortunately, I don't know how to send a break */ - dbg("%s", __func__); -} - -static void option_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void option_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s", __func__); /* Doesn't support option setting */ - tty_termios_copy_hw(port->tty->termios, old_termios); - option_send_setup(port); + tty_termios_copy_hw(tty->termios, old_termios); + option_send_setup(tty, port); } -static int option_tiocmget(struct usb_serial_port *port, struct file *file) +static int option_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; unsigned int value; struct option_port_private *portdata; @@ -459,9 +434,10 @@ static int option_tiocmget(struct usb_serial_port *port, struct file *file) return value; } -static int option_tiocmset(struct usb_serial_port *port, struct file *file, +static int option_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct option_port_private *portdata; portdata = usb_get_serial_port_data(port); @@ -476,17 +452,11 @@ static int option_tiocmset(struct usb_serial_port *port, struct file *file, portdata->rts_state = 0; if (clear & TIOCM_DTR) portdata->dtr_state = 0; - return option_send_setup(port); -} - -static int option_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) -{ - return -ENOIOCTLCMD; + return option_send_setup(tty, port); } /* Write */ -static int option_write(struct usb_serial_port *port, +static int option_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct option_port_private *portdata; @@ -562,7 +532,7 @@ static void option_indat_callback(struct urb *urb) dbg("%s: nonzero status: %d on endpoint %02x.", __func__, status, endpoint); } else { - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -572,7 +542,7 @@ static void option_indat_callback(struct urb *urb) } /* Resubmit urb so we continue receiving */ - if (port->open_count && status != -ESHUTDOWN) { + if (port->port.count && status != -ESHUTDOWN) { err = usb_submit_urb(urb, GFP_ATOMIC); if (err) printk(KERN_ERR "%s: resubmit read urb failed. " @@ -638,9 +608,9 @@ static void option_instat_callback(struct urb *urb) portdata->dsr_state = ((signals & 0x02) ? 1 : 0); portdata->ri_state = ((signals & 0x08) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) && + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state && !portdata->dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); } else { dbg("%s: type %x req %x", __func__, req_pkt->bRequestType,req_pkt->bRequest); @@ -658,8 +628,9 @@ static void option_instat_callback(struct urb *urb) } } -static int option_write_room(struct usb_serial_port *port) +static int option_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct option_port_private *portdata; int i; int data_len = 0; @@ -678,8 +649,9 @@ static int option_write_room(struct usb_serial_port *port) return data_len; } -static int option_chars_in_buffer(struct usb_serial_port *port) +static int option_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct option_port_private *portdata; int i; int data_len = 0; @@ -698,7 +670,8 @@ static int option_chars_in_buffer(struct usb_serial_port *port) return data_len; } -static int option_open(struct usb_serial_port *port, struct file *filp) +static int option_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct option_port_private *portdata; struct usb_serial *serial = port->serial; @@ -748,14 +721,16 @@ static int option_open(struct usb_serial_port *port, struct file *filp) usb_pipeout(urb->pipe), 0); */ } - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; - option_send_setup(port); + option_send_setup(tty, port); return (0); } -static void option_close(struct usb_serial_port *port, struct file *filp) +static void option_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int i; struct usb_serial *serial = port->serial; @@ -770,7 +745,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp) if (serial->dev) { mutex_lock(&serial->disc_mutex); if (!serial->disconnected) - option_send_setup(port); + option_send_setup(tty, port); mutex_unlock(&serial->disc_mutex); /* Stop reading/writing urbs */ @@ -779,7 +754,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp) for (i = 0; i < N_OUT_URB; i++) usb_kill_urb(portdata->out_urbs[i]); } - port->tty = NULL; + port->port.tty = NULL; /* FIXME */ } /* Helper functions used by option_setup_urbs */ @@ -841,7 +816,8 @@ static void option_setup_urbs(struct usb_serial *serial) * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN * CDC. */ -static int option_send_setup(struct usb_serial_port *port) +static int option_send_setup(struct tty_struct *tty, + struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct option_port_private *portdata; @@ -850,7 +826,7 @@ static int option_send_setup(struct usb_serial_port *port) portdata = usb_get_serial_port_data(port); - if (port->tty) { + if (tty) { int val = 0; if (portdata->dtr_state) val |= 0x01; @@ -861,7 +837,6 @@ static int option_send_setup(struct usb_serial_port *port) usb_rcvctrlpipe(serial->dev, 0), 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT); } - return 0; } diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index a9625c180dc..069d276a527 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c @@ -140,22 +140,23 @@ struct oti6858_control_pkt { && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) ) /* function prototypes */ -static int oti6858_open(struct usb_serial_port *port, struct file *filp); -static void oti6858_close(struct usb_serial_port *port, struct file *filp); -static void oti6858_set_termios(struct usb_serial_port *port, - struct ktermios *old); -static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, +static int oti6858_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void oti6858_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void oti6858_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static int oti6858_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); static void oti6858_read_int_callback(struct urb *urb); static void oti6858_read_bulk_callback(struct urb *urb); static void oti6858_write_bulk_callback(struct urb *urb); -static int oti6858_write(struct usb_serial_port *port, +static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int oti6858_write_room(struct usb_serial_port *port); -static void oti6858_break_ctl(struct usb_serial_port *port, int break_state); -static int oti6858_chars_in_buffer(struct usb_serial_port *port); -static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file); -static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file, +static int oti6858_write_room(struct tty_struct *tty); +static int oti6858_chars_in_buffer(struct tty_struct *tty); +static int oti6858_tiocmget(struct tty_struct *tty, struct file *file); +static int oti6858_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static int oti6858_startup(struct usb_serial *serial); static void oti6858_shutdown(struct usb_serial *serial); @@ -184,7 +185,6 @@ static struct usb_serial_driver oti6858_device = { .close = oti6858_close, .write = oti6858_write, .ioctl = oti6858_ioctl, - .break_ctl = oti6858_break_ctl, .set_termios = oti6858_set_termios, .tiocmget = oti6858_tiocmget, .tiocmset = oti6858_tiocmset, @@ -395,7 +395,7 @@ static int oti6858_startup(struct usb_serial *serial) return -ENOMEM; } -static int oti6858_write(struct usb_serial_port *port, +static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct oti6858_private *priv = usb_get_serial_port_data(port); @@ -413,8 +413,9 @@ static int oti6858_write(struct usb_serial_port *port, return count; } -static int oti6858_write_room(struct usb_serial_port *port) +static int oti6858_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct oti6858_private *priv = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -428,8 +429,9 @@ static int oti6858_write_room(struct usb_serial_port *port) return room; } -static int oti6858_chars_in_buffer(struct usb_serial_port *port) +static int oti6858_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct oti6858_private *priv = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; @@ -443,8 +445,8 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port) return chars; } -static void oti6858_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void oti6858_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct oti6858_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -455,22 +457,22 @@ static void oti6858_set_termios(struct usb_serial_port *port, dbg("%s(port = %d)", __func__, port->number); - if (!port->tty || !port->tty->termios) { + if (!tty) { dbg("%s(): no tty structures", __func__); return; } spin_lock_irqsave(&priv->lock, flags); if (!priv->flags.termios_initialized) { - *(port->tty->termios) = tty_std_termios; - port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; + *(tty->termios) = tty_std_termios; + tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 38400; + tty->termios->c_ospeed = 38400; priv->flags.termios_initialized = 1; - port->tty->termios->c_ispeed = 38400; - port->tty->termios->c_ospeed = 38400; } spin_unlock_irqrestore(&priv->lock, flags); - cflag = port->tty->termios->c_cflag; + cflag = tty->termios->c_cflag; spin_lock_irqsave(&priv->lock, flags); divisor = priv->pending_setup.divisor; @@ -500,7 +502,7 @@ static void oti6858_set_termios(struct usb_serial_port *port, * guarantee that any other baud rate will work (especially * the higher ones) */ - br = tty_get_baud_rate(port->tty); + br = tty_get_baud_rate(tty); if (br == 0) { divisor = 0; } else { @@ -511,7 +513,7 @@ static void oti6858_set_termios(struct usb_serial_port *port, new_divisor = (96000000 + 8 * br) / (16 * br); real_br = 96000000 / (16 * new_divisor); divisor = cpu_to_le16(new_divisor); - tty_encode_baud_rate(port->tty, real_br, real_br); + tty_encode_baud_rate(tty, real_br, real_br); } frame_fmt &= ~FMT_STOP_BITS_MASK; @@ -564,7 +566,8 @@ static void oti6858_set_termios(struct usb_serial_port *port, spin_unlock_irqrestore(&priv->lock, flags); } -static int oti6858_open(struct usb_serial_port *port, struct file *filp) +static int oti6858_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct oti6858_private *priv = usb_get_serial_port_data(port); struct ktermios tmp_termios; @@ -578,7 +581,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp) usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe); - if (port->open_count != 1) + if (port->port.count != 1) return 0; if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { @@ -617,18 +620,19 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp) if (result != 0) { dev_err(&port->dev, "%s(): usb_submit_urb() failed" " with error %d\n", __func__, result); - oti6858_close(port, NULL); + oti6858_close(tty, port, NULL); return -EPROTO; } /* setup termios */ - if (port->tty) - oti6858_set_termios(port, &tmp_termios); + if (tty) + oti6858_set_termios(tty, port, &tmp_termios); return 0; } -static void oti6858_close(struct usb_serial_port *port, struct file *filp) +static void oti6858_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct oti6858_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -641,7 +645,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */ init_waitqueue_entry(&wait, current); - add_wait_queue(&port->tty->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); dbg("%s(): entering wait loop", __func__); for (;;) { set_current_state(TASK_INTERRUPTIBLE); @@ -654,7 +658,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); } set_current_state(TASK_RUNNING); - remove_wait_queue(&port->tty->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); dbg("%s(): after wait loop", __func__); /* clear out any remaining data in the buffer */ @@ -669,7 +673,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) /* data is in the buffer to compute a delay */ /* that is not unnecessarily long) */ /* FIXME - bps = tty_get_baud_rate(port->tty); + bps = tty_get_baud_rate(tty); if (bps > 1200) timeout = max((HZ*2560)/bps,HZ/10); else @@ -690,7 +694,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) usb_kill_urb(port->interrupt_in_urb); /* - if (port->tty && (port->tty->termios->c_cflag) & HUPCL) { + if (tty && (tty->termios->c_cflag) & HUPCL) { // drop DTR and RTS spin_lock_irqsave(&priv->lock, flags); priv->pending_setup.control &= ~CONTROL_MASK; @@ -699,9 +703,10 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp) */ } -static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file, +static int oti6858_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct oti6858_private *priv = usb_get_serial_port_data(port); unsigned long flags; u8 control; @@ -732,8 +737,9 @@ static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file, return 0; } -static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file) +static int oti6858_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct oti6858_private *priv = usb_get_serial_port_data(port); unsigned long flags; unsigned pin_state; @@ -802,26 +808,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) return 0; } -static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, +static int oti6858_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { - void __user *user_arg = (void __user *) arg; - unsigned int x; + struct usb_serial_port *port = tty->driver_data; dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", __func__, port->number, cmd, arg); switch (cmd) { - case TIOCMBIS: - if (copy_from_user(&x, user_arg, sizeof(x))) - return -EFAULT; - return oti6858_tiocmset(port, NULL, x, 0); - - case TIOCMBIC: - if (copy_from_user(&x, user_arg, sizeof(x))) - return -EFAULT; - return oti6858_tiocmset(port, NULL, 0, x); - case TIOCMIWAIT: dbg("%s(): TIOCMIWAIT", __func__); return wait_modem_info(port, arg); @@ -834,24 +829,6 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static void oti6858_break_ctl(struct usb_serial_port *port, int break_state) -{ - int state; - - dbg("%s(port = %d)", __func__, port->number); - - state = (break_state == 0) ? 0 : 1; - dbg("%s(): turning break %s", __func__, state ? "on" : "off"); - - /* FIXME */ -/* - result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0), - BREAK_REQUEST, BREAK_REQUEST_TYPE, state, - 0, NULL, 0, 100); - if (result != 0) - dbg("%s(): error sending break", __func__); - */ -} static void oti6858_shutdown(struct usb_serial *serial) { @@ -1002,7 +979,7 @@ static void oti6858_read_bulk_callback(struct urb *urb) spin_unlock_irqrestore(&priv->lock, flags); if (status != 0) { - if (!port->open_count) { + if (!port->port.count) { dbg("%s(): port is closed, exiting", __func__); return; } @@ -1020,14 +997,14 @@ static void oti6858_read_bulk_callback(struct urb *urb) return; } - tty = port->tty; + tty = port->port.tty; if (tty != NULL && urb->actual_length > 0) { tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } // schedule the interrupt urb if we are still open */ - if (port->open_count != 0) { + if (port->port.count != 0) { port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result != 0) { diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 2a0dd1b50dc..a0016725d31 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -458,8 +458,8 @@ static void pl2303_send(struct usb_serial_port *port) usb_serial_port_softint(port); } -static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf, - int count) +static int pl2303_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -478,8 +478,9 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf, return count; } -static int pl2303_write_room(struct usb_serial_port *port) +static int pl2303_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct pl2303_private *priv = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -494,8 +495,9 @@ static int pl2303_write_room(struct usb_serial_port *port) return room; } -static int pl2303_chars_in_buffer(struct usb_serial_port *port) +static int pl2303_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct pl2303_private *priv = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; @@ -510,8 +512,8 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port) return chars; } -static void pl2303_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void pl2303_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct pl2303_private *priv = usb_get_serial_port_data(port); @@ -526,11 +528,10 @@ static void pl2303_set_termios(struct usb_serial_port *port, spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { - *(port->tty->termios) = tty_std_termios; - port->tty->termios->c_cflag = B9600 | CS8 | CREAD | - HUPCL | CLOCAL; - port->tty->termios->c_ispeed = 9600; - port->tty->termios->c_ospeed = 9600; + *(tty->termios) = tty_std_termios; + tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 9600; + tty->termios->c_ospeed = 9600; priv->termios_initialized = 1; } spin_unlock_irqrestore(&priv->lock, flags); @@ -539,16 +540,16 @@ static void pl2303_set_termios(struct usb_serial_port *port, serial settings even to the same values as before. Thus we actually need to filter in this specific case */ - if (!tty_termios_hw_change(port->tty->termios, old_termios)) + if (!tty_termios_hw_change(tty->termios, old_termios)) return; - cflag = port->tty->termios->c_cflag; + cflag = tty->termios->c_cflag; buf = kzalloc(7, GFP_KERNEL); if (!buf) { dev_err(&port->dev, "%s - out of memory.\n", __func__); /* Report back no change occurred */ - *port->tty->termios = *old_termios; + *tty->termios = *old_termios; return; } @@ -569,7 +570,7 @@ static void pl2303_set_termios(struct usb_serial_port *port, dbg("%s - data bits = %d", __func__, buf[6]); } - baud = tty_get_baud_rate(port->tty);; + baud = tty_get_baud_rate(tty); dbg("%s - baud = %d", __func__, baud); if (baud) { buf[0] = baud & 0xff; @@ -646,12 +647,13 @@ static void pl2303_set_termios(struct usb_serial_port *port, /* FIXME: Need to read back resulting baud rate */ if (baud) - tty_encode_baud_rate(port->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); kfree(buf); } -static void pl2303_close(struct usb_serial_port *port, struct file *filp) +static void pl2303_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -666,7 +668,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); timeout = PL2303_CLOSING_WAIT; init_waitqueue_entry(&wait, current); - add_wait_queue(&port->tty->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (pl2303_buf_data_avail(priv->buf) == 0 || @@ -678,7 +680,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); } set_current_state(TASK_RUNNING); - remove_wait_queue(&port->tty->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); /* clear out any remaining data in the buffer */ pl2303_buf_clear(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); @@ -690,7 +692,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) /* for lower rates we should really know how much */ /* data is in the buffer to compute a delay */ /* that is not unnecessarily long) */ - bps = tty_get_baud_rate(port->tty); + bps = tty_get_baud_rate(tty); if (bps > 1200) timeout = max((HZ*2560)/bps,HZ/10); else @@ -703,8 +705,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) usb_kill_urb(port->read_urb); usb_kill_urb(port->interrupt_in_urb); - if (port->tty) { - c_cflag = port->tty->termios->c_cflag; + if (tty) { + c_cflag = tty->termios->c_cflag; if (c_cflag & HUPCL) { /* drop DTR and RTS */ spin_lock_irqsave(&priv->lock, flags); @@ -715,7 +717,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp) } } -static int pl2303_open(struct usb_serial_port *port, struct file *filp) +static int pl2303_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct ktermios tmp_termios; struct usb_serial *serial = port->serial; @@ -734,9 +737,8 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) } /* Setup termios */ - if (port->tty) { - pl2303_set_termios(port, &tmp_termios); - } + if (tty) + pl2303_set_termios(tty, port, &tmp_termios); //FIXME: need to assert RTS and DTR if CRTSCTS off @@ -746,7 +748,7 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) if (result) { dev_err(&port->dev, "%s - failed submitting read urb," " error %d\n", __func__, result); - pl2303_close(port, NULL); + pl2303_close(tty, port, NULL); return -EPROTO; } @@ -756,15 +758,16 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) if (result) { dev_err(&port->dev, "%s - failed submitting interrupt urb," " error %d\n", __func__, result); - pl2303_close(port, NULL); + pl2303_close(tty, port, NULL); return -EPROTO; } return 0; } -static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file, +static int pl2303_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; u8 control; @@ -787,8 +790,9 @@ static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file, return set_control_lines(port->serial->dev, control); } -static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file) +static int pl2303_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; unsigned int mcr; @@ -853,9 +857,10 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) return 0; } -static int pl2303_ioctl(struct usb_serial_port *port, struct file *file, +static int pl2303_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); switch (cmd) { @@ -871,8 +876,9 @@ static int pl2303_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static void pl2303_break_ctl(struct usb_serial_port *port, int break_state) +static void pl2303_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; u16 state; int result; @@ -1001,7 +1007,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) if (status) { dbg("%s - urb status = %d", __func__, status); - if (!port->open_count) { + if (!port->port.count) { dbg("%s - port is closed, exiting.", __func__); return; } @@ -1044,7 +1050,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) tty_flag = TTY_FRAME; dbg("%s - tty_flag = %d", __func__, tty_flag); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length + 1); /* overrun is special, not associated with a char */ @@ -1056,7 +1062,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) } /* Schedule the next read _if_ we are still open */ - if (port->open_count) { + if (port->port.count) { urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 94bddf06ea4..f823e4dcea1 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -229,8 +229,8 @@ static void safe_read_bulk_callback (struct urb *urb) int actual_length = data[length - 2] >> 2; if (actual_length <= (length - 2)) { info ("%s - actual: %d", __func__, actual_length); - tty_insert_flip_string(port->tty, data, actual_length); - tty_flip_buffer_push (port->tty); + tty_insert_flip_string(port->port.tty, data, actual_length); + tty_flip_buffer_push (port->port.tty); } else { err ("%s - inconsistent lengths %d:%d", __func__, actual_length, length); @@ -239,8 +239,8 @@ static void safe_read_bulk_callback (struct urb *urb) err ("%s - bad CRC %x", __func__, fcs); } } else { - tty_insert_flip_string(port->tty, data, length); - tty_flip_buffer_push (port->tty); + tty_insert_flip_string(port->port.tty, data, length); + tty_flip_buffer_push (port->port.tty); } /* Continue trying to always read */ @@ -255,7 +255,8 @@ static void safe_read_bulk_callback (struct urb *urb) } } -static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { unsigned char *data; int result; @@ -349,8 +350,9 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i return (count); } -static int safe_write_room (struct usb_serial_port *port) +static int safe_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; int room = 0; /* Default: no room */ unsigned long flags; diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 29074c1ba22..892020d4855 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -250,7 +250,8 @@ struct sierra_port_private { int ri_state; }; -static int sierra_send_setup(struct usb_serial_port *port) +static int sierra_send_setup(struct tty_struct *tty, + struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct sierra_port_private *portdata; @@ -260,7 +261,7 @@ static int sierra_send_setup(struct usb_serial_port *port) portdata = usb_get_serial_port_data(port); - if (port->tty) { + if (tty) { int val = 0; if (portdata->dtr_state) val |= 0x01; @@ -284,32 +285,17 @@ static int sierra_send_setup(struct usb_serial_port *port) return 0; } -static void sierra_rx_throttle(struct usb_serial_port *port) +static void sierra_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s", __func__); + tty_termios_copy_hw(tty->termios, old_termios); + sierra_send_setup(tty, port); } -static void sierra_rx_unthrottle(struct usb_serial_port *port) -{ - dbg("%s", __func__); -} - -static void sierra_break_ctl(struct usb_serial_port *port, int break_state) -{ - /* Unfortunately, I don't know how to send a break */ - dbg("%s", __func__); -} - -static void sierra_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) -{ - dbg("%s", __func__); - tty_termios_copy_hw(port->tty->termios, old_termios); - sierra_send_setup(port); -} - -static int sierra_tiocmget(struct usb_serial_port *port, struct file *file) +static int sierra_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; unsigned int value; struct sierra_port_private *portdata; @@ -325,9 +311,10 @@ static int sierra_tiocmget(struct usb_serial_port *port, struct file *file) return value; } -static int sierra_tiocmset(struct usb_serial_port *port, struct file *file, +static int sierra_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct sierra_port_private *portdata; portdata = usb_get_serial_port_data(port); @@ -341,13 +328,7 @@ static int sierra_tiocmset(struct usb_serial_port *port, struct file *file, portdata->rts_state = 0; if (clear & TIOCM_DTR) portdata->dtr_state = 0; - return sierra_send_setup(port); -} - -static int sierra_ioctl(struct usb_serial_port *port, struct file *file, - unsigned int cmd, unsigned long arg) -{ - return -ENOIOCTLCMD; + return sierra_send_setup(tty, port); } static void sierra_outdat_callback(struct urb *urb) @@ -374,8 +355,8 @@ static void sierra_outdat_callback(struct urb *urb) } /* Write */ -static int sierra_write(struct usb_serial_port *port, - const unsigned char *buf, int count) +static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct sierra_port_private *portdata = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; @@ -463,7 +444,7 @@ static void sierra_indat_callback(struct urb *urb) dbg("%s: nonzero status: %d on endpoint %02x.", __func__, status, endpoint); } else { - tty = port->tty; + tty = port->port.tty; if (urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -473,7 +454,7 @@ static void sierra_indat_callback(struct urb *urb) } /* Resubmit urb so we continue receiving */ - if (port->open_count && status != -ESHUTDOWN) { + if (port->port.count && status != -ESHUTDOWN) { err = usb_submit_urb(urb, GFP_ATOMIC); if (err) dev_err(&port->dev, "resubmit read urb failed." @@ -517,9 +498,9 @@ static void sierra_instat_callback(struct urb *urb) portdata->dsr_state = ((signals & 0x02) ? 1 : 0); portdata->ri_state = ((signals & 0x08) ? 1 : 0); - if (port->tty && !C_CLOCAL(port->tty) && + if (port->port.tty && !C_CLOCAL(port->port.tty) && old_dcd_state && !portdata->dcd_state) - tty_hangup(port->tty); + tty_hangup(port->port.tty); } else { dbg("%s: type %x req %x", __func__, req_pkt->bRequestType, req_pkt->bRequest); @@ -537,8 +518,9 @@ static void sierra_instat_callback(struct urb *urb) } } -static int sierra_write_room(struct usb_serial_port *port) +static int sierra_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct sierra_port_private *portdata = usb_get_serial_port_data(port); unsigned long flags; @@ -557,22 +539,8 @@ static int sierra_write_room(struct usb_serial_port *port) return 2048; } -static int sierra_chars_in_buffer(struct usb_serial_port *port) -{ - dbg("%s - port %d", __func__, port->number); - - /* - * We can't really account for how much data we - * have sent out, but hasn't made it through to the - * device as we can't see the backend here, so just - * tell the tty layer that everything is flushed. - * - * FIXME: should walk the outstanding urbs info - */ - return 0; -} - -static int sierra_open(struct usb_serial_port *port, struct file *filp) +static int sierra_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct sierra_port_private *portdata; struct usb_serial *serial = port->serial; @@ -612,9 +580,10 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) } } - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; - sierra_send_setup(port); + sierra_send_setup(tty, port); /* start up the interrupt endpoint if we have one */ if (port->interrupt_in_urb) { @@ -626,7 +595,8 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) return 0; } -static void sierra_close(struct usb_serial_port *port, struct file *filp) +static void sierra_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int i; struct usb_serial *serial = port->serial; @@ -641,7 +611,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp) if (serial->dev) { mutex_lock(&serial->disc_mutex); if (!serial->disconnected) - sierra_send_setup(port); + sierra_send_setup(tty, port); mutex_unlock(&serial->disc_mutex); /* Stop reading/writing urbs */ @@ -651,7 +621,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp) usb_kill_urb(port->interrupt_in_urb); - port->tty = NULL; + port->port.tty = NULL; /* FIXME */ } static int sierra_startup(struct usb_serial *serial) @@ -754,12 +724,7 @@ static struct usb_serial_driver sierra_device = { .close = sierra_close, .write = sierra_write, .write_room = sierra_write_room, - .chars_in_buffer = sierra_chars_in_buffer, - .throttle = sierra_rx_throttle, - .unthrottle = sierra_rx_unthrottle, - .ioctl = sierra_ioctl, .set_termios = sierra_set_termios, - .break_ctl = sierra_break_ctl, .tiocmget = sierra_tiocmget, .tiocmset = sierra_tiocmset, .attach = sierra_startup, diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 55b2570b8b8..58495f5cca1 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -448,7 +448,8 @@ static void spcp8x5_set_workMode(struct usb_device *dev, u16 value, /* close the serial port. We should wait for data sending to device 1st and * then kill all urb. */ -static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) +static void spcp8x5_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct spcp8x5_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -464,7 +465,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); timeout = SPCP8x5_CLOSING_WAIT; init_waitqueue_entry(&wait, current); - add_wait_queue(&port->tty->write_wait, &wait); + add_wait_queue(&tty->write_wait, &wait); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (ringbuf_avail_data(priv->buf) == 0 || @@ -475,7 +476,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) spin_lock_irqsave(&priv->lock, flags); } set_current_state(TASK_RUNNING); - remove_wait_queue(&port->tty->write_wait, &wait); + remove_wait_queue(&tty->write_wait, &wait); /* clear out any remaining data in the buffer */ clear_ringbuf(priv->buf); @@ -486,7 +487,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) * flow control for data rates of 1200 bps or more, for lower rates we * should really know how much data is in the buffer to compute a delay * that is not unnecessarily long) */ - bps = tty_get_baud_rate(port->tty); + bps = tty_get_baud_rate(tty); if (bps > 1200) timeout = max((HZ*2560) / bps, HZ/10); else @@ -495,8 +496,8 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) schedule_timeout(timeout); /* clear control lines */ - if (port->tty) { - c_cflag = port->tty->termios->c_cflag; + if (tty) { + c_cflag = tty->termios->c_cflag; if (c_cflag & HUPCL) { spin_lock_irqsave(&priv->lock, flags); priv->line_control = 0; @@ -518,14 +519,14 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) } /* set the serial param for transfer. we should check if we really need to - * transfer. then if be set flow contorl we should do this too. */ -static void spcp8x5_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) + * transfer. if we set flow control we should do this too. */ +static void spcp8x5_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct spcp8x5_private *priv = usb_get_serial_port_data(port); unsigned long flags; - unsigned int cflag = port->tty->termios->c_cflag; + unsigned int cflag = tty->termios->c_cflag; unsigned int old_cflag = old_termios->c_cflag; unsigned short uartdata; unsigned char buf[2] = {0, 0}; @@ -533,21 +534,19 @@ static void spcp8x5_set_termios(struct usb_serial_port *port, int i; u8 control; - if ((!port->tty) || (!port->tty->termios)) - return; - /* for the 1st time call this function */ spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { - *(port->tty->termios) = tty_std_termios; - port->tty->termios->c_cflag = B115200 | CS8 | CREAD | - HUPCL | CLOCAL; + *(tty->termios) = tty_std_termios; + tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL; + tty->termios->c_ispeed = 115200; + tty->termios->c_ospeed = 115200; priv->termios_initialized = 1; } spin_unlock_irqrestore(&priv->lock, flags); /* check that they really want us to change something */ - if (!tty_termios_hw_change(port->tty->termios, old_termios)) + if (!tty_termios_hw_change(tty->termios, old_termios)) return; /* set DTR/RTS active */ @@ -567,7 +566,7 @@ static void spcp8x5_set_termios(struct usb_serial_port *port, } /* Set Baud Rate */ - baud = tty_get_baud_rate(port->tty);; + baud = tty_get_baud_rate(tty);; switch (baud) { case 300: buf[0] = 0x00; break; case 600: buf[0] = 0x01; break; @@ -643,7 +642,8 @@ static void spcp8x5_set_termios(struct usb_serial_port *port, /* open the serial port. do some usb system call. set termios and get the line * status of the device. then submit the read urb */ -static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) +static int spcp8x5_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct ktermios tmp_termios; struct usb_serial *serial = port->serial; @@ -665,7 +665,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) return ret; spin_lock_irqsave(&priv->lock, flags); - if (port->tty->termios->c_cflag & CBAUD) + if (tty && (tty->termios->c_cflag & CBAUD)) priv->line_control = MCR_DTR | MCR_RTS; else priv->line_control = 0; @@ -674,8 +674,8 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type); /* Setup termios */ - if (port->tty) - spcp8x5_set_termios(port, &tmp_termios); + if (tty) + spcp8x5_set_termios(tty, port, &tmp_termios); spcp8x5_get_msr(serial->dev, &status, priv->type); @@ -690,7 +690,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) port->read_urb->dev = serial->dev; ret = usb_submit_urb(port->read_urb, GFP_KERNEL); if (ret) { - spcp8x5_close(port, NULL); + spcp8x5_close(tty, port, NULL); return -EPROTO; } return 0; @@ -717,7 +717,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb) /* check the urb status */ if (urb->status) { - if (!port->open_count) + if (!port->port.count) return; if (urb->status == -EPROTO) { /* spcp8x5 mysteriously fails with -EPROTO */ @@ -755,7 +755,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb) tty_flag = TTY_FRAME; dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length + 1); /* overrun is special, not associated with a char */ @@ -767,7 +767,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb) } /* Schedule the next read _if_ we are still open */ - if (port->open_count) { + if (port->port.count) { urb->dev = port->serial->dev; result = usb_submit_urb(urb , GFP_ATOMIC); if (result) @@ -866,7 +866,7 @@ static void spcp8x5_write_bulk_callback(struct urb *urb) } /* write data to ring buffer. and then start the write transfer */ -static int spcp8x5_write(struct usb_serial_port *port, +static int spcp8x5_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct spcp8x5_private *priv = usb_get_serial_port_data(port); @@ -925,9 +925,10 @@ static int spcp8x5_wait_modem_info(struct usb_serial_port *port, return 0; } -static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file, +static int spcp8x5_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); switch (cmd) { @@ -943,9 +944,10 @@ static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file, +static int spcp8x5_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct spcp8x5_private *priv = usb_get_serial_port_data(port); unsigned long flags; u8 control; @@ -965,8 +967,9 @@ static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file, return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type); } -static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file) +static int spcp8x5_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct spcp8x5_private *priv = usb_get_serial_port_data(port); unsigned long flags; unsigned int mcr; @@ -989,8 +992,9 @@ static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file) } /* get the avail space room in ring buffer */ -static int spcp8x5_write_room(struct usb_serial_port *port) +static int spcp8x5_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct spcp8x5_private *priv = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -1003,8 +1007,9 @@ static int spcp8x5_write_room(struct usb_serial_port *port) } /* get the number of avail data in write ring buffer */ -static int spcp8x5_chars_in_buffer(struct usb_serial_port *port) +static int spcp8x5_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct spcp8x5_private *priv = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index a26a629dfc4..48831a755fc 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -70,6 +70,7 @@ #include #include +#include #include #include #include @@ -149,21 +150,23 @@ struct ti_device { static int ti_startup(struct usb_serial *serial); static void ti_shutdown(struct usb_serial *serial); -static int ti_open(struct usb_serial_port *port, struct file *file); -static void ti_close(struct usb_serial_port *port, struct file *file); -static int ti_write(struct usb_serial_port *port, const unsigned char *data, - int count); -static int ti_write_room(struct usb_serial_port *port); -static int ti_chars_in_buffer(struct usb_serial_port *port); -static void ti_throttle(struct usb_serial_port *port); -static void ti_unthrottle(struct usb_serial_port *port); -static int ti_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); -static void ti_set_termios(struct usb_serial_port *port, +static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *file); +static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *file); +static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *data, int count); +static int ti_write_room(struct tty_struct *tty); +static int ti_chars_in_buffer(struct tty_struct *tty); +static void ti_throttle(struct tty_struct *tty); +static void ti_unthrottle(struct tty_struct *tty); +static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static void ti_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); -static int ti_tiocmget(struct usb_serial_port *port, struct file *file); -static int ti_tiocmset(struct usb_serial_port *port, struct file *file, +static int ti_tiocmget(struct tty_struct *tty, struct file *file); +static int ti_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void ti_break(struct usb_serial_port *port, int break_state); +static void ti_break(struct tty_struct *tty, int break_state); static void ti_interrupt_callback(struct urb *urb); static void ti_bulk_in_callback(struct urb *urb); static void ti_bulk_out_callback(struct urb *urb); @@ -192,8 +195,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, static int ti_write_byte(struct ti_device *tdev, unsigned long addr, __u8 mask, __u8 byte); -static int ti_download_firmware(struct ti_device *tdev, char *fw_name); - +static int ti_download_firmware(struct ti_device *tdev, int type); /* circular buffer */ static struct circ_buf *ti_buf_alloc(void); @@ -430,11 +432,10 @@ static int ti_startup(struct usb_serial *serial) /* if we have only 1 configuration, download firmware */ if (dev->descriptor.bNumConfigurations == 1) { - if (tdev->td_is_3410) - status = ti_download_firmware(tdev, "ti_3410.fw"); + status = ti_download_firmware(tdev, 3410); else - status = ti_download_firmware(tdev, "ti_5052.fw"); + status = ti_download_firmware(tdev, 5052); if (status) goto free_tdev; @@ -519,7 +520,8 @@ static void ti_shutdown(struct usb_serial *serial) } -static int ti_open(struct usb_serial_port *port, struct file *file) +static int ti_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *file) { struct ti_port *tport = usb_get_serial_port_data(port); struct ti_device *tdev; @@ -543,9 +545,9 @@ static int ti_open(struct usb_serial_port *port, struct file *file) if (mutex_lock_interruptible(&tdev->td_open_close_lock)) return -ERESTARTSYS; - if (port->tty) - port->tty->low_latency = - (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; + if (tty) + tty->low_latency = + (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; port_number = port->number - port->serial->minor; @@ -573,7 +575,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file) } } - ti_set_termios(port, port->tty->termios); + if (tty) + ti_set_termios(tty, port, tty->termios); dbg("%s - sending TI_OPEN_PORT", __func__); status = ti_command_out_sync(tdev, TI_OPEN_PORT, @@ -610,7 +613,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file) usb_clear_halt(dev, port->write_urb->pipe); usb_clear_halt(dev, port->read_urb->pipe); - ti_set_termios(port, port->tty->termios); + if (tty) + ti_set_termios(tty, port, tty->termios); dbg("%s - sending TI_OPEN_PORT (2)", __func__); status = ti_command_out_sync(tdev, TI_OPEN_PORT, @@ -661,7 +665,8 @@ release_lock: } -static void ti_close(struct usb_serial_port *port, struct file *file) +static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *file) { struct ti_device *tdev; struct ti_port *tport; @@ -707,8 +712,8 @@ static void ti_close(struct usb_serial_port *port, struct file *file) } -static int ti_write(struct usb_serial_port *port, const unsigned char *data, - int count) +static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *data, int count) { struct ti_port *tport = usb_get_serial_port_data(port); unsigned long flags; @@ -733,8 +738,9 @@ static int ti_write(struct usb_serial_port *port, const unsigned char *data, } -static int ti_write_room(struct usb_serial_port *port) +static int ti_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); int room = 0; unsigned long flags; @@ -753,8 +759,9 @@ static int ti_write_room(struct usb_serial_port *port) } -static int ti_chars_in_buffer(struct usb_serial_port *port) +static int ti_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); int chars = 0; unsigned long flags; @@ -773,32 +780,26 @@ static int ti_chars_in_buffer(struct usb_serial_port *port) } -static void ti_throttle(struct usb_serial_port *port) +static void ti_throttle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); - struct tty_struct *tty; dbg("%s - port %d", __func__, port->number); if (tport == NULL) return; - tty = port->tty; - if (!tty) { - dbg("%s - no tty", __func__); - return; - } - if (I_IXOFF(tty) || C_CRTSCTS(tty)) ti_stop_read(tport, tty); } -static void ti_unthrottle(struct usb_serial_port *port) +static void ti_unthrottle(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); - struct tty_struct *tty; int status; dbg("%s - port %d", __func__, port->number); @@ -806,12 +807,6 @@ static void ti_unthrottle(struct usb_serial_port *port) if (tport == NULL) return; - tty = port->tty; - if (!tty) { - dbg("%s - no tty", __func__); - return; - } - if (I_IXOFF(tty) || C_CRTSCTS(tty)) { status = ti_restart_read(tport, tty); if (status) @@ -820,9 +815,10 @@ static void ti_unthrottle(struct usb_serial_port *port) } -static int ti_ioctl(struct usb_serial_port *port, struct file *file, +static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); struct async_icount cnow; struct async_icount cprev; @@ -875,11 +871,10 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file, } -static void ti_set_termios(struct usb_serial_port *port, - struct ktermios *old_termios) +static void ti_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { struct ti_port *tport = usb_get_serial_port_data(port); - struct tty_struct *tty = port->tty; struct ti_uart_config *config; tcflag_t cflag,iflag; int baud; @@ -1008,8 +1003,9 @@ static void ti_set_termios(struct usb_serial_port *port, } -static int ti_tiocmget(struct usb_serial_port *port, struct file *file) +static int ti_tiocmget(struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); unsigned int result; unsigned int msr; @@ -1040,9 +1036,10 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file) } -static int ti_tiocmset(struct usb_serial_port *port, struct file *file, +static int ti_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); unsigned int mcr; unsigned long flags; @@ -1074,8 +1071,9 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file, } -static void ti_break(struct usb_serial_port *port, int break_state) +static void ti_break(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; struct ti_port *tport = usb_get_serial_port_data(port); int status; @@ -1213,14 +1211,14 @@ static void ti_bulk_in_callback(struct urb *urb) return; } - if (port->tty && urb->actual_length) { + if (port->port.tty && urb->actual_length) { usb_serial_debug_data(debug, dev, __func__, urb->actual_length, urb->transfer_buffer); if (!tport->tp_is_open) dbg("%s - port closed, dropping data", __func__); else - ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer, + ti_recv(&urb->dev->dev, port->port.tty, urb->transfer_buffer, urb->actual_length); spin_lock(&tport->tp_lock); @@ -1302,7 +1300,7 @@ static void ti_send(struct ti_port *tport) { int count, result; struct usb_serial_port *port = tport->tp_port; - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; /* FIXME */ unsigned long flags; @@ -1442,8 +1440,9 @@ static int ti_set_serial_info(struct ti_port *tport, return -EFAULT; tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; - if (port->tty) - port->tty->low_latency = + /* FIXME */ + if (port->port.tty) + port->port.tty->low_latency = (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; tport->tp_closing_wait = new_serial.closing_wait; @@ -1477,7 +1476,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) tport->tp_msr = msr & TI_MSR_MASK; /* handle CTS flow control */ - tty = tport->tp_port->tty; + tty = tport->tp_port->port.tty; if (tty && C_CRTSCTS(tty)) { if (msr & TI_MSR_CTS) { tty->hw_stopped = 0; @@ -1655,65 +1654,65 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, return status; } - -static int ti_download_firmware(struct ti_device *tdev, - char *fw_name) +static int ti_do_download(struct usb_device *dev, int pipe, + u8 *buffer, int size) { - const struct firmware *fw; - int status = 0; - int buffer_size; int pos; - int len; + u8 cs = 0; int done; - __u8 cs = 0; - __u8 *buffer; - struct usb_device *dev = tdev->td_serial->dev; struct ti_firmware_header *header; - unsigned int pipe = usb_sndbulkpipe(dev, - tdev->td_serial->port[0]->bulk_out_endpointAddress); - - buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); - - if (request_firmware(&fw, fw_name, &dev->dev)) { - dev_err(&dev->dev, "%s - failed to load firmware \"%s\"\n", - __func__, fw_name); - return -ENOENT; - } - if (fw->size > buffer_size) { - dev_err(&dev->dev, "%s - firmware \"%s\" is too large\n", - __func__, fw_name); - release_firmware(fw); - return -EINVAL; - } - - buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!buffer) { - dev_err(&dev->dev, "%s - out of memory\n", __func__); - release_firmware(fw); - return -ENOMEM; - } - - memcpy(buffer, fw->data, fw->size); - memset(buffer+fw->size, 0xff, buffer_size-fw->size); - - for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++) + int status; + int len; + + for(pos = sizeof(struct ti_firmware_header); pos < size; pos++) cs = (__u8)(cs + buffer[pos]); header = (struct ti_firmware_header *)buffer; - header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header))); + header->wLength = cpu_to_le16((__u16)(size + - sizeof(struct ti_firmware_header))); header->bCheckSum = cs; dbg("%s - downloading firmware", __func__); - for (pos = 0; pos < buffer_size; pos += done) { - len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); - status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000); + for (pos = 0; pos < size; pos += done) { + len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); + status = usb_bulk_msg(dev, pipe, buffer + pos, len, + &done, 1000); if (status) break; } + return status; +} - kfree(buffer); - release_firmware(fw); +static int ti_download_firmware(struct ti_device *tdev, int type) +{ + int status = -ENOMEM; + int buffer_size; + __u8 *buffer; + struct usb_device *dev = tdev->td_serial->dev; + unsigned int pipe = usb_sndbulkpipe(dev, + tdev->td_serial->port[0]->bulk_out_endpointAddress); + const struct firmware *fw_p; + char buf[32]; + sprintf(buf, "ti_usb-%d.bin", type); + if (request_firmware(&fw_p, buf, &dev->dev)) { + dev_err(&dev->dev, "%s - firmware not found\n", __func__); + return -ENOENT; + } + if (fw_p->size > TI_FIRMWARE_BUF_SIZE) { + dev_err(&dev->dev, "%s - firmware too large\n", __func__); + return -ENOENT; + } + + buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); + buffer = kmalloc(buffer_size, GFP_KERNEL); + if (buffer) { + memcpy(buffer, fw_p->data, fw_p->size); + memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); + ti_do_download(dev, pipe, buffer, fw_p->size); + kfree(buffer); + } + release_firmware(fw_p); if (status) { dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); return status; diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 35379863190..ffaed8ace06 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -143,7 +143,7 @@ static void destroy_serial(struct kref *kref) return_serial(serial); for (i = 0; i < serial->num_ports; ++i) - serial->port[i]->open_count = 0; + serial->port[i]->port.count = 0; /* the ports are cleaned up and released in port_release() */ for (i = 0; i < serial->num_ports; ++i) @@ -208,14 +208,14 @@ static int serial_open (struct tty_struct *tty, struct file * filp) goto bailout_kref_put; } - ++port->open_count; + ++port->port.count; /* set up our port structure making the tty driver * remember our port object, and us it */ tty->driver_data = port; - port->tty = tty; + port->port.tty = tty; - if (port->open_count == 1) { + if (port->port.count == 1) { /* lock this module before we call it * this may fail, which means we must bail out, @@ -230,7 +230,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) goto bailout_module_put; /* only call the device specific open if this * is the first time the port is opened */ - retval = serial->type->open(port, filp); + retval = serial->type->open(tty, port, filp); if (retval) goto bailout_interface_put; } @@ -243,9 +243,9 @@ bailout_interface_put: bailout_module_put: module_put(serial->type->driver.owner); bailout_mutex_unlock: - port->open_count = 0; + port->port.count = 0; tty->driver_data = NULL; - port->tty = NULL; + port->port.tty = NULL; mutex_unlock(&port->mutex); bailout_kref_put: usb_serial_put(serial); @@ -263,26 +263,26 @@ static void serial_close(struct tty_struct *tty, struct file * filp) mutex_lock(&port->mutex); - if (port->open_count == 0) { + if (port->port.count == 0) { mutex_unlock(&port->mutex); return; } - --port->open_count; - if (port->open_count == 0) + --port->port.count; + if (port->port.count == 0) /* only call the device specific close if this * port is being closed by the last owner */ - port->serial->type->close(port, filp); + port->serial->type->close(tty, port, filp); - if (port->open_count == (port->console? 1 : 0)) { - if (port->tty) { - if (port->tty->driver_data) - port->tty->driver_data = NULL; - port->tty = NULL; + if (port->port.count == (port->console? 1 : 0)) { + if (port->port.tty) { + if (port->port.tty->driver_data) + port->port.tty->driver_data = NULL; + port->port.tty = NULL; } } - if (port->open_count == 0) { + if (port->port.count == 0) { mutex_lock(&port->serial->disc_mutex); if (!port->serial->disconnected) usb_autopm_put_interface(port->serial->interface); @@ -304,12 +304,12 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int dbg("%s - port %d, %d byte(s)", __func__, port->number, count); - /* open_count is managed under the mutex lock for the tty so cannot + /* count is managed under the mutex lock for the tty so cannot drop to zero until after the last close completes */ - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ - retval = port->serial->type->write(port, buf, count); + retval = port->serial->type->write(tty, port, buf, count); exit: return retval; @@ -319,9 +319,9 @@ static int serial_write_room (struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ - return port->serial->type->write_room(port); + return port->serial->type->write_room(tty); } static int serial_chars_in_buffer (struct tty_struct *tty) @@ -329,9 +329,9 @@ static int serial_chars_in_buffer (struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; dbg("%s = port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ - return port->serial->type->chars_in_buffer(port); + return port->serial->type->chars_in_buffer(tty); } static void serial_throttle (struct tty_struct * tty) @@ -339,10 +339,10 @@ static void serial_throttle (struct tty_struct * tty) struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ if (port->serial->type->throttle) - port->serial->type->throttle(port); + port->serial->type->throttle(tty); } static void serial_unthrottle (struct tty_struct * tty) @@ -350,10 +350,10 @@ static void serial_unthrottle (struct tty_struct * tty) struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ if (port->serial->type->unthrottle) - port->serial->type->unthrottle(port); + port->serial->type->unthrottle(tty); } static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) @@ -363,12 +363,12 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function if it is available */ if (port->serial->type->ioctl) { lock_kernel(); - retval = port->serial->type->ioctl(port, file, cmd, arg); + retval = port->serial->type->ioctl(tty, file, cmd, arg); unlock_kernel(); } else @@ -381,10 +381,10 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function if it is available */ if (port->serial->type->set_termios) - port->serial->type->set_termios(port, old); + port->serial->type->set_termios(tty, port, old); else tty_termios_copy_hw(tty->termios, old); } @@ -395,11 +395,11 @@ static void serial_break (struct tty_struct *tty, int break_state) dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); /* pass on to the driver specific version of this function if it is available */ if (port->serial->type->break_ctl) { lock_kernel(); - port->serial->type->break_ctl(port, break_state); + port->serial->type->break_ctl(tty, break_state); unlock_kernel(); } } @@ -457,9 +457,9 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); if (port->serial->type->tiocmget) - return port->serial->type->tiocmget(port, file); + return port->serial->type->tiocmget(tty, file); return -EINVAL; } @@ -470,9 +470,9 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, dbg("%s - port %d", __func__, port->number); - WARN_ON(!port->open_count); + WARN_ON(!port->port.count); if (port->serial->type->tiocmset) - return port->serial->type->tiocmset(port, file, set, clear); + return port->serial->type->tiocmset(tty, file, set, clear); return -EINVAL; } @@ -497,7 +497,7 @@ static void usb_serial_port_work(struct work_struct *work) if (!port) return; - tty = port->tty; + tty = port->port.tty; if (!tty) return; @@ -1010,8 +1010,8 @@ void usb_serial_disconnect(struct usb_interface *interface) for (i = 0; i < serial->num_ports; ++i) { port = serial->port[i]; if (port) { - if (port->tty) - tty_hangup(port->tty); + if (port->port.tty) + tty_hangup(port->port.tty); kill_traffic(port); } } diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index 9ca4d4db1dd..fc5d9952b03 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c @@ -31,10 +31,11 @@ static struct usb_driver debug_driver = { .no_dynamic_id = 1, }; -int usb_debug_open(struct usb_serial_port *port, struct file *filp) +int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; - return usb_serial_generic_open(port, filp); + return usb_serial_generic_open(tty, port, filp); } static struct usb_serial_driver debug_device = { diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 5fc20122145..373a3c7ea77 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -35,17 +35,15 @@ #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" /* function prototypes for a handspring visor */ -static int visor_open (struct usb_serial_port *port, struct file *filp); -static void visor_close (struct usb_serial_port *port, struct file *filp); -static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int visor_write_room (struct usb_serial_port *port); -static int visor_chars_in_buffer (struct usb_serial_port *port); -static void visor_throttle (struct usb_serial_port *port); -static void visor_unthrottle (struct usb_serial_port *port); +static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); +static int visor_write_room (struct tty_struct *tty); +static void visor_throttle (struct tty_struct *tty); +static void visor_unthrottle (struct tty_struct *tty); static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id); static int visor_calc_num_ports(struct usb_serial *serial); static void visor_shutdown (struct usb_serial *serial); -static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); static void visor_write_bulk_callback (struct urb *urb); static void visor_read_bulk_callback (struct urb *urb); static void visor_read_int_callback (struct urb *urb); @@ -198,10 +196,8 @@ static struct usb_serial_driver handspring_device = { .probe = visor_probe, .calc_num_ports = visor_calc_num_ports, .shutdown = visor_shutdown, - .ioctl = visor_ioctl, .write = visor_write, .write_room = visor_write_room, - .chars_in_buffer = visor_chars_in_buffer, .write_bulk_callback = visor_write_bulk_callback, .read_bulk_callback = visor_read_bulk_callback, .read_int_callback = visor_read_int_callback, @@ -225,10 +221,8 @@ static struct usb_serial_driver clie_5_device = { .probe = visor_probe, .calc_num_ports = visor_calc_num_ports, .shutdown = visor_shutdown, - .ioctl = visor_ioctl, .write = visor_write, .write_room = visor_write_room, - .chars_in_buffer = visor_chars_in_buffer, .write_bulk_callback = visor_write_bulk_callback, .read_bulk_callback = visor_read_bulk_callback, .read_int_callback = visor_read_int_callback, @@ -249,10 +243,8 @@ static struct usb_serial_driver clie_3_5_device = { .throttle = visor_throttle, .unthrottle = visor_unthrottle, .attach = clie_3_5_startup, - .ioctl = visor_ioctl, .write = visor_write, .write_room = visor_write_room, - .chars_in_buffer = visor_chars_in_buffer, .write_bulk_callback = visor_write_bulk_callback, .read_bulk_callback = visor_read_bulk_callback, }; @@ -274,7 +266,7 @@ static int stats; /****************************************************************************** * Handspring Visor specific driver functions ******************************************************************************/ -static int visor_open (struct usb_serial_port *port, struct file *filp) +static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; struct visor_private *priv = usb_get_serial_port_data(port); @@ -300,8 +292,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) * through, otherwise it is scheduled, and with high data rates (like * with OHCI) data can get lost. */ - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* Start reading from the device */ usb_fill_bulk_urb (port->read_urb, serial->dev, @@ -329,7 +321,8 @@ exit: } -static void visor_close (struct usb_serial_port *port, struct file * filp) +static void visor_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct visor_private *priv = usb_get_serial_port_data(port); unsigned char *transfer_buffer; @@ -361,7 +354,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) } -static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct visor_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; @@ -435,8 +429,9 @@ error_no_buffer: } -static int visor_write_room (struct usb_serial_port *port) +static int visor_write_room (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -460,22 +455,6 @@ static int visor_write_room (struct usb_serial_port *port) } -static int visor_chars_in_buffer (struct usb_serial_port *port) -{ - dbg("%s - port %d", __func__, port->number); - - /* - * We can't really account for how much data we - * have sent out, but hasn't made it through to the - * device, so just tell the tty layer that everything - * is flushed. - * - * FIXME: Should walk outstanding_urbs - */ - return 0; -} - - static void visor_write_bulk_callback (struct urb *urb) { struct usb_serial_port *port = urb->context; @@ -520,7 +499,7 @@ static void visor_read_bulk_callback (struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { available_room = tty_buffer_request_room(tty, urb->actual_length); if (available_room) { @@ -591,8 +570,9 @@ exit: __func__, result); } -static void visor_throttle (struct usb_serial_port *port) +static void visor_throttle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); unsigned long flags; @@ -603,8 +583,9 @@ static void visor_throttle (struct usb_serial_port *port) } -static void visor_unthrottle (struct usb_serial_port *port) +static void visor_unthrottle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); unsigned long flags; int result; @@ -922,13 +903,6 @@ static void visor_shutdown (struct usb_serial *serial) } } -static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) -{ - dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); - - return -ENOIOCTLCMD; -} - static int __init visor_init (void) { int i, retval; diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 665aa77a917..b07d6a5cac3 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -142,18 +142,18 @@ static int whiteheat_firmware_attach (struct usb_serial *serial); /* function prototypes for the Connect Tech WhiteHEAT serial converter */ static int whiteheat_attach (struct usb_serial *serial); static void whiteheat_shutdown (struct usb_serial *serial); -static int whiteheat_open (struct usb_serial_port *port, struct file *filp); -static void whiteheat_close (struct usb_serial_port *port, struct file *filp); -static int whiteheat_write (struct usb_serial_port *port, const unsigned char *buf, int count); -static int whiteheat_write_room (struct usb_serial_port *port); -static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); -static void whiteheat_set_termios (struct usb_serial_port *port, struct ktermios * old); -static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file); -static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); -static void whiteheat_break_ctl (struct usb_serial_port *port, int break_state); -static int whiteheat_chars_in_buffer (struct usb_serial_port *port); -static void whiteheat_throttle (struct usb_serial_port *port); -static void whiteheat_unthrottle (struct usb_serial_port *port); +static int whiteheat_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static void whiteheat_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int whiteheat_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); +static int whiteheat_write_room (struct tty_struct *tty); +static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); +static void whiteheat_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); +static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file); +static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); +static void whiteheat_break_ctl (struct tty_struct *tty, int break_state); +static int whiteheat_chars_in_buffer (struct tty_struct *tty); +static void whiteheat_throttle (struct tty_struct *tty); +static void whiteheat_unthrottle (struct tty_struct *tty); static void whiteheat_read_callback (struct urb *urb); static void whiteheat_write_callback (struct urb *urb); @@ -246,7 +246,7 @@ static void rx_data_softint(struct work_struct *work); static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); static int firm_open(struct usb_serial_port *port); static int firm_close(struct usb_serial_port *port); -static int firm_setup_port(struct usb_serial_port *port); +static int firm_setup_port(struct tty_struct *tty); static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); static int firm_set_break(struct usb_serial_port *port, __u8 onoff); @@ -613,7 +613,8 @@ static void whiteheat_shutdown (struct usb_serial *serial) } -static int whiteheat_open (struct usb_serial_port *port, struct file *filp) +static int whiteheat_open (struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int retval = 0; struct ktermios old_term; @@ -624,7 +625,8 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) if (retval) goto exit; - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* send an open port command */ retval = firm_open(port); @@ -640,9 +642,11 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) goto exit; } - old_term.c_cflag = ~port->tty->termios->c_cflag; - old_term.c_iflag = ~port->tty->termios->c_iflag; - whiteheat_set_termios(port, &old_term); + if (tty) { + old_term.c_cflag = ~tty->termios->c_cflag; + old_term.c_iflag = ~tty->termios->c_iflag; + whiteheat_set_termios(tty, port, &old_term); + } /* Work around HCD bugs */ usb_clear_halt(port->serial->dev, port->read_urb->pipe); @@ -663,7 +667,8 @@ exit: } -static void whiteheat_close(struct usb_serial_port *port, struct file * filp) +static void whiteheat_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; @@ -681,7 +686,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) } mutex_unlock(&port->serial->disc_mutex); - port->tty->closing = 1; + tty->closing = 1; /* * Not currently in use; tty_wait_until_sent() calls @@ -689,12 +694,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) * acquisition. This should be fixed at some point. Greg's been * notified. if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) { - tty_wait_until_sent(port->tty, CLOSING_DELAY); + tty_wait_until_sent(tty, CLOSING_DELAY); } */ - tty_driver_flush_buffer(port->tty); - tty_ldisc_flush(port->tty); + tty_driver_flush_buffer(tty); + tty_ldisc_flush(tty); firm_report_tx_done(port); @@ -728,11 +733,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) stop_command_port(port->serial); - port->tty->closing = 0; + tty->closing = 0; } -static int whiteheat_write(struct usb_serial_port *port, const unsigned char *buf, int count) +static int whiteheat_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct whiteheat_private *info = usb_get_serial_port_data(port); @@ -791,8 +797,9 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu } -static int whiteheat_write_room(struct usb_serial_port *port) +static int whiteheat_write_room(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); struct list_head *tmp; int room = 0; @@ -811,8 +818,9 @@ static int whiteheat_write_room(struct usb_serial_port *port) } -static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file) +static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned int modem_signals = 0; @@ -828,9 +836,10 @@ static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file) } -static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, +static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); @@ -851,8 +860,9 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, } -static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) +static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { + struct usb_serial_port *port = tty->driver_data; struct serial_struct serstruct; void __user *user_arg = (void __user *)arg; @@ -896,20 +906,21 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un } -static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) +static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { - dbg("%s -port %d", __func__, port->number); - firm_setup_port(port); + firm_setup_port(tty); } -static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) { +static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) { + struct usb_serial_port *port = tty->driver_data; firm_set_break(port, break_state); } -static int whiteheat_chars_in_buffer(struct usb_serial_port *port) +static int whiteheat_chars_in_buffer(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); struct list_head *tmp; struct whiteheat_urb_wrap *wrap; @@ -930,8 +941,9 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port) } -static void whiteheat_throttle (struct usb_serial_port *port) +static void whiteheat_throttle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned long flags; @@ -945,8 +957,9 @@ static void whiteheat_throttle (struct usb_serial_port *port) } -static void whiteheat_unthrottle (struct usb_serial_port *port) +static void whiteheat_unthrottle (struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); int actually_throttled; unsigned long flags; @@ -1184,9 +1197,10 @@ static int firm_close(struct usb_serial_port *port) { } -static int firm_setup_port(struct usb_serial_port *port) { +static int firm_setup_port(struct tty_struct *tty) { + struct usb_serial_port *port = tty->driver_data; struct whiteheat_port_settings port_settings; - unsigned int cflag = port->tty->termios->c_cflag; + unsigned int cflag = tty->termios->c_cflag; port_settings.port = port->number + 1; @@ -1235,22 +1249,22 @@ static int firm_setup_port(struct usb_serial_port *port) { (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); /* determine software flow control */ - if (I_IXOFF(port->tty)) + if (I_IXOFF(tty)) port_settings.sflow = WHITEHEAT_SFLOW_RXTX; else port_settings.sflow = WHITEHEAT_SFLOW_NONE; dbg("%s - software flow control = %c", __func__, port_settings.sflow); - port_settings.xon = START_CHAR(port->tty); - port_settings.xoff = STOP_CHAR(port->tty); + port_settings.xon = START_CHAR(tty); + port_settings.xoff = STOP_CHAR(tty); dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff); /* get the baud rate wanted */ - port_settings.baud = tty_get_baud_rate(port->tty); + port_settings.baud = tty_get_baud_rate(tty); dbg("%s - baud rate = %d", __func__, port_settings.baud); /* fixme: should set validated settings */ - tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); + tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); /* handle any settings that aren't specified in the tty structure */ port_settings.lloop = 0; @@ -1426,7 +1440,7 @@ static void rx_data_softint(struct work_struct *work) struct whiteheat_private *info = container_of(work, struct whiteheat_private, rx_work); struct usb_serial_port *port = info->port; - struct tty_struct *tty = port->tty; + struct tty_struct *tty = port->port.tty; struct whiteheat_urb_wrap *wrap; struct urb *urb; unsigned long flags; diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 8f891cbaf9a..09a3e6a7518 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -62,7 +62,7 @@ */ struct usb_serial_port { struct usb_serial *serial; - struct tty_struct *tty; + struct tty_port port; spinlock_t lock; struct mutex mutex; unsigned char number; @@ -89,7 +89,6 @@ struct usb_serial_port { wait_queue_head_t write_wait; struct work_struct work; - int open_count; char throttled; char throttle_req; char console; @@ -217,22 +216,27 @@ struct usb_serial_driver { int (*resume)(struct usb_serial *serial); /* serial function calls */ - int (*open)(struct usb_serial_port *port, struct file *filp); - void (*close)(struct usb_serial_port *port, struct file *filp); - int (*write)(struct usb_serial_port *port, const unsigned char *buf, - int count); - int (*write_room)(struct usb_serial_port *port); - int (*ioctl)(struct usb_serial_port *port, struct file *file, + /* Called by console with tty = NULL and by tty */ + int (*open)(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); + void (*close)(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); + int (*write)(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); + /* Called only by the tty layer */ + int (*write_room)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); - void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); - void (*break_ctl)(struct usb_serial_port *port, int break_state); - int (*chars_in_buffer)(struct usb_serial_port *port); - void (*throttle)(struct usb_serial_port *port); - void (*unthrottle)(struct usb_serial_port *port); - int (*tiocmget)(struct usb_serial_port *port, struct file *file); - int (*tiocmset)(struct usb_serial_port *port, struct file *file, + void (*set_termios)(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); + void (*break_ctl)(struct tty_struct *tty, int break_state); + int (*chars_in_buffer)(struct tty_struct *tty); + void (*throttle)(struct tty_struct *tty); + void (*unthrottle)(struct tty_struct *tty); + int (*tiocmget)(struct tty_struct *tty, struct file *file); + int (*tiocmset)(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); - + /* USB events */ void (*read_int_callback)(struct urb *urb); void (*write_int_callback)(struct urb *urb); void (*read_bulk_callback)(struct urb *urb); @@ -270,19 +274,19 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} /* Functions needed by other parts of the usbserial core */ extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); extern void usb_serial_put(struct usb_serial *serial); -extern int usb_serial_generic_open(struct usb_serial_port *port, - struct file *filp); -extern int usb_serial_generic_write(struct usb_serial_port *port, - const unsigned char *buf, int count); -extern void usb_serial_generic_close(struct usb_serial_port *port, - struct file *filp); +extern int usb_serial_generic_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +extern int usb_serial_generic_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count); +extern void usb_serial_generic_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); extern int usb_serial_generic_resume(struct usb_serial *serial); -extern int usb_serial_generic_write_room(struct usb_serial_port *port); -extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); +extern int usb_serial_generic_write_room(struct tty_struct *tty); +extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty); extern void usb_serial_generic_read_bulk_callback(struct urb *urb); extern void usb_serial_generic_write_bulk_callback(struct urb *urb); -extern void usb_serial_generic_throttle(struct usb_serial_port *port); -extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); +extern void usb_serial_generic_throttle(struct tty_struct *tty); +extern void usb_serial_generic_unthrottle(struct tty_struct *tty); extern void usb_serial_generic_shutdown(struct usb_serial *serial); extern int usb_serial_generic_register(int debug); extern void usb_serial_generic_deregister(void); -- cgit v1.2.3-70-g09d2 From 80359a9c5c03d585686e2596c9ee46703eb03047 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:16 +0100 Subject: whiteheat: coding style Bring ezusb and whiteheat into line with the coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ezusb.c | 22 +-- drivers/usb/serial/whiteheat.c | 386 +++++++++++++++++++++++------------------ drivers/usb/serial/whiteheat.h | 78 ++++++--- 3 files changed, 280 insertions(+), 206 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c index cc4fbd9d60b..711e84f6ed8 100644 --- a/drivers/usb/serial/ezusb.c +++ b/drivers/usb/serial/ezusb.c @@ -20,7 +20,8 @@ /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ #define CPUCS_REG 0x7F92 -int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest) +int ezusb_writememory(struct usb_serial *serial, int address, + unsigned char *data, int length, __u8 request) { int result; unsigned char *transfer_buffer; @@ -33,26 +34,27 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da transfer_buffer = kmemdup(data, length, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", + __func__, length); return -ENOMEM; } - result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); - kfree (transfer_buffer); + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + request, 0x40, address, 0, transfer_buffer, length, 3000); + kfree(transfer_buffer); return result; } +EXPORT_SYMBOL_GPL(ezusb_writememory); -int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit) +int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit) { int response; /* dbg("%s - %d", __func__, reset_bit); */ - response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0); + response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0); if (response < 0) - dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit); + dev_err(&serial->dev->dev, "%s- %d failed\n", + __func__, reset_bit); return response; } - - -EXPORT_SYMBOL_GPL(ezusb_writememory); EXPORT_SYMBOL_GPL(ezusb_set_reset); diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index b07d6a5cac3..2569b68b833 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -12,29 +12,31 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * (10/09/2002) Stuart MacDonald (stuartm@connecttech.com) * Upgrade to full working driver * * (05/30/2001) gkh - * switched from using spinlock to a semaphore, which fixes lots of problems. + * switched from using spinlock to a semaphore, which fixes lots of + * problems. * * (04/08/2001) gb * Identify version on module load. - * + * * 2001_Mar_19 gkh - * Fixed MOD_INC and MOD_DEC logic, the ability to open a port more + * Fixed MOD_INC and MOD_DEC logic, the ability to open a port more * than once, and the got the proper usb_device_id table entries so * the driver works again. * * (11/01/2000) Adam J. Richter * usb_device_id table support - * + * * (10/05/2000) gkh * Fixed bug with urb->dev not being set properly, now that the usb * core needs it. - * + * * (10/03/2000) smd * firmware is improved to guard against crap sent to device * firmware now replies CMD_FAILURE on bad things @@ -52,9 +54,9 @@ * Fixed bug with port->minor that was found by Al Borchers * * (07/04/2000) gkh - * Added support for port settings. Baud rate can now be changed. Line signals - * are not transferred to and from the tty layer yet, but things seem to be - * working well now. + * Added support for port settings. Baud rate can now be changed. Line + * signals are not transferred to and from the tty layer yet, but things + * seem to be working well now. * * (05/04/2000) gkh * First cut at open and close commands. Data can flow through the ports at @@ -62,7 +64,7 @@ * * (03/26/2000) gkh * Split driver up into device specific pieces. - * + * */ #include @@ -75,7 +77,7 @@ #include #include #include -#include +#include #include #include #include @@ -125,7 +127,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver whiteheat_driver = { .name = "whiteheat", @@ -136,26 +138,34 @@ static struct usb_driver whiteheat_driver = { }; /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ -static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id); -static int whiteheat_firmware_attach (struct usb_serial *serial); +static int whiteheat_firmware_download(struct usb_serial *serial, + const struct usb_device_id *id); +static int whiteheat_firmware_attach(struct usb_serial *serial); /* function prototypes for the Connect Tech WhiteHEAT serial converter */ -static int whiteheat_attach (struct usb_serial *serial); -static void whiteheat_shutdown (struct usb_serial *serial); -static int whiteheat_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void whiteheat_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int whiteheat_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int whiteheat_write_room (struct tty_struct *tty); -static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); -static void whiteheat_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); -static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file); -static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void whiteheat_break_ctl (struct tty_struct *tty, int break_state); -static int whiteheat_chars_in_buffer (struct tty_struct *tty); -static void whiteheat_throttle (struct tty_struct *tty); -static void whiteheat_unthrottle (struct tty_struct *tty); -static void whiteheat_read_callback (struct urb *urb); -static void whiteheat_write_callback (struct urb *urb); +static int whiteheat_attach(struct usb_serial *serial); +static void whiteheat_shutdown(struct usb_serial *serial); +static int whiteheat_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void whiteheat_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int whiteheat_write(struct tty_struct *tty, + struct usb_serial_port *port, + const unsigned char *buf, int count); +static int whiteheat_write_room(struct tty_struct *tty); +static int whiteheat_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); +static void whiteheat_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file); +static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +static void whiteheat_break_ctl(struct tty_struct *tty, int break_state); +static int whiteheat_chars_in_buffer(struct tty_struct *tty); +static void whiteheat_throttle(struct tty_struct *tty); +static void whiteheat_unthrottle(struct tty_struct *tty); +static void whiteheat_read_callback(struct urb *urb); +static void whiteheat_write_callback(struct urb *urb); static struct usb_serial_driver whiteheat_fake_device = { .driver = { @@ -202,7 +212,9 @@ struct whiteheat_command_private { struct mutex mutex; __u8 port_running; __u8 command_finished; - wait_queue_head_t wait_command; /* for handling sleeping while waiting for a command to finish */ + wait_queue_head_t wait_command; /* for handling sleeping whilst + waiting for a command to + finish */ __u8 result_buffer[64]; }; @@ -239,11 +251,13 @@ static void command_port_write_callback(struct urb *urb); static void command_port_read_callback(struct urb *urb); static int start_port_read(struct usb_serial_port *port); -static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); +static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, + struct list_head *head); static struct list_head *list_first(struct list_head *head); static void rx_data_softint(struct work_struct *work); -static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); +static int firm_send_command(struct usb_serial_port *port, __u8 command, + __u8 *data, __u8 datasize); static int firm_open(struct usb_serial_port *port); static int firm_close(struct usb_serial_port *port); static int firm_setup_port(struct tty_struct *tty); @@ -278,7 +292,8 @@ static int firm_report_tx_done(struct usb_serial_port *port); - device renumerated itself and comes up as new device id with all firmware download completed. */ -static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id) +static int whiteheat_firmware_download(struct usb_serial *serial, + const struct usb_device_id *id) { int response, ret = -ENOENT; const struct firmware *loader_fw = NULL, *firmware_fw = NULL; @@ -313,7 +328,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct record = ihex_next_binrec(record); } - response = ezusb_set_reset (serial, 0); + response = ezusb_set_reset(serial, 0); record = (const struct ihex_binrec *)firmware_fw->data; while (record && be32_to_cpu(record->addr) < 0x1b40) @@ -330,8 +345,8 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct } ++record; } - - response = ezusb_set_reset (serial, 1); + + response = ezusb_set_reset(serial, 1); record = (const struct ihex_binrec *)firmware_fw->data; while (record && be32_to_cpu(record->addr) < 0x1b40) { @@ -355,7 +370,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct } -static int whiteheat_firmware_attach (struct usb_serial *serial) +static int whiteheat_firmware_attach(struct usb_serial *serial) { /* We want this device to fail to have a driver assigned to it */ return 1; @@ -365,7 +380,7 @@ static int whiteheat_firmware_attach (struct usb_serial *serial) /***************************************************************************** * Connect Tech's White Heat serial driver functions *****************************************************************************/ -static int whiteheat_attach (struct usb_serial *serial) +static int whiteheat_attach(struct usb_serial *serial) { struct usb_serial_port *command_port; struct whiteheat_command_private *command_info; @@ -386,43 +401,52 @@ static int whiteheat_attach (struct usb_serial *serial) command_port = serial->port[COMMAND_PORT]; - pipe = usb_sndbulkpipe (serial->dev, command_port->bulk_out_endpointAddress); + pipe = usb_sndbulkpipe(serial->dev, + command_port->bulk_out_endpointAddress); command = kmalloc(2, GFP_KERNEL); if (!command) goto no_command_buffer; command[0] = WHITEHEAT_GET_HW_INFO; command[1] = 0; - + result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL); if (!result) goto no_result_buffer; /* * When the module is reloaded the firmware is still there and * the endpoints are still in the usb core unchanged. This is the - * unlinking bug in disguise. Same for the call below. - */ + * unlinking bug in disguise. Same for the call below. + */ usb_clear_halt(serial->dev, pipe); - ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS); + ret = usb_bulk_msg(serial->dev, pipe, command, 2, + &alen, COMMAND_TIMEOUT_MS); if (ret) { - err("%s: Couldn't send command [%d]", serial->type->description, ret); + err("%s: Couldn't send command [%d]", + serial->type->description, ret); goto no_firmware; } else if (alen != 2) { - err("%s: Send command incomplete [%d]", serial->type->description, alen); + err("%s: Send command incomplete [%d]", + serial->type->description, alen); goto no_firmware; } - pipe = usb_rcvbulkpipe (serial->dev, command_port->bulk_in_endpointAddress); + pipe = usb_rcvbulkpipe(serial->dev, + command_port->bulk_in_endpointAddress); /* See the comment on the usb_clear_halt() above */ usb_clear_halt(serial->dev, pipe); - ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); + ret = usb_bulk_msg(serial->dev, pipe, result, + sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); if (ret) { - err("%s: Couldn't get results [%d]", serial->type->description, ret); + err("%s: Couldn't get results [%d]", + serial->type->description, ret); goto no_firmware; } else if (alen != sizeof(*hw_info) + 1) { - err("%s: Get results incomplete [%d]", serial->type->description, alen); + err("%s: Get results incomplete [%d]", + serial->type->description, alen); goto no_firmware; } else if (result[0] != command[0]) { - err("%s: Command failed [%d]", serial->type->description, result[0]); + err("%s: Command failed [%d]", + serial->type->description, result[0]); goto no_firmware; } @@ -436,7 +460,8 @@ static int whiteheat_attach (struct usb_serial *serial) info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); if (info == NULL) { - err("%s: Out of memory for port structures\n", serial->type->description); + err("%s: Out of memory for port structures\n", + serial->type->description); goto no_private; } @@ -506,9 +531,11 @@ static int whiteheat_attach (struct usb_serial *serial) usb_set_serial_port_data(port, info); } - command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); + command_info = kmalloc(sizeof(struct whiteheat_command_private), + GFP_KERNEL); if (command_info == NULL) { - err("%s: Out of memory for port structures\n", serial->type->description); + err("%s: Out of memory for port structures\n", + serial->type->description); goto no_command_private; } @@ -525,9 +552,12 @@ static int whiteheat_attach (struct usb_serial *serial) no_firmware: /* Firmware likely not running */ - err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description); - err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description); - err("%s: please contact support@connecttech.com\n", serial->type->description); + err("%s: Unable to retrieve firmware version, try replugging\n", + serial->type->description); + err("%s: If the firmware is not running (status led not blinking)\n", + serial->type->description); + err("%s: please contact support@connecttech.com\n", + serial->type->description); kfree(result); return -ENODEV; @@ -570,7 +600,7 @@ no_command_buffer: } -static void whiteheat_shutdown (struct usb_serial *serial) +static void whiteheat_shutdown(struct usb_serial *serial) { struct usb_serial_port *command_port; struct usb_serial_port *port; @@ -585,7 +615,7 @@ static void whiteheat_shutdown (struct usb_serial *serial) /* free up our private data for our command port */ command_port = serial->port[COMMAND_PORT]; - kfree (usb_get_serial_port_data(command_port)); + kfree(usb_get_serial_port_data(command_port)); for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; @@ -612,8 +642,7 @@ static void whiteheat_shutdown (struct usb_serial *serial) return; } - -static int whiteheat_open (struct tty_struct *tty, +static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { int retval = 0; @@ -655,7 +684,8 @@ static int whiteheat_open (struct tty_struct *tty, /* Start reading from the device */ retval = start_port_read(port); if (retval) { - err("%s - failed submitting read urb, error %d", __func__, retval); + err("%s - failed submitting read urb, error %d", + __func__, retval); firm_close(port); stop_command_port(port->serial); goto exit; @@ -668,7 +698,7 @@ exit: static void whiteheat_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; @@ -769,16 +799,19 @@ static int whiteheat_write(struct tty_struct *tty, wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); urb = wrap->urb; - bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count; - memcpy (urb->transfer_buffer, buf + sent, bytes); + bytes = (count > port->bulk_out_size) ? + port->bulk_out_size : count; + memcpy(urb->transfer_buffer, buf + sent, bytes); - usb_serial_debug_data(debug, &port->dev, __func__, bytes, urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, + __func__, bytes, urb->transfer_buffer); urb->dev = serial->dev; urb->transfer_buffer_length = bytes; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); sent = result; spin_lock_irqsave(&info->lock, flags); list_add(tmp, &info->tx_urbs_free); @@ -796,7 +829,6 @@ static int whiteheat_write(struct tty_struct *tty, return sent; } - static int whiteheat_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; @@ -806,7 +838,7 @@ static int whiteheat_write_room(struct tty_struct *tty) unsigned long flags; dbg("%s - port %d", __func__, port->number); - + spin_lock_irqsave(&info->lock, flags); list_for_each(tmp, &info->tx_urbs_free) room++; @@ -817,8 +849,7 @@ static int whiteheat_write_room(struct tty_struct *tty) return (room); } - -static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file) +static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); @@ -835,8 +866,7 @@ static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file) return modem_signals; } - -static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, +static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; @@ -860,7 +890,8 @@ static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, } -static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) +static int whiteheat_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; struct serial_struct serstruct; @@ -869,50 +900,38 @@ static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); switch (cmd) { - case TIOCGSERIAL: - memset(&serstruct, 0, sizeof(serstruct)); - serstruct.type = PORT_16654; - serstruct.line = port->serial->minor; - serstruct.port = port->number; - serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; - serstruct.xmit_fifo_size = port->bulk_out_size; - serstruct.custom_divisor = 0; - serstruct.baud_base = 460800; - serstruct.close_delay = CLOSING_DELAY; - serstruct.closing_wait = CLOSING_DELAY; - - if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) - return -EFAULT; - - break; - - case TIOCSSERIAL: - if (copy_from_user(&serstruct, user_arg, sizeof(serstruct))) - return -EFAULT; - - /* - * For now this is ignored. dip sets the ASYNC_[V]HI flags - * but this isn't used by us at all. Maybe someone somewhere - * will need the custom_divisor setting. - */ - - break; - - default: - break; + case TIOCGSERIAL: + memset(&serstruct, 0, sizeof(serstruct)); + serstruct.type = PORT_16654; + serstruct.line = port->serial->minor; + serstruct.port = port->number; + serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; + serstruct.xmit_fifo_size = port->bulk_out_size; + serstruct.custom_divisor = 0; + serstruct.baud_base = 460800; + serstruct.close_delay = CLOSING_DELAY; + serstruct.closing_wait = CLOSING_DELAY; + + if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) + return -EFAULT; + break; + default: + break; } return -ENOIOCTLCMD; } -static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) +static void whiteheat_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios) { + /* FIXME */ firm_setup_port(tty); } - -static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) { +static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) +{ struct usb_serial_port *port = tty->driver_data; firm_set_break(port, break_state); } @@ -936,12 +955,12 @@ static int whiteheat_chars_in_buffer(struct tty_struct *tty) } spin_unlock_irqrestore(&info->lock, flags); - dbg ("%s - returns %d", __func__, chars); + dbg("%s - returns %d", __func__, chars); return chars; } -static void whiteheat_throttle (struct tty_struct *tty) +static void whiteheat_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); @@ -957,7 +976,7 @@ static void whiteheat_throttle (struct tty_struct *tty) } -static void whiteheat_unthrottle (struct tty_struct *tty) +static void whiteheat_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct whiteheat_private *info = usb_get_serial_port_data(port); @@ -1006,7 +1025,7 @@ static void command_port_read_callback(struct urb *urb) command_info = usb_get_serial_port_data(command_port); if (!command_info) { - dbg ("%s - command_info is NULL, exiting.", __func__); + dbg("%s - command_info is NULL, exiting.", __func__); return; } if (status) { @@ -1017,7 +1036,8 @@ static void command_port_read_callback(struct urb *urb) return; } - usb_serial_debug_data(debug, &command_port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &command_port->dev, + __func__, urb->actual_length, data); if (data[0] == WHITEHEAT_CMD_COMPLETE) { command_info->command_finished = WHITEHEAT_CMD_COMPLETE; @@ -1026,21 +1046,23 @@ static void command_port_read_callback(struct urb *urb) command_info->command_finished = WHITEHEAT_CMD_FAILURE; wake_up(&command_info->wait_command); } else if (data[0] == WHITEHEAT_EVENT) { - /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */ + /* These are unsolicited reports from the firmware, hence no + waiting command to wakeup */ dbg("%s - event received", __func__); } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { - memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1); + memcpy(command_info->result_buffer, &data[1], + urb->actual_length - 1); command_info->command_finished = WHITEHEAT_CMD_COMPLETE; wake_up(&command_info->wait_command); - } else { + } else dbg("%s - bad reply from firmware", __func__); - } - + /* Continue trying to always read */ command_port->read_urb->dev = command_port->serial->dev; result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); if (result) - dbg("%s - failed resubmitting read urb, error %d", __func__, result); + dbg("%s - failed resubmitting read urb, error %d", + __func__, result); } @@ -1073,7 +1095,8 @@ static void whiteheat_read_callback(struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, + __func__, urb->actual_length, data); spin_lock(&info->lock); list_add_tail(&wrap->list, &info->rx_urb_q); @@ -1120,7 +1143,8 @@ static void whiteheat_write_callback(struct urb *urb) /***************************************************************************** * Connect Tech's White Heat firmware interface *****************************************************************************/ -static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize) +static int firm_send_command(struct usb_serial_port *port, __u8 command, + __u8 *data, __u8 datasize) { struct usb_serial_port *command_port; struct whiteheat_command_private *command_info; @@ -1135,13 +1159,13 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d command_info = usb_get_serial_port_data(command_port); mutex_lock(&command_info->mutex); command_info->command_finished = false; - + transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; transfer_buffer[0] = command; - memcpy (&transfer_buffer[1], data, datasize); + memcpy(&transfer_buffer[1], data, datasize); command_port->write_urb->transfer_buffer_length = datasize + 1; command_port->write_urb->dev = port->serial->dev; - retval = usb_submit_urb (command_port->write_urb, GFP_NOIO); + retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); if (retval) { dbg("%s - submit urb failed", __func__); goto exit; @@ -1168,36 +1192,41 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { dbg("%s - command completed.", __func__); switch (command) { - case WHITEHEAT_GET_DTR_RTS: - info = usb_get_serial_port_data(port); - memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info)); + case WHITEHEAT_GET_DTR_RTS: + info = usb_get_serial_port_data(port); + memcpy(&info->mcr, command_info->result_buffer, + sizeof(struct whiteheat_dr_info)); break; } } - exit: mutex_unlock(&command_info->mutex); return retval; } -static int firm_open(struct usb_serial_port *port) { +static int firm_open(struct usb_serial_port *port) +{ struct whiteheat_simple open_command; open_command.port = port->number - port->serial->minor + 1; - return firm_send_command(port, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command)); + return firm_send_command(port, WHITEHEAT_OPEN, + (__u8 *)&open_command, sizeof(open_command)); } -static int firm_close(struct usb_serial_port *port) { +static int firm_close(struct usb_serial_port *port) +{ struct whiteheat_simple close_command; close_command.port = port->number - port->serial->minor + 1; - return firm_send_command(port, WHITEHEAT_CLOSE, (__u8 *)&close_command, sizeof(close_command)); + return firm_send_command(port, WHITEHEAT_CLOSE, + (__u8 *)&close_command, sizeof(close_command)); } -static int firm_setup_port(struct tty_struct *tty) { +static int firm_setup_port(struct tty_struct *tty) +{ struct usb_serial_port *port = tty->driver_data; struct whiteheat_port_settings port_settings; unsigned int cflag = tty->termios->c_cflag; @@ -1206,14 +1235,14 @@ static int firm_setup_port(struct tty_struct *tty) { /* get the byte size */ switch (cflag & CSIZE) { - case CS5: port_settings.bits = 5; break; - case CS6: port_settings.bits = 6; break; - case CS7: port_settings.bits = 7; break; - default: - case CS8: port_settings.bits = 8; break; + case CS5: port_settings.bits = 5; break; + case CS6: port_settings.bits = 6; break; + case CS7: port_settings.bits = 7; break; + default: + case CS8: port_settings.bits = 8; break; } dbg("%s - data bits = %d", __func__, port_settings.bits); - + /* determine the parity */ if (cflag & PARENB) if (cflag & CMSPAR) @@ -1239,7 +1268,8 @@ static int firm_setup_port(struct tty_struct *tty) { /* figure out the flow control settings */ if (cflag & CRTSCTS) - port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS); + port_settings.hflow = (WHITEHEAT_HFLOW_CTS | + WHITEHEAT_HFLOW_RTS); else port_settings.hflow = WHITEHEAT_HFLOW_NONE; dbg("%s - hardware flow control = %s %s %s %s", __func__, @@ -1247,17 +1277,18 @@ static int firm_setup_port(struct tty_struct *tty) { (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); - + /* determine software flow control */ if (I_IXOFF(tty)) port_settings.sflow = WHITEHEAT_SFLOW_RXTX; else port_settings.sflow = WHITEHEAT_SFLOW_NONE; dbg("%s - software flow control = %c", __func__, port_settings.sflow); - + port_settings.xon = START_CHAR(tty); port_settings.xoff = STOP_CHAR(tty); - dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff); + dbg("%s - XON = %2x, XOFF = %2x", + __func__, port_settings.xon, port_settings.xoff); /* get the baud rate wanted */ port_settings.baud = tty_get_baud_rate(tty); @@ -1267,61 +1298,74 @@ static int firm_setup_port(struct tty_struct *tty) { tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); /* handle any settings that aren't specified in the tty structure */ port_settings.lloop = 0; - + /* now send the message to the device */ - return firm_send_command(port, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings)); + return firm_send_command(port, WHITEHEAT_SETUP_PORT, + (__u8 *)&port_settings, sizeof(port_settings)); } -static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) { +static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) +{ struct whiteheat_set_rdb rts_command; rts_command.port = port->number - port->serial->minor + 1; rts_command.state = onoff; - return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&rts_command, sizeof(rts_command)); + return firm_send_command(port, WHITEHEAT_SET_RTS, + (__u8 *)&rts_command, sizeof(rts_command)); } -static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) { +static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) +{ struct whiteheat_set_rdb dtr_command; dtr_command.port = port->number - port->serial->minor + 1; dtr_command.state = onoff; - return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&dtr_command, sizeof(dtr_command)); + return firm_send_command(port, WHITEHEAT_SET_RTS, + (__u8 *)&dtr_command, sizeof(dtr_command)); } -static int firm_set_break(struct usb_serial_port *port, __u8 onoff) { +static int firm_set_break(struct usb_serial_port *port, __u8 onoff) +{ struct whiteheat_set_rdb break_command; break_command.port = port->number - port->serial->minor + 1; break_command.state = onoff; - return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&break_command, sizeof(break_command)); + return firm_send_command(port, WHITEHEAT_SET_RTS, + (__u8 *)&break_command, sizeof(break_command)); } -static int firm_purge(struct usb_serial_port *port, __u8 rxtx) { +static int firm_purge(struct usb_serial_port *port, __u8 rxtx) +{ struct whiteheat_purge purge_command; purge_command.port = port->number - port->serial->minor + 1; purge_command.what = rxtx; - return firm_send_command(port, WHITEHEAT_PURGE, (__u8 *)&purge_command, sizeof(purge_command)); + return firm_send_command(port, WHITEHEAT_PURGE, + (__u8 *)&purge_command, sizeof(purge_command)); } -static int firm_get_dtr_rts(struct usb_serial_port *port) { +static int firm_get_dtr_rts(struct usb_serial_port *port) +{ struct whiteheat_simple get_dr_command; get_dr_command.port = port->number - port->serial->minor + 1; - return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, (__u8 *)&get_dr_command, sizeof(get_dr_command)); + return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, + (__u8 *)&get_dr_command, sizeof(get_dr_command)); } -static int firm_report_tx_done(struct usb_serial_port *port) { +static int firm_report_tx_done(struct usb_serial_port *port) +{ struct whiteheat_simple close_command; close_command.port = port->number - port->serial->minor + 1; - return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, (__u8 *)&close_command, sizeof(close_command)); + return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, + (__u8 *)&close_command, sizeof(close_command)); } @@ -1333,7 +1377,7 @@ static int start_command_port(struct usb_serial *serial) struct usb_serial_port *command_port; struct whiteheat_command_private *command_info; int retval = 0; - + command_port = serial->port[COMMAND_PORT]; command_info = usb_get_serial_port_data(command_port); mutex_lock(&command_info->mutex); @@ -1344,7 +1388,8 @@ static int start_command_port(struct usb_serial *serial) command_port->read_urb->dev = serial->dev; retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); if (retval) { - err("%s - failed submitting read urb, error %d", __func__, retval); + err("%s - failed submitting read urb, error %d", + __func__, retval); goto exit; } } @@ -1414,7 +1459,8 @@ static int start_port_read(struct usb_serial_port *port) } -static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) +static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, + struct list_head *head) { struct whiteheat_urb_wrap *wrap; struct list_head *tmp; @@ -1463,7 +1509,8 @@ static void rx_data_softint(struct work_struct *work) urb = wrap->urb; if (tty && urb->actual_length) { - int len = tty_buffer_request_room(tty, urb->actual_length); + int len = tty_buffer_request_room(tty, + urb->actual_length); /* This stuff can go away now I suspect */ if (unlikely(len < urb->actual_length)) { spin_lock_irqsave(&info->lock, flags); @@ -1480,7 +1527,8 @@ static void rx_data_softint(struct work_struct *work) urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed resubmitting read urb, error %d", __func__, result); + err("%s - failed resubmitting read urb, error %d", + __func__, result); spin_lock_irqsave(&info->lock, flags); list_add(tmp, &info->rx_urbs_free); continue; @@ -1499,7 +1547,7 @@ static void rx_data_softint(struct work_struct *work) /***************************************************************************** * Connect Tech's White Heat module functions *****************************************************************************/ -static int __init whiteheat_init (void) +static int __init whiteheat_init(void) { int retval; retval = usb_serial_register(&whiteheat_fake_device); @@ -1522,19 +1570,19 @@ failed_fake_register: } -static void __exit whiteheat_exit (void) +static void __exit whiteheat_exit(void) { - usb_deregister (&whiteheat_driver); - usb_serial_deregister (&whiteheat_fake_device); - usb_serial_deregister (&whiteheat_device); + usb_deregister(&whiteheat_driver); + usb_serial_deregister(&whiteheat_fake_device); + usb_serial_deregister(&whiteheat_device); } module_init(whiteheat_init); module_exit(whiteheat_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("whiteheat.fw"); diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h index f1607970566..38065df4d2d 100644 --- a/drivers/usb/serial/whiteheat.h +++ b/drivers/usb/serial/whiteheat.h @@ -2,7 +2,7 @@ * USB ConnectTech WhiteHEAT driver * * Copyright (C) 2002 - * Connect Tech Inc. + * Connect Tech Inc. * * Copyright (C) 1999, 2000 * Greg Kroah-Hartman (greg@kroah.com) @@ -12,7 +12,8 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * */ @@ -30,13 +31,16 @@ #define WHITEHEAT_DUMP 7 /* dump memory */ #define WHITEHEAT_STATUS 8 /* get status */ #define WHITEHEAT_PURGE 9 /* clear the UART fifos */ -#define WHITEHEAT_GET_DTR_RTS 10 /* get the state of DTR and RTS for a port */ -#define WHITEHEAT_GET_HW_INFO 11 /* get EEPROM info and hardware ID */ +#define WHITEHEAT_GET_DTR_RTS 10 /* get the state of DTR and RTS + for a port */ +#define WHITEHEAT_GET_HW_INFO 11 /* get EEPROM info and + hardware ID */ #define WHITEHEAT_REPORT_TX_DONE 12 /* get the next TX done */ #define WHITEHEAT_EVENT 13 /* unsolicited status events */ -#define WHITEHEAT_ECHO 14 /* send data to the indicated IN endpoint */ -#define WHITEHEAT_DO_TEST 15 /* perform the specified test */ -#define WHITEHEAT_CMD_COMPLETE 16 /* reply for certain commands */ +#define WHITEHEAT_ECHO 14 /* send data to the indicated + IN endpoint */ +#define WHITEHEAT_DO_TEST 15 /* perform specified test */ +#define WHITEHEAT_CMD_COMPLETE 16 /* reply for some commands */ #define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */ @@ -67,20 +71,28 @@ struct whiteheat_simple { #define WHITEHEAT_PAR_MARK '1' /* mark (force 1) parity */ #define WHITEHEAT_SFLOW_NONE 'n' /* no software flow control */ -#define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX fills/empties */ -#define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will stop/start TX */ +#define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX + fills/empties */ +#define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will + stop/start TX */ #define WHITEHEAT_SFLOW_RXTX 'b' /* both SFLOW_RX and SFLOW_TX */ #define WHITEHEAT_HFLOW_NONE 0x00 /* no hardware flow control */ -#define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit, off otherwise */ -#define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX fills/empties */ -#define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on will stop/start TX */ -#define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on will stop/start TX */ -#define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX fills/empties */ +#define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit, + off otherwise */ +#define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX + fills/empties */ +#define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on + will stop/start TX */ +#define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on + will stop/start TX */ +#define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX + fills/empties */ struct whiteheat_port_settings { __u8 port; /* port number (1 to N) */ - __u32 baud; /* any value 7 - 460800, firmware calculates best fit; arrives little endian */ + __u32 baud; /* any value 7 - 460800, firmware calculates + best fit; arrives little endian */ __u8 bits; /* 5, 6, 7, or 8 */ __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */ __u8 parity; /* see WHITEHEAT_PAR_* above */ @@ -167,12 +179,14 @@ struct whiteheat_echo { */ #define WHITEHEAT_TEST_UART_RW 0x01 /* read/write uart registers */ #define WHITEHEAT_TEST_UART_INTR 0x02 /* uart interrupt */ -#define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for PORT_CONT/PORT_DISCONT */ +#define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for + PORT_CONT/PORT_DISCONT */ #define WHITEHEAT_TEST_PORT_CONT 0x04 /* port connect */ #define WHITEHEAT_TEST_PORT_DISCONT 0x05 /* port disconnect */ #define WHITEHEAT_TEST_UART_CLK_START 0x06 /* uart clock test start */ #define WHITEHEAT_TEST_UART_CLK_STOP 0x07 /* uart clock test stop */ -#define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a loopback cable/connector */ +#define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a + loopback cable/connector */ #define WHITEHEAT_TEST_ERASE_EEPROM 0x09 /* erase eeprom */ #define WHITEHEAT_TEST_READ_EEPROM 0x0a /* read eeprom */ #define WHITEHEAT_TEST_PROGRAM_EEPROM 0x0b /* program eeprom */ @@ -198,19 +212,27 @@ struct whiteheat_test { #define WHITEHEAT_EVENT_CONNECT 0x08 /* connect field is valid */ #define WHITEHEAT_FLOW_NONE 0x00 /* no flow control active */ -#define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS (waiting for CTS to go on) */ -#define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped by RTS */ -#define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF received (waiting for XON) */ -#define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF transmitted */ +#define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS + (waiting for CTS to go on) */ +#define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped + by RTS */ +#define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF + received (waiting for XON) */ +#define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF + transmitted */ #define WHITEHEAT_FLOW_TX_DONE 0x80 /* TX has completed */ struct whiteheat_status_info { __u8 port; /* port number (1 to N) */ - __u8 event; /* indicates what the current event is, see WHITEHEAT_EVENT_* above */ - __u8 modem; /* modem signal status (copy of uart's MSR register) */ + __u8 event; /* indicates what the current event is, + see WHITEHEAT_EVENT_* above */ + __u8 modem; /* modem signal status (copy of uart's + MSR register) */ __u8 error; /* line status (copy of uart's LSR register) */ - __u8 flow; /* flow control state, see WHITEHEAT_FLOW_* above */ - __u8 connect; /* 0 means not connected, non-zero means connected */ + __u8 flow; /* flow control state, see WHITEHEAT_FLOW_* + above */ + __u8 connect; /* 0 means not connected, non-zero means + connected */ }; @@ -256,7 +278,8 @@ struct whiteheat_hw_info { struct whiteheat_event_info { __u8 port; /* port number (1 to N) */ __u8 event; /* see whiteheat_status_info.event */ - __u8 info; /* see whiteheat_status_info.modem, .error, .flow, .connect */ + __u8 info; /* see whiteheat_status_info.modem, .error, + .flow, .connect */ }; @@ -269,7 +292,8 @@ struct whiteheat_event_info { struct whiteheat_test_info { __u8 port; /* port number (1 to N) */ - __u8 test; /* indicates which test this is a response for, see WHITEHEAT_DO_TEST above */ + __u8 test; /* indicates which test this is a response for, + see WHITEHEAT_DO_TEST above */ __u8 status; /* see WHITEHEAT_TEST_* above */ __u8 results[32]; /* test-dependent results */ }; -- cgit v1.2.3-70-g09d2 From 72e2741256e65f2adcc03754523d6a2fdb260e4a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:29 +0100 Subject: whiteheat: fix bugs found in the tidy and audit Termios tidy up, plus fix break and DTR. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/whiteheat.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 2569b68b833..05374b99a2f 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -671,11 +671,8 @@ static int whiteheat_open(struct tty_struct *tty, goto exit; } - if (tty) { - old_term.c_cflag = ~tty->termios->c_cflag; - old_term.c_iflag = ~tty->termios->c_iflag; - whiteheat_set_termios(tty, port, &old_term); - } + if (tty) + firm_setup_port(tty); /* Work around HCD bugs */ usb_clear_halt(port->serial->dev, port->read_urb->pipe); @@ -926,7 +923,6 @@ static int whiteheat_ioctl(struct tty_struct *tty, struct file *file, static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { - /* FIXME */ firm_setup_port(tty); } @@ -1322,7 +1318,7 @@ static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) dtr_command.port = port->number - port->serial->minor + 1; dtr_command.state = onoff; - return firm_send_command(port, WHITEHEAT_SET_RTS, + return firm_send_command(port, WHITEHEAT_SET_DTR, (__u8 *)&dtr_command, sizeof(dtr_command)); } @@ -1333,7 +1329,7 @@ static int firm_set_break(struct usb_serial_port *port, __u8 onoff) break_command.port = port->number - port->serial->minor + 1; break_command.state = onoff; - return firm_send_command(port, WHITEHEAT_SET_RTS, + return firm_send_command(port, WHITEHEAT_SET_BREAK, (__u8 *)&break_command, sizeof(break_command)); } -- cgit v1.2.3-70-g09d2 From b69c14992ecbff99d1b2b66d8ccbcffe131c6e38 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:39 +0100 Subject: belkin_sa: clean up code Coding style tidy up for belkin_sa Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/belkin_sa.c | 148 ++++++++++++++++++++++++----------------- drivers/usb/serial/belkin_sa.h | 15 +++-- 2 files changed, 94 insertions(+), 69 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 1a762692c73..2ebe06c3405 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -7,13 +7,14 @@ * This program is largely derived from work by the linux-usb group * and associated source files. Please see the usb/serial files for * individual credits and copyrights. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * TODO: * -- Add true modem contol line query capability. Currently we track the @@ -28,7 +29,8 @@ * compressed all the differnent device entries into 1. * * 30-May-2001 gkh - * switched from using spinlock to a semaphore, which fixes lots of problems. + * switched from using spinlock to a semaphore, which fixes lots of + * problems. * * 08-Apr-2001 gb * - Identify version on module load. @@ -41,7 +43,7 @@ * - Added support for the old Belkin and Peracom devices. * - Made the port able to be opened multiple times. * - Added some defaults incase the line settings are things these devices - * can't support. + * can't support. * * 18-Oct-2000 William Greathouse * Released into the wild (linux-usb-devel) @@ -72,7 +74,7 @@ #include #include #include -#include +#include #include #include #include "belkin_sa.h" @@ -87,15 +89,19 @@ static int debug; #define DRIVER_DESC "USB Belkin Serial converter driver" /* function prototypes for a Belkin USB Serial Adapter F5U103 */ -static int belkin_sa_startup (struct usb_serial *serial); -static void belkin_sa_shutdown (struct usb_serial *serial); -static int belkin_sa_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void belkin_sa_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void belkin_sa_read_int_callback (struct urb *urb); -static void belkin_sa_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); -static void belkin_sa_break_ctl (struct tty_struct *tty, int break_state ); -static int belkin_sa_tiocmget (struct tty_struct *tty, struct file *file); -static int belkin_sa_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); +static int belkin_sa_startup(struct usb_serial *serial); +static void belkin_sa_shutdown(struct usb_serial *serial); +static int belkin_sa_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void belkin_sa_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void belkin_sa_read_int_callback(struct urb *urb); +static void belkin_sa_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios * old); +static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state); +static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file); +static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); static struct usb_device_id id_table_combined [] = { @@ -105,10 +111,10 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) }, { USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) }, { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) }, - { } /* Terminating entry */ + { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver belkin_driver = { .name = "belkin", @@ -130,7 +136,8 @@ static struct usb_serial_driver belkin_device = { .num_ports = 1, .open = belkin_sa_open, .close = belkin_sa_close, - .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ + .read_int_callback = belkin_sa_read_int_callback, + /* How we get the status info */ .set_termios = belkin_sa_set_termios, .break_ctl = belkin_sa_break_ctl, .tiocmget = belkin_sa_tiocmget, @@ -158,12 +165,12 @@ struct belkin_sa_private { #define WDR_TIMEOUT 5000 /* default urb timeout */ /* assumes that struct usb_serial *serial is available */ -#define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \ +#define BSA_USB_CMD(c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \ (c), BELKIN_SA_SET_REQUEST_TYPE, \ (v), 0, NULL, 0, WDR_TIMEOUT) /* do some startup allocations not currently performed by usb_serial_probe() */ -static int belkin_sa_startup (struct usb_serial *serial) +static int belkin_sa_startup(struct usb_serial *serial) { struct usb_device *dev = serial->dev; struct belkin_sa_private *priv; @@ -171,20 +178,23 @@ static int belkin_sa_startup (struct usb_serial *serial) /* allocate the private data structure */ priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); if (!priv) - return (-1); /* error */ + return -1; /* error */ /* set initial values for control structures */ spin_lock_init(&priv->lock); priv->control_state = 0; priv->last_lsr = 0; priv->last_msr = 0; /* see comments at top of file */ - priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; - info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control); + priv->bad_flow_control = + (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; + info("bcdDevice: %04x, bfc: %d", + le16_to_cpu(dev->descriptor.bcdDevice), + priv->bad_flow_control); init_waitqueue_head(&serial->port[0]->write_wait); usb_set_serial_port_data(serial->port[0], priv); - - return (0); + + return 0; } @@ -192,11 +202,11 @@ static void belkin_sa_shutdown(struct usb_serial *serial) { struct belkin_sa_private *priv; int i; - - dbg ("%s", __func__); + + dbg("%s", __func__); /* stop reads and writes on all ports */ - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ priv = usb_get_serial_port_data(serial->port[i]); kfree(priv); @@ -204,7 +214,8 @@ static void belkin_sa_shutdown(struct usb_serial *serial) } -static int belkin_sa_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) +static int belkin_sa_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { int retval = 0; @@ -233,7 +244,7 @@ exit: } /* belkin_sa_open */ -static void belkin_sa_close (struct tty_struct *tty, +static void belkin_sa_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { dbg("%s port %d", __func__, port->number); @@ -271,7 +282,8 @@ static void belkin_sa_read_int_callback(struct urb *urb) goto exit; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); /* Handle known interrupt data */ /* ignore data[0] and data[1] */ @@ -279,7 +291,7 @@ static void belkin_sa_read_int_callback(struct urb *urb) priv = usb_get_serial_port_data(port); spin_lock_irqsave(&priv->lock, flags); priv->last_msr = data[BELKIN_SA_MSR_INDEX]; - + /* Record Control Line states */ if (priv->last_msr & BELKIN_SA_MSR_DSR) priv->control_state |= TIOCM_DSR; @@ -327,9 +339,9 @@ static void belkin_sa_read_int_callback(struct urb *urb) #endif spin_unlock_irqrestore(&priv->lock, flags); exit: - retval = usb_submit_urb (urb, GFP_ATOMIC); + retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) - err ("%s - usb_submit_urb failed with result %d", + err("%s - usb_submit_urb failed with result %d", __func__, retval); } @@ -348,7 +360,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, int bad_flow_control; speed_t baud; struct ktermios *termios = tty->termios; - + iflag = termios->c_iflag; cflag = termios->c_cflag; @@ -359,20 +371,21 @@ static void belkin_sa_set_termios(struct tty_struct *tty, control_state = priv->control_state; bad_flow_control = priv->bad_flow_control; spin_unlock_irqrestore(&priv->lock, flags); - + old_iflag = old_termios->c_iflag; old_cflag = old_termios->c_cflag; /* Set the baud rate */ if ((cflag & CBAUD) != (old_cflag & CBAUD)) { /* reassert DTR and (maybe) RTS on transition from B0 */ - if( (old_cflag&CBAUD) == B0 ) { + if ((old_cflag & CBAUD) == B0) { control_state |= (TIOCM_DTR|TIOCM_RTS); if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) err("Set DTR error"); /* don't set RTS if using hardware flow control */ if (!(old_cflag & CRTSCTS)) - if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST + , 1) < 0) err("Set RTS error"); } } @@ -392,7 +405,8 @@ static void belkin_sa_set_termios(struct tty_struct *tty, err("Set baudrate error"); } else { /* Disable flow control */ - if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, + BELKIN_SA_FLOW_NONE) < 0) err("Disable flowcontrol error"); /* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR | TIOCM_RTS); @@ -403,9 +417,10 @@ static void belkin_sa_set_termios(struct tty_struct *tty, } /* set the parity */ - if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) { + if ((cflag ^ old_cflag) & (PARENB | PARODD)) { if (cflag & PARENB) - urb_value = (cflag & PARODD) ? BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN; + urb_value = (cflag & PARODD) ? BELKIN_SA_PARITY_ODD + : BELKIN_SA_PARITY_EVEN; else urb_value = BELKIN_SA_PARITY_NONE; if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) @@ -413,31 +428,40 @@ static void belkin_sa_set_termios(struct tty_struct *tty, } /* set the number of data bits */ - if( (cflag&CSIZE) != (old_cflag&CSIZE) ) { + if ((cflag & CSIZE) != (old_cflag & CSIZE)) { switch (cflag & CSIZE) { - case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break; - case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break; - case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break; - case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break; - default: dbg("CSIZE was not CS5-CS8, using default of 8"); - urb_value = BELKIN_SA_DATA_BITS(8); - break; + case CS5: + urb_value = BELKIN_SA_DATA_BITS(5); + break; + case CS6: + urb_value = BELKIN_SA_DATA_BITS(6); + break; + case CS7: + urb_value = BELKIN_SA_DATA_BITS(7); + break; + case CS8: + urb_value = BELKIN_SA_DATA_BITS(8); + break; + default: dbg("CSIZE was not CS5-CS8, using default of 8"); + urb_value = BELKIN_SA_DATA_BITS(8); + break; } if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) err("Set data bits error"); } /* set the number of stop bits */ - if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) { - urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1); - if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0) + if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { + urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) + : BELKIN_SA_STOP_BITS(1); + if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, + urb_value) < 0) err("Set stop bits error"); } /* Set flow control */ - if( (iflag&IXOFF) != (old_iflag&IXOFF) - || (iflag&IXON) != (old_iflag&IXON) - || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) { + if (((iflag ^ old_iflag) & (IXOFF | IXON)) || + ((cflag ^ old_cflag) & CRTSCTS)) { urb_value = 0; if ((iflag & IXOFF) || (iflag & IXON)) urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON); @@ -479,7 +503,7 @@ static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file) struct belkin_sa_private *priv = usb_get_serial_port_data(port); unsigned long control_state; unsigned long flags; - + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); @@ -501,7 +525,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file, int retval; int rts = 0; int dtr = 0; - + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); @@ -563,17 +587,17 @@ failed_usb_serial_register: static void __exit belkin_sa_exit (void) { - usb_deregister (&belkin_driver); + usb_deregister(&belkin_driver); usb_serial_deregister(&belkin_device); } -module_init (belkin_sa_init); -module_exit (belkin_sa_exit); +module_init(belkin_sa_init); +module_exit(belkin_sa_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_VERSION( DRIVER_VERSION ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); diff --git a/drivers/usb/serial/belkin_sa.h b/drivers/usb/serial/belkin_sa.h index 9116b92f462..c66a6730d38 100644 --- a/drivers/usb/serial/belkin_sa.h +++ b/drivers/usb/serial/belkin_sa.h @@ -7,13 +7,14 @@ * This program is largely derived from work by the linux-usb group * and associated source files. Please see the usb/serial files for * individual credits and copyrights. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * 12-Mar-2001 gkh * Added GoHubs GO-COM232 device id. @@ -27,7 +28,7 @@ * adapter, so pardon any stupid mistakes. All of the information * I am using to write this driver was acquired by using a modified * UsbSnoop on Windows2000. - * + * */ #ifndef __LINUX_USB_SERIAL_BSA_H @@ -96,20 +97,20 @@ /* * It seems that the interrupt pipe is closely modelled after the - * 16550 register layout. This is probably because the adapter can + * 16550 register layout. This is probably because the adapter can * be used in a "DOS" environment to simulate a standard hardware port. */ -#define BELKIN_SA_LSR_INDEX 2 /* Line Status Register */ +#define BELKIN_SA_LSR_INDEX 2 /* Line Status Register */ #define BELKIN_SA_LSR_RDR 0x01 /* receive data ready */ #define BELKIN_SA_LSR_OE 0x02 /* overrun error */ #define BELKIN_SA_LSR_PE 0x04 /* parity error */ #define BELKIN_SA_LSR_FE 0x08 /* framing error */ #define BELKIN_SA_LSR_BI 0x10 /* break indicator */ -#define BELKIN_SA_LSR_THE 0x20 /* transmit holding register empty */ +#define BELKIN_SA_LSR_THE 0x20 /* tx holding register empty */ #define BELKIN_SA_LSR_TE 0x40 /* transmit register empty */ #define BELKIN_SA_LSR_ERR 0x80 /* OE | PE | FE | BI */ -#define BELKIN_SA_MSR_INDEX 3 /* Modem Status Register */ +#define BELKIN_SA_MSR_INDEX 3 /* Modem Status Register */ #define BELKIN_SA_MSR_DCTS 0x01 /* Delta CTS */ #define BELKIN_SA_MSR_DDSR 0x02 /* Delta DSR */ #define BELKIN_SA_MSR_DRI 0x04 /* Delta RI */ -- cgit v1.2.3-70-g09d2 From c97611c16d9b3c37fcf3c18cc442dfde3a8b5d43 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:48 +0100 Subject: usb-serial-bus: tidy coding style Tidy up Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/bus.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 0b14aea8ebd..83bbb5bca2e 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -15,7 +15,8 @@ #include #include -static int usb_serial_device_match (struct device *dev, struct device_driver *drv) +static int usb_serial_device_match(struct device *dev, + struct device_driver *drv) { struct usb_serial_driver *driver; const struct usb_serial_port *port; @@ -46,7 +47,7 @@ static ssize_t show_port_number(struct device *dev, static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL); -static int usb_serial_device_probe (struct device *dev) +static int usb_serial_device_probe(struct device *dev) { struct usb_serial_driver *driver; struct usb_serial_port *port; @@ -66,7 +67,7 @@ static int usb_serial_device_probe (struct device *dev) retval = -EIO; goto exit; } - retval = driver->port_probe (port); + retval = driver->port_probe(port); module_put(driver->driver.owner); if (retval) goto exit; @@ -77,8 +78,8 @@ static int usb_serial_device_probe (struct device *dev) goto exit; minor = port->number; - tty_register_device (usb_serial_tty_driver, minor, dev); - dev_info(&port->serial->dev->dev, + tty_register_device(usb_serial_tty_driver, minor, dev); + dev_info(&port->serial->dev->dev, "%s converter now attached to ttyUSB%d\n", driver->description, minor); @@ -86,7 +87,7 @@ exit: return retval; } -static int usb_serial_device_remove (struct device *dev) +static int usb_serial_device_remove(struct device *dev) { struct usb_serial_driver *driver; struct usb_serial_port *port; @@ -94,9 +95,8 @@ static int usb_serial_device_remove (struct device *dev) int minor; port = to_usb_serial_port(dev); - if (!port) { + if (!port) return -ENODEV; - } device_remove_file(&port->dev, &dev_attr_port_number); @@ -107,12 +107,12 @@ static int usb_serial_device_remove (struct device *dev) retval = -EIO; goto exit; } - retval = driver->port_remove (port); + retval = driver->port_remove(port); module_put(driver->driver.owner); } exit: minor = port->number; - tty_unregister_device (usb_serial_tty_driver, minor); + tty_unregister_device(usb_serial_tty_driver, minor); dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", driver->description, minor); -- cgit v1.2.3-70-g09d2 From 4dbd5a0961ff55cb8a7bce309dd5ef9b04090570 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:57 +0100 Subject: tty-usb-console: tidy the USB console code Code tidy Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/console.c | 127 ++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 61 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 940f5de6898..9a4cd0a932b 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -6,7 +6,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. - * + * * Thanks to Randy Dunlap for the original version of this code. * */ @@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options) struct tty_struct *tty = NULL; struct ktermios *termios = NULL, dummy; - dbg ("%s", __func__); + dbg("%s", __func__); if (options) { baud = simple_strtoul(options, NULL, 10); @@ -84,52 +84,52 @@ static int usb_console_setup(struct console *co, char *options) /* build a cflag setting */ switch (baud) { - case 1200: - cflag |= B1200; - break; - case 2400: - cflag |= B2400; - break; - case 4800: - cflag |= B4800; - break; - case 19200: - cflag |= B19200; - break; - case 38400: - cflag |= B38400; - break; - case 57600: - cflag |= B57600; - break; - case 115200: - cflag |= B115200; - break; - case 9600: - default: - cflag |= B9600; - /* - * Set this to a sane value to prevent a divide error - */ - baud = 9600; - break; + case 1200: + cflag |= B1200; + break; + case 2400: + cflag |= B2400; + break; + case 4800: + cflag |= B4800; + break; + case 19200: + cflag |= B19200; + break; + case 38400: + cflag |= B38400; + break; + case 57600: + cflag |= B57600; + break; + case 115200: + cflag |= B115200; + break; + case 9600: + default: + cflag |= B9600; + /* + * Set this to a sane value to prevent a divide error + */ + baud = 9600; + break; } switch (bits) { - case 7: - cflag |= CS7; - break; - default: - case 8: - cflag |= CS8; - break; + case 7: + cflag |= CS7; + break; + default: + case 8: + cflag |= CS8; + break; } switch (parity) { - case 'o': case 'O': - cflag |= PARODD; - break; - case 'e': case 'E': - cflag |= PARENB; - break; + case 'o': case 'O': + cflag |= PARODD; + break; + case 'e': case 'E': + cflag |= PARENB; + break; } co->cflag = cflag; @@ -140,7 +140,7 @@ static int usb_console_setup(struct console *co, char *options) serial = usb_serial_get_by_index(co->index); if (serial == NULL) { /* no device is connected yet, sorry :( */ - err ("No USB device connected to ttyUSB%i", co->index); + err("No USB device connected to ttyUSB%i", co->index); return -ENODEV; } @@ -148,7 +148,7 @@ static int usb_console_setup(struct console *co, char *options) port->port.tty = NULL; info->port = port; - + ++port->port.count; if (port->port.count == 1) { if (serial->type->set_termios) { @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options) port->port.tty = tty; } - /* only call the device specific open if this + /* only call the device specific open if this * is the first time the port is opened */ if (serial->type->open) retval = serial->type->open(NULL, port, NULL); @@ -211,7 +211,8 @@ reset_open_count: goto out; } -static void usb_console_write(struct console *co, const char *buf, unsigned count) +static void usb_console_write(struct console *co, + const char *buf, unsigned count) { static struct usbcons_info *info = &usbcons_info; struct usb_serial_port *port = info->port; @@ -228,7 +229,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun dbg("%s - port %d, %d byte(s)", __func__, port->number, count); if (!port->port.count) { - dbg ("%s - port not opened", __func__); + dbg("%s - port not opened", __func__); return; } @@ -236,14 +237,15 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun unsigned int i; unsigned int lf; /* search for LF so we can insert CR if necessary */ - for (i=0, lf=0 ; i < count ; i++) { + for (i = 0, lf = 0 ; i < count ; i++) { if (*(buf + i) == 10) { lf = 1; i++; break; } } - /* pass on to the driver specific version of this function if it is available */ + /* pass on to the driver specific version of this function if + it is available */ if (serial->type->write) retval = serial->type->write(NULL, port, buf, i); else @@ -253,9 +255,11 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun /* append CR after LF */ unsigned char cr = 13; if (serial->type->write) - retval = serial->type->write(NULL, port, &cr, 1); + retval = serial->type->write(NULL, + port, &cr, 1); else - retval = usb_serial_generic_write(NULL, port, &cr, 1); + retval = usb_serial_generic_write(NULL, + port, &cr, 1); dbg("%s - return value : %d", __func__, retval); } buf += i; @@ -273,18 +277,19 @@ static struct console usbcons = { void usb_serial_console_disconnect(struct usb_serial *serial) { - if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) { + if (serial && serial->port && serial->port[0] + && serial->port[0] == usbcons_info.port) { usb_serial_console_exit(); usb_serial_put(serial); } } -void usb_serial_console_init (int serial_debug, int minor) +void usb_serial_console_init(int serial_debug, int minor) { debug = serial_debug; if (minor == 0) { - /* + /* * Call register_console() if this is the first device plugged * in. If we call it earlier, then the callback to * console_setup() will fail, as there is not a device seen by @@ -293,16 +298,16 @@ void usb_serial_console_init (int serial_debug, int minor) /* * Register console. * NOTES: - * console_setup() is called (back) immediately (from register_console). - * console_write() is called immediately from register_console iff - * CON_PRINTBUFFER is set in flags. + * console_setup() is called (back) immediately (from + * register_console). console_write() is called immediately + * from register_console iff CON_PRINTBUFFER is set in flags. */ - dbg ("registering the USB serial console."); + dbg("registering the USB serial console."); register_console(&usbcons); } } -void usb_serial_console_exit (void) +void usb_serial_console_exit(void) { if (usbcons_info.port) { unregister_console(&usbcons); -- cgit v1.2.3-70-g09d2 From c17ee886976b64d29ea89ee5d87751438e26025b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:10:08 +0100 Subject: tty-usb-console: Fix termios Setting CFLAG bits is all well and good but you must sort out ispeed and ospeed properly. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/console.c | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 9a4cd0a932b..7b74238ad1c 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -81,39 +81,11 @@ static int usb_console_setup(struct console *co, char *options) if (*s) doflow = (*s++ == 'r'); } + + /* Sane default */ + if (baud == 0) + baud = 9600; - /* build a cflag setting */ - switch (baud) { - case 1200: - cflag |= B1200; - break; - case 2400: - cflag |= B2400; - break; - case 4800: - cflag |= B4800; - break; - case 19200: - cflag |= B19200; - break; - case 38400: - cflag |= B38400; - break; - case 57600: - cflag |= B57600; - break; - case 115200: - cflag |= B115200; - break; - case 9600: - default: - cflag |= B9600; - /* - * Set this to a sane value to prevent a divide error - */ - baud = 9600; - break; - } switch (bits) { case 7: cflag |= CS7; @@ -188,6 +160,7 @@ static int usb_console_setup(struct console *co, char *options) if (serial->type->set_termios) { termios->c_cflag = cflag; + tty_termios_encode_baud_rate(termios, baud, baud); serial->type->set_termios(NULL, port, &dummy); port->port.tty = NULL; -- cgit v1.2.3-70-g09d2 From ff7eb602605cc0100f089d57966fcd347e137137 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:10:17 +0100 Subject: cp2101: coding style Bring up to coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/cp2101.c | 315 ++++++++++++++++++++--------------------- drivers/usb/serial/whiteheat.c | 1 - 2 files changed, 156 insertions(+), 160 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 46c33fc9f6c..442cba69cce 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include /* @@ -45,12 +45,12 @@ static void cp2101_close(struct tty_struct *, struct usb_serial_port *, static void cp2101_get_termios(struct tty_struct *); static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *, struct ktermios*); -static int cp2101_tiocmget (struct tty_struct *, struct file *); -static int cp2101_tiocmset (struct tty_struct *, struct file *, +static int cp2101_tiocmget(struct tty_struct *, struct file *); +static int cp2101_tiocmset(struct tty_struct *, struct file *, unsigned int, unsigned int); static void cp2101_break_ctl(struct tty_struct *, int); -static int cp2101_startup (struct usb_serial *); -static void cp2101_shutdown(struct usb_serial*); +static int cp2101_startup(struct usb_serial *); +static void cp2101_shutdown(struct usb_serial *); static int debug; @@ -96,7 +96,7 @@ static struct usb_device_id id_table [] = { { } /* Terminating Entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver cp2101_driver = { .name = "cp2101", @@ -205,12 +205,12 @@ static int cp2101_get_config(struct usb_serial_port *port, u8 request, request++; /* Issue the request, attempting to read 'size' bytes */ - result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), request, REQTYPE_DEVICE_TO_HOST, 0x0000, 0, buf, size, 300); /* Convert data into an array of integers */ - for (i=0; i 2) { - result = usb_control_msg (serial->dev, + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), request, REQTYPE_HOST_TO_DEVICE, 0x0000, 0, buf, size, 300); } else { - result = usb_control_msg (serial->dev, + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), request, REQTYPE_HOST_TO_DEVICE, data[0], 0, NULL, 0, 300); @@ -274,7 +274,7 @@ static int cp2101_set_config(struct usb_serial_port *port, u8 request, } /* Single data value */ - result = usb_control_msg (serial->dev, + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), request, REQTYPE_HOST_TO_DEVICE, data[0], 0, NULL, 0, 300); @@ -292,7 +292,7 @@ static inline int cp2101_set_config_single(struct usb_serial_port *port, return cp2101_set_config(port, request, &data, 2); } -static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port, +static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; @@ -307,7 +307,7 @@ static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port, } /* Start reading from the device */ - usb_fill_bulk_urb (port->read_urb, serial->dev, + usb_fill_bulk_urb(port->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -330,7 +330,7 @@ static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port, return 0; } -static void cp2101_cleanup (struct usb_serial_port *port) +static void cp2101_cleanup(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; @@ -346,7 +346,7 @@ static void cp2101_cleanup (struct usb_serial_port *port) } static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port, - struct file * filp) + struct file *filp) { dbg("%s - port %d", __func__, port->number); @@ -388,99 +388,97 @@ static void cp2101_get_termios (struct tty_struct *tty) cp2101_get_config(port, CP2101_BITS, &bits, 2); cflag &= ~CSIZE; - switch(bits & BITS_DATA_MASK) { - case BITS_DATA_5: - dbg("%s - data bits = 5", __func__); - cflag |= CS5; - break; - case BITS_DATA_6: - dbg("%s - data bits = 6", __func__); - cflag |= CS6; - break; - case BITS_DATA_7: - dbg("%s - data bits = 7", __func__); - cflag |= CS7; - break; - case BITS_DATA_8: - dbg("%s - data bits = 8", __func__); - cflag |= CS8; - break; - case BITS_DATA_9: - dbg("%s - data bits = 9 (not supported, " - "using 8 data bits)", __func__); - cflag |= CS8; - bits &= ~BITS_DATA_MASK; - bits |= BITS_DATA_8; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; - default: - dbg("%s - Unknown number of data bits, " - "using 8", __func__); - cflag |= CS8; - bits &= ~BITS_DATA_MASK; - bits |= BITS_DATA_8; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; + switch (bits & BITS_DATA_MASK) { + case BITS_DATA_5: + dbg("%s - data bits = 5", __func__); + cflag |= CS5; + break; + case BITS_DATA_6: + dbg("%s - data bits = 6", __func__); + cflag |= CS6; + break; + case BITS_DATA_7: + dbg("%s - data bits = 7", __func__); + cflag |= CS7; + break; + case BITS_DATA_8: + dbg("%s - data bits = 8", __func__); + cflag |= CS8; + break; + case BITS_DATA_9: + dbg("%s - data bits = 9 (not supported, using 8 data bits)", + __func__); + cflag |= CS8; + bits &= ~BITS_DATA_MASK; + bits |= BITS_DATA_8; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; + default: + dbg("%s - Unknown number of data bits, using 8", __func__); + cflag |= CS8; + bits &= ~BITS_DATA_MASK; + bits |= BITS_DATA_8; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; } - switch(bits & BITS_PARITY_MASK) { - case BITS_PARITY_NONE: - dbg("%s - parity = NONE", __func__); - cflag &= ~PARENB; - break; - case BITS_PARITY_ODD: - dbg("%s - parity = ODD", __func__); - cflag |= (PARENB|PARODD); - break; - case BITS_PARITY_EVEN: - dbg("%s - parity = EVEN", __func__); - cflag &= ~PARODD; - cflag |= PARENB; - break; - case BITS_PARITY_MARK: - dbg("%s - parity = MARK (not supported, " - "disabling parity)", __func__); - cflag &= ~PARENB; - bits &= ~BITS_PARITY_MASK; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; - case BITS_PARITY_SPACE: - dbg("%s - parity = SPACE (not supported, " - "disabling parity)", __func__); - cflag &= ~PARENB; - bits &= ~BITS_PARITY_MASK; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; - default: - dbg("%s - Unknown parity mode, " - "disabling parity", __func__); - cflag &= ~PARENB; - bits &= ~BITS_PARITY_MASK; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; + switch (bits & BITS_PARITY_MASK) { + case BITS_PARITY_NONE: + dbg("%s - parity = NONE", __func__); + cflag &= ~PARENB; + break; + case BITS_PARITY_ODD: + dbg("%s - parity = ODD", __func__); + cflag |= (PARENB|PARODD); + break; + case BITS_PARITY_EVEN: + dbg("%s - parity = EVEN", __func__); + cflag &= ~PARODD; + cflag |= PARENB; + break; + case BITS_PARITY_MARK: + dbg("%s - parity = MARK (not supported, disabling parity)", + __func__); + cflag &= ~PARENB; + bits &= ~BITS_PARITY_MASK; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; + case BITS_PARITY_SPACE: + dbg("%s - parity = SPACE (not supported, disabling parity)", + __func__); + cflag &= ~PARENB; + bits &= ~BITS_PARITY_MASK; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; + default: + dbg("%s - Unknown parity mode, disabling parity", __func__); + cflag &= ~PARENB; + bits &= ~BITS_PARITY_MASK; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; } cflag &= ~CSTOPB; - switch(bits & BITS_STOP_MASK) { - case BITS_STOP_1: - dbg("%s - stop bits = 1", __func__); - break; - case BITS_STOP_1_5: - dbg("%s - stop bits = 1.5 (not supported, " - "using 1 stop bit)", __func__); - bits &= ~BITS_STOP_MASK; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; - case BITS_STOP_2: - dbg("%s - stop bits = 2", __func__); - cflag |= CSTOPB; - break; - default: - dbg("%s - Unknown number of stop bits, " - "using 1 stop bit", __func__); - bits &= ~BITS_STOP_MASK; - cp2101_set_config(port, CP2101_BITS, &bits, 2); - break; + switch (bits & BITS_STOP_MASK) { + case BITS_STOP_1: + dbg("%s - stop bits = 1", __func__); + break; + case BITS_STOP_1_5: + dbg("%s - stop bits = 1.5 (not supported, using 1 stop bit)", + __func__); + bits &= ~BITS_STOP_MASK; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; + case BITS_STOP_2: + dbg("%s - stop bits = 2", __func__); + cflag |= CSTOPB; + break; + default: + dbg("%s - Unknown number of stop bits, using 1 stop bit", + __func__); + bits &= ~BITS_STOP_MASK; + cp2101_set_config(port, CP2101_BITS, &bits, 2); + break; } cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); @@ -495,7 +493,7 @@ static void cp2101_get_termios (struct tty_struct *tty) tty->termios->c_cflag = cflag; } -static void cp2101_set_termios (struct tty_struct *tty, +static void cp2101_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { unsigned int cflag, old_cflag; @@ -515,30 +513,30 @@ static void cp2101_set_termios (struct tty_struct *tty, /* If the baud rate is to be updated*/ if (baud != tty_termios_baud_rate(old_termios)) { switch (baud) { - case 0: - case 600: - case 1200: - case 1800: - case 2400: - case 4800: - case 7200: - case 9600: - case 14400: - case 19200: - case 28800: - case 38400: - case 55854: - case 57600: - case 115200: - case 127117: - case 230400: - case 460800: - case 921600: - case 3686400: - break; - default: - baud = 9600; - break; + case 0: + case 600: + case 1200: + case 1800: + case 2400: + case 4800: + case 7200: + case 9600: + case 14400: + case 19200: + case 28800: + case 38400: + case 55854: + case 57600: + case 115200: + case 127117: + case 230400: + case 460800: + case 921600: + case 3686400: + break; + default: + baud = 9600; + break; } if (baud) { @@ -560,28 +558,28 @@ static void cp2101_set_termios (struct tty_struct *tty, cp2101_get_config(port, CP2101_BITS, &bits, 2); bits &= ~BITS_DATA_MASK; switch (cflag & CSIZE) { - case CS5: - bits |= BITS_DATA_5; - dbg("%s - data bits = 5", __func__); - break; - case CS6: - bits |= BITS_DATA_6; - dbg("%s - data bits = 6", __func__); - break; - case CS7: - bits |= BITS_DATA_7; - dbg("%s - data bits = 7", __func__); - break; - case CS8: - bits |= BITS_DATA_8; - dbg("%s - data bits = 8", __func__); - break; - /*case CS9: - bits |= BITS_DATA_9; - dbg("%s - data bits = 9", __func__); - break;*/ - default: - dev_err(&port->dev, "cp2101 driver does not " + case CS5: + bits |= BITS_DATA_5; + dbg("%s - data bits = 5", __func__); + break; + case CS6: + bits |= BITS_DATA_6; + dbg("%s - data bits = 6", __func__); + break; + case CS7: + bits |= BITS_DATA_7; + dbg("%s - data bits = 7", __func__); + break; + case CS8: + bits |= BITS_DATA_8; + dbg("%s - data bits = 8", __func__); + break; + /*case CS9: + bits |= BITS_DATA_9; + dbg("%s - data bits = 9", __func__); + break;*/ + default: + dev_err(&port->dev, "cp2101 driver does not " "support the number of bits requested," " using 8 bit mode\n"); bits |= BITS_DATA_8; @@ -714,30 +712,29 @@ static void cp2101_break_ctl (struct tty_struct *tty, int break_state) else state = BREAK_ON; dbg("%s - turning break %s", __func__, - state==BREAK_OFF ? "off" : "on"); + state == BREAK_OFF ? "off" : "on"); cp2101_set_config(port, CP2101_BREAK, &state, 2); } -static int cp2101_startup (struct usb_serial *serial) +static int cp2101_startup(struct usb_serial *serial) { /* CP2101 buffers behave strangely unless device is reset */ usb_reset_device(serial->dev); return 0; } -static void cp2101_shutdown (struct usb_serial *serial) +static void cp2101_shutdown(struct usb_serial *serial) { int i; dbg("%s", __func__); /* Stop reads and writes on all ports */ - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) cp2101_cleanup(serial->port[i]); - } } -static int __init cp2101_init (void) +static int __init cp2101_init(void) { int retval; @@ -757,10 +754,10 @@ static int __init cp2101_init (void) return 0; } -static void __exit cp2101_exit (void) +static void __exit cp2101_exit(void) { - usb_deregister (&cp2101_driver); - usb_serial_deregister (&cp2101_device); + usb_deregister(&cp2101_driver); + usb_serial_deregister(&cp2101_device); } module_init(cp2101_init); diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 05374b99a2f..3a9d14384a4 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -646,7 +646,6 @@ static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { int retval = 0; - struct ktermios old_term; dbg("%s - port %d", __func__, port->number); -- cgit v1.2.3-70-g09d2 From b9c52f155f86eca9c4625b254b5f41dc151431be Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:10:27 +0100 Subject: cyberjack: Coding style Coding style fixups Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/cyberjack.c | 131 ++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 62 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 546178ea6f2..b4d72351cb9 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -65,7 +65,7 @@ static void cyberjack_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); static int cyberjack_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int cyberjack_write_room( struct tty_struct *tty); +static int cyberjack_write_room(struct tty_struct *tty); static void cyberjack_read_int_callback(struct urb *urb); static void cyberjack_read_bulk_callback(struct urb *urb); static void cyberjack_write_bulk_callback(struct urb *urb); @@ -75,7 +75,7 @@ static struct usb_device_id id_table [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver cyberjack_driver = { .name = "cyberjack", @@ -138,20 +138,20 @@ static int cyberjack_startup(struct usb_serial *serial) for (i = 0; i < serial->num_ports; ++i) { int result; serial->port[i]->interrupt_in_urb->dev = serial->dev; - result = usb_submit_urb(serial->port[i]->interrupt_in_urb, + result = usb_submit_urb(serial->port[i]->interrupt_in_urb, GFP_KERNEL); if (result) err(" usb_submit_urb(read int) failed"); dbg("%s - usb_submit_urb(int urb)", __func__); } - return( 0 ); + return 0; } static void cyberjack_shutdown(struct usb_serial *serial) { int i; - + dbg("%s", __func__); for (i = 0; i < serial->num_ports; ++i) { @@ -161,7 +161,7 @@ static void cyberjack_shutdown(struct usb_serial *serial) usb_set_serial_port_data(serial->port[i], NULL); } } - + static int cyberjack_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { @@ -171,7 +171,7 @@ static int cyberjack_open(struct tty_struct *tty, dbg("%s - port %d", __func__, port->number); - dbg("%s - usb_clear_halt", __func__ ); + dbg("%s - usb_clear_halt", __func__); usb_clear_halt(port->serial->dev, port->write_urb->pipe); /* force low_latency on so that our tty_push actually forces @@ -230,7 +230,7 @@ static int cyberjack_write(struct tty_struct *tty, spin_lock_irqsave(&priv->lock, flags); - if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) { + if (count+priv->wrfilled > sizeof(priv->wrbuf)) { /* To much data for buffer. Reset buffer. */ priv->wrfilled = 0; port->write_urb_busy = 0; @@ -239,42 +239,43 @@ static int cyberjack_write(struct tty_struct *tty, } /* Copy data */ - memcpy (priv->wrbuf+priv->wrfilled, buf, count); + memcpy(priv->wrbuf + priv->wrfilled, buf, count); usb_serial_debug_data(debug, &port->dev, __func__, count, - priv->wrbuf+priv->wrfilled); + priv->wrbuf + priv->wrfilled); priv->wrfilled += count; - if( priv->wrfilled >= 3 ) { + if (priv->wrfilled >= 3) { wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; dbg("%s - expected data: %d", __func__, wrexpected); - } else { + } else wrexpected = sizeof(priv->wrbuf); - } - if( priv->wrfilled >= wrexpected ) { + if (priv->wrfilled >= wrexpected) { /* We have enough data to begin transmission */ int length; dbg("%s - transmitting data (frame 1)", __func__); - length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected; + length = (wrexpected > port->bulk_out_size) ? + port->bulk_out_size : wrexpected; - memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length ); - priv->wrsent=length; + memcpy(port->write_urb->transfer_buffer, priv->wrbuf, length); + priv->wrsent = length; /* set up our urb */ - usb_fill_bulk_urb(port->write_urb, serial->dev, + usb_fill_bulk_urb(port->write_urb, serial->dev, usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, length, - ((serial->type->write_bulk_callback) ? - serial->type->write_bulk_callback : - cyberjack_write_bulk_callback), + ((serial->type->write_bulk_callback) ? + serial->type->write_bulk_callback : + cyberjack_write_bulk_callback), port); /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); /* Throw away data. No better idea what to do with it. */ priv->wrfilled = 0; priv->wrsent = 0; @@ -283,12 +284,12 @@ static int cyberjack_write(struct tty_struct *tty, return 0; } - dbg("%s - priv->wrsent=%d", __func__,priv->wrsent); - dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled); + dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); + dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); - if( priv->wrsent>=priv->wrfilled ) { + if (priv->wrsent >= priv->wrfilled) { dbg("%s - buffer cleaned", __func__); - memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); + memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); priv->wrfilled = 0; priv->wrsent = 0; } @@ -296,8 +297,8 @@ static int cyberjack_write(struct tty_struct *tty, spin_unlock_irqrestore(&priv->lock, flags); - return (count); -} + return count; +} static int cyberjack_write_room(struct tty_struct *tty) { @@ -319,10 +320,11 @@ static void cyberjack_read_int_callback(struct urb *urb) if (status) return; - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); /* React only to interrupts signaling a bulk_in transfer */ - if( (urb->actual_length == 4) && (data[0] == 0x01) ) { + if (urb->actual_length == 4 && data[0] == 0x01) { short old_rdtodo; /* This is a announcement of coming bulk_ins. */ @@ -332,8 +334,8 @@ static void cyberjack_read_int_callback(struct urb *urb) old_rdtodo = priv->rdtodo; - if( (old_rdtodo+size)<(old_rdtodo) ) { - dbg( "To many bulk_in urbs to do." ); + if (old_rdtodo + size < old_rdtodo) { + dbg("To many bulk_in urbs to do."); spin_unlock(&priv->lock); goto resubmit; } @@ -345,10 +347,10 @@ static void cyberjack_read_int_callback(struct urb *urb) spin_unlock(&priv->lock); - if( !old_rdtodo ) { + if (!old_rdtodo) { port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); - if( result ) + if (result) err("%s - failed resubmitting read urb, error %d", __func__, result); dbg("%s - usb_submit_urb(read urb)", __func__); } @@ -374,7 +376,8 @@ static void cyberjack_read_bulk_callback(struct urb *urb) dbg("%s - port %d", __func__, port->number); - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); if (status) { dbg("%s - nonzero read bulk status received: %d", __func__, status); @@ -389,15 +392,16 @@ static void cyberjack_read_bulk_callback(struct urb *urb) if (urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(tty); } spin_lock(&priv->lock); /* Reduce urbs to do by one. */ - priv->rdtodo-=urb->actual_length; + priv->rdtodo -= urb->actual_length; /* Just to be sure */ - if ( priv->rdtodo<0 ) priv->rdtodo = 0; + if (priv->rdtodo < 0) + priv->rdtodo = 0; todo = priv->rdtodo; spin_unlock(&priv->lock); @@ -405,11 +409,12 @@ static void cyberjack_read_bulk_callback(struct urb *urb) dbg("%s - rdtodo: %d", __func__, todo); /* Continue to read if we have still urbs to do. */ - if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) { + if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __func__, result); + err("%s - failed resubmitting read urb, error %d", + __func__, result); dbg("%s - usb_submit_urb(read urb)", __func__); } } @@ -432,7 +437,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) spin_lock(&priv->lock); /* only do something if we have more data to send */ - if( priv->wrfilled ) { + if (priv->wrfilled) { int length, blksize, result; dbg("%s - transmitting data (frame n)", __func__); @@ -440,37 +445,39 @@ static void cyberjack_write_bulk_callback(struct urb *urb) length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? port->bulk_out_size : (priv->wrfilled - priv->wrsent); - memcpy (port->write_urb->transfer_buffer, priv->wrbuf + priv->wrsent, - length ); - priv->wrsent+=length; + memcpy(port->write_urb->transfer_buffer, + priv->wrbuf + priv->wrsent, length); + priv->wrsent += length; /* set up our urb */ - usb_fill_bulk_urb(port->write_urb, port->serial->dev, + usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, length, - ((port->serial->type->write_bulk_callback) ? - port->serial->type->write_bulk_callback : - cyberjack_write_bulk_callback), + ((port->serial->type->write_bulk_callback) ? + port->serial->type->write_bulk_callback : + cyberjack_write_bulk_callback), port); /* send the data out the bulk port */ result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); /* Throw away data. No better idea what to do with it. */ priv->wrfilled = 0; priv->wrsent = 0; goto exit; } - dbg("%s - priv->wrsent=%d", __func__,priv->wrsent); - dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled); + dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); + dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; - if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) { + if (priv->wrsent >= priv->wrfilled || + priv->wrsent >= blksize) { dbg("%s - buffer cleaned", __func__); - memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); + memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); priv->wrfilled = 0; priv->wrsent = 0; } @@ -481,14 +488,14 @@ exit: usb_serial_port_softint(port); } -static int __init cyberjack_init (void) +static int __init cyberjack_init(void) { int retval; retval = usb_serial_register(&cyberjack_device); if (retval) goto failed_usb_serial_register; retval = usb_register(&cyberjack_driver); - if (retval) + if (retval) goto failed_usb_register; info(DRIVER_VERSION " " DRIVER_AUTHOR); @@ -501,18 +508,18 @@ failed_usb_serial_register: return retval; } -static void __exit cyberjack_exit (void) +static void __exit cyberjack_exit(void) { - usb_deregister (&cyberjack_driver); - usb_serial_deregister (&cyberjack_device); + usb_deregister(&cyberjack_driver); + usb_serial_deregister(&cyberjack_device); } module_init(cyberjack_init); module_exit(cyberjack_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_VERSION( DRIVER_VERSION ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 813a224fa5bff3e34309a6494e231d5ebfa0fb4e Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:10:36 +0100 Subject: cypress_m8: coding style Coding style clean ups Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/cypress_m8.c | 617 +++++++++++++++++++++------------------- drivers/usb/serial/cypress_m8.h | 2 +- 2 files changed, 325 insertions(+), 294 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 6999d3372d8..bb9c7c45e98 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -2,7 +2,7 @@ * USB Cypress M8 driver * * Copyright (C) 2004 - * Lonnie Mendez (dignome@gmail.com) + * Lonnie Mendez (dignome@gmail.com) * Copyright (C) 2003,2004 * Neil Whelchel (koyama@firstlight.net) * @@ -11,19 +11,21 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * See http://geocities.com/i0xox0i for information on this driver and the * earthmate usb device. * * Lonnie Mendez * 4-29-2005 - * Fixed problem where setting or retreiving the serial config would fail with - * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial - * adapters. Issued new interval of 1ms instead of the default 10ms. As a - * result, transfer speed has been substantially increased. From avg. 850bps to - * avg. 3300bps. initial termios has also been modified. Cleaned up code and - * formatting issues so it is more readable. Replaced the C++ style comments. + * Fixed problem where setting or retreiving the serial config would fail + * with EPIPE. Removed CRTS toggling so the driver behaves more like + * other usbserial adapters. Issued new interval of 1ms instead of the + * default 10ms. As a result, transfer speed has been substantially + * increased from avg. 850bps to avg. 3300bps. initial termios has also + * been modified. Cleaned up code and formatting issues so it is more + * readable. Replaced the C++ style comments. * * Lonnie Mendez * 12-15-2004 @@ -42,10 +44,11 @@ * */ -/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */ +/* Thanks to Neil Whelchel for writing the first cypress m8 implementation + for linux. */ /* Thanks to cypress for providing references for the hid reports. */ /* Thanks to Jiang Zhang for providing links and for general help. */ -/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */ +/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others.*/ #include @@ -62,7 +65,7 @@ #include #include #include -#include +#include #include "cypress_m8.h" @@ -112,7 +115,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver cypress_driver = { .name = "cypress", @@ -146,11 +149,13 @@ struct cypress_private { __u8 rx_flags; /* throttling - used from whiteheat/ftdi_sio */ enum packet_format pkt_fmt; /* format to use for packet send / receive */ int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */ - int baud_rate; /* stores current baud rate in integer form */ + int baud_rate; /* stores current baud rate in + integer form */ int isthrottled; /* if throttled, discard reads */ wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ char prev_status, diff_status; /* used for TIOCMIWAIT */ - /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */ + /* we pass a pointer to this as the arguement sent to + cypress_set_termios old_termios */ struct ktermios tmp_termios; /* stores the old termios settings */ }; @@ -163,33 +168,41 @@ struct cypress_buf { }; /* function prototypes for the Cypress USB to serial device */ -static int cypress_earthmate_startup (struct usb_serial *serial); -static int cypress_hidcom_startup (struct usb_serial *serial); -static int cypress_ca42v2_startup (struct usb_serial *serial); -static void cypress_shutdown (struct usb_serial *serial); -static int cypress_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void cypress_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int cypress_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static void cypress_send (struct usb_serial_port *port); -static int cypress_write_room (struct tty_struct *tty); -static int cypress_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); -static void cypress_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); -static int cypress_tiocmget (struct tty_struct *tty, struct file *file); -static int cypress_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static int cypress_chars_in_buffer (struct tty_struct *tty); -static void cypress_throttle (struct tty_struct *tty); -static void cypress_unthrottle (struct tty_struct *tty); -static void cypress_set_dead (struct usb_serial_port *port); -static void cypress_read_int_callback (struct urb *urb); -static void cypress_write_int_callback (struct urb *urb); +static int cypress_earthmate_startup(struct usb_serial *serial); +static int cypress_hidcom_startup(struct usb_serial *serial); +static int cypress_ca42v2_startup(struct usb_serial *serial); +static void cypress_shutdown(struct usb_serial *serial); +static int cypress_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void cypress_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static void cypress_send(struct usb_serial_port *port); +static int cypress_write_room(struct tty_struct *tty); +static int cypress_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); +static void cypress_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static int cypress_tiocmget(struct tty_struct *tty, struct file *file); +static int cypress_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +static int cypress_chars_in_buffer(struct tty_struct *tty); +static void cypress_throttle(struct tty_struct *tty); +static void cypress_unthrottle(struct tty_struct *tty); +static void cypress_set_dead(struct usb_serial_port *port); +static void cypress_read_int_callback(struct urb *urb); +static void cypress_write_int_callback(struct urb *urb); /* write buffer functions */ static struct cypress_buf *cypress_buf_alloc(unsigned int size); -static void cypress_buf_free(struct cypress_buf *cb); -static void cypress_buf_clear(struct cypress_buf *cb); -static unsigned int cypress_buf_data_avail(struct cypress_buf *cb); -static unsigned int cypress_buf_space_avail(struct cypress_buf *cb); -static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count); -static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count); +static void cypress_buf_free(struct cypress_buf *cb); +static void cypress_buf_clear(struct cypress_buf *cb); +static unsigned int cypress_buf_data_avail(struct cypress_buf *cb); +static unsigned int cypress_buf_space_avail(struct cypress_buf *cb); +static unsigned int cypress_buf_put(struct cypress_buf *cb, + const char *buf, unsigned int count); +static unsigned int cypress_buf_get(struct cypress_buf *cb, + char *buf, unsigned int count); static struct usb_serial_driver cypress_earthmate_device = { @@ -247,7 +260,7 @@ static struct usb_serial_driver cypress_hidcom_device = { static struct usb_serial_driver cypress_ca42v2_device = { .driver = { .owner = THIS_MODULE, - .name = "nokiaca42v2", + .name = "nokiaca42v2", }, .description = "Nokia CA-42 V2 Adapter", .usb_driver = &cypress_driver, @@ -322,7 +335,7 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) /* This function can either set or retrieve the current serial line settings */ -static int cypress_serial_control (struct tty_struct *tty, +static int cypress_serial_control(struct tty_struct *tty, struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits, int parity_enable, int parity_type, int reset, int cypress_request_type) @@ -333,111 +346,114 @@ static int cypress_serial_control (struct tty_struct *tty, unsigned long flags; dbg("%s", __func__); - + priv = usb_get_serial_port_data(port); if (!priv->comm_is_ok) return -ENODEV; - switch(cypress_request_type) { - case CYPRESS_SET_CONFIG: + switch (cypress_request_type) { + case CYPRESS_SET_CONFIG: + new_baudrate = priv->baud_rate; + /* 0 means 'Hang up' so doesn't change the true bit rate */ + if (baud_rate == 0) new_baudrate = priv->baud_rate; - /* 0 means 'Hang up' so doesn't change the true bit rate */ - if (baud_rate == 0) - new_baudrate = priv->baud_rate; - /* Change of speed ? */ - else if (baud_rate != priv->baud_rate) { - dbg("%s - baud rate is changing", __func__); - retval = analyze_baud_rate(port, baud_rate); - if (retval >= 0) { - new_baudrate = retval; - dbg("%s - New baud rate set to %d", - __func__, new_baudrate); - } - } - dbg("%s - baud rate is being sent as %d", __func__, new_baudrate); - - memset(feature_buffer, 0, sizeof(feature_buffer)); - /* fill the feature_buffer with new configuration */ - *((u_int32_t *)feature_buffer) = new_baudrate; - - feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ - /* 1 bit gap */ - feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ - feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */ - feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */ - /* 1 bit gap */ - feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ - - dbg("%s - device is being sent this feature report:", __func__); - dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, feature_buffer[0], feature_buffer[1], - feature_buffer[2], feature_buffer[3], feature_buffer[4]); - - do { - retval = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - HID_REQ_SET_REPORT, - USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, - sizeof(feature_buffer), 500); - - if (tries++ >= 3) - break; - - } while (retval != sizeof(feature_buffer) && - retval != -ENODEV); - - if (retval != sizeof(feature_buffer)) { - err("%s - failed sending serial line settings - %d", __func__, retval); - cypress_set_dead(port); - } else { - spin_lock_irqsave(&priv->lock, flags); - priv->baud_rate = new_baudrate; - priv->current_config = feature_buffer[4]; - spin_unlock_irqrestore(&priv->lock, flags); - /* If we asked for a speed change encode it */ - if (baud_rate) - tty_encode_baud_rate(tty, - new_baudrate, new_baudrate); - } - break; - case CYPRESS_GET_CONFIG: - if (priv->get_cfg_unsafe) { - /* Not implemented for this device, - and if we try to do it we're likely - to crash the hardware. */ - return -ENOTTY; - } - dbg("%s - retreiving serial line settings", __func__); - /* set initial values in feature buffer */ - memset(feature_buffer, 0, sizeof(feature_buffer)); - - do { - retval = usb_control_msg(port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0), - HID_REQ_GET_REPORT, - USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, - sizeof(feature_buffer), 500); - - if (tries++ >= 3) - break; - - } while (retval != sizeof(feature_buffer) && - retval != -ENODEV); - - if (retval != sizeof(feature_buffer)) { - err("%s - failed to retrieve serial line settings - %d", __func__, retval); - cypress_set_dead(port); - return retval; - } else { - spin_lock_irqsave(&priv->lock, flags); - - /* store the config in one byte, and later use bit masks to check values */ - priv->current_config = feature_buffer[4]; - priv->baud_rate = *((u_int32_t *)feature_buffer); - spin_unlock_irqrestore(&priv->lock, flags); + /* Change of speed ? */ + else if (baud_rate != priv->baud_rate) { + dbg("%s - baud rate is changing", __func__); + retval = analyze_baud_rate(port, baud_rate); + if (retval >= 0) { + new_baudrate = retval; + dbg("%s - New baud rate set to %d", + __func__, new_baudrate); } + } + dbg("%s - baud rate is being sent as %d", + __func__, new_baudrate); + + memset(feature_buffer, 0, sizeof(feature_buffer)); + /* fill the feature_buffer with new configuration */ + *((u_int32_t *)feature_buffer) = new_baudrate; + feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ + /* 1 bit gap */ + feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ + feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */ + feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */ + /* 1 bit gap */ + feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ + + dbg("%s - device is being sent this feature report:", + __func__); + dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, + feature_buffer[0], feature_buffer[1], + feature_buffer[2], feature_buffer[3], + feature_buffer[4]); + + do { + retval = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + HID_REQ_SET_REPORT, + USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, + 0x0300, 0, feature_buffer, + sizeof(feature_buffer), 500); + + if (tries++ >= 3) + break; + + } while (retval != sizeof(feature_buffer) && + retval != -ENODEV); + + if (retval != sizeof(feature_buffer)) { + err("%s - failed sending serial line settings - %d", + __func__, retval); + cypress_set_dead(port); + } else { + spin_lock_irqsave(&priv->lock, flags); + priv->baud_rate = new_baudrate; + priv->current_config = feature_buffer[4]; + spin_unlock_irqrestore(&priv->lock, flags); + /* If we asked for a speed change encode it */ + if (baud_rate) + tty_encode_baud_rate(tty, + new_baudrate, new_baudrate); + } + break; + case CYPRESS_GET_CONFIG: + if (priv->get_cfg_unsafe) { + /* Not implemented for this device, + and if we try to do it we're likely + to crash the hardware. */ + return -ENOTTY; + } + dbg("%s - retreiving serial line settings", __func__); + /* set initial values in feature buffer */ + memset(feature_buffer, 0, sizeof(feature_buffer)); + + do { + retval = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + HID_REQ_GET_REPORT, + USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, + 0x0300, 0, feature_buffer, + sizeof(feature_buffer), 500); + + if (tries++ >= 3) + break; + } while (retval != sizeof(feature_buffer) + && retval != -ENODEV); + + if (retval != sizeof(feature_buffer)) { + err("%s - failed to retrieve serial line settings - %d", __func__, retval); + cypress_set_dead(port); + return retval; + } else { + spin_lock_irqsave(&priv->lock, flags); + /* store the config in one byte, and later + use bit masks to check values */ + priv->current_config = feature_buffer[4]; + priv->baud_rate = *((u_int32_t *)feature_buffer); + spin_unlock_irqrestore(&priv->lock, flags); + } } spin_lock_irqsave(&priv->lock, flags); ++priv->cmd_count; @@ -470,14 +486,14 @@ static void cypress_set_dead(struct usb_serial_port *port) *****************************************************************************/ -static int generic_startup (struct usb_serial *serial) +static int generic_startup(struct usb_serial *serial) { struct cypress_private *priv; struct usb_serial_port *port = serial->port[0]; dbg("%s - port %d", __func__, port->number); - priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); + priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -489,9 +505,9 @@ static int generic_startup (struct usb_serial *serial) return -ENOMEM; } init_waitqueue_head(&priv->delta_msr_wait); - - usb_reset_configuration (serial->dev); - + + usb_reset_configuration(serial->dev); + priv->cmd_ctrl = 0; priv->line_control = 0; priv->termios_initialized = 0; @@ -502,30 +518,30 @@ static int generic_startup (struct usb_serial *serial) small. Otherwise we can use the slightly more compact format. This is in accordance with the cypress_m8 serial converter app note. */ - if (port->interrupt_out_size > 9) { + if (port->interrupt_out_size > 9) priv->pkt_fmt = packet_format_1; - } else { + else priv->pkt_fmt = packet_format_2; - } + if (interval > 0) { priv->write_urb_interval = interval; priv->read_urb_interval = interval; dbg("%s - port %d read & write intervals forced to %d", - __func__,port->number,interval); + __func__, port->number, interval); } else { priv->write_urb_interval = port->interrupt_out_urb->interval; priv->read_urb_interval = port->interrupt_in_urb->interval; dbg("%s - port %d intervals: read=%d write=%d", - __func__,port->number, - priv->read_urb_interval,priv->write_urb_interval); + __func__, port->number, + priv->read_urb_interval, priv->write_urb_interval); } usb_set_serial_port_data(port, priv); - + return 0; } -static int cypress_earthmate_startup (struct usb_serial *serial) +static int cypress_earthmate_startup(struct usb_serial *serial) { struct cypress_private *priv; struct usb_serial_port *port = serial->port[0]; @@ -543,7 +559,8 @@ static int cypress_earthmate_startup (struct usb_serial *serial) /* All Earthmate devices use the separated-count packet format! Idiotic. */ priv->pkt_fmt = packet_format_1; - if (serial->dev->descriptor.idProduct != cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) { + if (serial->dev->descriptor.idProduct != + cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) { /* The old original USB Earthmate seemed able to handle GET_CONFIG requests; everything they've produced since that time crashes if this command is @@ -557,7 +574,7 @@ static int cypress_earthmate_startup (struct usb_serial *serial) } /* cypress_earthmate_startup */ -static int cypress_hidcom_startup (struct usb_serial *serial) +static int cypress_hidcom_startup(struct usb_serial *serial) { struct cypress_private *priv; @@ -571,12 +588,12 @@ static int cypress_hidcom_startup (struct usb_serial *serial) priv = usb_get_serial_port_data(serial->port[0]); priv->chiptype = CT_CYPHIDCOM; - + return 0; } /* cypress_hidcom_startup */ -static int cypress_ca42v2_startup (struct usb_serial *serial) +static int cypress_ca42v2_startup(struct usb_serial *serial) { struct cypress_private *priv; @@ -595,11 +612,11 @@ static int cypress_ca42v2_startup (struct usb_serial *serial) } /* cypress_ca42v2_startup */ -static void cypress_shutdown (struct usb_serial *serial) +static void cypress_shutdown(struct usb_serial *serial) { struct cypress_private *priv; - dbg ("%s - port %d", __func__, serial->port[0]->number); + dbg("%s - port %d", __func__, serial->port[0]->number); /* all open ports are closed at this point */ @@ -650,7 +667,9 @@ static int cypress_open(struct tty_struct *tty, result = cypress_write(tty, port, NULL, 0); if (result) { - dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed setting the control lines - error %d\n", + __func__, result); return result; } else dbg("%s - success setting the control lines", __func__); @@ -659,19 +678,22 @@ static int cypress_open(struct tty_struct *tty, cypress_set_termios(tty, port, &priv->tmp_termios); /* setup the port and start reading from the device */ - if(!port->interrupt_in_urb){ + if (!port->interrupt_in_urb) { err("%s - interrupt_in_urb is empty!", __func__); - return(-1); + return -1; } usb_fill_int_urb(port->interrupt_in_urb, serial->dev, usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), - port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, + port->interrupt_in_urb->transfer_buffer, + port->interrupt_in_urb->transfer_buffer_length, cypress_read_int_callback, port, priv->read_urb_interval); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); - if (result){ - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); + if (result) { + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); cypress_set_dead(port); } @@ -680,7 +702,7 @@ static int cypress_open(struct tty_struct *tty, static void cypress_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct cypress_private *priv = usb_get_serial_port_data(port); unsigned int c_cflag; @@ -722,15 +744,15 @@ static void cypress_close(struct tty_struct *tty, if (tty) { bps = tty_get_baud_rate(tty); if (bps > 1200) - timeout = max((HZ*2560)/bps,HZ/10); + timeout = max((HZ * 2560) / bps, HZ / 10); else - timeout = 2*HZ; + timeout = 2 * HZ; schedule_timeout_interruptible(timeout); } dbg("%s - stopping urbs", __func__); - usb_kill_urb (port->interrupt_in_urb); - usb_kill_urb (port->interrupt_out_urb); + usb_kill_urb(port->interrupt_in_urb); + usb_kill_urb(port->interrupt_out_urb); if (tty) { c_cflag = tty->termios->c_cflag; @@ -746,8 +768,8 @@ static void cypress_close(struct tty_struct *tty, } if (stats) - dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n", - priv->bytes_in, priv->bytes_out, priv->cmd_count); + dev_info(&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n", + priv->bytes_in, priv->bytes_out, priv->cmd_count); mutex_unlock(&port->serial->disc_mutex); } /* cypress_close */ @@ -757,7 +779,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, { struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - + dbg("%s - port %d, %d bytes", __func__, port->number, count); /* line control commands, which need to be executed immediately, @@ -767,10 +789,10 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, count = 0; goto finish; } - + if (!count) return count; - + spin_lock_irqsave(&priv->lock, flags); count = cypress_buf_put(priv->buf, buf, count); spin_unlock_irqrestore(&priv->lock, flags); @@ -787,13 +809,14 @@ static void cypress_send(struct usb_serial_port *port) int count = 0, result, offset, actual_size; struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - + if (!priv->comm_is_ok) return; dbg("%s - port %d", __func__, port->number); - dbg("%s - interrupt out size is %d", __func__, port->interrupt_out_size); - + dbg("%s - interrupt out size is %d", __func__, + port->interrupt_out_size); + spin_lock_irqsave(&priv->lock, flags); if (priv->write_urb_in_use) { dbg("%s - can't write, urb in use", __func__); @@ -803,7 +826,8 @@ static void cypress_send(struct usb_serial_port *port) spin_unlock_irqrestore(&priv->lock, flags); /* clear buffer */ - memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size); + memset(port->interrupt_out_urb->transfer_buffer, 0, + port->interrupt_out_size); spin_lock_irqsave(&priv->lock, flags); switch (priv->pkt_fmt) { @@ -834,9 +858,8 @@ static void cypress_send(struct usb_serial_port *port) count = cypress_buf_get(priv->buf, &port->interrupt_out_buffer[offset], port->interrupt_out_size-offset); - if (count == 0) { + if (count == 0) return; - } switch (priv->pkt_fmt) { default: @@ -860,26 +883,29 @@ send: actual_size = count + (priv->pkt_fmt == packet_format_1 ? 2 : 1); - usb_serial_debug_data(debug, &port->dev, __func__, port->interrupt_out_size, - port->interrupt_out_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, + port->interrupt_out_size, + port->interrupt_out_urb->transfer_buffer); usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress), port->interrupt_out_buffer, port->interrupt_out_size, cypress_write_int_callback, port, priv->write_urb_interval); - result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); + result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, - result); + dev_err(&port->dev, + "%s - failed submitting write urb, error %d\n", + __func__, result); priv->write_urb_in_use = 0; cypress_set_dead(port); } spin_lock_irqsave(&priv->lock, flags); - if (priv->cmd_ctrl) { + if (priv->cmd_ctrl) priv->cmd_ctrl = 0; - } - priv->bytes_out += count; /* do not count the line control and size bytes */ + + /* do not count the line control and size bytes */ + priv->bytes_out += count; spin_unlock_irqrestore(&priv->lock, flags); usb_serial_port_softint(port); @@ -912,7 +938,7 @@ static int cypress_tiocmget(struct tty_struct *tty, struct file *file) __u8 status, control; unsigned int result = 0; unsigned long flags; - + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); @@ -939,7 +965,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file, struct usb_serial_port *port = tty->driver_data; struct cypress_private *priv = usb_get_serial_port_data(port); unsigned long flags; - + dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); @@ -958,7 +984,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file, } -static int cypress_ioctl(struct tty_struct *tty, struct file * file, +static int cypress_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; @@ -967,38 +993,37 @@ static int cypress_ioctl(struct tty_struct *tty, struct file * file, dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); switch (cmd) { - /* This code comes from drivers/char/serial.c and ftdi_sio.c */ - case TIOCMIWAIT: - while (priv != NULL) { - interruptible_sleep_on(&priv->delta_msr_wait); - /* see if a signal did it */ - if (signal_pending(current)) - return -ERESTARTSYS; - else { - char diff = priv->diff_status; - - if (diff == 0) { - return -EIO; /* no change => error */ - } - - /* consume all events */ - priv->diff_status = 0; - - /* return 0 if caller wanted to know about these bits */ - if ( ((arg & TIOCM_RNG) && (diff & UART_RI)) || - ((arg & TIOCM_DSR) && (diff & UART_DSR)) || - ((arg & TIOCM_CD) && (diff & UART_CD)) || - ((arg & TIOCM_CTS) && (diff & UART_CTS)) ) { - return 0; - } - /* otherwise caller can't care less about what happened, - * and so we continue to wait for more events. - */ - } + /* This code comes from drivers/char/serial.c and ftdi_sio.c */ + case TIOCMIWAIT: + while (priv != NULL) { + interruptible_sleep_on(&priv->delta_msr_wait); + /* see if a signal did it */ + if (signal_pending(current)) + return -ERESTARTSYS; + else { + char diff = priv->diff_status; + if (diff == 0) + return -EIO; /* no change => error */ + + /* consume all events */ + priv->diff_status = 0; + + /* return 0 if caller wanted to know about + these bits */ + if (((arg & TIOCM_RNG) && (diff & UART_RI)) || + ((arg & TIOCM_DSR) && (diff & UART_DSR)) || + ((arg & TIOCM_CD) && (diff & UART_CD)) || + ((arg & TIOCM_CTS) && (diff & UART_CTS))) + return 0; + /* otherwise caller can't care less about what + * happened, and so we continue to wait for + * more events. + */ } - return 0; - default: - break; + } + return 0; + default: + break; } dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); return -ENOIOCTLCMD; @@ -1070,23 +1095,22 @@ static void cypress_set_termios(struct tty_struct *tty, if (cflag & CSIZE) { switch (cflag & CSIZE) { - case CS5: - data_bits = 0; - break; - case CS6: - data_bits = 1; - break; - case CS7: - data_bits = 2; - break; - case CS8: - data_bits = 3; - break; - default: - err("%s - CSIZE was set, but not CS5-CS8", - __func__); - data_bits = 3; - } + case CS5: + data_bits = 0; + break; + case CS6: + data_bits = 1; + break; + case CS7: + data_bits = 2; + break; + case CS8: + data_bits = 3; + break; + default: + err("%s - CSIZE was set, but not CS5-CS8", + __func__); + data_bits = 3; } else data_bits = 3; @@ -1104,8 +1128,10 @@ static void cypress_set_termios(struct tty_struct *tty, "%d data_bits (+5)", __func__, stop_bits, parity_enable, parity_type, data_bits); - cypress_serial_control(tty, port, tty_get_baud_rate(tty), data_bits, stop_bits, - parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); + cypress_serial_control(tty, port, tty_get_baud_rate(tty), + data_bits, stop_bits, + parity_enable, parity_type, + 0, CYPRESS_SET_CONFIG); /* we perform a CYPRESS_GET_CONFIG so that the current settings are * filled into the private structure this should confirm that all is @@ -1116,7 +1142,7 @@ static void cypress_set_termios(struct tty_struct *tty, * termios flag base comes from empeg.c */ spin_lock_irqsave(&priv->lock, flags); - if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) { + if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { dbg("Using custom termios settings for a baud rate of " "4800bps."); /* define custom termios settings for NMEA protocol */ @@ -1164,7 +1190,7 @@ static int cypress_chars_in_buffer(struct tty_struct *tty) unsigned long flags; dbg("%s - port %d", __func__, port->number); - + spin_lock_irqsave(&priv->lock, flags); chars = cypress_buf_data_avail(priv->buf); spin_unlock_irqrestore(&priv->lock, flags); @@ -1243,12 +1269,13 @@ static void cypress_read_int_callback(struct urb *urb) /* precursor to disconnect so just go away */ return; case -EPIPE: - usb_clear_halt(port->serial->dev,0x81); + usb_clear_halt(port->serial->dev, 0x81); break; default: /* something ugly is going on... */ - dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n", - __func__, status); + dev_err(&urb->dev->dev, + "%s - unexpected nonzero read status received: %d\n", + __func__, status); cypress_set_dead(port); return; } @@ -1296,8 +1323,8 @@ static void cypress_read_int_callback(struct urb *urb) goto continue_read; } - usb_serial_debug_data (debug, &port->dev, __func__, - urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); spin_lock_irqsave(&priv->lock, flags); /* check to see if status has changed */ @@ -1356,7 +1383,8 @@ continue_read: port->interrupt_in_endpointAddress), port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, - cypress_read_int_callback, port, priv->read_urb_interval); + cypress_read_int_callback, port, + priv->read_urb_interval); result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (result) { dev_err(&urb->dev->dev, "%s - failed resubmitting " @@ -1380,42 +1408,43 @@ static void cypress_write_int_callback(struct urb *urb) dbg("%s - port %d", __func__, port->number); switch (status) { - case 0: - /* success */ + case 0: + /* success */ + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + /* this urb is terminated, clean up */ + dbg("%s - urb shutting down with status: %d", + __func__, status); + priv->write_urb_in_use = 0; + return; + case -EPIPE: /* no break needed; clear halt and resubmit */ + if (!priv->comm_is_ok) break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - /* this urb is terminated, clean up */ - dbg("%s - urb shutting down with status: %d", - __func__, status); - priv->write_urb_in_use = 0; + usb_clear_halt(port->serial->dev, 0x02); + /* error in the urb, so we have to resubmit it */ + dbg("%s - nonzero write bulk status received: %d", + __func__, status); + port->interrupt_out_urb->transfer_buffer_length = 1; + port->interrupt_out_urb->dev = port->serial->dev; + result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); + if (!result) return; - case -EPIPE: /* no break needed; clear halt and resubmit */ - if (!priv->comm_is_ok) - break; - usb_clear_halt(port->serial->dev, 0x02); - /* error in the urb, so we have to resubmit it */ - dbg("%s - nonzero write bulk status received: %d", - __func__, status); - port->interrupt_out_urb->transfer_buffer_length = 1; - port->interrupt_out_urb->dev = port->serial->dev; - result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); - if (!result) - return; - dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", - __func__, result); - cypress_set_dead(port); - break; - default: - dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n", - __func__, status); - cypress_set_dead(port); - break; + dev_err(&urb->dev->dev, + "%s - failed resubmitting write urb, error %d\n", + __func__, result); + cypress_set_dead(port); + break; + default: + dev_err(&urb->dev->dev, + "%s - unexpected nonzero write status received: %d\n", + __func__, status); + cypress_set_dead(port); + break; } - priv->write_urb_in_use = 0; - + /* send any buffered data */ cypress_send(port); } @@ -1497,7 +1526,8 @@ static void cypress_buf_clear(struct cypress_buf *cb) static unsigned int cypress_buf_data_avail(struct cypress_buf *cb) { if (cb != NULL) - return ((cb->buf_size + cb->buf_put - cb->buf_get) % cb->buf_size); + return (cb->buf_size + cb->buf_put - cb->buf_get) + % cb->buf_size; else return 0; } @@ -1513,7 +1543,8 @@ static unsigned int cypress_buf_data_avail(struct cypress_buf *cb) static unsigned int cypress_buf_space_avail(struct cypress_buf *cb) { if (cb != NULL) - return ((cb->buf_size + cb->buf_get - cb->buf_put - 1) % cb->buf_size); + return (cb->buf_size + cb->buf_get - cb->buf_put - 1) + % cb->buf_size; else return 0; } @@ -1613,9 +1644,9 @@ static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, static int __init cypress_init(void) { int retval; - + dbg("%s", __func__); - + retval = usb_serial_register(&cypress_earthmate_device); if (retval) goto failed_em_register; @@ -1643,23 +1674,23 @@ failed_em_register: } -static void __exit cypress_exit (void) +static void __exit cypress_exit(void) { dbg("%s", __func__); - usb_deregister (&cypress_driver); - usb_serial_deregister (&cypress_earthmate_device); - usb_serial_deregister (&cypress_hidcom_device); - usb_serial_deregister (&cypress_ca42v2_device); + usb_deregister(&cypress_driver); + usb_serial_deregister(&cypress_earthmate_device); + usb_serial_deregister(&cypress_hidcom_device); + usb_serial_deregister(&cypress_ca42v2_device); } module_init(cypress_init); module_exit(cypress_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_VERSION( DRIVER_VERSION ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h index 0388065bb79..e772b01ac3a 100644 --- a/drivers/usb/serial/cypress_m8.h +++ b/drivers/usb/serial/cypress_m8.h @@ -54,7 +54,7 @@ #define UART_DSR 0x20 /* data set ready - flow control - device to host */ #define CONTROL_RTS 0x10 /* request to send - flow control - host to device */ #define UART_CTS 0x10 /* clear to send - flow control - device to host */ -#define UART_RI 0x10 /* ring indicator - modem - device to host */ +#define UART_RI 0x10 /* ring indicator - modem - device to host */ #define UART_CD 0x40 /* carrier detect - modem - device to host */ #define CYP_ERROR 0x08 /* received from input report - device to host */ /* Note - the below has nothing to to with the "feature report" reset */ -- cgit v1.2.3-70-g09d2 From 77336828c01933d37102c4bef6e2a2cf7e3243b3 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:10:53 +0100 Subject: usb-cypress: There is no 0 case to go with CS5/6/7/8 so remove the test Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/cypress_m8.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index bb9c7c45e98..22837a3f2f8 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -1093,27 +1093,24 @@ static void cypress_set_termios(struct tty_struct *tty, } else parity_enable = parity_type = 0; - if (cflag & CSIZE) { - switch (cflag & CSIZE) { - case CS5: - data_bits = 0; - break; - case CS6: - data_bits = 1; - break; - case CS7: - data_bits = 2; - break; - case CS8: - data_bits = 3; - break; - default: - err("%s - CSIZE was set, but not CS5-CS8", - __func__); - data_bits = 3; - } else + switch (cflag & CSIZE) { + case CS5: + data_bits = 0; + break; + case CS6: + data_bits = 1; + break; + case CS7: + data_bits = 2; + break; + case CS8: data_bits = 3; - + break; + default: + err("%s - CSIZE was set, but not CS5-CS8", + __func__); + data_bits = 3; + } spin_lock_irqsave(&priv->lock, flags); oldlines = priv->line_control; if ((cflag & CBAUD) == B0) { -- cgit v1.2.3-70-g09d2 From 41ad427da1f9303e2e34811398b31c999c3d39d1 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:02 +0100 Subject: digi_acceleport: coding style Code tidy Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/digi_acceleport.c | 344 +++++++++++++++++++---------------- 1 file changed, 184 insertions(+), 160 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index dc92dbfc962..240aad1acaa 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -241,7 +241,7 @@ #include #include #include -#include +#include #include #include #include @@ -441,8 +441,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, unsigned int modem_signals, int interruptible); static int digi_transmit_idle(struct usb_serial_port *port, unsigned long timeout); -static void digi_rx_throttle (struct tty_struct *tty); -static void digi_rx_unthrottle (struct tty_struct *tty); +static void digi_rx_throttle(struct tty_struct *tty); +static void digi_rx_unthrottle(struct tty_struct *tty); static void digi_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); static void digi_break_ctl(struct tty_struct *tty, int break_state); @@ -486,7 +486,7 @@ static struct usb_device_id id_table_4 [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver digi_driver = { .name = "digi_acceleport", @@ -555,17 +555,17 @@ static struct usb_serial_driver digi_acceleport_4_device = { /* Functions */ /* -* Cond Wait Interruptible Timeout Irqrestore -* -* Do spin_unlock_irqrestore and interruptible_sleep_on_timeout -* so that wake ups are not lost if they occur between the unlock -* and the sleep. In other words, spin_unlock_irqrestore and -* interruptible_sleep_on_timeout are "atomic" with respect to -* wake ups. This is used to implement condition variables. -* -* interruptible_sleep_on_timeout is deprecated and has been replaced -* with the equivalent code. -*/ + * Cond Wait Interruptible Timeout Irqrestore + * + * Do spin_unlock_irqrestore and interruptible_sleep_on_timeout + * so that wake ups are not lost if they occur between the unlock + * and the sleep. In other words, spin_unlock_irqrestore and + * interruptible_sleep_on_timeout are "atomic" with respect to + * wake ups. This is used to implement condition variables. + * + * interruptible_sleep_on_timeout is deprecated and has been replaced + * with the equivalent code. + */ static long cond_wait_interruptible_timeout_irqrestore( wait_queue_head_t *q, long timeout, @@ -584,15 +584,16 @@ __releases(lock) /* -* Digi Wakeup Write -* -* Wake up port, line discipline, and tty processes sleeping -* on writes. -*/ + * Digi Wakeup Write + * + * Wake up port, line discipline, and tty processes sleeping + * on writes. + */ static void digi_wakeup_write_lock(struct work_struct *work) { - struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work); + struct digi_port *priv = + container_of(work, struct digi_port, dp_wakeup_work); struct usb_serial_port *port = priv->dp_port; unsigned long flags; @@ -608,15 +609,15 @@ static void digi_wakeup_write(struct usb_serial_port *port) /* -* Digi Write OOB Command -* -* Write commands on the out of band port. Commands are 4 -* bytes each, multiple commands can be sent at once, and -* no command will be split across USB packets. Returns 0 -* if successful, -EINTR if interrupted while sleeping and -* the interruptible flag is true, or a negative error -* returned by usb_submit_urb. -*/ + * Digi Write OOB Command + * + * Write commands on the out of band port. Commands are 4 + * bytes each, multiple commands can be sent at once, and + * no command will be split across USB packets. Returns 0 + * if successful, -EINTR if interrupted while sleeping and + * the interruptible flag is true, or a negative error + * returned by usb_submit_urb. + */ static int digi_write_oob_command(struct usb_serial_port *port, unsigned char *buf, int count, int interruptible) @@ -631,8 +632,8 @@ static int digi_write_oob_command(struct usb_serial_port *port, dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count); spin_lock_irqsave(&oob_priv->dp_port_lock, flags); - while(count > 0) { - while(oob_port->write_urb->status == -EINPROGRESS + while (count > 0) { + while (oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) { cond_wait_interruptible_timeout_irqrestore( &oob_port->write_wait, DIGI_RETRY_TIMEOUT, @@ -649,7 +650,8 @@ static int digi_write_oob_command(struct usb_serial_port *port, memcpy(oob_port->write_urb->transfer_buffer, buf, len); oob_port->write_urb->transfer_buffer_length = len; oob_port->write_urb->dev = port->serial->dev; - if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) { + ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); + if (ret == 0) { oob_priv->dp_write_urb_in_use = 1; count -= len; buf += len; @@ -664,16 +666,16 @@ static int digi_write_oob_command(struct usb_serial_port *port, /* -* Digi Write In Band Command -* -* Write commands on the given port. Commands are 4 -* bytes each, multiple commands can be sent at once, and -* no command will be split across USB packets. If timeout -* is non-zero, write in band command will return after -* waiting unsuccessfully for the URB status to clear for -* timeout ticks. Returns 0 if successful, or a negative -* error returned by digi_write. -*/ + * Digi Write In Band Command + * + * Write commands on the given port. Commands are 4 + * bytes each, multiple commands can be sent at once, and + * no command will be split across USB packets. If timeout + * is non-zero, write in band command will return after + * waiting unsuccessfully for the URB status to clear for + * timeout ticks. Returns 0 if successful, or a negative + * error returned by digi_write. + */ static int digi_write_inb_command(struct usb_serial_port *port, unsigned char *buf, int count, unsigned long timeout) @@ -693,9 +695,10 @@ static int digi_write_inb_command(struct usb_serial_port *port, timeout = ULONG_MAX; spin_lock_irqsave(&priv->dp_port_lock, flags); - while(count > 0 && ret == 0) { - while((port->write_urb->status == -EINPROGRESS - || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) { + while (count > 0 && ret == 0) { + while ((port->write_urb->status == -EINPROGRESS + || priv->dp_write_urb_in_use) + && time_before(jiffies, timeout)) { cond_wait_interruptible_timeout_irqrestore( &port->write_wait, DIGI_RETRY_TIMEOUT, &priv->dp_port_lock, flags); @@ -726,7 +729,8 @@ static int digi_write_inb_command(struct usb_serial_port *port, } port->write_urb->dev = port->serial->dev; - if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { + ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); + if (ret == 0) { priv->dp_write_urb_in_use = 1; priv->dp_out_buf_len = 0; count -= len; @@ -744,14 +748,14 @@ static int digi_write_inb_command(struct usb_serial_port *port, /* -* Digi Set Modem Signals -* -* Sets or clears DTR and RTS on the port, according to the -* modem_signals argument. Use TIOCM_DTR and TIOCM_RTS flags -* for the modem_signals argument. Returns 0 if successful, -* -EINTR if interrupted while sleeping, or a non-zero error -* returned by usb_submit_urb. -*/ + * Digi Set Modem Signals + * + * Sets or clears DTR and RTS on the port, according to the + * modem_signals argument. Use TIOCM_DTR and TIOCM_RTS flags + * for the modem_signals argument. Returns 0 if successful, + * -EINTR if interrupted while sleeping, or a non-zero error + * returned by usb_submit_urb. + */ static int digi_set_modem_signals(struct usb_serial_port *port, unsigned int modem_signals, int interruptible) @@ -759,7 +763,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port, int ret; struct digi_port *port_priv = usb_get_serial_port_data(port); - struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; + struct usb_serial_port *oob_port = (struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); unsigned char *data = oob_port->write_urb->transfer_buffer; unsigned long flags = 0; @@ -771,7 +775,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, spin_lock_irqsave(&oob_priv->dp_port_lock, flags); spin_lock(&port_priv->dp_port_lock); - while(oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) { + while (oob_port->write_urb->status == -EINPROGRESS || + oob_priv->dp_write_urb_in_use) { spin_unlock(&port_priv->dp_port_lock); cond_wait_interruptible_timeout_irqrestore( &oob_port->write_wait, DIGI_RETRY_TIMEOUT, @@ -783,17 +788,20 @@ static int digi_set_modem_signals(struct usb_serial_port *port, } data[0] = DIGI_CMD_SET_DTR_SIGNAL; data[1] = port_priv->dp_port_num; - data[2] = (modem_signals&TIOCM_DTR) ? DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE; + data[2] = (modem_signals & TIOCM_DTR) ? + DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE; data[3] = 0; data[4] = DIGI_CMD_SET_RTS_SIGNAL; data[5] = port_priv->dp_port_num; - data[6] = (modem_signals&TIOCM_RTS) ? DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE; + data[6] = (modem_signals & TIOCM_RTS) ? + DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE; data[7] = 0; oob_port->write_urb->transfer_buffer_length = 8; oob_port->write_urb->dev = port->serial->dev; - if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) { + ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); + if (ret == 0) { oob_priv->dp_write_urb_in_use = 1; port_priv->dp_modem_signals = (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS)) @@ -807,16 +815,16 @@ static int digi_set_modem_signals(struct usb_serial_port *port, } /* -* Digi Transmit Idle -* -* Digi transmit idle waits, up to timeout ticks, for the transmitter -* to go idle. It returns 0 if successful or a negative error. -* -* There are race conditions here if more than one process is calling -* digi_transmit_idle on the same port at the same time. However, this -* is only called from close, and only one process can be in close on a -* port at a time, so its ok. -*/ + * Digi Transmit Idle + * + * Digi transmit idle waits, up to timeout ticks, for the transmitter + * to go idle. It returns 0 if successful or a negative error. + * + * There are race conditions here if more than one process is calling + * digi_transmit_idle on the same port at the same time. However, this + * is only called from close, and only one process can be in close on a + * port at a time, so its ok. + */ static int digi_transmit_idle(struct usb_serial_port *port, unsigned long timeout) @@ -835,12 +843,13 @@ static int digi_transmit_idle(struct usb_serial_port *port, timeout += jiffies; - if ((ret = digi_write_inb_command(port, buf, 2, timeout - jiffies)) != 0) + ret = digi_write_inb_command(port, buf, 2, timeout - jiffies); + if (ret != 0) return ret; spin_lock_irqsave(&priv->dp_port_lock, flags); - while(time_before(jiffies, timeout) && !priv->dp_transmit_idle) { + while (time_before(jiffies, timeout) && !priv->dp_transmit_idle) { cond_wait_interruptible_timeout_irqrestore( &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, &priv->dp_port_lock, flags); @@ -901,7 +910,7 @@ static void digi_rx_unthrottle(struct tty_struct *tty) } -static void digi_set_termios(struct tty_struct *tty, +static void digi_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { struct digi_port *priv = usb_get_serial_port_data(port); @@ -911,14 +920,15 @@ static void digi_set_termios(struct tty_struct *tty, unsigned int old_cflag = old_termios->c_cflag; unsigned char buf[32]; unsigned int modem_signals; - int arg,ret; + int arg, ret; int i = 0; speed_t baud; dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); /* set baud rate */ - if ((baud = tty_get_baud_rate(tty)) != tty_termios_baud_rate(old_termios)) { + baud = tty_get_baud_rate(tty); + if (baud != tty_termios_baud_rate(old_termios)) { arg = -1; /* reassert DTR and (maybe) RTS on transition from B0 */ @@ -932,30 +942,30 @@ static void digi_set_termios(struct tty_struct *tty, digi_set_modem_signals(port, modem_signals, 1); } switch (baud) { - /* drop DTR and RTS on transition to B0 */ - case 0: digi_set_modem_signals(port, 0, 1); break; - case 50: arg = DIGI_BAUD_50; break; - case 75: arg = DIGI_BAUD_75; break; - case 110: arg = DIGI_BAUD_110; break; - case 150: arg = DIGI_BAUD_150; break; - case 200: arg = DIGI_BAUD_200; break; - case 300: arg = DIGI_BAUD_300; break; - case 600: arg = DIGI_BAUD_600; break; - case 1200: arg = DIGI_BAUD_1200; break; - case 1800: arg = DIGI_BAUD_1800; break; - case 2400: arg = DIGI_BAUD_2400; break; - case 4800: arg = DIGI_BAUD_4800; break; - case 9600: arg = DIGI_BAUD_9600; break; - case 19200: arg = DIGI_BAUD_19200; break; - case 38400: arg = DIGI_BAUD_38400; break; - case 57600: arg = DIGI_BAUD_57600; break; - case 115200: arg = DIGI_BAUD_115200; break; - case 230400: arg = DIGI_BAUD_230400; break; - case 460800: arg = DIGI_BAUD_460800; break; - default: - arg = DIGI_BAUD_9600; - baud = 9600; - break; + /* drop DTR and RTS on transition to B0 */ + case 0: digi_set_modem_signals(port, 0, 1); break; + case 50: arg = DIGI_BAUD_50; break; + case 75: arg = DIGI_BAUD_75; break; + case 110: arg = DIGI_BAUD_110; break; + case 150: arg = DIGI_BAUD_150; break; + case 200: arg = DIGI_BAUD_200; break; + case 300: arg = DIGI_BAUD_300; break; + case 600: arg = DIGI_BAUD_600; break; + case 1200: arg = DIGI_BAUD_1200; break; + case 1800: arg = DIGI_BAUD_1800; break; + case 2400: arg = DIGI_BAUD_2400; break; + case 4800: arg = DIGI_BAUD_4800; break; + case 9600: arg = DIGI_BAUD_9600; break; + case 19200: arg = DIGI_BAUD_19200; break; + case 38400: arg = DIGI_BAUD_38400; break; + case 57600: arg = DIGI_BAUD_57600; break; + case 115200: arg = DIGI_BAUD_115200; break; + case 230400: arg = DIGI_BAUD_230400; break; + case 460800: arg = DIGI_BAUD_460800; break; + default: + arg = DIGI_BAUD_9600; + baud = 9600; + break; } if (arg != -1) { buf[i++] = DIGI_CMD_SET_BAUD_RATE; @@ -1081,7 +1091,8 @@ static void digi_set_termios(struct tty_struct *tty, buf[i++] = arg; buf[i++] = 0; } - if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) + ret = digi_write_oob_command(port, buf, i, 1); + if (ret != 0) dbg("digi_set_termios: write oob failed, ret=%d", ret); tty_encode_baud_rate(tty, baud, baud); } @@ -1137,7 +1148,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { - int ret,data_len,new_len; + int ret, data_len, new_len; struct digi_port *priv = usb_get_serial_port_data(port); unsigned char *data = port->write_urb->transfer_buffer; unsigned long flags = 0; @@ -1155,7 +1166,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, spin_lock_irqsave(&priv->dp_port_lock, flags); /* wait for urb status clear to submit another urb */ - if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) { + if (port->write_urb->status == -EINPROGRESS || + priv->dp_write_urb_in_use) { /* buffer data if count is 1 (probably put_char) if possible */ if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) { priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; @@ -1190,7 +1202,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, /* copy in new data */ memcpy(data, buf, new_len); - if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { + ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); + if (ret == 0) { priv->dp_write_urb_in_use = 1; ret = new_len; priv->dp_out_buf_len = 0; @@ -1204,7 +1217,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, dbg("digi_write: returning %d", ret); return ret; -} +} static void digi_write_bulk_callback(struct urb *urb) { @@ -1219,13 +1232,13 @@ static void digi_write_bulk_callback(struct urb *urb) dbg("digi_write_bulk_callback: TOP, urb->status=%d", status); /* port and serial sanity check */ - if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) { + if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { err("%s: port or port->private is NULL, status=%d", __func__, status); return; } serial = port->serial; - if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) { + if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) { err("%s: serial or serial->private is NULL, status=%d", __func__, status); return; @@ -1248,13 +1261,15 @@ static void digi_write_bulk_callback(struct urb *urb) && priv->dp_out_buf_len > 0) { *((unsigned char *)(port->write_urb->transfer_buffer)) = (unsigned char)DIGI_CMD_SEND_DATA; - *((unsigned char *)(port->write_urb->transfer_buffer)+1) + *((unsigned char *)(port->write_urb->transfer_buffer) + 1) = (unsigned char)priv->dp_out_buf_len; - port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2; + port->write_urb->transfer_buffer_length = + priv->dp_out_buf_len + 2; port->write_urb->dev = serial->dev; - memcpy(port->write_urb->transfer_buffer+2, priv->dp_out_buf, + memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf, priv->dp_out_buf_len); - if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { + ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); + if (ret == 0) { priv->dp_write_urb_in_use = 1; priv->dp_out_buf_len = 0; } @@ -1280,7 +1295,8 @@ static int digi_write_room(struct tty_struct *tty) spin_lock_irqsave(&priv->dp_port_lock, flags); - if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) + if (port->write_urb->status == -EINPROGRESS || + priv->dp_write_urb_in_use) room = 0; else room = port->bulk_out_size - 2 - priv->dp_out_buf_len; @@ -1336,7 +1352,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, } /* wait for a close in progress to finish */ - while(priv->dp_in_close) { + while (priv->dp_in_close) { cond_wait_interruptible_timeout_irqrestore( &priv->dp_close_wait, DIGI_RETRY_TIMEOUT, &priv->dp_port_lock, flags); @@ -1346,7 +1362,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, } spin_unlock_irqrestore(&priv->dp_port_lock, flags); - + /* read modem signals automatically whenever they change */ buf[0] = DIGI_CMD_READ_INPUT_SIGNALS; buf[1] = priv->dp_port_num; @@ -1359,7 +1375,8 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; buf[7] = 0; - if ((ret = digi_write_oob_command(port, buf, 8, 1)) != 0) + ret = digi_write_oob_command(port, buf, 8, 1); + if (ret != 0) dbg("digi_open: write oob failed, ret=%d", ret); /* set termios settings */ @@ -1410,9 +1427,8 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port, if (port->serial->dev) { /* wait for transmit idle */ - if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) { + if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT); - } /* drop DTR and RTS */ digi_set_modem_signals(port, 0, 0); @@ -1446,11 +1462,13 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port, buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; buf[19] = 0; - if ((ret = digi_write_oob_command(port, buf, 20, 0)) != 0) + ret = digi_write_oob_command(port, buf, 20, 0); + if (ret != 0) dbg("digi_close: write oob failed, ret=%d", ret); /* wait for final commands on oob port to complete */ - prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); + prepare_to_wait(&priv->dp_flush_wait, &wait, + TASK_INTERRUPTIBLE); schedule_timeout(DIGI_CLOSE_TIMEOUT); finish_wait(&priv->dp_flush_wait, &wait); @@ -1470,15 +1488,15 @@ exit: /* -* Digi Startup Device -* -* Starts reads on all ports. Must be called AFTER startup, with -* urbs initialized. Returns 0 if successful, non-zero error otherwise. -*/ + * Digi Startup Device + * + * Starts reads on all ports. Must be called AFTER startup, with + * urbs initialized. Returns 0 if successful, non-zero error otherwise. + */ static int digi_startup_device(struct usb_serial *serial) { - int i,ret = 0; + int i, ret = 0; struct digi_serial *serial_priv = usb_get_serial_data(serial); struct usb_serial_port *port; @@ -1496,7 +1514,8 @@ static int digi_startup_device(struct usb_serial *serial) for (i = 0; i < serial->type->num_ports + 1; i++) { port = serial->port[i]; port->write_urb->dev = port->serial->dev; - if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) { + ret = usb_submit_urb(port->read_urb, GFP_KERNEL); + if (ret != 0) { err("%s: usb_submit_urb failed, ret=%d, port=%d", __func__, ret, i); break; @@ -1517,7 +1536,7 @@ static int digi_startup(struct usb_serial *serial) /* allocate the private data structures for all ports */ /* number of regular ports + 1 for the out-of-band port */ - for(i = 0; i < serial->type->num_ports + 1; i++) { + for (i = 0; i < serial->type->num_ports + 1; i++) { /* allocate port private structure */ priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL); if (priv == NULL) { @@ -1580,7 +1599,7 @@ static void digi_shutdown(struct usb_serial *serial) /* free the private data structures for all ports */ /* number of regular ports + 1 for the out-of-band port */ - for(i = 0; i < serial->type->num_ports + 1; i++) + for (i = 0; i < serial->type->num_ports + 1; i++) kfree(usb_get_serial_port_data(serial->port[i])); kfree(usb_get_serial_data(serial)); } @@ -1603,7 +1622,7 @@ static void digi_read_bulk_callback(struct urb *urb) return; } if (port->serial == NULL || - (serial_priv=usb_get_serial_data(port->serial)) == NULL) { + (serial_priv = usb_get_serial_data(port->serial)) == NULL) { err("%s: serial is bad or serial->private is NULL, status=%d", __func__, status); return; @@ -1627,22 +1646,23 @@ static void digi_read_bulk_callback(struct urb *urb) /* continue read */ urb->dev = port->serial->dev; - if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret != 0) { err("%s: failed resubmitting urb, ret=%d, port=%d", __func__, ret, priv->dp_port_num); } } -/* -* Digi Read INB Callback -* -* Digi Read INB Callback handles reads on the in band ports, sending -* the data on to the tty subsystem. When called we know port and -* port->private are not NULL and port->serial has been validated. -* It returns 0 if successful, 1 if successful but the port is -* throttled, and -1 if the sanity checks failed. -*/ +/* + * Digi Read INB Callback + * + * Digi Read INB Callback handles reads on the in band ports, sending + * the data on to the tty subsystem. When called we know port and + * port->private are not NULL and port->serial has been validated. + * It returns 0 if successful, 1 if successful but the port is + * throttled, and -1 if the sanity checks failed. + */ static int digi_read_inb_callback(struct urb *urb) { @@ -1653,8 +1673,8 @@ static int digi_read_inb_callback(struct urb *urb) int opcode = ((unsigned char *)urb->transfer_buffer)[0]; int len = ((unsigned char *)urb->transfer_buffer)[1]; int port_status = ((unsigned char *)urb->transfer_buffer)[2]; - unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3; - int flag,throttled; + unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3; + int flag, throttled; int i; int status = urb->status; @@ -1665,7 +1685,7 @@ static int digi_read_inb_callback(struct urb *urb) /* short/multiple packet check */ if (urb->actual_length != len + 2) { - err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " + err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " "port=%d, opcode=%d, len=%d, actual_length=%d, " "status=%d", __func__, status, priv->dp_port_num, opcode, len, urb->actual_length, port_status); @@ -1707,8 +1727,9 @@ static int digi_read_inb_callback(struct urb *urb) if (flag == TTY_NORMAL) tty_insert_flip_string(tty, data, len); else { - for(i = 0; i < len; i++) - tty_insert_flip_char(tty, data[i], flag); + for (i = 0; i < len; i++) + tty_insert_flip_char(tty, + data[i], flag); } tty_flip_buffer_push(tty); } @@ -1720,19 +1741,19 @@ static int digi_read_inb_callback(struct urb *urb) else if (opcode != DIGI_CMD_RECEIVE_DATA) dbg("%s: unknown opcode: %d", __func__, opcode); - return(throttled ? 1 : 0); + return throttled ? 1 : 0; } -/* -* Digi Read OOB Callback -* -* Digi Read OOB Callback handles reads on the out of band port. -* When called we know port and port->private are not NULL and -* the port->serial is valid. It returns 0 if successful, and -* -1 if the sanity checks failed. -*/ +/* + * Digi Read OOB Callback + * + * Digi Read OOB Callback handles reads on the out of band port. + * When called we know port and port->private are not NULL and + * the port->serial is valid. It returns 0 if successful, and + * -1 if the sanity checks failed. + */ static int digi_read_oob_callback(struct urb *urb) { @@ -1742,12 +1763,13 @@ static int digi_read_oob_callback(struct urb *urb) struct digi_port *priv = usb_get_serial_port_data(port); int opcode, line, status, val; int i; + unsigned int rts; dbg("digi_read_oob_callback: port=%d, len=%d", priv->dp_port_num, urb->actual_length); /* handle each oob command */ - for(i = 0; i < urb->actual_length - 3;) { + for (i = 0; i < urb->actual_length - 3;) { opcode = ((unsigned char *)urb->transfer_buffer)[i++]; line = ((unsigned char *)urb->transfer_buffer)[i++]; status = ((unsigned char *)urb->transfer_buffer)[i++]; @@ -1761,27 +1783,29 @@ static int digi_read_oob_callback(struct urb *urb) port = serial->port[line]; - if ((priv=usb_get_serial_port_data(port)) == NULL) + priv = usb_get_serial_port_data(port); + if (priv == NULL) return -1; + rts = 0; + if (port->port.count) + rts = port->port.tty->termios->c_cflag & CRTSCTS; + if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { spin_lock(&priv->dp_port_lock); /* convert from digi flags to termiox flags */ if (val & DIGI_READ_INPUT_SIGNALS_CTS) { priv->dp_modem_signals |= TIOCM_CTS; /* port must be open to use tty struct */ - if (port->port.count - && port->port.tty->termios->c_cflag & CRTSCTS) { + if (rts) { port->port.tty->hw_stopped = 0; digi_wakeup_write(port); } } else { priv->dp_modem_signals &= ~TIOCM_CTS; /* port must be open to use tty struct */ - if (port->port.count - && port->port.tty->termios->c_cflag & CRTSCTS) { + if (rts) port->port.tty->hw_stopped = 1; - } } if (val & DIGI_READ_INPUT_SIGNALS_DSR) priv->dp_modem_signals |= TIOCM_DSR; @@ -1818,7 +1842,7 @@ static int __init digi_init(void) if (retval) goto failed_acceleport_2_device; retval = usb_serial_register(&digi_acceleport_4_device); - if (retval) + if (retval) goto failed_acceleport_4_device; retval = usb_register(&digi_driver); if (retval) -- cgit v1.2.3-70-g09d2 From 93c467952ff6b5c3d92fddf4b1a609e68f6d08d1 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:11 +0100 Subject: empeg: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/empeg.c | 203 ++++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 96 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 47ebdf5fad8..a6ab5b58d9c 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -11,36 +11,39 @@ * it under the terms of the GNU General Public License, as published by * the Free Software Foundation, version 2. * - * See Documentation/usb/usb-serial.txt for more information on using this driver - * + * See Documentation/usb/usb-serial.txt for more information on using this + * driver + * * (07/16/2001) gb - * remove unused code in empeg_close() (thanks to Oliver Neukum for pointing this - * out) and rewrote empeg_set_termios(). - * + * remove unused code in empeg_close() (thanks to Oliver Neukum for + * pointing this out) and rewrote empeg_set_termios(). + * * (05/30/2001) gkh - * switched from using spinlock to a semaphore, which fixes lots of problems. + * switched from using spinlock to a semaphore, which fixes lots of + * problems. * * (04/08/2001) gb * Identify version on module load. - * + * * (01/22/2001) gb - * Added write_room() and chars_in_buffer() support. - * + * Added write_room() and chars_in_buffer() support. + * * (12/21/2000) gb * Moved termio stuff inside the port->active check. * Moved MOD_DEC_USE_COUNT to end of empeg_close(). - * + * * (12/03/2000) gb - * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open() - * This notifies the tty driver that the termios have changed. - * + * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to + * empeg_open(). This notifies the tty driver that the termios have + * changed. + * * (11/13/2000) gb - * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to empeg_open() - * (It only needs to be set once - Doh!) - * + * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to + * empeg_open() (It only needs to be set once - Doh!) + * * (11/11/2000) gb * Updated to work with id_table structure. - * + * * (11/04/2000) gb * Forked this from visor.c, and hacked it up to work with an * Empeg ltd. empeg-car player. Constructive criticism welcomed. @@ -48,7 +51,7 @@ * use of his code, and for his guidance, advice and patience. :) * A 'Thank You' is in order for John Ripley of Empeg ltd for his * advice, and patience too. - * + * */ #include @@ -60,7 +63,7 @@ #include #include #include -#include +#include #include #include @@ -77,27 +80,30 @@ static int debug; #define EMPEG_PRODUCT_ID 0x0001 /* function prototypes for an empeg-car player */ -static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port, - const unsigned char *buf, - int count); -static int empeg_write_room (struct tty_struct *tty); -static int empeg_chars_in_buffer (struct tty_struct *tty); -static void empeg_throttle (struct tty_struct *tty); -static void empeg_unthrottle (struct tty_struct *tty); -static int empeg_startup (struct usb_serial *serial); -static void empeg_shutdown (struct usb_serial *serial); -static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); -static void empeg_write_bulk_callback (struct urb *urb); -static void empeg_read_bulk_callback (struct urb *urb); +static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, + int count); +static int empeg_write_room(struct tty_struct *tty); +static int empeg_chars_in_buffer(struct tty_struct *tty); +static void empeg_throttle(struct tty_struct *tty); +static void empeg_unthrottle(struct tty_struct *tty); +static int empeg_startup(struct usb_serial *serial); +static void empeg_shutdown(struct usb_serial *serial); +static void empeg_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); +static void empeg_write_bulk_callback(struct urb *urb); +static void empeg_read_bulk_callback(struct urb *urb); static struct usb_device_id id_table [] = { { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver empeg_driver = { .name = "empeg", @@ -149,7 +155,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, dbg("%s - port %d", __func__, port->number); /* Force default termio settings */ - empeg_set_termios (tty, port, NULL) ; + empeg_set_termios(tty, port, NULL) ; bytes_in = 0; bytes_out = 0; @@ -157,7 +163,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, /* Start reading from the device */ usb_fill_bulk_urb( port->read_urb, - serial->dev, + serial->dev, usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -168,14 +174,16 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); return result; } static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, - struct file * filp) + struct file *filp) { dbg("%s - port %d", __func__, port->number); @@ -186,7 +194,8 @@ static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, } -static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) +static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct urb *urb; @@ -203,7 +212,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con /* try to find a free urb in our list of them */ urb = NULL; - spin_lock_irqsave (&write_urb_pool_lock, flags); + spin_lock_irqsave(&write_urb_pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]->status != -EINPROGRESS) { @@ -212,7 +221,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con } } - spin_unlock_irqrestore (&write_urb_pool_lock, flags); + spin_unlock_irqrestore(&write_urb_pool_lock, flags); if (urb == NULL) { dbg("%s - no more free urbs", __func__); @@ -220,25 +229,27 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con } if (urb->transfer_buffer == NULL) { - urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); + urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); if (urb->transfer_buffer == NULL) { - dev_err(&port->dev, "%s no more kernel memory...\n", __func__); + dev_err(&port->dev, + "%s no more kernel memory...\n", + __func__); goto exit; } } - transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); + transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); - memcpy (urb->transfer_buffer, current_position, transfer_size); + memcpy(urb->transfer_buffer, current_position, transfer_size); usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer); /* build up our urb */ - usb_fill_bulk_urb ( + usb_fill_bulk_urb( urb, serial->dev, usb_sndbulkpipe(serial->dev, - port->bulk_out_endpointAddress), + port->bulk_out_endpointAddress), urb->transfer_buffer, transfer_size, empeg_write_bulk_callback, @@ -260,7 +271,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con } exit: return bytes_sent; -} +} static int empeg_write_room(struct tty_struct *tty) @@ -272,14 +283,13 @@ static int empeg_write_room(struct tty_struct *tty) dbg("%s - port %d", __func__, port->number); - spin_lock_irqsave (&write_urb_pool_lock, flags); + spin_lock_irqsave(&write_urb_pool_lock, flags); /* tally up the number of bytes available */ for (i = 0; i < NUM_URBS; ++i) { - if (write_urb_pool[i]->status != -EINPROGRESS) { + if (write_urb_pool[i]->status != -EINPROGRESS) room += URB_TRANSFER_BUFFER_SIZE; - } - } - spin_unlock_irqrestore (&write_urb_pool_lock, flags); + } + spin_unlock_irqrestore(&write_urb_pool_lock, flags); dbg("%s - returns %d", __func__, room); return room; @@ -295,25 +305,21 @@ static int empeg_chars_in_buffer(struct tty_struct *tty) dbg("%s - port %d", __func__, port->number); - spin_lock_irqsave (&write_urb_pool_lock, flags); + spin_lock_irqsave(&write_urb_pool_lock, flags); /* tally up the number of bytes waiting */ for (i = 0; i < NUM_URBS; ++i) { - if (write_urb_pool[i]->status == -EINPROGRESS) { + if (write_urb_pool[i]->status == -EINPROGRESS) chars += URB_TRANSFER_BUFFER_SIZE; - } } - spin_unlock_irqrestore (&write_urb_pool_lock, flags); - + spin_unlock_irqrestore(&write_urb_pool_lock, flags); dbg("%s - returns %d", __func__, chars); - - return (chars); - + return chars; } -static void empeg_write_bulk_callback (struct urb *urb) +static void empeg_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; int status = urb->status; @@ -330,7 +336,7 @@ static void empeg_write_bulk_callback (struct urb *urb) } -static void empeg_read_bulk_callback (struct urb *urb) +static void empeg_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct tty_struct *tty; @@ -346,8 +352,8 @@ static void empeg_read_bulk_callback (struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty; if (urb->actual_length) { @@ -360,7 +366,7 @@ static void empeg_read_bulk_callback (struct urb *urb) /* Continue trying to always read */ usb_fill_bulk_urb( port->read_urb, - port->serial->dev, + port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -371,7 +377,9 @@ static void empeg_read_bulk_callback (struct urb *urb) result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); + dev_err(&urb->dev->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); return; @@ -395,11 +403,13 @@ static void empeg_unthrottle(struct tty_struct *tty) port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); } -static int empeg_startup (struct usb_serial *serial) +static int empeg_startup(struct usb_serial *serial) { int r; @@ -411,7 +421,7 @@ static int empeg_startup (struct usb_serial *serial) return -ENODEV; } dbg("%s - reset config", __func__); - r = usb_reset_configuration (serial->dev); + r = usb_reset_configuration(serial->dev); /* continue on with initialization */ return r; @@ -419,9 +429,9 @@ static int empeg_startup (struct usb_serial *serial) } -static void empeg_shutdown (struct usb_serial *serial) +static void empeg_shutdown(struct usb_serial *serial) { - dbg ("%s", __func__); + dbg("%s", __func__); } @@ -432,14 +442,14 @@ static void empeg_set_termios(struct tty_struct *tty, dbg("%s - port %d", __func__, port->number); /* - * The empeg-car player wants these particular tty settings. - * You could, for example, change the baud rate, however the - * player only supports 115200 (currently), so there is really - * no point in support for changes to the tty settings. - * (at least for now) - * - * The default requirements for this device are: - */ + * The empeg-car player wants these particular tty settings. + * You could, for example, change the baud rate, however the + * player only supports 115200 (currently), so there is really + * no point in support for changes to the tty settings. + * (at least for now) + * + * The default requirements for this device are: + */ termios->c_iflag &= ~(IGNBRK /* disable ignore break */ | BRKINT /* disable break causes interrupt */ @@ -478,13 +488,13 @@ static void empeg_set_termios(struct tty_struct *tty, } -static int __init empeg_init (void) +static int __init empeg_init(void) { struct urb *urb; int i, retval; - /* create our write urb pool and transfer buffers */ - spin_lock_init (&write_urb_pool_lock); + /* create our write urb pool and transfer buffers */ + spin_lock_init(&write_urb_pool_lock); for (i = 0; i < NUM_URBS; ++i) { urb = usb_alloc_urb(0, GFP_KERNEL); write_urb_pool[i] = urb; @@ -493,9 +503,10 @@ static int __init empeg_init (void) continue; } - urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); + urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, + GFP_KERNEL); if (!urb->transfer_buffer) { - err("%s - out of memory for urb buffers.", + err("%s - out of memory for urb buffers.", __func__); continue; } @@ -524,36 +535,36 @@ failed_usb_serial_register: } -static void __exit empeg_exit (void) +static void __exit empeg_exit(void) { int i; unsigned long flags; usb_deregister(&empeg_driver); - usb_serial_deregister (&empeg_device); + usb_serial_deregister(&empeg_device); - spin_lock_irqsave (&write_urb_pool_lock, flags); + spin_lock_irqsave(&write_urb_pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - /* FIXME - uncomment the following usb_kill_urb call when - * the host controllers get fixed to set urb->dev = NULL after - * the urb is finished. Otherwise this call oopses. */ + /* FIXME - uncomment the following usb_kill_urb call + * when the host controllers get fixed to set urb->dev + * = NULL after the urb is finished. Otherwise this + * call oopses. */ /* usb_kill_urb(write_urb_pool[i]); */ kfree(write_urb_pool[i]->transfer_buffer); - usb_free_urb (write_urb_pool[i]); + usb_free_urb(write_urb_pool[i]); } } - - spin_unlock_irqrestore (&write_urb_pool_lock, flags); + spin_unlock_irqrestore(&write_urb_pool_lock, flags); } module_init(empeg_init); module_exit(empeg_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 464cbb24698ddb7bf24b2b73204e3dc121886211 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:23 +0100 Subject: ftdi_sio: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ftdi_sio.c | 1078 ++++++++++++++++++++++------------------- drivers/usb/serial/ftdi_sio.h | 126 ++--- 2 files changed, 635 insertions(+), 569 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index abbb447e537..83871725014 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -12,7 +12,8 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * See http://ftdi-usb-sio.sourceforge.net for upto date testing info * and extra documentation @@ -25,7 +26,8 @@ /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */ /* Thanx to FTDI for so kindly providing details of the protocol required */ /* to talk to the device */ -/* Thanx to gkh and the rest of the usb dev group for all code I have assimilated :-) */ +/* Thanx to gkh and the rest of the usb dev group for all code I have + assimilated :-) */ #include #include @@ -36,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,17 +57,22 @@ static __u16 product; struct ftdi_private { ftdi_chip_type_t chip_type; - /* type of the device, either SIO or FT8U232AM */ + /* type of device, either SIO or FT8U232AM */ int baud_base; /* baud base clock for divisor setting */ - int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ + int custom_divisor; /* custom_divisor kludge, this is for + baud_base (different from what goes to the + chip!) */ __u16 last_set_data_urb_value ; - /* the last data state set - needed for doing a break */ - int write_offset; /* This is the offset in the usb data block to write the serial data - - * it is different between devices + /* the last data state set - needed for doing + * a break + */ + int write_offset; /* This is the offset in the usb data block to + * write the serial data - it varies between + * devices */ int flags; /* some ASYNC_xxxx flags are supported */ unsigned long last_dtr_rts; /* saved modem control outputs */ - wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ + wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ char prev_status, diff_status; /* Used for TIOCMIWAIT */ __u8 rx_flags; /* receive state flags (throttling) */ spinlock_t rx_lock; /* spinlock for receive state */ @@ -76,8 +83,10 @@ struct ftdi_private { __u16 interface; /* FT2232C port interface (0 for FT232/245) */ - speed_t force_baud; /* if non-zero, force the baud rate to this value */ - int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ + speed_t force_baud; /* if non-zero, force the baud rate to + this value */ + int force_rtscts; /* if non-zero, force RTS-CTS to always + be enabled */ spinlock_t tx_lock; /* spinlock for transmit state */ unsigned long tx_bytes; @@ -88,13 +97,14 @@ struct ftdi_private { /* struct ftdi_sio_quirk is used by devices requiring special attention. */ struct ftdi_sio_quirk { int (*probe)(struct usb_serial *); - void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */ + /* Special settings for probed ports. */ + void (*port_probe)(struct ftdi_private *); }; -static int ftdi_jtag_probe (struct usb_serial *serial); -static int ftdi_mtxorb_hack_setup (struct usb_serial *serial); -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv); -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv); +static int ftdi_jtag_probe(struct usb_serial *serial); +static int ftdi_mtxorb_hack_setup(struct usb_serial *serial); +static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); +static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); static struct ftdi_sio_quirk ftdi_jtag_quirk = { .probe = ftdi_jtag_probe, @@ -174,270 +184,270 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID), + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID), .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) }, - { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) }, + { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, @@ -642,7 +652,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver ftdi_driver = { .name = "ftdi_sio", @@ -678,30 +688,37 @@ static const char *ftdi_chip_name[] = { | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP) /* function prototypes for a FTDI serial converter */ -static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id); -static void ftdi_shutdown (struct usb_serial *serial); -static int ftdi_sio_port_probe (struct usb_serial_port *port); -static int ftdi_sio_port_remove (struct usb_serial_port *port); -static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int ftdi_write_room (struct tty_struct *tty); -static int ftdi_chars_in_buffer (struct tty_struct *tty); -static void ftdi_write_bulk_callback (struct urb *urb); -static void ftdi_read_bulk_callback (struct urb *urb); -static void ftdi_process_read (struct work_struct *work); -static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); -static int ftdi_tiocmget (struct tty_struct *tty, struct file *file); -static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear); -static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); -static void ftdi_break_ctl (struct tty_struct *tty, int break_state ); -static void ftdi_throttle (struct tty_struct *tty); -static void ftdi_unthrottle (struct tty_struct *tty); - -static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); -static unsigned short int ftdi_232am_baud_to_divisor (int baud); -static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); -static __u32 ftdi_232bm_baud_to_divisor (int baud); +static int ftdi_sio_probe(struct usb_serial *serial, + const struct usb_device_id *id); +static void ftdi_shutdown(struct usb_serial *serial); +static int ftdi_sio_port_probe(struct usb_serial_port *port); +static int ftdi_sio_port_remove(struct usb_serial_port *port); +static int ftdi_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void ftdi_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static int ftdi_write_room(struct tty_struct *tty); +static int ftdi_chars_in_buffer(struct tty_struct *tty); +static void ftdi_write_bulk_callback(struct urb *urb); +static void ftdi_read_bulk_callback(struct urb *urb); +static void ftdi_process_read(struct work_struct *work); +static void ftdi_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static int ftdi_tiocmget(struct tty_struct *tty, struct file *file); +static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +static int ftdi_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); +static void ftdi_break_ctl(struct tty_struct *tty, int break_state); +static void ftdi_throttle(struct tty_struct *tty); +static void ftdi_unthrottle(struct tty_struct *tty); + +static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); +static unsigned short int ftdi_232am_baud_to_divisor(int baud); +static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base); +static __u32 ftdi_232bm_baud_to_divisor(int baud); static struct usb_serial_driver ftdi_sio_device = { .driver = { @@ -752,44 +769,54 @@ static struct usb_serial_driver ftdi_sio_device = { static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) { unsigned short int divisor; - int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left - if ((divisor3 & 0x7) == 7) divisor3 ++; // round x.7/8 up to x+1 + /* divisor shifted 3 bits to the left */ + int divisor3 = base / 2 / baud; + if ((divisor3 & 0x7) == 7) + divisor3++; /* round x.7/8 up to x+1 */ divisor = divisor3 >> 3; divisor3 &= 0x7; - if (divisor3 == 1) divisor |= 0xc000; else // 0.125 - if (divisor3 >= 4) divisor |= 0x4000; else // 0.5 - if (divisor3 != 0) divisor |= 0x8000; // 0.25 - if (divisor == 1) divisor = 0; /* special case for maximum baud rate */ + if (divisor3 == 1) + divisor |= 0xc000; + else if (divisor3 >= 4) + divisor |= 0x4000; + else if (divisor3 != 0) + divisor |= 0x8000; + else if (divisor == 1) + divisor = 0; /* special case for maximum baud rate */ return divisor; } static unsigned short int ftdi_232am_baud_to_divisor(int baud) { - return(ftdi_232am_baud_base_to_divisor(baud, 48000000)); + return ftdi_232am_baud_base_to_divisor(baud, 48000000); } static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) { static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 }; __u32 divisor; - int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left + /* divisor shifted 3 bits to the left */ + int divisor3 = base / 2 / baud; divisor = divisor3 >> 3; divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; /* Deal with special cases for highest baud rates. */ - if (divisor == 1) divisor = 0; else // 1.0 - if (divisor == 0x4001) divisor = 1; // 1.5 + if (divisor == 1) + divisor = 0; + else if (divisor == 0x4001) + divisor = 1; return divisor; } static __u32 ftdi_232bm_baud_to_divisor(int baud) { - return(ftdi_232bm_baud_base_to_divisor(baud, 48000000)); + return ftdi_232bm_baud_base_to_divisor(baud, 48000000); } #define set_mctrl(port, set) update_mctrl((port), (set), 0) #define clear_mctrl(port, clear) update_mctrl((port), 0, (clear)) -static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear) +static int update_mctrl(struct usb_serial_port *port, unsigned int set, + unsigned int clear) { struct ftdi_private *priv = usb_get_serial_port_data(port); char *buf; @@ -843,7 +870,8 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned } -static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port) +static __u32 get_ftdi_divisor(struct tty_struct *tty, + struct usb_serial_port *port) { /* get_ftdi_divisor */ struct ftdi_private *priv = usb_get_serial_port_data(port); __u32 div_value = 0; @@ -851,48 +879,56 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po int baud; /* - * The logic involved in setting the baudrate can be cleanly split in 3 steps. - * Obtaining the actual baud rate is a little tricky since unix traditionally - * somehow ignored the possibility to set non-standard baud rates. + * The logic involved in setting the baudrate can be cleanly split into + * 3 steps. * 1. Standard baud rates are set in tty->termios->c_cflag - * 2. If these are not enough, you can set any speed using alt_speed as follows: + * 2. If these are not enough, you can set any speed using alt_speed as + * follows: * - set tty->termios->c_cflag speed to B38400 * - set your real speed in tty->alt_speed; it gets ignored when * alt_speed==0, (or) - * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: - * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], this just - * sets alt_speed to (HI: 57600, VHI: 115200, SHI: 230400, WARP: 460800) + * - call TIOCSSERIAL ioctl with (struct serial_struct) set as + * follows: + * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], + * this just sets alt_speed to (HI: 57600, VHI: 115200, + * SHI: 230400, WARP: 460800) * ** Steps 1, 2 are done courtesy of tty_get_baud_rate * 3. You can also set baud rate by setting custom divisor as follows * - set tty->termios->c_cflag speed to B38400 - * - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows: + * - call TIOCSSERIAL ioctl with (struct serial_struct) set as + * follows: * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST * o custom_divisor set to baud_base / your_new_baudrate - * ** Step 3 is done courtesy of code borrowed from serial.c - I should really - * spend some time and separate+move this common code to serial.c, it is - * replicated in nearly every serial driver you see. + * ** Step 3 is done courtesy of code borrowed from serial.c + * I should really spend some time and separate + move this common + * code to serial.c, it is replicated in nearly every serial driver + * you see. */ - /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ + /* 1. Get the baud rate from the tty settings, this observes + alt_speed hack */ baud = tty_get_baud_rate(tty); dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); - /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ + /* 2. Observe async-compatible custom_divisor hack, update baudrate + if needed */ if (baud == 38400 && ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && (priv->custom_divisor)) { baud = priv->baud_base / priv->custom_divisor; - dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud); + dbg("%s - custom divisor %d sets baud rate to %d", + __func__, priv->custom_divisor, baud); } /* 3. Convert baudrate to device-specific divisor */ - if (!baud) baud = 9600; - switch(priv->chip_type) { + if (!baud) + baud = 9600; + switch (priv->chip_type) { case SIO: /* SIO chip */ - switch(baud) { + switch (baud) { case 300: div_value = ftdi_sio_b300; break; case 600: div_value = ftdi_sio_b600; break; case 1200: div_value = ftdi_sio_b1200; break; @@ -905,7 +941,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po case 115200: div_value = ftdi_sio_b115200; break; } /* baud */ if (div_value == 0) { - dbg("%s - Baudrate (%d) requested is not supported", __func__, baud); + dbg("%s - Baudrate (%d) requested is not supported", + __func__, baud); div_value = ftdi_sio_b9600; baud = 9600; div_okay = 0; @@ -915,7 +952,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po if (baud <= 3000000) { div_value = ftdi_232am_baud_to_divisor(baud); } else { - dbg("%s - Baud rate too high!", __func__); + dbg("%s - Baud rate too high!", __func__); baud = 9600; div_value = ftdi_232am_baud_to_divisor(9600); div_okay = 0; @@ -927,7 +964,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po if (baud <= 3000000) { div_value = ftdi_232bm_baud_to_divisor(baud); } else { - dbg("%s - Baud rate too high!", __func__); + dbg("%s - Baud rate too high!", __func__); div_value = ftdi_232bm_baud_to_divisor(9600); div_okay = 0; baud = 9600; @@ -942,14 +979,14 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *po } tty_encode_baud_rate(tty, baud, baud); - return(div_value); + return div_value; } static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); char *buf; - __u16 urb_value; + __u16 urb_value; __u16 urb_index; __u32 urb_index_value; int rv; @@ -978,7 +1015,8 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) -static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) +static int get_serial_info(struct usb_serial_port *port, + struct serial_struct __user *retinfo) { struct ftdi_private *priv = usb_get_serial_port_data(port); struct serial_struct tmp; @@ -996,7 +1034,7 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _ static int set_serial_info(struct tty_struct *tty, - struct usb_serial_port * port, struct serial_struct __user * newinfo) + struct usb_serial_port *port, struct serial_struct __user *newinfo) { /* set_serial_info */ struct ftdi_private *priv = usb_get_serial_port_data(port); struct serial_struct new_serial; @@ -1004,7 +1042,7 @@ static int set_serial_info(struct tty_struct *tty, if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) return -EFAULT; - old_priv = * priv; + old_priv = *priv; /* Do error checking and permission checking */ @@ -1025,7 +1063,7 @@ static int set_serial_info(struct tty_struct *tty, /* Make the changes - these are privileged changes! */ priv->flags = ((priv->flags & ~ASYNC_FLAGS) | - (new_serial.flags & ASYNC_FLAGS)); + (new_serial.flags & ASYNC_FLAGS)); priv->custom_divisor = new_serial.custom_divisor; tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; @@ -1079,11 +1117,10 @@ static void ftdi_determine_type(struct usb_serial_port *port) priv->chip_type = FT2232C; /* Determine interface code. */ inter = serial->interface->altsetting->desc.bInterfaceNumber; - if (inter == 0) { + if (inter == 0) priv->interface = PIT_SIOA; - } else { + else priv->interface = PIT_SIOB; - } /* BM-type devices have a bug where bcdDevice gets set * to 0x200 when iSerialNumber is 0. */ if (version < 0x500) { @@ -1117,7 +1154,8 @@ static void ftdi_determine_type(struct usb_serial_port *port) * *************************************************************************** */ -static ssize_t show_latency_timer(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_latency_timer(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_serial_port *port = to_usb_serial_port(dev); struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -1126,14 +1164,14 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a int rv = 0; - dbg("%s",__func__); + dbg("%s", __func__); rv = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), FTDI_SIO_GET_LATENCY_TIMER_REQUEST, FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 0, priv->interface, - (char*) &latency, 1, WDR_TIMEOUT); + (char *) &latency, 1, WDR_TIMEOUT); if (rv < 0) { dev_err(dev, "Unable to read latency timer: %i\n", rv); @@ -1143,8 +1181,9 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a } /* Write a new value of the latency timer, in units of milliseconds. */ -static ssize_t store_latency_timer(struct device *dev, struct device_attribute *attr, const char *valbuf, - size_t count) +static ssize_t store_latency_timer(struct device *dev, + struct device_attribute *attr, const char *valbuf, + size_t count) { struct usb_serial_port *port = to_usb_serial_port(dev); struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -1172,8 +1211,8 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute * /* Write an event character directly to the FTDI register. The ASCII value is in the low 8 bits, with the enable bit in the 9th bit. */ -static ssize_t store_event_char(struct device *dev, struct device_attribute *attr, const char *valbuf, - size_t count) +static ssize_t store_event_char(struct device *dev, + struct device_attribute *attr, const char *valbuf, size_t count) { struct usb_serial_port *port = to_usb_serial_port(dev); struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -1199,7 +1238,8 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att return count; } -static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer); +static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, + store_latency_timer); static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char); static int create_sysfs_attrs(struct usb_serial_port *port) @@ -1207,7 +1247,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port) struct ftdi_private *priv = usb_get_serial_port_data(port); int retval = 0; - dbg("%s",__func__); + dbg("%s", __func__); /* XXX I've no idea if the original SIO supports the event_char * sysfs parameter, so I'm playing it safe. */ @@ -1229,7 +1269,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); - dbg("%s",__func__); + dbg("%s", __func__); /* XXX see create_sysfs_attrs */ if (priv->chip_type != SIO) { @@ -1250,9 +1290,11 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) */ /* Probe function to check for special devices */ -static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id) +static int ftdi_sio_probe(struct usb_serial *serial, + const struct usb_device_id *id) { - struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info; + struct ftdi_sio_quirk *quirk = + (struct ftdi_sio_quirk *)id->driver_info; if (quirk && quirk->probe) { int ret = quirk->probe(serial); @@ -1271,17 +1313,18 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); - dbg("%s",__func__); + dbg("%s", __func__); priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); - if (!priv){ - err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private)); + if (!priv) { + err("%s- kmalloc(%Zd) failed.", __func__, + sizeof(struct ftdi_private)); return -ENOMEM; } spin_lock_init(&priv->rx_lock); spin_lock_init(&priv->tx_lock); - init_waitqueue_head(&priv->delta_msr_wait); + init_waitqueue_head(&priv->delta_msr_wait); /* This will push the characters through immediately rather than queue a task to deliver them */ priv->flags = ASYNC_LOW_LATENCY; @@ -1291,9 +1334,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) /* Increase the size of read buffers */ kfree(port->bulk_in_buffer); - port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL); + port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL); if (!port->bulk_in_buffer) { - kfree (priv); + kfree(priv); return -ENOMEM; } if (port->read_urb) { @@ -1306,7 +1349,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) /* Free port's existing write urb and transfer buffer. */ if (port->write_urb) { - usb_free_urb (port->write_urb); + usb_free_urb(port->write_urb); port->write_urb = NULL; } kfree(port->bulk_out_buffer); @@ -1314,7 +1357,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) usb_set_serial_port_data(port, priv); - ftdi_determine_type (port); + ftdi_determine_type(port); create_sysfs_attrs(port); return 0; } @@ -1322,9 +1365,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) /* Setup for the USB-UIRT device, which requires hardwired * baudrate (38400 gets mapped to 312500) */ /* Called from usbserial:serial_probe */ -static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) +static void ftdi_USB_UIRT_setup(struct ftdi_private *priv) { - dbg("%s",__func__); + dbg("%s", __func__); priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 77; @@ -1333,9 +1376,10 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) /* Setup for the HE-TIRA1 device, which requires hardwired * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ -static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) + +static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv) { - dbg("%s",__func__); + dbg("%s", __func__); priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 240; @@ -1353,7 +1397,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial) struct usb_device *udev = serial->dev; struct usb_interface *interface = serial->interface; - dbg("%s",__func__); + dbg("%s", __func__); if (interface == udev->actconfig->interface[0]) { info("Ignoring serial port reserved for JTAG"); @@ -1387,7 +1431,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial) * calls __serial_close for each open of the port * shutdown is called then (ie ftdi_shutdown) */ -static void ftdi_shutdown (struct usb_serial *serial) +static void ftdi_shutdown(struct usb_serial *serial) { dbg("%s", __func__); } @@ -1401,7 +1445,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) remove_sysfs_attrs(port); /* all open ports are closed at this point - * (by usbserial.c:__serial_close, which calls ftdi_close) + * (by usbserial.c:__serial_close, which calls ftdi_close) */ if (priv) { @@ -1462,12 +1506,14 @@ static int ftdi_open(struct tty_struct *tty, /* Start reading from the device */ priv->rx_processed = 0; usb_fill_bulk_urb(port->read_urb, dev, - usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ftdi_read_bulk_callback, port); + usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ftdi_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - err("%s - failed submitting read urb, error %d", __func__, result); + err("%s - failed submitting read urb, error %d", + __func__, result); return result; @@ -1493,7 +1539,7 @@ static void ftdi_close(struct tty_struct *tty, dbg("%s", __func__); mutex_lock(&port->serial->disc_mutex); - if (c_cflag & HUPCL && !port->serial->disconnected){ + if (c_cflag & HUPCL && !port->serial->disconnected) { /* Disable flow control */ if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), @@ -1553,7 +1599,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, spin_unlock_irqrestore(&priv->tx_lock, flags); data_offset = priv->write_offset; - dbg("data_offset set to %d",data_offset); + dbg("data_offset set to %d", data_offset); /* Determine total transfer size */ transfer_size = count; @@ -1564,7 +1610,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, (PKTSZ - data_offset))); } - buffer = kmalloc (transfer_size, GFP_ATOMIC); + buffer = kmalloc(transfer_size, GFP_ATOMIC); if (!buffer) { err("%s ran out of kernel memory for urb ...", __func__); count = -ENOMEM; @@ -1580,20 +1626,20 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, /* Copy data */ if (data_offset > 0) { - /* Original sio requires control byte at start of each packet. */ + /* Original sio requires control byte at start of + each packet. */ int user_pktsz = PKTSZ - data_offset; int todo = count; unsigned char *first_byte = buffer; const unsigned char *current_position = buf; while (todo > 0) { - if (user_pktsz > todo) { + if (user_pktsz > todo) user_pktsz = todo; - } /* Write the control byte at the front of the packet*/ *first_byte = 1 | ((user_pktsz) << 2); /* Copy data for packet */ - memcpy (first_byte + data_offset, + memcpy(first_byte + data_offset, current_position, user_pktsz); first_byte += user_pktsz + data_offset; current_position += user_pktsz; @@ -1602,20 +1648,23 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, } else { /* No control byte required. */ /* Copy in the data to send */ - memcpy (buffer, buf, count); + memcpy(buffer, buf, count); } - usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer); + usb_serial_debug_data(debug, &port->dev, __func__, + transfer_size, buffer); /* fill the buffer and send it */ usb_fill_bulk_urb(urb, port->serial->dev, - usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), - buffer, transfer_size, - ftdi_write_bulk_callback, port); + usb_sndbulkpipe(port->serial->dev, + port->bulk_out_endpointAddress), + buffer, transfer_size, + ftdi_write_bulk_callback, port); status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { - err("%s - failed submitting write urb, error %d", __func__, status); + err("%s - failed submitting write urb, error %d", + __func__, status); count = status; goto error; } else { @@ -1634,7 +1683,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, error: usb_free_urb(urb); error_no_urb: - kfree (buffer); + kfree(buffer); error_no_buffer: spin_lock_irqsave(&priv->tx_lock, flags); priv->tx_outstanding_urbs--; @@ -1645,7 +1694,7 @@ error_no_buffer: /* This function may get called when the device is closed */ -static void ftdi_write_bulk_callback (struct urb *urb) +static void ftdi_write_bulk_callback(struct urb *urb) { unsigned long flags; struct usb_serial_port *port = urb->context; @@ -1655,7 +1704,7 @@ static void ftdi_write_bulk_callback (struct urb *urb) int status = urb->status; /* free up the transfer buffer, as usb_free_urb() does not do this */ - kfree (urb->transfer_buffer); + kfree(urb->transfer_buffer); dbg("%s - port %d", __func__, port->number); @@ -1738,9 +1787,11 @@ static void ftdi_read_bulk_callback(struct urb *urb) int status = urb->status; if (urb->number_of_packets > 0) { - err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__, - urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets ); - err("%s transfer_flags %x ", __func__,urb->transfer_flags ); + err("%s transfer_buffer_length %d actual_length %d number of packets %d", + __func__, + urb->transfer_buffer_length, + urb->actual_length, urb->number_of_packets); + err("%s transfer_flags %x ", __func__, urb->transfer_flags); } dbg("%s - port %d", __func__, port->number); @@ -1750,7 +1801,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) tty = port->port.tty; if (!tty) { - dbg("%s - bad tty pointer - exiting",__func__); + dbg("%s - bad tty pointer - exiting", __func__); return; } @@ -1760,14 +1811,13 @@ static void ftdi_read_bulk_callback(struct urb *urb) return; } - if (urb != port->read_urb) { + if (urb != port->read_urb) err("%s - Not my urb!", __func__); - } if (status) { - /* This will happen at close every time so it is a dbg not an err */ - dbg("(this is ok on close) nonzero read bulk status received: " - "%d", status); + /* This will happen at close every time so it is a dbg not an + err */ + dbg("(this is ok on close) nonzero read bulk status received: %d", status); return; } @@ -1783,7 +1833,7 @@ static void ftdi_read_bulk_callback(struct urb *urb) } /* ftdi_read_bulk_callback */ -static void ftdi_process_read (struct work_struct *work) +static void ftdi_process_read(struct work_struct *work) { /* ftdi_process_read */ struct ftdi_private *priv = container_of(work, struct ftdi_private, rx_work.work); @@ -1806,7 +1856,7 @@ static void ftdi_process_read (struct work_struct *work) tty = port->port.tty; if (!tty) { - dbg("%s - bad tty pointer - exiting",__func__); + dbg("%s - bad tty pointer - exiting", __func__); return; } @@ -1830,11 +1880,11 @@ static void ftdi_process_read (struct work_struct *work) urb->actual_length - priv->rx_processed); } else { /* The first two bytes of every read packet are status */ - if (urb->actual_length > 2) { - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - } else { - dbg("Status only: %03oo %03oo",data[0],data[1]); - } + if (urb->actual_length > 2) + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); + else + dbg("Status only: %03oo %03oo", data[0], data[1]); } @@ -1844,16 +1894,19 @@ static void ftdi_process_read (struct work_struct *work) /* if CD is dropped and the line is not CLOCAL then we should hangup */ need_flip = 0; - for (packet_offset = priv->rx_processed; packet_offset < urb->actual_length; packet_offset += PKTSZ) { + for (packet_offset = priv->rx_processed; + packet_offset < urb->actual_length; packet_offset += PKTSZ) { int length; - /* Compare new line status to the old one, signal if different */ - /* N.B. packet may be processed more than once, but differences - * are only processed once. */ + /* Compare new line status to the old one, signal if different/ + N.B. packet may be processed more than once, but differences + are only processed once. */ if (priv != NULL) { - char new_status = data[packet_offset+0] & FTDI_STATUS_B0_MASK; + char new_status = data[packet_offset + 0] & + FTDI_STATUS_B0_MASK; if (new_status != priv->prev_status) { - priv->diff_status |= new_status ^ priv->prev_status; + priv->diff_status |= + new_status ^ priv->prev_status; wake_up_interruptible(&priv->delta_msr_wait); priv->prev_status = new_status; } @@ -1870,30 +1923,31 @@ static void ftdi_process_read (struct work_struct *work) break; } if (tty_buffer_request_room(tty, length) < length) { - /* break out & wait for throttling/unthrottling to happen */ + /* break out & wait for throttling/unthrottling to + happen */ dbg("%s - receive room low", __func__); break; } /* Handle errors and break */ error_flag = TTY_NORMAL; - /* Although the device uses a bitmask and hence can have multiple */ - /* errors on a packet - the order here sets the priority the */ - /* error is returned to the tty layer */ + /* Although the device uses a bitmask and hence can have + multiple errors on a packet - the order here sets the + priority the error is returned to the tty layer */ - if ( data[packet_offset+1] & FTDI_RS_OE ) { + if (data[packet_offset+1] & FTDI_RS_OE) { error_flag = TTY_OVERRUN; dbg("OVERRRUN error"); } - if ( data[packet_offset+1] & FTDI_RS_BI ) { + if (data[packet_offset+1] & FTDI_RS_BI) { error_flag = TTY_BREAK; dbg("BREAK received"); } - if ( data[packet_offset+1] & FTDI_RS_PE ) { + if (data[packet_offset+1] & FTDI_RS_PE) { error_flag = TTY_PARITY; dbg("PARITY error"); } - if ( data[packet_offset+1] & FTDI_RS_FE ) { + if (data[packet_offset+1] & FTDI_RS_FE) { error_flag = TTY_FRAME; dbg("FRAMING error"); } @@ -1902,7 +1956,8 @@ static void ftdi_process_read (struct work_struct *work) /* Note that the error flag is duplicated for every character received since we don't know which character it applied to */ - tty_insert_flip_char(tty, data[packet_offset+i], error_flag); + tty_insert_flip_char(tty, + data[packet_offset + i], error_flag); } need_flip = 1; } @@ -1910,19 +1965,19 @@ static void ftdi_process_read (struct work_struct *work) #ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW /* if a parity error is detected you get status packets forever until a character is sent without a parity error. - This doesn't work well since the application receives a never - ending stream of bad data - even though new data hasn't been sent. - Therefore I (bill) have taken this out. + This doesn't work well since the application receives a + never ending stream of bad data - even though new data + hasn't been sent. Therefore I (bill) have taken this out. However - this might make sense for framing errors and so on so I am leaving the code in for now. */ else { - if (error_flag != TTY_NORMAL){ + if (error_flag != TTY_NORMAL) { dbg("error_flag is not normal"); - /* In this case it is just status - if that is an error send a bad character */ - if(tty->flip.count >= TTY_FLIPBUF_SIZE) { + /* In this case it is just status - if that is + an error send a bad character */ + if (tty->flip.count >= TTY_FLIPBUF_SIZE) tty_flip_buffer_push(tty); - } tty_insert_flip_char(tty, 0xff, error_flag); need_flip = 1; } @@ -1931,9 +1986,8 @@ static void ftdi_process_read (struct work_struct *work) } /* "for(packet_offset=0..." */ /* Low latency */ - if (need_flip) { + if (need_flip) tty_flip_buffer_push(tty); - } if (packet_offset < urb->actual_length) { /* not completely processed - record progress */ @@ -1952,12 +2006,11 @@ static void ftdi_process_read (struct work_struct *work) } spin_unlock_irqrestore(&priv->rx_lock, flags); /* if the port is closed stop trying to read */ - if (port->port.count > 0){ + if (port->port.count > 0) /* delay processing of remainder */ schedule_delayed_work(&priv->rx_work, 1); - } else { + else dbg("%s - port is closed", __func__); - } return; } @@ -1965,19 +2018,20 @@ static void ftdi_process_read (struct work_struct *work) priv->rx_processed = 0; /* if the port is closed stop trying to read */ - if (port->port.count > 0){ + if (port->port.count > 0) { /* Continue trying to always read */ usb_fill_bulk_urb(port->read_urb, port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ftdi_read_bulk_callback, port); + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ftdi_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __func__, result); + err("%s - failed resubmitting read urb, error %d", + __func__, result); } - - return; } /* ftdi_process_read */ @@ -1992,22 +2046,23 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) /* see drivers/char/tty_io.c to see it used */ /* last_set_data_urb_value NEVER has the break bit set in it */ - if (break_state) { + if (break_state) urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; - } else { + else urb_value = priv->last_set_data_urb_value; - } - - if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_DATA_REQUEST, - FTDI_SIO_SET_DATA_REQUEST_TYPE, - urb_value , priv->interface, - buf, 0, WDR_TIMEOUT) < 0) { - err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state); + if (usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + FTDI_SIO_SET_DATA_REQUEST, + FTDI_SIO_SET_DATA_REQUEST_TYPE, + urb_value , priv->interface, + buf, 0, WDR_TIMEOUT) < 0) { + err("%s FAILED to enable/disable break state (state was %d)", + __func__, break_state); } - dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value); + dbg("%s break state is %d - urb is %d", __func__, + break_state, urb_value); } @@ -2027,14 +2082,15 @@ static void ftdi_set_termios(struct tty_struct *tty, __u16 urb_value; /* will hold the new flags */ char buf[1]; /* Perhaps I should dynamically alloc this? */ - // Added for xon/xoff support + /* Added for xon/xoff support */ unsigned int iflag = termios->c_iflag; unsigned char vstop; unsigned char vstart; dbg("%s", __func__); - /* Force baud rate if this device requires it, unless it is set to B0. */ + /* Force baud rate if this device requires it, unless it is set to + B0. */ if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { dbg("%s: forcing baud rate for this device", __func__); tty_encode_baud_rate(tty, priv->force_baud, @@ -2053,8 +2109,8 @@ static void ftdi_set_termios(struct tty_struct *tty, not - so just do the change regardless - should be able to compare old_termios and tty->termios */ /* NOTE These routines can get interrupted by - ftdi_sio_read_bulk_callback - need to examine what this - means - don't see any problems yet */ + ftdi_sio_read_bulk_callback - need to examine what this means - + don't see any problems yet */ /* Set number of data bits, parity, stop bits */ @@ -2078,8 +2134,8 @@ static void ftdi_set_termios(struct tty_struct *tty, } } - /* This is needed by the break command since it uses the same command - but is - * or'ed with this value */ + /* This is needed by the break command since it uses the same command + - but is or'ed with this value */ priv->last_set_data_urb_value = urb_value; if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), @@ -2091,7 +2147,7 @@ static void ftdi_set_termios(struct tty_struct *tty, } /* Now do the baudrate */ - if ((cflag & CBAUD) == B0 ) { + if ((cflag & CBAUD) == B0) { /* Disable flow control */ if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, @@ -2104,13 +2160,11 @@ static void ftdi_set_termios(struct tty_struct *tty, clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); } else { /* set the baudrate determined before */ - if (change_speed(tty, port)) { + if (change_speed(tty, port)) err("%s urb failed to set baudrate", __func__); - } /* Ensure RTS and DTR are raised when baudrate changed from 0 */ - if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) { + if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) set_mctrl(port, TIOCM_DTR | TIOCM_RTS); - } } /* Set flow control */ @@ -2130,18 +2184,22 @@ static void ftdi_set_termios(struct tty_struct *tty, /* * Xon/Xoff code * - * Check the IXOFF status in the iflag component of the termios structure - * if IXOFF is not set, the pre-xon/xoff code is executed. - */ + * Check the IXOFF status in the iflag component of the + * termios structure. If IXOFF is not set, the pre-xon/xoff + * code is executed. + */ if (iflag & IXOFF) { - dbg("%s request to enable xonxoff iflag=%04x",__func__,iflag); - // Try to enable the XON/XOFF on the ftdi_sio - // Set the vstart and vstop -- could have been done up above where - // a lot of other dereferencing is done but that would be very - // inefficient as vstart and vstop are not always needed + dbg("%s request to enable xonxoff iflag=%04x", + __func__, iflag); + /* Try to enable the XON/XOFF on the ftdi_sio + * Set the vstart and vstop -- could have been done up + * above where a lot of other dereferencing is done but + * that would be very inefficient as vstart and vstop + * are not always needed. + */ vstart = termios->c_cc[VSTART]; vstop = termios->c_cc[VSTOP]; - urb_value=(vstop << 8) | (vstart); + urb_value = (vstop << 8) | (vstart); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), @@ -2153,8 +2211,9 @@ static void ftdi_set_termios(struct tty_struct *tty, err("urb failed to set to xon/xoff flow control"); } } else { - /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ - /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ + /* else clause to only run if cflag ! CRTSCTS and iflag + * ! XOFF. CHECKME Assuming XON/XOFF handled by tty + * stack - not by device */ dbg("%s Turning off hardware flow control", __func__); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), @@ -2181,32 +2240,35 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) switch (priv->chip_type) { case SIO: /* Request the status from the device */ - if ((ret = usb_control_msg(port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0), - FTDI_SIO_GET_MODEM_STATUS_REQUEST, - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, - 0, 0, - buf, 1, WDR_TIMEOUT)) < 0 ) { + ret = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + FTDI_SIO_GET_MODEM_STATUS_REQUEST, + FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, + 0, 0, + buf, 1, WDR_TIMEOUT); + if (ret < 0) { err("%s Could not get modem status of device - err: %d", __func__, ret); - return(ret); + return ret; } break; case FT8U232AM: case FT232BM: case FT2232C: case FT232RL: - /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same - format as the data returned from the in point */ - if ((ret = usb_control_msg(port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0), - FTDI_SIO_GET_MODEM_STATUS_REQUEST, - FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, - 0, priv->interface, - buf, 2, WDR_TIMEOUT)) < 0 ) { + /* the 8U232AM returns a two byte value (the sio is a 1 byte + value) - in the same format as the data returned from the in + point */ + ret = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + FTDI_SIO_GET_MODEM_STATUS_REQUEST, + FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, + 0, priv->interface, + buf, 2, WDR_TIMEOUT); + if (ret < 0) { err("%s Could not get modem status of device - err: %d", __func__, ret); - return(ret); + return ret; } break; default: @@ -2221,7 +2283,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) priv->last_dtr_rts; } -static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, +static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; @@ -2230,7 +2292,8 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, } -static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) +static int ftdi_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; struct ftdi_private *priv = usb_get_serial_port_data(port); @@ -2241,10 +2304,12 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c switch (cmd) { case TIOCGSERIAL: /* gets serial port data */ - return get_serial_info(port, (struct serial_struct __user *) arg); + return get_serial_info(port, + (struct serial_struct __user *) arg); case TIOCSSERIAL: /* sets serial port data */ - return set_serial_info(tty, port, (struct serial_struct __user *) arg); + return set_serial_info(tty, port, + (struct serial_struct __user *) arg); /* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change @@ -2263,23 +2328,24 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c else { char diff = priv->diff_status; - if (diff == 0) { + if (diff == 0) return -EIO; /* no change => error */ - } /* Consume all events */ priv->diff_status = 0; - /* Return 0 if caller wanted to know about these bits */ - if ( ((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) || - ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) || - ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) || - ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS)) ) { + /* Return 0 if caller wanted to know about + these bits */ + if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) || + ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) || + ((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) || + ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) { return 0; } /* - * Otherwise caller can't care less about what happened, - * and so we continue to wait for more events. + * Otherwise caller can't care less about what + * happened,and so we continue to wait for more + * events. */ } } @@ -2287,8 +2353,8 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int c default: break; } - /* This is not necessarily an error - turns out the higher layers will do - * some ioctls itself (see comment above) + /* This is not necessarily an error - turns out the higher layers + * will do some ioctls themselves (see comment above) */ dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); return -ENOIOCTLCMD; @@ -2326,7 +2392,7 @@ static void ftdi_unthrottle(struct tty_struct *tty) schedule_delayed_work(&priv->rx_work, 0); } -static int __init ftdi_init (void) +static int __init ftdi_init(void) { int retval; @@ -2356,13 +2422,13 @@ failed_sio_register: } -static void __exit ftdi_exit (void) +static void __exit ftdi_exit(void) { dbg("%s", __func__); - usb_deregister (&ftdi_driver); - usb_serial_deregister (&ftdi_sio_device); + usb_deregister(&ftdi_driver); + usb_serial_deregister(&ftdi_sio_device); } @@ -2370,8 +2436,8 @@ static void __exit ftdi_exit (void) module_init(ftdi_init); module_exit(ftdi_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 8302eca893e..a577ea44dcf 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -1,20 +1,20 @@ /* - * Definitions for the FTDI USB Single Port Serial Converter - - * known as FTDI_SIO (Serial Input/Output application of the chipset) + * Definitions for the FTDI USB Single Port Serial Converter - + * known as FTDI_SIO (Serial Input/Output application of the chipset) * * The example I have is known as the USC-1000 which is available from * http://www.dse.co.nz - cat no XH4214 It looks similar to this: * http://www.dansdata.com/usbser.htm but I can't be sure There are other * USC-1000s which don't look like my device though so beware! * - * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, + * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, * USB on the other. * * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details * of the protocol required to talk to the device and ongoing assistence * during development. * - * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the + * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the * FTDI_SIO implementation. * * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais @@ -472,7 +472,7 @@ /* * DSS-20 Sync Station for Sony Ericsson P800 */ -#define FTDI_DSS20_PID 0xFC82 +#define FTDI_DSS20_PID 0xFC82 /* * Home Electronics (www.home-electro.com) USB gadgets @@ -884,7 +884,7 @@ /* * BmRequestType: 0100 0000B * bRequest: FTDI_SIO_RESET - * wValue: Control Value + * wValue: Control Value * 0 = Reset SIO * 1 = Purge RX buffer * 2 = Purge TX buffer @@ -952,7 +952,7 @@ * 101 - add .625 to divisor * 110 - add .750 to divisor * 111 - add .875 to divisor - * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is + * Bits 15 to 0 of the 17-bit divisor are placed in the urb value. Bit 16 is * placed in bit 0 of the urb index. * * Note that there are a couple of special cases to support the highest baud @@ -971,8 +971,8 @@ typedef enum { } ftdi_chip_type_t; typedef enum { - ftdi_sio_b300 = 0, - ftdi_sio_b600 = 1, + ftdi_sio_b300 = 0, + ftdi_sio_b600 = 1, ftdi_sio_b1200 = 2, ftdi_sio_b2400 = 3, ftdi_sio_b4800 = 4, @@ -981,7 +981,7 @@ typedef enum { ftdi_sio_b38400 = 7, ftdi_sio_b57600 = 8, ftdi_sio_b115200 = 9 -} FTDI_SIO_baudrate_t ; +} FTDI_SIO_baudrate_t; /* * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values @@ -990,19 +990,19 @@ typedef enum { #define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA #define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40 -#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 ) -#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11 ) -#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11 ) -#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11 ) +#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8) +#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8) +#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8) +#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8) +#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8) +#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11) +#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) +#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11) #define FTDI_SIO_SET_BREAK (0x1 << 14) /* FTDI_SIO_SET_DATA */ /* - * BmRequestType: 0100 0000B + * BmRequestType: 0100 0000B * bRequest: FTDI_SIO_SET_DATA * wValue: Data characteristics (see below) * wIndex: Port @@ -1035,7 +1035,7 @@ typedef enum { #define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40 #define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL -/* +/* * BmRequestType: 0100 0000B * bRequest: FTDI_SIO_MODEM_CTRL * wValue: ControlValue (see below) @@ -1049,11 +1049,11 @@ typedef enum { */ #define FTDI_SIO_SET_DTR_MASK 0x1 -#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8)) -#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8)) +#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK << 8)) +#define FTDI_SIO_SET_DTR_LOW (0 | (FTDI_SIO_SET_DTR_MASK << 8)) #define FTDI_SIO_SET_RTS_MASK 0x2 -#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 )) -#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 )) +#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8)) +#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8)) /* * ControlValue @@ -1076,7 +1076,7 @@ typedef enum { /* FTDI_SIO_SET_FLOW_CTRL */ #define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40 #define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL -#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0 +#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0 #define FTDI_SIO_RTS_CTS_HS (0x1 << 8) #define FTDI_SIO_DTR_DSR_HS (0x2 << 8) #define FTDI_SIO_XON_XOFF_HS (0x4 << 8) @@ -1085,7 +1085,7 @@ typedef enum { * bRequest: FTDI_SIO_SET_FLOW_CTRL * wValue: Xoff/Xon * wIndex: Protocol/Port - hIndex is protocl / lIndex is port - * wLength: 0 + * wLength: 0 * Data: None * * hIndex protocol is: @@ -1101,10 +1101,10 @@ typedef enum { * * A value of zero in the hIndex field disables handshaking * - * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character + * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character * and the lValue field contains the XON character. - */ - + */ + /* * FTDI_SIO_GET_LATENCY_TIMER * @@ -1118,7 +1118,7 @@ typedef enum { #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER #define FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0 -/* +/* * BmRequestType: 1100 0000b * bRequest: FTDI_SIO_GET_LATENCY_TIMER * wValue: 0 @@ -1127,7 +1127,7 @@ typedef enum { * Data: latency (on return) */ -/* +/* * FTDI_SIO_SET_LATENCY_TIMER * * Set the timeout interval. The FTDI collects data from the slave @@ -1140,7 +1140,7 @@ typedef enum { #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER #define FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40 -/* +/* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_LATENCY_TIMER * wValue: Latency (milliseconds) @@ -1155,7 +1155,7 @@ typedef enum { */ /* - * FTDI_SIO_SET_EVENT_CHAR + * FTDI_SIO_SET_EVENT_CHAR * * Set the special event character for the specified communications port. * If the device sees this character it will immediately return the @@ -1168,7 +1168,7 @@ typedef enum { #define FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40 -/* +/* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_EVENT_CHAR * wValue: EventChar @@ -1184,12 +1184,12 @@ typedef enum { * B9..15 Reserved * */ - + /* FTDI_SIO_SET_ERROR_CHAR */ /* Set the parity error replacement character for the specified communications port */ -/* +/* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_EVENT_CHAR * wValue: Error Char @@ -1215,15 +1215,15 @@ typedef enum { #define FTDI_SIO_DSR_MASK 0x20 #define FTDI_SIO_RI_MASK 0x40 #define FTDI_SIO_RLSD_MASK 0x80 -/* +/* * BmRequestType: 1100 0000b * bRequest: FTDI_SIO_GET_MODEM_STATUS * wValue: zero * wIndex: Port * wLength: 1 * Data: Status - * - * One byte of data is returned + * + * One byte of data is returned * B0..3 0 * B4 CTS * 0 = inactive @@ -1236,15 +1236,15 @@ typedef enum { * 1 = active * B7 Receive Line Signal Detect (RLSD) * 0 = inactive - * 1 = active + * 1 = active */ -/* Descriptors returned by the device - * +/* Descriptors returned by the device + * * Device Descriptor - * + * * Offset Field Size Value Description * 0 bLength 1 0x12 Size of descriptor in bytes * 1 bDescriptorType 1 0x01 DEVICE Descriptor Type @@ -1260,9 +1260,9 @@ typedef enum { * 15 iProduct 1 0x02 Index of prod string desc * 16 iSerialNumber 1 0x02 Index of serial nmr string desc * 17 bNumConfigurations 1 0x01 Number of possible configurations - * + * * Configuration Descriptor - * + * * Offset Field Size Value * 0 bLength 1 0x09 Size of descriptor in bytes * 1 bDescriptorType 1 0x02 CONFIGURATION Descriptor Type @@ -1272,9 +1272,9 @@ typedef enum { * 6 iConfiguration 1 0x02 Index of config string descriptor * 7 bmAttributes 1 0x20 Config characteristics Remote Wakeup * 8 MaxPower 1 0x1E Max power consumption - * + * * Interface Descriptor - * + * * Offset Field Size Value * 0 bLength 1 0x09 Size of descriptor in bytes * 1 bDescriptorType 1 0x04 INTERFACE Descriptor Type @@ -1285,9 +1285,9 @@ typedef enum { * 6 bInterfaceSubClass 1 0xFF Subclass Code * 7 bInterfaceProtocol 1 0xFF Protocol Code * 8 iInterface 1 0x02 Index of interface string description - * + * * IN Endpoint Descriptor - * + * * Offset Field Size Value * 0 bLength 1 0x07 Size of descriptor in bytes * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type @@ -1295,9 +1295,9 @@ typedef enum { * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk * 4 bNumEndpoints 2 0x0040 maximum packet size * 5 bInterval 1 0x00 Interval for polling endpoint - * + * * OUT Endpoint Descriptor - * + * * Offset Field Size Value * 0 bLength 1 0x07 Size of descriptor in bytes * 1 bDescriptorType 1 0x05 ENDPOINT descriptor type @@ -1305,17 +1305,17 @@ typedef enum { * 3 bmAttributes 1 0x02 Endpoint attributes - Bulk * 4 bNumEndpoints 2 0x0040 maximum packet size * 5 bInterval 1 0x00 Interval for polling endpoint - * + * * DATA FORMAT - * + * * IN Endpoint - * + * * The device reserves the first two bytes of data on this endpoint to contain the current * values of the modem and line status registers. In the absence of data, the device * generates a message consisting of these two status bytes every 40 ms - * + * * Byte 0: Modem Status - * + * * Offset Description * B0 Reserved - must be 1 * B1 Reserved - must be 0 @@ -1325,9 +1325,9 @@ typedef enum { * B5 Data Set Ready (DSR) * B6 Ring Indicator (RI) * B7 Receive Line Signal Detect (RLSD) - * + * * Byte 1: Line Status - * + * * Offset Description * B0 Data Ready (DR) * B1 Overrun Error (OE) @@ -1337,7 +1337,7 @@ typedef enum { * B5 Transmitter Holding Register (THRE) * B6 Transmitter Empty (TEMT) * B7 Error in RCVR FIFO - * + * */ #define FTDI_RS0_CTS (1 << 4) #define FTDI_RS0_DSR (1 << 5) @@ -1355,17 +1355,17 @@ typedef enum { /* * OUT Endpoint - * + * * This device reserves the first bytes of data on this endpoint contain the length * and port identifier of the message. For the FTDI USB Serial converter the port * identifier is always 1. - * + * * Byte 0: Line Status - * + * * Offset Description * B0 Reserved - must be 1 * B1 Reserved - must be 0 * B2..7 Length of message - (not including Byte 0) - * + * */ -- cgit v1.2.3-70-g09d2 From 64701e8122fff3605c674c056749864c97485de4 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:34 +0100 Subject: funsoft: Switch to linux/uaccess Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/funsoft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index e8ba2cb5995..d30f736d2cc 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include static int debug; -- cgit v1.2.3-70-g09d2 From af6d780b578778d442278ac4894ff10847bebae2 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:44 +0100 Subject: garmin_gps: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/garmin_gps.c | 354 ++++++++++++++++++++-------------------- 1 file changed, 176 insertions(+), 178 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 06cfa43c6f0..2e663f1afd5 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ static int initial_mode = 1; /* debug flag */ -static int debug = 0; +static int debug; #define GARMIN_VENDOR_ID 0x091E @@ -56,7 +56,7 @@ static int debug = 0; #define VERSION_MINOR 31 #define _STR(s) #s -#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b) +#define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b) #define DRIVER_VERSION _DRIVER_VERSION(VERSION_MAJOR, VERSION_MINOR) #define DRIVER_AUTHOR "hermann kneissel" #define DRIVER_DESC "garmin gps driver" @@ -65,37 +65,37 @@ static int debug = 0; #define EINVPKT 1000 /* invalid packet structure */ -// size of the header of a packet using the usb protocol +/* size of the header of a packet using the usb protocol */ #define GARMIN_PKTHDR_LENGTH 12 -// max. possible size of a packet using the serial protocol -#define MAX_SERIAL_PKT_SIZ (3+255+3) +/* max. possible size of a packet using the serial protocol */ +#define MAX_SERIAL_PKT_SIZ (3 + 255 + 3) -// max. possible size of a packet with worst case stuffing -#define MAX_SERIAL_PKT_SIZ_STUFFED MAX_SERIAL_PKT_SIZ+256 +/* max. possible size of a packet with worst case stuffing */ +#define MAX_SERIAL_PKT_SIZ_STUFFED (MAX_SERIAL_PKT_SIZ + 256) -// size of a buffer able to hold a complete (no stuffing) packet -// (the document protocol does not contain packets with a larger -// size, but in theory a packet may be 64k+12 bytes - if in -// later protocol versions larger packet sizes occur, this value -// should be increased accordingly, so the input buffer is always -// large enough the store a complete packet inclusive header) -#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) +/* size of a buffer able to hold a complete (no stuffing) packet + * (the document protocol does not contain packets with a larger + * size, but in theory a packet may be 64k+12 bytes - if in + * later protocol versions larger packet sizes occur, this value + * should be increased accordingly, so the input buffer is always + * large enough the store a complete packet inclusive header) */ +#define GPS_IN_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) -// size of a buffer able to hold a complete (incl. stuffing) packet -#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) +/* size of a buffer able to hold a complete (incl. stuffing) packet */ +#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) -// where to place the packet id of a serial packet, so we can -// prepend the usb-packet header without the need to move the -// packets data +/* where to place the packet id of a serial packet, so we can + * prepend the usb-packet header without the need to move the + * packets data */ #define GSP_INITIAL_OFFSET (GARMIN_PKTHDR_LENGTH-2) -// max. size of incoming private packets (header+1 param) +/* max. size of incoming private packets (header+1 param) */ #define PRIVPKTSIZ (GARMIN_PKTHDR_LENGTH+4) #define GARMIN_LAYERID_TRANSPORT 0 #define GARMIN_LAYERID_APPL 20 -// our own layer-id to use for some control mechanisms +/* our own layer-id to use for some control mechanisms */ #define GARMIN_LAYERID_PRIVATE 0x01106E4B #define GARMIN_PKTID_PVT_DATA 51 @@ -103,7 +103,7 @@ static int debug = 0; #define CMND_ABORT_TRANSFER 0 -// packet ids used in private layer +/* packet ids used in private layer */ #define PRIV_PKTID_SET_DEBUG 1 #define PRIV_PKTID_SET_MODE 2 #define PRIV_PKTID_INFO_REQ 3 @@ -121,7 +121,8 @@ static int debug = 0; struct garmin_packet { struct list_head list; int seq; - int size; // the real size of the data array, always > 0 + /* the real size of the data array, always > 0 */ + int size; __u8 data[1]; }; @@ -164,7 +165,7 @@ struct garmin_data { #define MODE_NATIVE 0 #define MODE_GARMIN_SERIAL 1 -// Flags used in garmin_data.flags: +/* Flags used in garmin_data.flags: */ #define FLAGS_SESSION_REPLY_MASK 0x00C0 #define FLAGS_SESSION_REPLY1_SEEN 0x0080 #define FLAGS_SESSION_REPLY2_SEEN 0x0040 @@ -185,7 +186,7 @@ struct garmin_data { /* function prototypes */ -static void gsp_next_packet(struct garmin_data * garmin_data_p); +static void gsp_next_packet(struct garmin_data *garmin_data_p); static int garmin_write_bulk(struct usb_serial_port *port, const unsigned char *buf, int count, int dismiss_ack); @@ -217,12 +218,13 @@ static unsigned char const PRIVATE_REQ[] static struct usb_device_id id_table [] = { - /* the same device id seems to be used by all usb enabled gps devices */ - { USB_DEVICE(GARMIN_VENDOR_ID, 3 ) }, + /* the same device id seems to be used by all + usb enabled GPS devices */ + { USB_DEVICE(GARMIN_VENDOR_ID, 3) }, { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver garmin_driver = { .name = "garmin_gps", @@ -233,9 +235,10 @@ static struct usb_driver garmin_driver = { }; -static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p) +static inline int noResponseFromAppLayer(struct garmin_data *garmin_data_p) { - return atomic_read(&garmin_data_p->req_count) == atomic_read(&garmin_data_p->resp_count); + return atomic_read(&garmin_data_p->req_count) == + atomic_read(&garmin_data_p->resp_count); } @@ -261,10 +264,10 @@ static inline int getDataLength(const __u8 *usbPacket) */ static inline int isAbortTrfCmnd(const unsigned char *buf) { - if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, - sizeof(GARMIN_STOP_TRANSFER_REQ)) || - 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, - sizeof(GARMIN_STOP_TRANSFER_REQ_V2))) + if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, + sizeof(GARMIN_STOP_TRANSFER_REQ)) || + 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, + sizeof(GARMIN_STOP_TRANSFER_REQ_V2))) return 1; else return 0; @@ -279,7 +282,7 @@ static void send_to_tty(struct usb_serial_port *port, if (tty && actual_length) { - usb_serial_debug_data(debug, &port->dev, + usb_serial_debug_data(debug, &port->dev, __func__, actual_length, data); tty_buffer_request_room(tty, actual_length); @@ -296,7 +299,7 @@ static void send_to_tty(struct usb_serial_port *port, /* * queue a received (usb-)packet for later processing */ -static int pkt_add(struct garmin_data * garmin_data_p, +static int pkt_add(struct garmin_data *garmin_data_p, unsigned char *data, unsigned int data_length) { int state = 0; @@ -307,7 +310,7 @@ static int pkt_add(struct garmin_data * garmin_data_p, /* process only packets containg data ... */ if (data_length) { pkt = kmalloc(sizeof(struct garmin_packet)+data_length, - GFP_ATOMIC); + GFP_ATOMIC); if (pkt == NULL) { dev_err(&garmin_data_p->port->dev, "out of memory\n"); return 0; @@ -325,16 +328,15 @@ static int pkt_add(struct garmin_data * garmin_data_p, /* in serial mode, if someone is waiting for data from the device, iconvert and send the next packet to tty. */ - if (result && (state == STATE_GSP_WAIT_DATA)) { + if (result && (state == STATE_GSP_WAIT_DATA)) gsp_next_packet(garmin_data_p); - } } return result; } /* get the next pending packet */ -static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p) +static struct garmin_packet *pkt_pop(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *result = NULL; @@ -350,7 +352,7 @@ static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p) /* free up all queued data */ -static void pkt_clear(struct garmin_data * garmin_data_p) +static void pkt_clear(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *result = NULL; @@ -372,7 +374,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p) ******************************************************************************/ /* send an ack packet back to the tty */ -static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) +static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) { __u8 pkt[10]; __u8 cksum = 0; @@ -391,9 +393,8 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) *ptr++ = pkt_id; cksum += pkt_id; - if (pkt_id == DLE) { + if (pkt_id == DLE) *ptr++ = DLE; - } *ptr++ = 0; *ptr++ = 0xFF & (-cksum); @@ -415,12 +416,12 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) * at GSP_INITIAL_OFFSET. * * count - number of bytes in the input buffer including space reserved for - * the usb header: GSP_INITIAL_OFFSET + number of bytes in packet + * the usb header: GSP_INITIAL_OFFSET + number of bytes in packet * (including pkt-id, data-length a. cksum) */ -static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) +static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) { - const __u8* recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; + const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; int cksum = 0; @@ -440,8 +441,8 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) cksum += *recpkt++; cksum += *recpkt++; - // sanity check, remove after test ... - if ((__u8*)&(usbdata[3]) != recpkt) { + /* sanity check, remove after test ... */ + if ((__u8 *)&(usbdata[3]) != recpkt) { dbg("%s - ptr mismatch %p - %p", __func__, &(usbdata[4]), recpkt); return -EINVPKT; @@ -462,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) usbdata[1] = __cpu_to_le32(pktid); usbdata[2] = __cpu_to_le32(size); - garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer, + garmin_write_bulk(garmin_data_p->port, garmin_data_p->inbuffer, GARMIN_PKTHDR_LENGTH+size, 0); /* if this was an abort-transfer command, flush all @@ -495,7 +496,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) * if the input is an abort command, drop all queued data. */ -static int gsp_receive(struct garmin_data * garmin_data_p, +static int gsp_receive(struct garmin_data *garmin_data_p, const unsigned char *buf, int count) { unsigned long flags; @@ -504,10 +505,11 @@ static int gsp_receive(struct garmin_data * garmin_data_p, int i = 0; __u8 *dest; int size; - // dleSeen: set if last byte read was a DLE + /* dleSeen: set if last byte read was a DLE */ int dleSeen; - // skip: if set, skip incoming data until possible start of - // new packet + /* skip: if set, skip incoming data until possible start of + * new packet + */ int skip; __u8 data; @@ -521,14 +523,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p, dbg("%s - dle=%d skip=%d size=%d count=%d", __func__, dleSeen, skip, size, count); - if (size == 0) { + if (size == 0) size = GSP_INITIAL_OFFSET; - } while (offs < count) { data = *(buf+offs); - offs ++; + offs++; if (data == DLE) { if (skip) { /* start of a new pkt */ @@ -554,9 +555,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p, ack_or_nak_seen = NAK; dbg("NAK packet complete."); } else { - dbg("packet complete " - "- id=0x%X.", - 0xFF & data); + dbg("packet complete - id=0x%X.", + 0xFF & data); gsp_rec_packet(garmin_data_p, size); } @@ -589,7 +589,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p, garmin_data_p->insize = size; - // copy flags back to structure + /* copy flags back to structure */ if (skip) garmin_data_p->flags |= FLAGS_GSP_SKIP; else @@ -600,16 +600,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p, else garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN; - if (ack_or_nak_seen) { + if (ack_or_nak_seen) garmin_data_p->state = STATE_GSP_WAIT_DATA; - } spin_unlock_irqrestore(&garmin_data_p->lock, flags); - if (ack_or_nak_seen) { + if (ack_or_nak_seen) gsp_next_packet(garmin_data_p); - } - return count; } @@ -623,7 +620,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p, * * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent */ -static int gsp_send(struct garmin_data * garmin_data_p, +static int gsp_send(struct garmin_data *garmin_data_p, const unsigned char *buf, int count) { const unsigned char *src; @@ -631,11 +628,11 @@ static int gsp_send(struct garmin_data * garmin_data_p, int pktid = 0; int datalen = 0; int cksum = 0; - int i=0; + int i = 0; int k; dbg("%s - state %d - %d bytes.", __func__, - garmin_data_p->state, count); + garmin_data_p->state, count); k = garmin_data_p->outsize; if ((k+count) > GPS_OUT_BUFSIZ) { @@ -650,7 +647,7 @@ static int gsp_send(struct garmin_data * garmin_data_p, if (k >= GARMIN_PKTHDR_LENGTH) { pktid = getPacketId(garmin_data_p->outbuffer); - datalen= getDataLength(garmin_data_p->outbuffer); + datalen = getDataLength(garmin_data_p->outbuffer); i = GARMIN_PKTHDR_LENGTH + datalen; if (k < i) return 0; @@ -658,19 +655,18 @@ static int gsp_send(struct garmin_data * garmin_data_p, return 0; } - dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, - k, i); + dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); /* garmin_data_p->outbuffer now contains a complete packet */ usb_serial_debug_data(debug, &garmin_data_p->port->dev, - __func__, k, garmin_data_p->outbuffer); + __func__, k, garmin_data_p->outbuffer); garmin_data_p->outsize = 0; if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { - dbg("not an application packet (%d)", - getLayerId(garmin_data_p->outbuffer)); + dbg("not an application packet (%d)", + getLayerId(garmin_data_p->outbuffer)); return -1; } @@ -688,14 +684,14 @@ static int gsp_send(struct garmin_data * garmin_data_p, k = 0; src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH; - for (i=0; ioutbuffer+GARMIN_PKTHDR_LENGTH; if (k > (GARMIN_PKTHDR_LENGTH-2)) { - /* can't add stuffing DLEs in place, move data to end + /* can't add stuffing DLEs in place, move data to end of buffer ... */ dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen; memcpy(dst, src, datalen); @@ -712,14 +708,14 @@ static int gsp_send(struct garmin_data * garmin_data_p, if (datalen == DLE) *dst++ = DLE; - for (i=0; iinsize >= GARMIN_PKTHDR_LENGTH) len = GARMIN_PKTHDR_LENGTH +getDataLength(garmin_data_p->inbuffer); @@ -792,9 +788,9 @@ static int nat_receive(struct garmin_data * garmin_data_p, len = GARMIN_PKTHDR_LENGTH; if (len >= GPS_IN_BUFSIZ) { - /* seem to be an invalid packet, ignore rest of input */ - dbg("%s - packet size too large: %d", - __func__, len); + /* seems to be an invalid packet, ignore rest + of input */ + dbg("%s - packet size too large: %d", __func__, len); garmin_data_p->insize = 0; count = 0; result = -EINVPKT; @@ -804,7 +800,7 @@ static int nat_receive(struct garmin_data * garmin_data_p, len = (count-offs); if (len > 0) { dest = garmin_data_p->inbuffer - +garmin_data_p->insize; + + garmin_data_p->insize; memcpy(dest, buf+offs, len); garmin_data_p->insize += len; offs += len; @@ -816,17 +812,19 @@ static int nat_receive(struct garmin_data * garmin_data_p, len = GARMIN_PKTHDR_LENGTH+ getDataLength(garmin_data_p->inbuffer); if (garmin_data_p->insize >= len) { - garmin_write_bulk (garmin_data_p->port, - garmin_data_p->inbuffer, - len, 0); + garmin_write_bulk(garmin_data_p->port, + garmin_data_p->inbuffer, + len, 0); garmin_data_p->insize = 0; /* if this was an abort-transfer command, flush all queued data. */ if (isAbortTrfCmnd(garmin_data_p->inbuffer)) { - spin_lock_irqsave(&garmin_data_p->lock, flags); + spin_lock_irqsave(&garmin_data_p->lock, + flags); garmin_data_p->flags |= FLAGS_DROP_DATA; - spin_unlock_irqrestore(&garmin_data_p->lock, flags); + spin_unlock_irqrestore( + &garmin_data_p->lock, flags); pkt_clear(garmin_data_p); } } @@ -842,7 +840,7 @@ static int nat_receive(struct garmin_data * garmin_data_p, static void priv_status_resp(struct usb_serial_port *port) { - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); __le32 *pkt = (__le32 *)garmin_data_p->privpkt; pkt[0] = __cpu_to_le32(GARMIN_LAYERID_PRIVATE); @@ -852,7 +850,7 @@ static void priv_status_resp(struct usb_serial_port *port) pkt[4] = __cpu_to_le32(garmin_data_p->mode); pkt[5] = __cpu_to_le32(garmin_data_p->serial_num); - send_to_tty(port, (__u8*)pkt, 6*4); + send_to_tty(port, (__u8 *)pkt, 6 * 4); } @@ -864,7 +862,7 @@ static int process_resetdev_request(struct usb_serial_port *port) { unsigned long flags; int status; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED); @@ -872,8 +870,8 @@ static int process_resetdev_request(struct usb_serial_port *port) garmin_data_p->serial_num = 0; spin_unlock_irqrestore(&garmin_data_p->lock, flags); - usb_kill_urb (port->interrupt_in_urb); - dbg("%s - usb_reset_device", __func__ ); + usb_kill_urb(port->interrupt_in_urb); + dbg("%s - usb_reset_device", __func__); status = usb_reset_device(port->serial->dev); if (status) dbg("%s - usb_reset_device failed: %d", @@ -886,7 +884,7 @@ static int process_resetdev_request(struct usb_serial_port *port) /* * clear all cached data */ -static int garmin_clear(struct garmin_data * garmin_data_p) +static int garmin_clear(struct garmin_data *garmin_data_p) { unsigned long flags; int status = 0; @@ -896,8 +894,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p) if (port != NULL && atomic_read(&garmin_data_p->resp_count)) { /* send a terminate command */ status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ, - sizeof(GARMIN_STOP_TRANSFER_REQ), - 1); + sizeof(GARMIN_STOP_TRANSFER_REQ), 1); } /* flush all queued data */ @@ -920,28 +917,26 @@ static int garmin_init_session(struct usb_serial_port *port) { unsigned long flags; struct usb_serial *serial = port->serial; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); int status = 0; if (status == 0) { - usb_kill_urb (port->interrupt_in_urb); + usb_kill_urb(port->interrupt_in_urb); dbg("%s - adding interrupt input", __func__); port->interrupt_in_urb->dev = serial->dev; status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (status) dev_err(&serial->dev->dev, - "%s - failed submitting interrupt urb," - " error %d\n", - __func__, status); + "%s - failed submitting interrupt urb, error %d\n", + __func__, status); } if (status == 0) { dbg("%s - starting session ...", __func__); garmin_data_p->state = STATE_ACTIVE; status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, - sizeof(GARMIN_START_SESSION_REQ), - 0); + sizeof(GARMIN_START_SESSION_REQ), 0); if (status >= 0) { @@ -951,14 +946,14 @@ static int garmin_init_session(struct usb_serial_port *port) /* not needed, but the win32 driver does it too ... */ status = garmin_write_bulk(port, - GARMIN_START_SESSION_REQ2, - sizeof(GARMIN_START_SESSION_REQ2), - 0); + GARMIN_START_SESSION_REQ2, + sizeof(GARMIN_START_SESSION_REQ2), 0); if (status >= 0) { status = 0; spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->ignorePkts++; - spin_unlock_irqrestore(&garmin_data_p->lock, flags); + spin_unlock_irqrestore(&garmin_data_p->lock, + flags); } } } @@ -970,12 +965,12 @@ static int garmin_init_session(struct usb_serial_port *port) -static int garmin_open (struct tty_struct *tty, +static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { unsigned long flags; int status = 0; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); @@ -996,8 +991,8 @@ static int garmin_open (struct tty_struct *tty, spin_unlock_irqrestore(&garmin_data_p->lock, flags); /* shutdown any bulk reads that might be going on */ - usb_kill_urb (port->write_urb); - usb_kill_urb (port->read_urb); + usb_kill_urb(port->write_urb); + usb_kill_urb(port->read_urb); if (garmin_data_p->state == STATE_RESET) status = garmin_init_session(port); @@ -1008,10 +1003,10 @@ static int garmin_open (struct tty_struct *tty, static void garmin_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, port->number, garmin_data_p->mode, @@ -1025,8 +1020,8 @@ static void garmin_close(struct tty_struct *tty, garmin_clear(garmin_data_p); /* shutdown our urbs */ - usb_kill_urb (port->read_urb); - usb_kill_urb (port->write_urb); + usb_kill_urb(port->read_urb); + usb_kill_urb(port->write_urb); if (!port->serial->disconnected) { if (noResponseFromAppLayer(garmin_data_p) || @@ -1042,20 +1037,22 @@ static void garmin_close(struct tty_struct *tty, mutex_unlock(&port->serial->disc_mutex); } -static void garmin_write_bulk_callback (struct urb *urb) +static void garmin_write_bulk_callback(struct urb *urb) { unsigned long flags; struct usb_serial_port *port = urb->context; int status = urb->status; if (port) { - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = + usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer) && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { - gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]); + gsp_send_ack(garmin_data_p, + ((__u8 *)urb->transfer_buffer)[4]); } if (status) { @@ -1069,20 +1066,21 @@ static void garmin_write_bulk_callback (struct urb *urb) usb_serial_port_softint(port); } - /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */ + /* Ignore errors that resulted from garmin_write_bulk with + dismiss_ack = 1 */ /* free up the transfer buffer, as usb_free_urb() does not do this */ - kfree (urb->transfer_buffer); + kfree(urb->transfer_buffer); } -static int garmin_write_bulk (struct usb_serial_port *port, +static int garmin_write_bulk(struct usb_serial_port *port, const unsigned char *buf, int count, int dismiss_ack) { unsigned long flags; struct usb_serial *serial = port->serial; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); struct urb *urb; unsigned char *buffer; int status; @@ -1094,7 +1092,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, garmin_data_p->flags &= ~FLAGS_DROP_DATA; spin_unlock_irqrestore(&garmin_data_p->lock, flags); - buffer = kmalloc (count, GFP_ATOMIC); + buffer = kmalloc(count, GFP_ATOMIC); if (!buffer) { dev_err(&port->dev, "out of memory\n"); return -ENOMEM; @@ -1103,17 +1101,17 @@ static int garmin_write_bulk (struct usb_serial_port *port, urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { dev_err(&port->dev, "no more free urbs\n"); - kfree (buffer); + kfree(buffer); return -ENOMEM; } - memcpy (buffer, buf, count); + memcpy(buffer, buf, count); usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); - usb_fill_bulk_urb (urb, serial->dev, - usb_sndbulkpipe (serial->dev, - port->bulk_out_endpointAddress), + usb_fill_bulk_urb(urb, serial->dev, + usb_sndbulkpipe(serial->dev, + port->bulk_out_endpointAddress), buffer, count, garmin_write_bulk_callback, dismiss_ack ? NULL : port); @@ -1131,24 +1129,23 @@ static int garmin_write_bulk (struct usb_serial_port *port, status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { dev_err(&port->dev, - "%s - usb_submit_urb(write bulk) " - "failed with status = %d\n", + "%s - usb_submit_urb(write bulk) failed with status = %d\n", __func__, status); count = status; } /* we are done with this urb, so let the host driver * really free it when it is finished with it */ - usb_free_urb (urb); + usb_free_urb(urb); return count; } -static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port, +static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { int pktid, pktsiz, len; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; usb_serial_debug_data(debug, &port->dev, __func__, count, buf); @@ -1165,15 +1162,16 @@ static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port, pktid = getPacketId(garmin_data_p->privpkt); if (count == (GARMIN_PKTHDR_LENGTH+pktsiz) - && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) { + && GARMIN_LAYERID_PRIVATE == + getLayerId(garmin_data_p->privpkt)) { dbg("%s - processing private request %d", __func__, pktid); - // drop all unfinished transfers + /* drop all unfinished transfers */ garmin_clear(garmin_data_p); - switch(pktid) { + switch (pktid) { case PRIV_PKTID_SET_DEBUG: if (pktsiz != 4) @@ -1228,25 +1226,25 @@ static int garmin_write_room(struct tty_struct *tty) /* * Report back the bytes currently available in the output buffer. */ - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); return GPS_OUT_BUFSIZ-garmin_data_p->outsize; } -static void garmin_read_process(struct garmin_data * garmin_data_p, +static void garmin_read_process(struct garmin_data *garmin_data_p, unsigned char *data, unsigned data_length) { if (garmin_data_p->flags & FLAGS_DROP_DATA) { /* abort-transfer cmd is actice */ dbg("%s - pkt dropped", __func__); } else if (garmin_data_p->state != STATE_DISCONNECTED && - garmin_data_p->state != STATE_RESET ) { + garmin_data_p->state != STATE_RESET) { /* remember any appl.layer packets, so we know if a reset is required or not when closing the device */ if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, - sizeof(GARMIN_APP_LAYER_REPLY))) { + sizeof(GARMIN_APP_LAYER_REPLY))) { atomic_inc(&garmin_data_p->resp_count); } @@ -1256,9 +1254,8 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, if (garmin_data_p->flags & FLAGS_QUEUING) { pkt_add(garmin_data_p, data, data_length); } else if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { - if (getLayerId(data) == GARMIN_LAYERID_APPL) { + if (getLayerId(data) == GARMIN_LAYERID_APPL) pkt_add(garmin_data_p, data, data_length); - } } else { send_to_tty(garmin_data_p->port, data, data_length); } @@ -1266,12 +1263,12 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, } -static void garmin_read_bulk_callback (struct urb *urb) +static void garmin_read_bulk_callback(struct urb *urb) { unsigned long flags; struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; int retval; @@ -1289,7 +1286,7 @@ static void garmin_read_bulk_callback (struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, + usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); garmin_read_process(garmin_data_p, data, urb->actual_length); @@ -1323,13 +1320,13 @@ static void garmin_read_bulk_callback (struct urb *urb) } -static void garmin_read_int_callback (struct urb *urb) +static void garmin_read_int_callback(struct urb *urb) { unsigned long flags; int retval; struct usb_serial_port *port = urb->context; struct usb_serial *serial = port->serial; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; int status = urb->status; @@ -1355,30 +1352,31 @@ static void garmin_read_int_callback (struct urb *urb) if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, - sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { + sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { dbg("%s - bulk data available.", __func__); if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { /* bulk data available */ - usb_fill_bulk_urb (port->read_urb, serial->dev, - usb_rcvbulkpipe (serial->dev, - port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, garmin_read_bulk_callback, port); retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (retval) { dev_err(&port->dev, - "%s - failed submitting read urb, error %d\n", - __func__, retval); + "%s - failed submitting read urb, error %d\n", + __func__, retval); } else { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE; /* do not send this packet to the user */ garmin_data_p->ignorePkts = 1; - spin_unlock_irqrestore(&garmin_data_p->lock, flags); + spin_unlock_irqrestore(&garmin_data_p->lock, + flags); } } else { /* bulk-in transfer still active */ @@ -1389,15 +1387,15 @@ static void garmin_read_int_callback (struct urb *urb) } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY)) && 0 == memcmp(data, GARMIN_START_SESSION_REPLY, - sizeof(GARMIN_START_SESSION_REPLY))) { + sizeof(GARMIN_START_SESSION_REPLY))) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN; spin_unlock_irqrestore(&garmin_data_p->lock, flags); /* save the serial number */ - garmin_data_p->serial_num - = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH)); + garmin_data_p->serial_num = __le32_to_cpup( + (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); dbg("%s - start-of-session reply seen - serial %u.", __func__, garmin_data_p->serial_num); @@ -1416,7 +1414,7 @@ static void garmin_read_int_callback (struct urb *urb) } port->interrupt_in_urb->dev = port->serial->dev; - retval = usb_submit_urb (urb, GFP_ATOMIC); + retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", @@ -1429,7 +1427,7 @@ static void garmin_read_int_callback (struct urb *urb) * and then sets a timer to call itself again until all queued data * is sent. */ -static int garmin_flush_queue(struct garmin_data * garmin_data_p) +static int garmin_flush_queue(struct garmin_data *garmin_data_p) { unsigned long flags; struct garmin_packet *pkt; @@ -1454,7 +1452,7 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p) static void garmin_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned long flags; dbg("%s - port %d", __func__, port->number); @@ -1466,10 +1464,10 @@ static void garmin_throttle(struct tty_struct *tty) } -static void garmin_unthrottle (struct tty_struct *tty) +static void garmin_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); unsigned long flags; int status; @@ -1513,7 +1511,7 @@ static int garmin_attach(struct usb_serial *serial) { int status = 0; struct usb_serial_port *port = serial->port[0]; - struct garmin_data * garmin_data_p = NULL; + struct garmin_data *garmin_data_p = NULL; dbg("%s", __func__); @@ -1525,7 +1523,7 @@ static int garmin_attach(struct usb_serial *serial) init_timer(&garmin_data_p->timer); spin_lock_init(&garmin_data_p->lock); INIT_LIST_HEAD(&garmin_data_p->pktlist); - //garmin_data_p->timer.expires = jiffies + session_timeout; + /* garmin_data_p->timer.expires = jiffies + session_timeout; */ garmin_data_p->timer.data = (unsigned long)garmin_data_p; garmin_data_p->timer.function = timeout_handler; garmin_data_p->port = port; @@ -1542,13 +1540,13 @@ static int garmin_attach(struct usb_serial *serial) static void garmin_shutdown(struct usb_serial *serial) { struct usb_serial_port *port = serial->port[0]; - struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); + struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); dbg("%s", __func__); - usb_kill_urb (port->interrupt_in_urb); + usb_kill_urb(port->interrupt_in_urb); del_timer_sync(&garmin_data_p->timer); - kfree (garmin_data_p); + kfree(garmin_data_p); usb_set_serial_port_data(port, NULL); } @@ -1578,7 +1576,7 @@ static struct usb_serial_driver garmin_device = { -static int __init garmin_init (void) +static int __init garmin_init(void) { int retval; @@ -1598,10 +1596,10 @@ failed_garmin_register: } -static void __exit garmin_exit (void) +static void __exit garmin_exit(void) { - usb_deregister (&garmin_driver); - usb_serial_deregister (&garmin_device); + usb_deregister(&garmin_driver); + usb_serial_deregister(&garmin_device); } @@ -1610,8 +1608,8 @@ static void __exit garmin_exit (void) module_init(garmin_init); module_exit(garmin_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IWUSR | S_IRUGO); -- cgit v1.2.3-70-g09d2 From ae64387a54fd519d68aa7d1aacba095140f1a647 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:11:55 +0100 Subject: tty-usb-generic: Code cleanup Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/generic.c | 87 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 38 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 5128018c276..fe84c88ec20 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include static int debug; @@ -81,7 +81,7 @@ static int generic_probe(struct usb_interface *interface, } #endif -int usb_serial_generic_register (int _debug) +int usb_serial_generic_register(int _debug) { int retval = 0; @@ -89,10 +89,11 @@ int usb_serial_generic_register (int _debug) #ifdef CONFIG_USB_SERIAL_GENERIC generic_device_ids[0].idVendor = vendor; generic_device_ids[0].idProduct = product; - generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; + generic_device_ids[0].match_flags = + USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; /* register our generic driver with ourselves */ - retval = usb_serial_register (&usb_serial_generic_device); + retval = usb_serial_register(&usb_serial_generic_device); if (retval) goto exit; retval = usb_register(&generic_driver); @@ -103,12 +104,12 @@ exit: return retval; } -void usb_serial_generic_deregister (void) +void usb_serial_generic_deregister(void) { #ifdef CONFIG_USB_SERIAL_GENERIC /* remove our generic driver */ usb_deregister(&generic_driver); - usb_serial_deregister (&usb_serial_generic_device); + usb_serial_deregister(&usb_serial_generic_device); #endif } @@ -121,9 +122,9 @@ int usb_serial_generic_open(struct tty_struct *tty, dbg("%s - port %d", __func__, port->number); - /* force low_latency on so that our tty_push actually forces the data through, - otherwise it is scheduled, and with high data rates (like with OHCI) data - can get lost. */ + /* force low_latency on so that our tty_push actually forces the data + through, otherwise it is scheduled, and with high data rates (like + with OHCI) data can get lost. */ if (tty) tty->low_latency = 1; @@ -136,8 +137,9 @@ int usb_serial_generic_open(struct tty_struct *tty, /* if we have a bulk endpoint, start reading from it */ if (serial->num_bulk_in) { /* Start reading from the device */ - usb_fill_bulk_urb (port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ((serial->type->read_bulk_callback) ? @@ -146,7 +148,9 @@ int usb_serial_generic_open(struct tty_struct *tty, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); } return result; @@ -194,10 +198,10 @@ int usb_serial_generic_resume(struct usb_serial *serial) } void usb_serial_generic_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); - generic_cleanup (port); + generic_cleanup(port); } int usb_serial_generic_write(struct tty_struct *tty, @@ -211,7 +215,7 @@ int usb_serial_generic_write(struct tty_struct *tty, if (count == 0) { dbg("%s - write request of 0 bytes", __func__); - return (0); + return 0; } /* only do something if we have a bulk out endpoint */ @@ -226,27 +230,32 @@ int usb_serial_generic_write(struct tty_struct *tty, port->write_urb_busy = 1; spin_unlock_irqrestore(&port->lock, flags); - count = (count > port->bulk_out_size) ? port->bulk_out_size : count; + count = (count > port->bulk_out_size) ? + port->bulk_out_size : count; - memcpy (port->write_urb->transfer_buffer, buf, count); + memcpy(port->write_urb->transfer_buffer, buf, count); data = port->write_urb->transfer_buffer; usb_serial_debug_data(debug, &port->dev, __func__, count, data); /* set up our urb */ - usb_fill_bulk_urb (port->write_urb, serial->dev, - usb_sndbulkpipe (serial->dev, - port->bulk_out_endpointAddress), + usb_fill_bulk_urb(port->write_urb, serial->dev, + usb_sndbulkpipe(serial->dev, + port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, count, - ((serial->type->write_bulk_callback) ? + ((serial->type->write_bulk_callback) ? serial->type->write_bulk_callback : - usb_serial_generic_write_bulk_callback), port); + usb_serial_generic_write_bulk_callback), + port); /* send the data out the bulk port */ port->write_urb_busy = 1; result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); - /* don't have to grab the lock here, as we will retry if != 0 */ + dev_err(&port->dev, + "%s - failed submitting write urb, error %d\n", + __func__, result); + /* don't have to grab the lock here, as we will + retry if != 0 */ port->write_urb_busy = 0; } else result = count; @@ -258,7 +267,7 @@ int usb_serial_generic_write(struct tty_struct *tty, return 0; } -int usb_serial_generic_write_room (struct tty_struct *tty) +int usb_serial_generic_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; @@ -302,17 +311,19 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) int result; /* Continue reading from device */ - usb_fill_bulk_urb (urb, serial->dev, - usb_rcvbulkpipe (serial->dev, - port->bulk_in_endpointAddress), + usb_fill_bulk_urb(urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_in_endpointAddress), urb->transfer_buffer, urb->transfer_buffer_length, - ((serial->type->read_bulk_callback) ? - serial->type->read_bulk_callback : + ((serial->type->read_bulk_callback) ? + serial->type->read_bulk_callback : usb_serial_generic_read_bulk_callback), port); result = usb_submit_urb(urb, mem_flags); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); } /* Push data to tty layer and resubmit the bulk read URB */ @@ -349,16 +360,17 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); /* Throttle the device if requested by tty */ spin_lock_irqsave(&port->lock, flags); - if (!(port->throttled = port->throttle_req)) { + port->throttled = port->throttle_req; + if (!port->throttled) { spin_unlock_irqrestore(&port->lock, flags); flush_and_resubmit_read_urb(port); - } else { + } else spin_unlock_irqrestore(&port->lock, flags); - } } EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); @@ -413,15 +425,14 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) } } -void usb_serial_generic_shutdown (struct usb_serial *serial) +void usb_serial_generic_shutdown(struct usb_serial *serial) { int i; dbg("%s", __func__); /* stop reads and writes on all ports */ - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) generic_cleanup(serial->port[i]); - } } -- cgit v1.2.3-70-g09d2 From 3a262b2ea7c0905026c0be3618dba1f825e5387a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:05 +0100 Subject: tty-usb-hp4x: Fix overlong line Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/hp4x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 75b88b356eb..ab905869e95 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c @@ -9,7 +9,8 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver */ #include -- cgit v1.2.3-70-g09d2 From d60d43965e46674b9097b422336a55c6ca08559a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:15 +0100 Subject: tty-usb-visor: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/visor.c | 340 +++++++++++++++++++++++++-------------------- 1 file changed, 191 insertions(+), 149 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 373a3c7ea77..cf8924f9a2c 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -9,7 +9,8 @@ * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * */ @@ -23,7 +24,7 @@ #include #include #include -#include +#include #include #include #include "visor.h" @@ -35,23 +36,29 @@ #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" /* function prototypes for a handspring visor */ -static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int visor_write_room (struct tty_struct *tty); -static void visor_throttle (struct tty_struct *tty); -static void visor_unthrottle (struct tty_struct *tty); -static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id); +static int visor_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void visor_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static int visor_write_room(struct tty_struct *tty); +static void visor_throttle(struct tty_struct *tty); +static void visor_unthrottle(struct tty_struct *tty); +static int visor_probe(struct usb_serial *serial, + const struct usb_device_id *id); static int visor_calc_num_ports(struct usb_serial *serial); -static void visor_shutdown (struct usb_serial *serial); -static void visor_write_bulk_callback (struct urb *urb); -static void visor_read_bulk_callback (struct urb *urb); -static void visor_read_int_callback (struct urb *urb); -static int clie_3_5_startup (struct usb_serial *serial); -static int treo_attach (struct usb_serial *serial); -static int clie_5_attach (struct usb_serial *serial); -static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id); -static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id); +static void visor_shutdown(struct usb_serial *serial); +static void visor_write_bulk_callback(struct urb *urb); +static void visor_read_bulk_callback(struct urb *urb); +static void visor_read_int_callback(struct urb *urb); +static int clie_3_5_startup(struct usb_serial *serial); +static int treo_attach(struct usb_serial *serial); +static int clie_5_attach(struct usb_serial *serial); +static int palm_os_3_probe(struct usb_serial *serial, + const struct usb_device_id *id); +static int palm_os_4_probe(struct usb_serial *serial, + const struct usb_device_id *id); /* Parameters that may be passed into the module. */ static int debug; @@ -103,13 +110,13 @@ static struct usb_device_id id_table [] = { .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, - { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), + { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID), .driver_info = (kernel_ulong_t)&palm_os_4_probe }, @@ -168,7 +175,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver visor_driver = { .name = "visor", @@ -178,7 +185,8 @@ static struct usb_driver visor_driver = { .no_dynamic_id = 1, }; -/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ +/* All of the device info needed for the Handspring Visor, + and Palm 4.0 devices */ static struct usb_serial_driver handspring_device = { .driver = { .owner = THIS_MODULE, @@ -266,7 +274,8 @@ static int stats; /****************************************************************************** * Handspring Visor specific driver functions ******************************************************************************/ -static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) +static int visor_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp) { struct usb_serial *serial = port->serial; struct visor_private *priv = usb_get_serial_port_data(port); @@ -296,39 +305,41 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str tty->low_latency = 1; /* Start reading from the device */ - usb_fill_bulk_urb (port->read_urb, serial->dev, - usb_rcvbulkpipe (serial->dev, + usb_fill_bulk_urb(port->read_urb, serial->dev, + usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, visor_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", - __func__, result); + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); goto exit; } - + if (port->interrupt_in_urb) { dbg("%s - adding interrupt input for treo", __func__); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result) - dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", - __func__, result); + dev_err(&port->dev, + "%s - failed submitting interrupt urb, error %d\n", + __func__, result); } -exit: +exit: return result; } static void visor_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct visor_private *priv = usb_get_serial_port_data(port); unsigned char *transfer_buffer; dbg("%s - port %d", __func__, port->number); - + /* shutdown our urbs */ usb_kill_urb(port->read_urb); usb_kill_urb(port->interrupt_in_urb); @@ -336,14 +347,14 @@ static void visor_close(struct tty_struct *tty, mutex_lock(&port->serial->disc_mutex); if (!port->serial->disconnected) { /* Try to send shutdown message, unless the device is gone */ - transfer_buffer = kmalloc (0x12, GFP_KERNEL); + transfer_buffer = kmalloc(0x12, GFP_KERNEL); if (transfer_buffer) { - usb_control_msg (port->serial->dev, + usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), VISOR_CLOSE_NOTIFICATION, 0xc2, 0x0000, 0x0000, transfer_buffer, 0x12, 300); - kfree (transfer_buffer); + kfree(transfer_buffer); } } mutex_unlock(&port->serial->disc_mutex); @@ -375,7 +386,7 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, priv->outstanding_urbs++; spin_unlock_irqrestore(&priv->lock, flags); - buffer = kmalloc (count, GFP_ATOMIC); + buffer = kmalloc(count, GFP_ATOMIC); if (!buffer) { dev_err(&port->dev, "out of memory\n"); count = -ENOMEM; @@ -389,21 +400,22 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, goto error_no_urb; } - memcpy (buffer, buf, count); + memcpy(buffer, buf, count); usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); - usb_fill_bulk_urb (urb, serial->dev, - usb_sndbulkpipe (serial->dev, + usb_fill_bulk_urb(urb, serial->dev, + usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), - buffer, count, + buffer, count, visor_write_bulk_callback, port); /* send it down the pipe */ status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { - dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", - __func__, status); + dev_err(&port->dev, + "%s - usb_submit_urb(write bulk) failed with status = %d\n", + __func__, status); count = status; goto error; } else { @@ -429,7 +441,7 @@ error_no_buffer: } -static int visor_write_room (struct tty_struct *tty) +static int visor_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); @@ -455,7 +467,7 @@ static int visor_write_room (struct tty_struct *tty) } -static void visor_write_bulk_callback (struct urb *urb) +static void visor_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct visor_private *priv = usb_get_serial_port_data(port); @@ -463,7 +475,7 @@ static void visor_write_bulk_callback (struct urb *urb) unsigned long flags; /* free up the transfer buffer, as usb_free_urb() does not do this */ - kfree (urb->transfer_buffer); + kfree(urb->transfer_buffer); dbg("%s - port %d", __func__, port->number); @@ -479,7 +491,7 @@ static void visor_write_bulk_callback (struct urb *urb) } -static void visor_read_bulk_callback (struct urb *urb) +static void visor_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct visor_private *priv = usb_get_serial_port_data(port); @@ -497,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty; if (tty && urb->actual_length) { - available_room = tty_buffer_request_room(tty, urb->actual_length); + available_room = tty_buffer_request_room(tty, + urb->actual_length); if (available_room) { tty_insert_flip_string(tty, data, available_room); tty_flip_buffer_push(tty); @@ -515,22 +529,23 @@ static void visor_read_bulk_callback (struct urb *urb) /* Continue trying to always read if we should */ if (!priv->throttled) { - usb_fill_bulk_urb (port->read_urb, port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, - port->bulk_in_endpointAddress), + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, visor_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); - } else { + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); + } else priv->actually_throttled = 1; - } spin_unlock(&priv->lock); } -static void visor_read_int_callback (struct urb *urb) +static void visor_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; int status = urb->status; @@ -564,13 +579,14 @@ static void visor_read_int_callback (struct urb *urb) urb->actual_length, urb->transfer_buffer); exit: - result = usb_submit_urb (urb, GFP_ATOMIC); + result = usb_submit_urb(urb, GFP_ATOMIC); if (result) - dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", - __func__, result); + dev_err(&urb->dev->dev, + "%s - Error %d submitting interrupt urb\n", + __func__, result); } -static void visor_throttle (struct tty_struct *tty) +static void visor_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); @@ -583,7 +599,7 @@ static void visor_throttle (struct tty_struct *tty) } -static void visor_unthrottle (struct tty_struct *tty) +static void visor_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct visor_private *priv = usb_get_serial_port_data(port); @@ -599,10 +615,13 @@ static void visor_unthrottle (struct tty_struct *tty) port->read_urb->dev = port->serial->dev; result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed submitting read urb, error %d\n", + __func__, result); } -static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id) +static int palm_os_3_probe(struct usb_serial *serial, + const struct usb_device_id *id) { struct device *dev = &serial->dev->dev; struct visor_connection_info *connection_info; @@ -614,7 +633,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i dbg("%s", __func__); - transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); + transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL); if (!transfer_buffer) { dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, sizeof(*connection_info)); @@ -622,7 +641,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i } /* send a get connection info request */ - retval = usb_control_msg (serial->dev, + retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_GET_CONNECTION_INFORMATION, 0xc2, 0x0000, 0x0000, transfer_buffer, @@ -634,29 +653,31 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i } if (retval == sizeof(*connection_info)) { - connection_info = (struct visor_connection_info *)transfer_buffer; + connection_info = (struct visor_connection_info *) + transfer_buffer; num_ports = le16_to_cpu(connection_info->num_ports); for (i = 0; i < num_ports; ++i) { - switch (connection_info->connections[i].port_function_id) { - case VISOR_FUNCTION_GENERIC: - string = "Generic"; - break; - case VISOR_FUNCTION_DEBUGGER: - string = "Debugger"; - break; - case VISOR_FUNCTION_HOTSYNC: - string = "HotSync"; - break; - case VISOR_FUNCTION_CONSOLE: - string = "Console"; - break; - case VISOR_FUNCTION_REMOTE_FILE_SYS: - string = "Remote File System"; - break; - default: - string = "unknown"; - break; + switch ( + connection_info->connections[i].port_function_id) { + case VISOR_FUNCTION_GENERIC: + string = "Generic"; + break; + case VISOR_FUNCTION_DEBUGGER: + string = "Debugger"; + break; + case VISOR_FUNCTION_HOTSYNC: + string = "HotSync"; + break; + case VISOR_FUNCTION_CONSOLE: + string = "Console"; + break; + case VISOR_FUNCTION_REMOTE_FILE_SYS: + string = "Remote File System"; + break; + default: + string = "unknown"; + break; } dev_info(dev, "%s: port %d, is for %s use\n", serial->type->description, @@ -667,11 +688,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i * Handle devices that report invalid stuff here. */ if (num_ports == 0 || num_ports > 2) { - dev_warn (dev, "%s: No valid connect info available\n", + dev_warn(dev, "%s: No valid connect info available\n", serial->type->description); num_ports = 2; } - + dev_info(dev, "%s: Number of ports: %d\n", serial->type->description, num_ports); @@ -681,8 +702,9 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i */ usb_set_serial_data(serial, (void *)(long)num_ports); - /* ask for the number of bytes available, but ignore the response as it is broken */ - retval = usb_control_msg (serial->dev, + /* ask for the number of bytes available, but ignore the + response as it is broken */ + retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_REQUEST_BYTES_AVAILABLE, 0xc2, 0x0000, 0x0005, transfer_buffer, @@ -693,12 +715,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i retval = 0; exit: - kfree (transfer_buffer); + kfree(transfer_buffer); return retval; } -static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id) +static int palm_os_4_probe(struct usb_serial *serial, + const struct usb_device_id *id) { struct device *dev = &serial->dev->dev; struct palm_ext_connection_info *connection_info; @@ -707,18 +730,18 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i dbg("%s", __func__); - transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); + transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL); if (!transfer_buffer) { dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, sizeof(*connection_info)); return -ENOMEM; } - retval = usb_control_msg (serial->dev, - usb_rcvctrlpipe(serial->dev, 0), + retval = usb_control_msg(serial->dev, + usb_rcvctrlpipe(serial->dev, 0), PALM_GET_EXT_CONNECTION_INFORMATION, 0xc2, 0x0000, 0x0000, transfer_buffer, - sizeof (*connection_info), 300); + sizeof(*connection_info), 300); if (retval < 0) dev_err(dev, "%s - error %d getting connection info\n", __func__, retval); @@ -726,15 +749,17 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i usb_serial_debug_data(debug, &serial->dev->dev, __func__, retval, transfer_buffer); - kfree (transfer_buffer); + kfree(transfer_buffer); return 0; } -static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id) +static int visor_probe(struct usb_serial *serial, + const struct usb_device_id *id) { int retval = 0; - int (*startup) (struct usb_serial *serial, const struct usb_device_id *id); + int (*startup)(struct usb_serial *serial, + const struct usb_device_id *id); dbg("%s", __func__); @@ -752,7 +777,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i return retval; } -static int visor_calc_num_ports (struct usb_serial *serial) +static int visor_calc_num_ports(struct usb_serial *serial) { int num_ports = (int)(long)(usb_get_serial_data(serial)); @@ -769,7 +794,7 @@ static int generic_startup(struct usb_serial *serial) int i; for (i = 0; i < serial->num_ports; ++i) { - priv = kzalloc (sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) { while (i-- != 0) { priv = usb_get_serial_port_data(ports[i]); @@ -784,7 +809,7 @@ static int generic_startup(struct usb_serial *serial) return 0; } -static int clie_3_5_startup (struct usb_serial *serial) +static int clie_3_5_startup(struct usb_serial *serial) { struct device *dev = &serial->dev->dev; int result; @@ -797,62 +822,72 @@ static int clie_3_5_startup (struct usb_serial *serial) */ /* get the config number */ - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 0, 0, &data, 1, 3000); if (result < 0) { - dev_err(dev, "%s: get config number failed: %d\n", __func__, result); + dev_err(dev, "%s: get config number failed: %d\n", + __func__, result); return result; } if (result != 1) { - dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result); + dev_err(dev, "%s: get config number bad return length: %d\n", + __func__, result); return -EIO; } /* get the interface number */ - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), - USB_REQ_GET_INTERFACE, + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), + USB_REQ_GET_INTERFACE, USB_DIR_IN | USB_RECIP_INTERFACE, 0, 0, &data, 1, 3000); if (result < 0) { - dev_err(dev, "%s: get interface number failed: %d\n", __func__, result); + dev_err(dev, "%s: get interface number failed: %d\n", + __func__, result); return result; } if (result != 1) { - dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result); + dev_err(dev, + "%s: get interface number bad return length: %d\n", + __func__, result); return -EIO; } return generic_startup(serial); } - -static int treo_attach (struct usb_serial *serial) + +static int treo_attach(struct usb_serial *serial) { struct usb_serial_port *swap_port; /* Only do this endpoint hack for the Handspring devices with * interrupt in endpoints, which for now are the Treo devices. */ - if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) || - (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) || - (serial->num_interrupt_in == 0)) + if (!((le16_to_cpu(serial->dev->descriptor.idVendor) + == HANDSPRING_VENDOR_ID) || + (le16_to_cpu(serial->dev->descriptor.idVendor) + == KYOCERA_VENDOR_ID)) || + (serial->num_interrupt_in == 0)) goto generic_startup; dbg("%s", __func__); /* - * It appears that Treos and Kyoceras want to use the - * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, - * so let's swap the 1st and 2nd bulk in and interrupt endpoints. - * Note that swapping the bulk out endpoints would break lots of + * It appears that Treos and Kyoceras want to use the + * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, + * so let's swap the 1st and 2nd bulk in and interrupt endpoints. + * Note that swapping the bulk out endpoints would break lots of * apps that want to communicate on the second port. */ #define COPY_PORT(dest, src) \ - dest->read_urb = src->read_urb; \ - dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress; \ - dest->bulk_in_buffer = src->bulk_in_buffer; \ - dest->interrupt_in_urb = src->interrupt_in_urb; \ - dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \ - dest->interrupt_in_buffer = src->interrupt_in_buffer; + do { \ + dest->read_urb = src->read_urb; \ + dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\ + dest->bulk_in_buffer = src->bulk_in_buffer; \ + dest->interrupt_in_urb = src->interrupt_in_urb; \ + dest->interrupt_in_endpointAddress = \ + src->interrupt_in_endpointAddress;\ + dest->interrupt_in_buffer = src->interrupt_in_buffer; \ + } while (0); swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL); if (!swap_port) @@ -866,28 +901,30 @@ generic_startup: return generic_startup(serial); } -static int clie_5_attach (struct usb_serial *serial) +static int clie_5_attach(struct usb_serial *serial) { dbg("%s", __func__); - /* TH55 registers 2 ports. - Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 - Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1 - + /* TH55 registers 2 ports. + Communication in from the UX50/TH55 uses bulk_in_endpointAddress + from port 0. Communication out to the UX50/TH55 uses + bulk_out_endpointAddress from port 1 + Lets do a quick and dirty mapping */ - + /* some sanity check */ if (serial->num_ports < 2) return -1; - + /* port 0 now uses the modified endpoint Address */ - serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress; + serial->port[0]->bulk_out_endpointAddress = + serial->port[1]->bulk_out_endpointAddress; return generic_startup(serial); } -static void visor_shutdown (struct usb_serial *serial) +static void visor_shutdown(struct usb_serial *serial) { struct visor_private *priv; int i; @@ -903,30 +940,35 @@ static void visor_shutdown (struct usb_serial *serial) } } -static int __init visor_init (void) +static int __init visor_init(void) { int i, retval; /* Only if parameters were passed to us */ - if ((vendor>0) && (product>0)) { - struct usb_device_id usb_dev_temp[]= - {{USB_DEVICE(vendor, product), - .driver_info = (kernel_ulong_t)&palm_os_4_probe }}; + if (vendor > 0 && product > 0) { + struct usb_device_id usb_dev_temp[] = { + { + USB_DEVICE(vendor, product), + .driver_info = + (kernel_ulong_t) &palm_os_4_probe + } + }; /* Find the last entry in id_table */ - for (i=0; ; i++) { - if (id_table[i].idVendor==0) { + for (i = 0;; i++) { + if (id_table[i].idVendor == 0) { id_table[i] = usb_dev_temp[0]; break; } } /* Find the last entry in id_table_combined */ - for (i=0; ; i++) { - if (id_table_combined[i].idVendor==0) { + for (i = 0;; i++) { + if (id_table_combined[i].idVendor == 0) { id_table_combined[i] = usb_dev_temp[0]; break; } } - info("Untested USB device specified at time of module insertion"); + info( + "Untested USB device specified at time of module insertion"); info("Warning: This is not guaranteed to work"); info("Using a newer kernel is preferred to this method"); info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x", @@ -942,7 +984,7 @@ static int __init visor_init (void) if (retval) goto failed_clie_5_register; retval = usb_register(&visor_driver); - if (retval) + if (retval) goto failed_usb_register; info(DRIVER_DESC); @@ -960,18 +1002,18 @@ failed_handspring_register: static void __exit visor_exit (void) { - usb_deregister (&visor_driver); - usb_serial_deregister (&handspring_device); - usb_serial_deregister (&clie_3_5_device); - usb_serial_deregister (&clie_5_device); + usb_deregister(&visor_driver); + usb_serial_deregister(&handspring_device); + usb_serial_deregister(&clie_3_5_device); + usb_serial_deregister(&clie_5_device); } module_init(visor_init); module_exit(visor_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From a8d6f0a9c4c9af0e478383d870e828693e983dfb Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:24 +0100 Subject: usb-serial: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/usb-serial.c | 304 ++++++++++++++++++++++------------------ 1 file changed, 164 insertions(+), 140 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index ffaed8ace06..51917b0f079 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -12,7 +12,8 @@ * This driver was originally based on the ACM driver by Armin Fuerst (which was * based on a driver by Brad Keryan) * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * */ @@ -28,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "pl2303.h" @@ -59,7 +60,8 @@ static struct usb_driver usb_serial_driver = { */ static int debug; -static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ +/* initially all NULL */ +static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; static DEFINE_MUTEX(table_lock); static LIST_HEAD(usb_serial_driver_list); @@ -76,7 +78,8 @@ struct usb_serial *usb_serial_get_by_index(unsigned index) return serial; } -static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_ports, unsigned int *minor) +static struct usb_serial *get_free_serial(struct usb_serial *serial, + int num_ports, unsigned int *minor) { unsigned int i, j; int good_spot; @@ -122,9 +125,8 @@ static void return_serial(struct usb_serial *serial) if (serial == NULL) return; - for (i = 0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) serial_table[serial->minor + i] = NULL; - } } static void destroy_serial(struct kref *kref) @@ -156,7 +158,8 @@ static void destroy_serial(struct kref *kref) * not get cleaned up in port_release() as it was never registered with * the driver core */ if (serial->num_ports < serial->num_port_pointers) { - for (i = serial->num_ports; i < serial->num_port_pointers; ++i) { + for (i = serial->num_ports; + i < serial->num_port_pointers; ++i) { port = serial->port[i]; if (!port) continue; @@ -167,7 +170,7 @@ static void destroy_serial(struct kref *kref) usb_put_dev(serial->dev); /* free up any memory that we allocated */ - kfree (serial); + kfree(serial); } void usb_serial_put(struct usb_serial *serial) @@ -180,13 +183,13 @@ void usb_serial_put(struct usb_serial *serial) /***************************************************************************** * Driver tty interface functions *****************************************************************************/ -static int serial_open (struct tty_struct *tty, struct file * filp) +static int serial_open (struct tty_struct *tty, struct file *filp) { struct usb_serial *serial; struct usb_serial_port *port; unsigned int portNumber; int retval; - + dbg("%s", __func__); /* get the serial object associated with this tty pointer */ @@ -207,7 +210,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) retval = -ERESTARTSYS; goto bailout_kref_put; } - + ++port->port.count; /* set up our port structure making the tty driver @@ -228,7 +231,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) retval = usb_autopm_get_interface(serial->interface); if (retval) goto bailout_module_put; - /* only call the device specific open if this + /* only call the device specific open if this * is the first time the port is opened */ retval = serial->type->open(tty, port, filp); if (retval) @@ -252,7 +255,7 @@ bailout_kref_put: return retval; } -static void serial_close(struct tty_struct *tty, struct file * filp) +static void serial_close(struct tty_struct *tty, struct file *filp) { struct usb_serial_port *port = tty->driver_data; @@ -270,7 +273,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) --port->port.count; if (port->port.count == 0) - /* only call the device specific close if this + /* only call the device specific close if this * port is being closed by the last owner */ port->serial->type->close(tty, port, filp); @@ -294,7 +297,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp) usb_serial_put(port->serial); } -static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) +static int serial_write(struct tty_struct *tty, const unsigned char *buf, + int count) { struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; @@ -305,7 +309,7 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int dbg("%s - port %d, %d byte(s)", __func__, port->number, count); /* count is managed under the mutex lock for the tty so cannot - drop to zero until after the last close completes */ + drop to zero until after the last close completes */ WARN_ON(!port->port.count); /* pass on to the driver specific version of this function */ @@ -315,7 +319,7 @@ exit: return retval; } -static int serial_write_room (struct tty_struct *tty) +static int serial_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); @@ -324,7 +328,7 @@ static int serial_write_room (struct tty_struct *tty) return port->serial->type->write_room(tty); } -static int serial_chars_in_buffer (struct tty_struct *tty) +static int serial_chars_in_buffer(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s = port %d", __func__, port->number); @@ -334,7 +338,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty) return port->serial->type->chars_in_buffer(tty); } -static void serial_throttle (struct tty_struct * tty) +static void serial_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); @@ -345,7 +349,7 @@ static void serial_throttle (struct tty_struct * tty) port->serial->type->throttle(tty); } -static void serial_unthrottle (struct tty_struct * tty) +static void serial_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); @@ -356,7 +360,8 @@ static void serial_unthrottle (struct tty_struct * tty) port->serial->type->unthrottle(tty); } -static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) +static int serial_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; @@ -365,38 +370,40 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in WARN_ON(!port->port.count); - /* pass on to the driver specific version of this function if it is available */ + /* pass on to the driver specific version of this function + if it is available */ if (port->serial->type->ioctl) { lock_kernel(); retval = port->serial->type->ioctl(tty, file, cmd, arg); unlock_kernel(); - } - else + } else retval = -ENOIOCTLCMD; return retval; } -static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) +static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); WARN_ON(!port->port.count); - /* pass on to the driver specific version of this function if it is available */ + /* pass on to the driver specific version of this function + if it is available */ if (port->serial->type->set_termios) port->serial->type->set_termios(tty, port, old); else tty_termios_copy_hw(tty->termios, old); } -static void serial_break (struct tty_struct *tty, int break_state) +static void serial_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); WARN_ON(!port->port.count); - /* pass on to the driver specific version of this function if it is available */ + /* pass on to the driver specific version of this function + if it is available */ if (port->serial->type->break_ctl) { lock_kernel(); port->serial->type->break_ctl(tty, break_state); @@ -404,7 +411,8 @@ static void serial_break (struct tty_struct *tty, int break_state) } } -static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) +static int serial_read_proc(char *page, char **start, off_t off, int count, + int *eof, void *data) { struct usb_serial *serial; int length = 0; @@ -413,26 +421,29 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int char tmp[40]; dbg("%s", __func__); - length += sprintf (page, "usbserinfo:1.0 driver:2.0\n"); + length += sprintf(page, "usbserinfo:1.0 driver:2.0\n"); for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { serial = usb_serial_get_by_index(i); if (serial == NULL) continue; - length += sprintf (page+length, "%d:", i); + length += sprintf(page+length, "%d:", i); if (serial->type->driver.owner) - length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner)); - length += sprintf (page+length, " name:\"%s\"", serial->type->description); - length += sprintf (page+length, " vendor:%04x product:%04x", - le16_to_cpu(serial->dev->descriptor.idVendor), - le16_to_cpu(serial->dev->descriptor.idProduct)); - length += sprintf (page+length, " num_ports:%d", serial->num_ports); - length += sprintf (page+length, " port:%d", i - serial->minor + 1); - + length += sprintf(page+length, " module:%s", + module_name(serial->type->driver.owner)); + length += sprintf(page+length, " name:\"%s\"", + serial->type->description); + length += sprintf(page+length, " vendor:%04x product:%04x", + le16_to_cpu(serial->dev->descriptor.idVendor), + le16_to_cpu(serial->dev->descriptor.idProduct)); + length += sprintf(page+length, " num_ports:%d", + serial->num_ports); + length += sprintf(page+length, " port:%d", + i - serial->minor + 1); usb_make_path(serial->dev, tmp, sizeof(tmp)); - length += sprintf (page+length, " path:%s", tmp); - - length += sprintf (page+length, "\n"); + length += sprintf(page+length, " path:%s", tmp); + + length += sprintf(page+length, "\n"); if ((length + begin) > (off + count)) { usb_serial_put(serial); goto done; @@ -448,10 +459,10 @@ done: if (off >= (length + begin)) return 0; *start = page + (off-begin); - return ((count < begin+length-off) ? count : begin+length-off); + return (count < begin+length-off) ? count : begin+length-off; } -static int serial_tiocmget (struct tty_struct *tty, struct file *file) +static int serial_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; @@ -463,7 +474,7 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) return -EINVAL; } -static int serial_tiocmset (struct tty_struct *tty, struct file *file, +static int serial_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; @@ -485,6 +496,7 @@ void usb_serial_port_softint(struct usb_serial_port *port) { schedule_work(&port->work); } +EXPORT_SYMBOL_GPL(usb_serial_port_softint); static void usb_serial_port_work(struct work_struct *work) { @@ -493,7 +505,7 @@ static void usb_serial_port_work(struct work_struct *work) struct tty_struct *tty; dbg("%s - port %d", __func__, port->number); - + if (!port) return; @@ -546,9 +558,9 @@ static void port_free(struct usb_serial_port *port) kfree(port); } -static struct usb_serial * create_serial (struct usb_device *dev, - struct usb_interface *interface, - struct usb_serial_driver *driver) +static struct usb_serial *create_serial(struct usb_device *dev, + struct usb_interface *interface, + struct usb_serial_driver *driver) { struct usb_serial *serial; @@ -567,7 +579,7 @@ static struct usb_serial * create_serial (struct usb_device *dev, } static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf, - struct usb_serial_driver *drv) + struct usb_serial_driver *drv) { struct usb_dynid *dynid; @@ -599,7 +611,8 @@ exit: return id; } -static struct usb_serial_driver *search_serial_device(struct usb_interface *iface) +static struct usb_serial_driver *search_serial_device( + struct usb_interface *iface) { const struct usb_device_id *id; struct usb_serial_driver *drv; @@ -617,7 +630,7 @@ static struct usb_serial_driver *search_serial_device(struct usb_interface *ifac int usb_serial_probe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_device *dev = interface_to_usbdev (interface); + struct usb_device *dev = interface_to_usbdev(interface); struct usb_serial *serial = NULL; struct usb_serial_port *port; struct usb_host_interface *iface_desc; @@ -646,7 +659,7 @@ int usb_serial_probe(struct usb_interface *interface, return -ENODEV; } - serial = create_serial (dev, interface, type); + serial = create_serial(dev, interface, type); if (!serial) { unlock_kernel(); dev_err(&interface->dev, "%s - out of memory\n", __func__); @@ -659,8 +672,9 @@ int usb_serial_probe(struct usb_interface *interface, if (!try_module_get(type->driver.owner)) { unlock_kernel(); - dev_err(&interface->dev, "module get failed, exiting\n"); - kfree (serial); + dev_err(&interface->dev, + "module get failed, exiting\n"); + kfree(serial); return -EIO; } @@ -670,8 +684,8 @@ int usb_serial_probe(struct usb_interface *interface, if (retval) { unlock_kernel(); - dbg ("sub driver rejected device"); - kfree (serial); + dbg("sub driver rejected device"); + kfree(serial); return retval; } } @@ -712,7 +726,7 @@ int usb_serial_probe(struct usb_interface *interface, } #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE) - /* BEGIN HORRIBLE HACK FOR PL2303 */ + /* BEGIN HORRIBLE HACK FOR PL2303 */ /* this is needed due to the looney way its endpoints are set up */ if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) || @@ -741,7 +755,7 @@ int usb_serial_probe(struct usb_interface *interface, if (num_bulk_in == 0 || num_bulk_out == 0) { unlock_kernel(); dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); - kfree (serial); + kfree(serial); return -ENODEV; } } @@ -753,8 +767,9 @@ int usb_serial_probe(struct usb_interface *interface, num_ports = num_bulk_out; if (num_ports == 0) { unlock_kernel(); - dev_err(&interface->dev, "Generic device with no bulk out, not allowed.\n"); - kfree (serial); + dev_err(&interface->dev, + "Generic device with no bulk out, not allowed.\n"); + kfree(serial); return -EIO; } } @@ -764,11 +779,12 @@ int usb_serial_probe(struct usb_interface *interface, if (type->calc_num_ports) { if (!try_module_get(type->driver.owner)) { unlock_kernel(); - dev_err(&interface->dev, "module get failed, exiting\n"); - kfree (serial); + dev_err(&interface->dev, + "module get failed, exiting\n"); + kfree(serial); return -EIO; } - num_ports = type->calc_num_ports (serial); + num_ports = type->calc_num_ports(serial); module_put(type->driver.owner); } if (!num_ports) @@ -786,7 +802,8 @@ int usb_serial_probe(struct usb_interface *interface, type->description); /* create our ports, we need as many as the max endpoints */ - /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */ + /* we don't use num_ports here because some devices have more + endpoint pairs than ports */ max_endpoints = max(num_bulk_in, num_bulk_out); max_endpoints = max(max_endpoints, num_interrupt_in); max_endpoints = max(max_endpoints, num_interrupt_out); @@ -794,7 +811,8 @@ int usb_serial_probe(struct usb_interface *interface, serial->num_port_pointers = max_endpoints; unlock_kernel(); - dbg("%s - setting up %d port structures for this device", __func__, max_endpoints); + dbg("%s - setting up %d port structures for this device", + __func__, max_endpoints); for (i = 0; i < max_endpoints; ++i) { port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); if (!port) @@ -810,7 +828,7 @@ int usb_serial_probe(struct usb_interface *interface, for (i = 0; i < num_bulk_in; ++i) { endpoint = bulk_in_endpoint[i]; port = serial->port[i]; - port->read_urb = usb_alloc_urb (0, GFP_KERNEL); + port->read_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->read_urb) { dev_err(&interface->dev, "No free urbs available\n"); goto probe_error; @@ -818,17 +836,17 @@ int usb_serial_probe(struct usb_interface *interface, buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->bulk_in_size = buffer_size; port->bulk_in_endpointAddress = endpoint->bEndpointAddress; - port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); + port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!port->bulk_in_buffer) { - dev_err(&interface->dev, "Couldn't allocate bulk_in_buffer\n"); + dev_err(&interface->dev, + "Couldn't allocate bulk_in_buffer\n"); goto probe_error; } - usb_fill_bulk_urb (port->read_urb, dev, - usb_rcvbulkpipe (dev, - endpoint->bEndpointAddress), - port->bulk_in_buffer, buffer_size, - serial->type->read_bulk_callback, - port); + usb_fill_bulk_urb(port->read_urb, dev, + usb_rcvbulkpipe(dev, + endpoint->bEndpointAddress), + port->bulk_in_buffer, buffer_size, + serial->type->read_bulk_callback, port); } for (i = 0; i < num_bulk_out; ++i) { @@ -842,17 +860,17 @@ int usb_serial_probe(struct usb_interface *interface, buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->bulk_out_size = buffer_size; port->bulk_out_endpointAddress = endpoint->bEndpointAddress; - port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL); + port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); if (!port->bulk_out_buffer) { - dev_err(&interface->dev, "Couldn't allocate bulk_out_buffer\n"); + dev_err(&interface->dev, + "Couldn't allocate bulk_out_buffer\n"); goto probe_error; } - usb_fill_bulk_urb (port->write_urb, dev, - usb_sndbulkpipe (dev, - endpoint->bEndpointAddress), - port->bulk_out_buffer, buffer_size, - serial->type->write_bulk_callback, - port); + usb_fill_bulk_urb(port->write_urb, dev, + usb_sndbulkpipe(dev, + endpoint->bEndpointAddress), + port->bulk_out_buffer, buffer_size, + serial->type->write_bulk_callback, port); } if (serial->type->read_int_callback) { @@ -861,73 +879,82 @@ int usb_serial_probe(struct usb_interface *interface, port = serial->port[i]; port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->interrupt_in_urb) { - dev_err(&interface->dev, "No free urbs available\n"); + dev_err(&interface->dev, + "No free urbs available\n"); goto probe_error; } buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); - port->interrupt_in_endpointAddress = endpoint->bEndpointAddress; - port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); + port->interrupt_in_endpointAddress = + endpoint->bEndpointAddress; + port->interrupt_in_buffer = kmalloc(buffer_size, + GFP_KERNEL); if (!port->interrupt_in_buffer) { - dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n"); + dev_err(&interface->dev, + "Couldn't allocate interrupt_in_buffer\n"); goto probe_error; } - usb_fill_int_urb (port->interrupt_in_urb, dev, - usb_rcvintpipe (dev, - endpoint->bEndpointAddress), - port->interrupt_in_buffer, buffer_size, - serial->type->read_int_callback, port, - endpoint->bInterval); + usb_fill_int_urb(port->interrupt_in_urb, dev, + usb_rcvintpipe(dev, + endpoint->bEndpointAddress), + port->interrupt_in_buffer, buffer_size, + serial->type->read_int_callback, port, + endpoint->bInterval); } } else if (num_interrupt_in) { dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined"); } - + if (serial->type->write_int_callback) { for (i = 0; i < num_interrupt_out; ++i) { endpoint = interrupt_out_endpoint[i]; port = serial->port[i]; port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->interrupt_out_urb) { - dev_err(&interface->dev, "No free urbs available\n"); + dev_err(&interface->dev, + "No free urbs available\n"); goto probe_error; } buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->interrupt_out_size = buffer_size; - port->interrupt_out_endpointAddress = endpoint->bEndpointAddress; - port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL); + port->interrupt_out_endpointAddress = + endpoint->bEndpointAddress; + port->interrupt_out_buffer = kmalloc(buffer_size, + GFP_KERNEL); if (!port->interrupt_out_buffer) { - dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n"); + dev_err(&interface->dev, + "Couldn't allocate interrupt_out_buffer\n"); goto probe_error; } - usb_fill_int_urb (port->interrupt_out_urb, dev, - usb_sndintpipe (dev, - endpoint->bEndpointAddress), - port->interrupt_out_buffer, buffer_size, - serial->type->write_int_callback, port, - endpoint->bInterval); + usb_fill_int_urb(port->interrupt_out_urb, dev, + usb_sndintpipe(dev, + endpoint->bEndpointAddress), + port->interrupt_out_buffer, buffer_size, + serial->type->write_int_callback, port, + endpoint->bInterval); } } else if (num_interrupt_out) { dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined"); } - + /* if this device type has an attach function, call it */ if (type->attach) { if (!try_module_get(type->driver.owner)) { - dev_err(&interface->dev, "module get failed, exiting\n"); + dev_err(&interface->dev, + "module get failed, exiting\n"); goto probe_error; } - retval = type->attach (serial); + retval = type->attach(serial); module_put(type->driver.owner); if (retval < 0) goto probe_error; if (retval > 0) { - /* quietly accept this device, but don't bind to a serial port - * as it's about to disappear */ + /* quietly accept this device, but don't bind to a + serial port as it's about to disappear */ goto exit; } } - if (get_free_serial (serial, num_ports, &minor) == NULL) { + if (get_free_serial(serial, num_ports, &minor) == NULL) { dev_err(&interface->dev, "No more free serial devices\n"); goto probe_error; } @@ -949,11 +976,11 @@ int usb_serial_probe(struct usb_interface *interface, "continuing\n"); } - usb_serial_console_init (debug, minor); + usb_serial_console_init(debug, minor); exit: /* success */ - usb_set_intfdata (interface, serial); + usb_set_intfdata(interface, serial); return 0; probe_error: @@ -989,22 +1016,23 @@ probe_error: /* free up any memory that we allocated */ for (i = 0; i < serial->num_port_pointers; ++i) kfree(serial->port[i]); - kfree (serial); + kfree(serial); return -EIO; } +EXPORT_SYMBOL_GPL(usb_serial_probe); void usb_serial_disconnect(struct usb_interface *interface) { int i; - struct usb_serial *serial = usb_get_intfdata (interface); + struct usb_serial *serial = usb_get_intfdata(interface); struct device *dev = &interface->dev; struct usb_serial_port *port; usb_serial_console_disconnect(serial); - dbg ("%s", __func__); + dbg("%s", __func__); mutex_lock(&serial->disc_mutex); - usb_set_intfdata (interface, NULL); + usb_set_intfdata(interface, NULL); /* must set a flag, to signal subdrivers */ serial->disconnected = 1; for (i = 0; i < serial->num_ports; ++i) { @@ -1021,6 +1049,7 @@ void usb_serial_disconnect(struct usb_interface *interface) usb_serial_put(serial); dev_info(dev, "device disconnected\n"); } +EXPORT_SYMBOL_GPL(usb_serial_disconnect); int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) { @@ -1079,9 +1108,8 @@ static int __init usb_serial_init(void) return -ENOMEM; /* Initialize our global data */ - for (i = 0; i < SERIAL_TTY_MINORS; ++i) { + for (i = 0; i < SERIAL_TTY_MINORS; ++i) serial_table[i] = NULL; - } result = bus_register(&usb_serial_bus_type); if (result) { @@ -1096,9 +1124,11 @@ static int __init usb_serial_init(void) usb_serial_tty_driver->minor_start = 0; usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL; - usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV; usb_serial_tty_driver->init_termios = tty_std_termios; - usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; + usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD + | HUPCL | CLOCAL; usb_serial_tty_driver->init_termios.c_ispeed = 9600; usb_serial_tty_driver->init_termios.c_ospeed = 9600; tty_set_operations(usb_serial_tty_driver, &serial_ops); @@ -1136,7 +1166,7 @@ exit_reg_driver: bus_unregister(&usb_serial_bus_type); exit_bus: - err ("%s - returning with error %d", __func__, result); + err("%s - returning with error %d", __func__, result); put_tty_driver(usb_serial_tty_driver); return result; } @@ -1163,7 +1193,7 @@ module_exit(usb_serial_exit); if (!type->function) { \ type->function = usb_serial_generic_##function; \ dbg("Had to override the " #function \ - " usb serial operation with the generic one.");\ + " usb serial operation with the generic one.");\ } \ } while (0) @@ -1180,8 +1210,9 @@ static void fixup_generic(struct usb_serial_driver *device) set_to_generic_if_null(device, resume); } -int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */ +int usb_serial_register(struct usb_serial_driver *driver) { + /* must be called with BKL held */ int retval; fixup_generic(driver); @@ -1194,37 +1225,30 @@ int usb_serial_register(struct usb_serial_driver *driver) /* must be called with retval = usb_serial_bus_register(driver); if (retval) { - err("problem %d when registering driver %s", retval, driver->description); + err("problem %d when registering driver %s", + retval, driver->description); list_del(&driver->driver_list); - } - else - info("USB Serial support registered for %s", driver->description); + } else + info("USB Serial support registered for %s", + driver->description); return retval; } +EXPORT_SYMBOL_GPL(usb_serial_register); -void usb_serial_deregister(struct usb_serial_driver *device) /* must be called with BKL held */ +void usb_serial_deregister(struct usb_serial_driver *device) { + /* must be called with BKL held */ info("USB Serial deregistering driver %s", device->description); list_del(&device->driver_list); usb_serial_bus_deregister(device); } - - - -/* If the usb-serial core is built into the core, the usb-serial drivers - need these symbols to load properly as modules. */ -EXPORT_SYMBOL_GPL(usb_serial_register); EXPORT_SYMBOL_GPL(usb_serial_deregister); -EXPORT_SYMBOL_GPL(usb_serial_probe); -EXPORT_SYMBOL_GPL(usb_serial_disconnect); -EXPORT_SYMBOL_GPL(usb_serial_port_softint); - /* Module information */ -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 2e0ddd626d14f3b69d6c1bdd526721a65d52f93b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:33 +0100 Subject: io_ti: Minor coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/io_ti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 7cf383a2a55..cb4c54316cf 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2419,7 +2419,7 @@ static void change_port_settings(struct tty_struct *tty, return; } -static void edge_set_termios(struct tty_struct *tty, +static void edge_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); -- cgit v1.2.3-70-g09d2 From eb6215ccd403153c6376f7eaa7b31eef19e488f5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:41 +0100 Subject: ipaq: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ipaq.c | 97 +++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index a7784642d6a..832a5a4f3cb 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include "ipaq.h" @@ -82,10 +82,10 @@ static int ipaq_startup(struct usb_serial *serial); static void ipaq_shutdown(struct usb_serial *serial); static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, - int count); +static int ipaq_write_bulk(struct usb_serial_port *port, + const unsigned char *buf, int count); static void ipaq_write_gather(struct usb_serial_port *port); -static void ipaq_read_bulk_callback (struct urb *urb); +static void ipaq_read_bulk_callback(struct urb *urb); static void ipaq_write_bulk_callback(struct urb *urb); static int ipaq_write_room(struct tty_struct *tty); static int ipaq_chars_in_buffer(struct tty_struct *tty); @@ -552,7 +552,7 @@ static struct usb_device_id ipaq_id_table [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, ipaq_id_table); +MODULE_DEVICE_TABLE(usb, ipaq_id_table); static struct usb_driver ipaq_driver = { .name = "ipaq", @@ -620,9 +620,9 @@ static int ipaq_open(struct tty_struct *tty, for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) { pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL); - if (pkt == NULL) { + if (pkt == NULL) goto enomem; - } + pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL); if (pkt->data == NULL) { kfree(pkt); @@ -667,8 +667,9 @@ static int ipaq_open(struct tty_struct *tty, port->read_urb->transfer_buffer = port->bulk_in_buffer; port->write_urb->transfer_buffer = port->bulk_out_buffer; port->read_urb->transfer_buffer_length = URBDATA_SIZE; - port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE; - + port->bulk_out_size = port->write_urb->transfer_buffer_length + = URBDATA_SIZE; + msleep(1000*initial_wait); /* @@ -697,13 +698,15 @@ static int ipaq_open(struct tty_struct *tty, /* Start reading from the device */ usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ipaq_read_bulk_callback, port); + usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipaq_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result) { - err("%s - failed submitting read urb, error %d", __func__, result); + err("%s - failed submitting read urb, error %d", + __func__, result); goto error; } @@ -725,7 +728,7 @@ static void ipaq_close(struct tty_struct *tty, struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - port %d", __func__, port->number); - + /* * shut down bulk read and write */ @@ -735,7 +738,8 @@ static void ipaq_close(struct tty_struct *tty, kfree(priv); usb_set_serial_port_data(port, NULL); - /* Uncomment the following line if you want to see some statistics in your syslog */ + /* Uncomment the following line if you want to see some statistics + * in your syslog */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ } @@ -755,7 +759,8 @@ static void ipaq_read_bulk_callback(struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty; if (tty && urb->actual_length) { @@ -766,13 +771,15 @@ static void ipaq_read_bulk_callback(struct urb *urb) } /* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - ipaq_read_bulk_callback, port); + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipaq_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __func__, result); + err("%s - failed resubmitting read urb, error %d", + __func__, result); return; } @@ -787,9 +794,8 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, while (count > 0) { transfer_size = min(count, PACKET_SIZE); - if (ipaq_write_bulk(port, current_position, transfer_size)) { + if (ipaq_write_bulk(port, current_position, transfer_size)) break; - } current_position += transfer_size; bytes_sent += transfer_size; count -= transfer_size; @@ -797,10 +803,10 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, } return bytes_sent; -} +} -static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, - int count) +static int ipaq_write_bulk(struct usb_serial_port *port, + const unsigned char *buf, int count) { struct ipaq_private *priv = usb_get_serial_port_data(port); struct ipaq_packet *pkt = NULL; @@ -837,9 +843,9 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu ipaq_write_gather(port); spin_unlock_irqrestore(&write_list_lock, flags); result = usb_submit_urb(port->write_urb, GFP_ATOMIC); - if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); - } + if (result) + err("%s - failed submitting write urb, error %d", + __func__, result); } else { spin_unlock_irqrestore(&write_list_lock, flags); } @@ -866,16 +872,15 @@ static void ipaq_write_gather(struct usb_serial_port *port) list_move(&pkt->list, &priv->freelist); priv->free_len += PACKET_SIZE; } - if (room == 0) { + if (room == 0) break; - } } count = URBDATA_SIZE - room; - usb_fill_bulk_urb(port->write_urb, serial->dev, - usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), - port->write_urb->transfer_buffer, count, ipaq_write_bulk_callback, - port); + usb_fill_bulk_urb(port->write_urb, serial->dev, + usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), + port->write_urb->transfer_buffer, count, + ipaq_write_bulk_callback, port); return; } @@ -900,9 +905,9 @@ static void ipaq_write_bulk_callback(struct urb *urb) ipaq_write_gather(port); spin_unlock_irqrestore(&write_list_lock, flags); result = usb_submit_urb(port->write_urb, GFP_ATOMIC); - if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); - } + if (result) + err("%s - failed submitting write urb, error %d", + __func__, result); } else { priv->active = 0; spin_unlock_irqrestore(&write_list_lock, flags); @@ -953,7 +958,7 @@ static int ipaq_startup(struct usb_serial *serial) serial->dev->actconfig->desc.bConfigurationValue); return -ENODEV; } - return usb_reset_configuration (serial->dev); + return usb_reset_configuration(serial->dev); } static void ipaq_shutdown(struct usb_serial *serial) @@ -966,7 +971,7 @@ static int __init ipaq_init(void) int retval; spin_lock_init(&write_list_lock); retval = usb_serial_register(&ipaq_device); - if (retval) + if (retval) goto failed_usb_serial_register; info(DRIVER_DESC " " DRIVER_VERSION); if (vendor) { @@ -976,7 +981,7 @@ static int __init ipaq_init(void) retval = usb_register(&ipaq_driver); if (retval) goto failed_usb_register; - + return 0; failed_usb_register: usb_serial_deregister(&ipaq_device); @@ -995,8 +1000,8 @@ static void __exit ipaq_exit(void) module_init(ipaq_init); module_exit(ipaq_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); @@ -1009,7 +1014,9 @@ module_param(product, ushort, 0); MODULE_PARM_DESC(product, "User specified USB idProduct"); module_param(connect_retries, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)"); +MODULE_PARM_DESC(connect_retries, + "Maximum number of connect retries (one second each)"); module_param(initial_wait, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)"); +MODULE_PARM_DESC(initial_wait, + "Time to wait before attempting a connection (in seconds)"); -- cgit v1.2.3-70-g09d2 From 6d1d1698966ab6a5ac7ddcb16602ffebcf97f887 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:51 +0100 Subject: tty-usb-ipw: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ipw.c | 279 ++++++++++++++++++++++++----------------------- 1 file changed, 144 insertions(+), 135 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index a89ebfe9e91..a842025b9b5 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -10,27 +10,27 @@ * (at your option) any later version. * * All information about the device was acquired using SnoopyPro - * on MSFT's O/S, and examing the MSFT drivers' debug output + * on MSFT's O/S, and examing the MSFT drivers' debug output * (insanely left _on_ in the enduser version) * * It was written out of frustration with the IPWireless USB modem * supplied by Axity3G/Sentech South Africa not supporting * Linux whatsoever. * - * Nobody provided any proprietary information that was not already + * Nobody provided any proprietary information that was not already * available for this device. - * - * The modem adheres to the "3GPP TS 27.007 AT command set for 3G - * User Equipment (UE)" standard, available from + * + * The modem adheres to the "3GPP TS 27.007 AT command set for 3G + * User Equipment (UE)" standard, available from * http://www.3gpp.org/ftp/Specs/html-info/27007.htm * * The code was only tested the IPWireless handheld modem distributed * in South Africa by Sentech. - * + * * It may work for Woosh Inc in .nz too, as it appears they use the * same kit. * - * There is still some work to be done in terms of handling + * There is still some work to be done in terms of handling * DCD, DTR, RTS, CTS which are currently faked. * It's good enough for PPP at this point. It's based off all kinds of * code found in usb/serial and usb/class @@ -47,7 +47,7 @@ #include #include #include -#include +#include /* * Version Information @@ -64,7 +64,7 @@ /* Message sizes */ #define EVENT_BUFFER_SIZE 0xFF -#define CHAR2INT16(c1,c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) +#define CHAR2INT16(c1, c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) #define NUM_BULK_URBS 24 #define NUM_CONTROL_URBS 16 @@ -94,33 +94,34 @@ enum { /* data bits */ #define ipw_dtb_7 0x700 -#define ipw_dtb_8 0x810 // ok so the define is misleading, I know, but forces 8,n,1 - // I mean, is there a point to any other setting these days? :) +#define ipw_dtb_8 0x810 /* ok so the define is misleading, I know, but forces 8,n,1 */ + /* I mean, is there a point to any other setting these days? :) */ /* usb control request types : */ -#define IPW_SIO_RXCTL 0x00 // control bulk rx channel transmissions, value=1/0 (on/off) -#define IPW_SIO_SET_BAUD 0x01 // set baud, value=requested ipw_sio_bxxxx -#define IPW_SIO_SET_LINE 0x03 // set databits, parity. value=ipw_dtb_x -#define IPW_SIO_SET_PIN 0x03 // set/clear dtr/rts value=ipw_pin_xxx -#define IPW_SIO_POLL 0x08 // get serial port status byte, call with value=0 -#define IPW_SIO_INIT 0x11 // initializes ? value=0 (appears as first thing todo on open) -#define IPW_SIO_PURGE 0x12 // purge all transmissions?, call with value=numchar_to_purge -#define IPW_SIO_HANDFLOW 0x13 // set xon/xoff limits value=0, and a buffer of 0x10 bytes -#define IPW_SIO_SETCHARS 0x13 // set the flowcontrol special chars, value=0, buf=6 bytes, - // last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 +#define IPW_SIO_RXCTL 0x00 /* control bulk rx channel transmissions, value=1/0 (on/off) */ +#define IPW_SIO_SET_BAUD 0x01 /* set baud, value=requested ipw_sio_bxxxx */ +#define IPW_SIO_SET_LINE 0x03 /* set databits, parity. value=ipw_dtb_x */ +#define IPW_SIO_SET_PIN 0x03 /* set/clear dtr/rts value=ipw_pin_xxx */ +#define IPW_SIO_POLL 0x08 /* get serial port status byte, call with value=0 */ +#define IPW_SIO_INIT 0x11 /* initializes ? value=0 (appears as first thing todo on open) */ +#define IPW_SIO_PURGE 0x12 /* purge all transmissions?, call with value=numchar_to_purge */ +#define IPW_SIO_HANDFLOW 0x13 /* set xon/xoff limits value=0, and a buffer of 0x10 bytes */ +#define IPW_SIO_SETCHARS 0x13 /* set the flowcontrol special chars, value=0, buf=6 bytes, */ + /* last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 */ /* values used for request IPW_SIO_SET_PIN */ #define IPW_PIN_SETDTR 0x101 #define IPW_PIN_SETRTS 0x202 #define IPW_PIN_CLRDTR 0x100 -#define IPW_PIN_CLRRTS 0x200 // unconfirmed +#define IPW_PIN_CLRRTS 0x200 /* unconfirmed */ /* values used for request IPW_SIO_RXCTL */ #define IPW_RXBULK_ON 1 #define IPW_RXBULK_OFF 0 /* various 16 byte hardcoded transferbuffers used by flow control */ -#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +#define IPW_BYTES_FLOWINIT { 0x01, 0, 0, 0, 0x40, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0 } /* Interpretation of modem status lines */ /* These need sorting out by individually connecting pins and checking @@ -132,17 +133,6 @@ enum { #define IPW_CTS ((1<<5) | (1<<4)) #define IPW_WANTS_TO_SEND 0x30 -//#define IPW_DTR /* Data Terminal Ready */ -//#define IPW_CTS /* Clear To Send */ -//#define IPW_CD /* Carrier Detect */ -//#define IPW_DSR /* Data Set Ready */ -//#define IPW_RxD /* Receive pin */ - -//#define IPW_LE -//#define IPW_RTS -//#define IPW_ST -//#define IPW_SR -//#define IPW_RI /* Ring Indicator */ static struct usb_device_id usb_ipw_ids[] = { { USB_DEVICE(IPW_VID, IPW_PID) }, @@ -177,7 +167,8 @@ static void ipw_read_bulk_callback(struct urb *urb) return; } - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); tty = port->port.tty; if (tty && urb->actual_length) { @@ -187,15 +178,17 @@ static void ipw_read_bulk_callback(struct urb *urb) } /* Continue trying to always read */ - usb_fill_bulk_urb (port->read_urb, port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, - port->read_urb->transfer_buffer_length, - ipw_read_bulk_callback, port); + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + ipw_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (result) - dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); + dev_err(&port->dev, + "%s - failed resubmitting read urb, error %d\n", + __func__, result); return; } @@ -216,26 +209,30 @@ static int ipw_open(struct tty_struct *tty, if (tty) tty->low_latency = 1; - /* --1: Tell the modem to initialize (we think) From sniffs this is always the - * first thing that gets sent to the modem during opening of the device */ - dbg("%s: Sending SIO_INIT (we guess)",__func__); - result = usb_control_msg(dev, usb_sndctrlpipe(dev,0), - IPW_SIO_INIT, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - 0, - 0, /* index */ - NULL, - 0, - 100000); + /* --1: Tell the modem to initialize (we think) From sniffs this is + * always the first thing that gets sent to the modem during + * opening of the device */ + dbg("%s: Sending SIO_INIT (we guess)", __func__); + result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + IPW_SIO_INIT, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + 0, + 0, /* index */ + NULL, + 0, + 100000); if (result < 0) - dev_err(&port->dev, "Init of modem failed (error = %d)\n", result); + dev_err(&port->dev, + "Init of modem failed (error = %d)\n", result); /* reset the bulk pipes */ - usb_clear_halt(dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress)); - usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); + usb_clear_halt(dev, + usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress)); + usb_clear_halt(dev, + usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); - /*--2: Start reading from the device */ - dbg("%s: setting up bulk read callback",__func__); + /*--2: Start reading from the device */ + dbg("%s: setting up bulk read callback", __func__); usb_fill_bulk_urb(port->read_urb, dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), port->bulk_in_buffer, @@ -243,67 +240,72 @@ static int ipw_open(struct tty_struct *tty, ipw_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result < 0) - dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result); + dbg("%s - usb_submit_urb(read bulk) failed with status %d", + __func__, result); /*--3: Tell the modem to open the floodgates on the rx bulk channel */ - dbg("%s:asking modem for RxRead (RXBULK_ON)",__func__); + dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_RXCTL, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_RXBULK_ON, - 0, /* index */ - NULL, - 0, - 100000); - if (result < 0) - dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result); + IPW_SIO_RXCTL, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_RXBULK_ON, + 0, /* index */ + NULL, + 0, + 100000); + if (result < 0) + dev_err(&port->dev, + "Enabling bulk RxRead failed (error = %d)\n", result); /*--4: setup the initial flowcontrol */ - dbg("%s:setting init flowcontrol (%s)",__func__,buf_flow_init); + dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_HANDFLOW, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - 0, - 0, - buf_flow_init, - 0x10, - 200000); + IPW_SIO_HANDFLOW, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + 0, + 0, + buf_flow_init, + 0x10, + 200000); if (result < 0) - dev_err(&port->dev, "initial flowcontrol failed (error = %d)\n", result); + dev_err(&port->dev, + "initial flowcontrol failed (error = %d)\n", result); /*--5: raise the dtr */ - dbg("%s:raising dtr",__func__); + dbg("%s:raising dtr", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_SET_PIN, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_PIN_SETDTR, - 0, - NULL, - 0, - 200000); + IPW_SIO_SET_PIN, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_PIN_SETDTR, + 0, + NULL, + 0, + 200000); if (result < 0) - dev_err(&port->dev, "setting dtr failed (error = %d)\n", result); + dev_err(&port->dev, + "setting dtr failed (error = %d)\n", result); /*--6: raise the rts */ - dbg("%s:raising rts",__func__); + dbg("%s:raising rts", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_SET_PIN, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_PIN_SETRTS, - 0, - NULL, - 0, - 200000); + IPW_SIO_SET_PIN, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_PIN_SETRTS, + 0, + NULL, + 0, + 200000); if (result < 0) - dev_err(&port->dev, "setting dtr failed (error = %d)\n", result); - + dev_err(&port->dev, + "setting dtr failed (error = %d)\n", result); + kfree(buf_flow_init); return 0; } static void ipw_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct usb_device *dev = port->serial->dev; int result; @@ -314,56 +316,62 @@ static void ipw_close(struct tty_struct *tty, } /*--1: drop the dtr */ - dbg("%s:dropping dtr",__func__); + dbg("%s:dropping dtr", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_SET_PIN, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_PIN_CLRDTR, - 0, - NULL, - 0, - 200000); + IPW_SIO_SET_PIN, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_PIN_CLRDTR, + 0, + NULL, + 0, + 200000); if (result < 0) - dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result); + dev_err(&port->dev, "dropping dtr failed (error = %d)\n", + result); /*--2: drop the rts */ - dbg("%s:dropping rts",__func__); + dbg("%s:dropping rts", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_PIN_CLRRTS, - 0, - NULL, - 0, - 200000); + IPW_SIO_SET_PIN, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_PIN_CLRRTS, + 0, + NULL, + 0, + 200000); if (result < 0) - dev_err(&port->dev, "dropping rts failed (error = %d)\n", result); + dev_err(&port->dev, + "dropping rts failed (error = %d)\n", result); /*--3: purge */ - dbg("%s:sending purge",__func__); + dbg("%s:sending purge", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - 0x03, - 0, - NULL, - 0, - 200000); + IPW_SIO_PURGE, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, + 0x03, + 0, + NULL, + 0, + 200000); if (result < 0) dev_err(&port->dev, "purge failed (error = %d)\n", result); - /* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */ + /* send RXBULK_off (tell modem to stop transmitting bulk data on + rx chan) */ result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - IPW_SIO_RXCTL, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_RXBULK_OFF, - 0, /* index */ - NULL, - 0, - 100000); + IPW_SIO_RXCTL, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_RXBULK_OFF, + 0, /* index */ + NULL, + 0, + 100000); if (result < 0) - dev_err(&port->dev, "Disabling bulk RxRead failed (error = %d)\n", result); + dev_err(&port->dev, + "Disabling bulk RxRead failed (error = %d)\n", result); /* shutdown any in-flight urbs that we know about */ usb_kill_urb(port->read_urb); @@ -393,7 +401,7 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, int ret; dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__, - count, in_interrupt() ); + count, in_interrupt()); if (count == 0) { dbg("%s - write request of 0 bytes", __func__); @@ -424,13 +432,14 @@ static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (ret != 0) { port->write_urb_busy = 0; - dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __func__, ret); + dbg("%s - usb_submit_urb(write bulk) failed with error = %d", + __func__, ret); return ret; } dbg("%s returning %d", __func__, count); return count; -} +} static int ipw_probe(struct usb_serial_port *port) { @@ -489,8 +498,8 @@ module_init(usb_ipw_init); module_exit(usb_ipw_exit); /* Module information */ -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 9e8e2d2ab58ee942b700a9453541d7539b704994 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:12:59 +0100 Subject: tty-usb-iuu-phoenix: Clean up to coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/iuu_phoenix.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index d6541488834..ddff37fa633 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -318,11 +318,10 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count) port->bulk_out_endpointAddress), buf, count, &actual, HZ * 1); - if (status != IUU_OPERATION_OK) { + if (status != IUU_OPERATION_OK) dbg("%s - error = %2x", __func__, status); - } else { + else dbg("%s - write OK !", __func__); - } return status; } @@ -342,12 +341,10 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count) port->bulk_in_endpointAddress), buf, count, &actual, HZ * 1); - if (status != IUU_OPERATION_OK) { + if (status != IUU_OPERATION_OK) dbg("%s - error = %2x", __func__, status); - } else { + else dbg("%s - read OK !", __func__); - } - return status; } @@ -770,14 +767,14 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, if (priv->writelen > 0) { /* buffer already filled but not commited */ spin_unlock_irqrestore(&priv->lock, flags); - return (0); + return 0; } /* fill the buffer */ memcpy(priv->writebuf, buf, count); priv->writelen = count; spin_unlock_irqrestore(&priv->lock, flags); - return (count); + return count; } static void read_rxcmd_callback(struct urb *urb) -- cgit v1.2.3-70-g09d2 From deb91685784fc0bc845c582f8b2bc229cb7bc9da Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:13:08 +0100 Subject: tty-usb-keyspan: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/keyspan.c | 825 ++++++++++++++++++++++--------------------- 1 file changed, 418 insertions(+), 407 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index a371c41bb3a..2b1cfcbf8f9 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -1,29 +1,29 @@ /* Keyspan USB to Serial Converter driver - + (C) Copyright (C) 2000-2001 Hugh Blemings (C) Copyright (C) 2002 Greg Kroah-Hartman - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See http://misc.nu/hugh/keyspan.html for more information. - + Code in this driver inspired by and in a number of places taken from Brian Warner's original Keyspan-PDA driver. This driver has been put together with the support of Innosys, Inc. and Keyspan, Inc the manufacturers of the Keyspan USB-serial products. Thanks Guys :) - + Thanks to Paulus for miscellaneous tidy ups, some largish chunks of much nicer and/or completely new code and (perhaps most uniquely) having the patience to sit down and explain why and where he'd changed - stuff. - - Tip 'o the hat to IBM (and previously Linuxcare :) for supporting + stuff. + + Tip 'o the hat to IBM (and previously Linuxcare :) for supporting staff in their work on open source projects. Change History @@ -70,21 +70,21 @@ Thu May 31 11:56:42 PDT 2001 gkh switched from using spinlock to a semaphore - + (04/08/2001) gb Identify version on module load. - + (11/01/2000) Adam J. Richter usb_device_id table support. - + Tue Oct 10 23:15:33 EST 2000 Hugh Merged Paul's changes with my USA-49W mods. Work in progress still... - + Wed Jul 19 14:00:42 EST 2000 gkh Added module_init and module_exit functions to handle the fact that this driver is a loadable module now. - + Tue Jul 18 16:14:52 EST 2000 Hugh Basic character input/output for USA-19 now mostly works, fixed at 9600 baud for the moment. @@ -107,7 +107,7 @@ #include #include #include -#include +#include #include #include #include "keyspan.h" @@ -132,15 +132,15 @@ struct keyspan_serial_private { struct urb *instat_urb; char instat_buf[INSTAT_BUFLEN]; - /* added to support 49wg, where data from all 4 ports comes in on 1 EP */ - /* and high-speed supported */ + /* added to support 49wg, where data from all 4 ports comes in + on 1 EP and high-speed supported */ struct urb *indat_urb; char indat_buf[INDAT49W_BUFLEN]; /* XXX this one probably will need a lock */ struct urb *glocont_urb; char glocont_buf[GLOCONT_BUFLEN]; - char ctrl_buf[8]; // for EP0 control message + char ctrl_buf[8]; /* for EP0 control message */ }; struct keyspan_port_private { @@ -186,19 +186,19 @@ struct keyspan_port_private { int resend_cont; /* need to resend control packet */ }; - /* Include Keyspan message headers. All current Keyspan Adapters make use of one of five message formats which are referred - to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */ + to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and + within this driver. */ #include "keyspan_usa26msg.h" #include "keyspan_usa28msg.h" #include "keyspan_usa49msg.h" #include "keyspan_usa90msg.h" #include "keyspan_usa67msg.h" - + /* Functions used by new usb-serial code. */ -static int __init keyspan_init (void) +static int __init keyspan_init(void) { int retval; retval = usb_serial_register(&keyspan_pre_device); @@ -214,7 +214,7 @@ static int __init keyspan_init (void) if (retval) goto failed_4port_device_register; retval = usb_register(&keyspan_driver); - if (retval) + if (retval) goto failed_usb_register; info(DRIVER_VERSION ":" DRIVER_DESC); @@ -232,13 +232,13 @@ failed_pre_device_register: return retval; } -static void __exit keyspan_exit (void) +static void __exit keyspan_exit(void) { - usb_deregister (&keyspan_driver); - usb_serial_deregister (&keyspan_pre_device); - usb_serial_deregister (&keyspan_1port_device); - usb_serial_deregister (&keyspan_2port_device); - usb_serial_deregister (&keyspan_4port_device); + usb_deregister(&keyspan_driver); + usb_serial_deregister(&keyspan_pre_device); + usb_serial_deregister(&keyspan_1port_device); + usb_serial_deregister(&keyspan_2port_device); + usb_serial_deregister(&keyspan_4port_device); } module_init(keyspan_init); @@ -249,7 +249,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) struct usb_serial_port *port = tty->driver_data; struct keyspan_port_private *p_priv; - dbg("%s", __func__); + dbg("%s", __func__); p_priv = usb_get_serial_port_data(port); @@ -262,7 +262,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) } -static void keyspan_set_termios (struct tty_struct *tty, +static void keyspan_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { int baud_rate, device_port; @@ -280,7 +280,7 @@ static void keyspan_set_termios (struct tty_struct *tty, /* Baud rate calculation takes baud rate as an integer so other rates can be generated if desired. */ baud_rate = tty_get_baud_rate(tty); - /* If no match or invalid, don't change */ + /* If no match or invalid, don't change */ if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { /* FIXME - more to do here to ensure rate changes cleanly */ @@ -305,13 +305,13 @@ static int keyspan_tiocmget(struct tty_struct *tty, struct file *file) struct usb_serial_port *port = tty->driver_data; struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); unsigned int value; - + value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | ((p_priv->dtr_state) ? TIOCM_DTR : 0) | ((p_priv->cts_state) ? TIOCM_CTS : 0) | ((p_priv->dsr_state) ? TIOCM_DSR : 0) | ((p_priv->dcd_state) ? TIOCM_CAR : 0) | - ((p_priv->ri_state) ? TIOCM_RNG : 0); + ((p_priv->ri_state) ? TIOCM_RNG : 0); return value; } @@ -321,7 +321,7 @@ static int keyspan_tiocmset(struct tty_struct *tty, struct file *file, { struct usb_serial_port *port = tty->driver_data; struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); - + if (set & TIOCM_RTS) p_priv->rts_state = 1; if (set & TIOCM_DTR) @@ -344,19 +344,19 @@ static int keyspan_write(struct tty_struct *tty, int flip; int left, todo; struct urb *this_urb; - int err, maxDataLen, dataOffset; + int err, maxDataLen, dataOffset; p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; if (d_details->msg_format == msg_usa90) { - maxDataLen = 64; + maxDataLen = 64; dataOffset = 0; } else { maxDataLen = 63; dataOffset = 1; } - + dbg("%s - for port %d (%d chars), flip=%d", __func__, port->number, count, p_priv->out_flip); @@ -366,37 +366,40 @@ static int keyspan_write(struct tty_struct *tty, todo = maxDataLen; flip = p_priv->out_flip; - + /* Check we have a valid urb/endpoint before we use it... */ - if ((this_urb = p_priv->out_urbs[flip]) == NULL) { + this_urb = p_priv->out_urbs[flip]; + if (this_urb == NULL) { /* no bulk out, so return 0 bytes written */ dbg("%s - no output urb :(", __func__); return count; } - dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip); + dbg("%s - endpoint %d flip %d", + __func__, usb_pipeendpoint(this_urb->pipe), flip); if (this_urb->status == -EINPROGRESS) { - if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) + if (time_before(jiffies, + p_priv->tx_start_time[flip] + 10 * HZ)) break; usb_unlink_urb(this_urb); break; } - /* First byte in buffer is "last flag" (except for usa19hx) - unused so - for now so set to zero */ + /* First byte in buffer is "last flag" (except for usa19hx) + - unused so for now so set to zero */ ((char *)this_urb->transfer_buffer)[0] = 0; - memcpy (this_urb->transfer_buffer + dataOffset, buf, todo); + memcpy(this_urb->transfer_buffer + dataOffset, buf, todo); buf += todo; /* send the data out the bulk port */ this_urb->transfer_buffer_length = todo + dataOffset; this_urb->dev = port->serial->dev; - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(this_urb, GFP_ATOMIC); + if (err != 0) dbg("usb_submit_urb(write bulk) failed (%d)", err); - } p_priv->tx_start_time[flip] = jiffies; /* Flip for next time if usa26 or usa28 interface @@ -416,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); @@ -431,13 +434,14 @@ static void usa26_indat_callback(struct urb *urb) if (tty && urb->actual_length) { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { - /* no errors on individual bytes, only possible overrun err*/ + /* no errors on individual bytes, only + possible overrun err */ if (data[0] & RXERROR_OVERRUN) - err = TTY_OVERRUN; - else err = 0; - for (i = 1; i < urb->actual_length ; ++i) { + err = TTY_OVERRUN; + else + err = 0; + for (i = 1; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], err); - } } else { /* some bytes had errors, every byte has status */ dbg("%s - RX error!!!!", __func__); @@ -455,17 +459,19 @@ static void usa26_indat_callback(struct urb *urb) } tty_flip_buffer_push(tty); } - - /* Resubmit urb so we continue receiving */ + + /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->port.count) - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } + if (port->port.count) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) + dbg("%s - resubmit read urb failed. (%d)", + __func__, err); + } return; } - /* Outdat handling is common for all devices */ +/* Outdat handling is common for all devices */ static void usa2x_outdat_callback(struct urb *urb) { struct usb_serial_port *port; @@ -473,7 +479,7 @@ static void usa2x_outdat_callback(struct urb *urb) port = urb->context; p_priv = usb_get_serial_port_data(port); - dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); + dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); if (port->port.count) usb_serial_port_softint(port); @@ -481,8 +487,8 @@ static void usa2x_outdat_callback(struct urb *urb) static void usa26_inack_callback(struct urb *urb) { - dbg ("%s", __func__); - + dbg("%s", __func__); + } static void usa26_outcont_callback(struct urb *urb) @@ -494,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __func__); - keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1); + dbg("%s - sending setup", __func__); + keyspan_usa26_send_setup(port->serial, port, + p_priv->resend_cont - 1); } } @@ -531,14 +538,14 @@ static void usa26_instat_callback(struct urb *urb) /* Now do something useful with the data */ - /* Check port number from message and retrieve private data */ + /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __func__, msg->port); + dbg("%s - Unexpected port number %d", __func__, msg->port); goto exit; } port = serial->port[msg->port]; p_priv = usb_get_serial_port_data(port); - + /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); @@ -553,19 +560,18 @@ static void usa26_instat_callback(struct urb *urb) /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } - + /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } exit: ; } static void usa26_glocont_callback(struct urb *urb) { - dbg ("%s", __func__); - + dbg("%s", __func__); } @@ -578,7 +584,7 @@ static void usa28_indat_callback(struct urb *urb) struct keyspan_port_private *p_priv; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); port = urb->context; p_priv = usb_get_serial_port_data(port); @@ -600,18 +606,19 @@ static void usa28_indat_callback(struct urb *urb) tty = port->port.tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { + for (i = 0; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], 0); - } tty_flip_buffer_push(tty); } /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->port.count) - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } + if (port->port.count) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) + dbg("%s - resubmit read urb failed. (%d)", + __func__, err); + } p_priv->in_flip ^= 1; urb = p_priv->in_urbs[p_priv->in_flip]; @@ -620,7 +627,7 @@ static void usa28_indat_callback(struct urb *urb) static void usa28_inack_callback(struct urb *urb) { - dbg ("%s", __func__); + dbg("%s", __func__); } static void usa28_outcont_callback(struct urb *urb) @@ -632,8 +639,9 @@ static void usa28_outcont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __func__); - keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1); + dbg("%s - sending setup", __func__); + keyspan_usa28_send_setup(port->serial, port, + p_priv->resend_cont - 1); } } @@ -663,19 +671,18 @@ static void usa28_instat_callback(struct urb *urb) /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]);*/ - - /* Now do something useful with the data */ - msg = (struct keyspan_usa28_portStatusMessage *)data; + /* Now do something useful with the data */ + msg = (struct keyspan_usa28_portStatusMessage *)data; - /* Check port number from message and retrieve private data */ + /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __func__, msg->port); + dbg("%s - Unexpected port number %d", __func__, msg->port); goto exit; } port = serial->port[msg->port]; p_priv = usb_get_serial_port_data(port); - + /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ? 1 : 0); @@ -693,15 +700,15 @@ static void usa28_instat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } exit: ; } static void usa28_glocont_callback(struct urb *urb) { - dbg ("%s", __func__); + dbg("%s", __func__); } @@ -712,7 +719,7 @@ static void usa49_glocont_callback(struct urb *urb) struct keyspan_port_private *p_priv; int i; - dbg ("%s", __func__); + dbg("%s", __func__); serial = urb->context; for (i = 0; i < serial->num_ports; ++i) { @@ -720,8 +727,9 @@ static void usa49_glocont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __func__); - keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1); + dbg("%s - sending setup", __func__); + keyspan_usa49_send_setup(serial, port, + p_priv->resend_cont - 1); break; } } @@ -740,7 +748,7 @@ static void usa49_instat_callback(struct urb *urb) int old_dcd_state; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); serial = urb->context; @@ -749,7 +757,8 @@ static void usa49_instat_callback(struct urb *urb) return; } - if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) { + if (urb->actual_length != + sizeof(struct keyspan_usa49_portStatusMessage)) { dbg("%s - bad length %d", __func__, urb->actual_length); goto exit; } @@ -757,18 +766,19 @@ static void usa49_instat_callback(struct urb *urb) /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10]);*/ - - /* Now do something useful with the data */ + + /* Now do something useful with the data */ msg = (struct keyspan_usa49_portStatusMessage *)data; - /* Check port number from message and retrieve private data */ + /* Check port number from message and retrieve private data */ if (msg->portNumber >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __func__, msg->portNumber); + dbg("%s - Unexpected port number %d", + __func__, msg->portNumber); goto exit; } port = serial->port[msg->portNumber]; p_priv = usb_get_serial_port_data(port); - + /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ? 1 : 0); @@ -784,18 +794,18 @@ static void usa49_instat_callback(struct urb *urb) /* wake_up_interruptible(&p_priv->open_wait); */ } - /* Resubmit urb so we continue receiving */ + /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } exit: ; } static void usa49_inack_callback(struct urb *urb) { - dbg ("%s", __func__); + dbg("%s", __func__); } static void usa49_indat_callback(struct urb *urb) @@ -807,7 +817,7 @@ static void usa49_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); @@ -823,9 +833,8 @@ static void usa49_indat_callback(struct urb *urb) /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no error on any byte */ - for (i = 1; i < urb->actual_length ; ++i) { + for (i = 1; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], 0); - } } else { /* some bytes had errors, every byte has status */ for (i = 0; i + 1 < urb->actual_length; i += 2) { @@ -842,13 +851,15 @@ static void usa49_indat_callback(struct urb *urb) } tty_flip_buffer_push(tty); } - - /* Resubmit urb so we continue receiving */ + + /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->port.count) - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } + if (port->port.count) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) + dbg("%s - resubmit read urb failed. (%d)", + __func__, err); + } } static void usa49wg_indat_callback(struct urb *urb) @@ -860,7 +871,7 @@ static void usa49wg_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); serial = urb->context; @@ -878,7 +889,7 @@ static void usa49wg_indat_callback(struct urb *urb) /* Check port number from message*/ if (data[i] >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", + dbg("%s - Unexpected port number %d", __func__, data[i]); return; } @@ -931,7 +942,7 @@ static void usa49wg_indat_callback(struct urb *urb) /* not used, usa-49 doesn't have per-port control endpoints */ static void usa49_outcont_callback(struct urb *urb) { - dbg ("%s", __func__); + dbg("%s", __func__); } static void usa90_indat_callback(struct urb *urb) @@ -944,7 +955,7 @@ static void usa90_indat_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); endpoint = usb_pipeendpoint(urb->pipe); @@ -959,27 +970,25 @@ static void usa90_indat_callback(struct urb *urb) tty = port->port.tty; if (urb->actual_length) { - /* if current mode is DMA, looks like usa28 format - otherwise looks like usa26 data format */ + otherwise looks like usa26 data format */ if (p_priv->baud > 57600) { - for (i = 0; i < urb->actual_length ; ++i) + for (i = 0; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], 0); - } - else { - + } else { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { - /* no errors on individual bytes, only possible overrun err*/ + /* no errors on individual bytes, only + possible overrun err*/ if (data[0] & RXERROR_OVERRUN) - err = TTY_OVERRUN; - else err = 0; - for (i = 1; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], err); - - } - else { + err = TTY_OVERRUN; + else + err = 0; + for (i = 1; i < urb->actual_length ; ++i) + tty_insert_flip_char(tty, data[i], + err); + } else { /* some bytes had errors, every byte has status */ dbg("%s - RX error!!!!", __func__); for (i = 0; i + 1 < urb->actual_length; i += 2) { @@ -991,19 +1000,22 @@ static void usa90_indat_callback(struct urb *urb) if (stat & RXERROR_PARITY) flag |= TTY_PARITY; /* XXX should handle break (0x10) */ - tty_insert_flip_char(tty, data[i+1], flag); + tty_insert_flip_char(tty, data[i+1], + flag); } } } tty_flip_buffer_push(tty); } - + /* Resubmit urb so we continue receiving */ urb->dev = port->serial->dev; - if (port->port.count) - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { - dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } + if (port->port.count) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) + dbg("%s - resubmit read urb failed. (%d)", + __func__, err); + } return; } @@ -1035,7 +1047,7 @@ static void usa90_instat_callback(struct urb *urb) port = serial->port[0]; p_priv = usb_get_serial_port_data(port); - + /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; p_priv->cts_state = ((msg->cts) ? 1 : 0); @@ -1050,12 +1062,12 @@ static void usa90_instat_callback(struct urb *urb) /* else */ /* wake_up_interruptible(&p_priv->open_wait); */ } - + /* Resubmit urb so we continue receiving */ urb->dev = serial->dev; - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err != 0) dbg("%s - resubmit read urb failed. (%d)", __func__, err); - } exit: ; } @@ -1069,8 +1081,9 @@ static void usa90_outcont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __func__); - keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1); + dbg("%s - sending setup", __func__); + keyspan_usa90_send_setup(port->serial, port, + p_priv->resend_cont - 1); } } @@ -1086,7 +1099,7 @@ static void usa67_instat_callback(struct urb *urb) int old_dcd_state; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); serial = urb->context; @@ -1095,7 +1108,8 @@ static void usa67_instat_callback(struct urb *urb) return; } - if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) { + if (urb->actual_length != + sizeof(struct keyspan_usa67_portStatusMessage)) { dbg("%s - bad length %d", __func__, urb->actual_length); return; } @@ -1106,7 +1120,7 @@ static void usa67_instat_callback(struct urb *urb) /* Check port number from message and retrieve private data */ if (msg->port >= serial->num_ports) { - dbg ("%s - Unexpected port number %d", __func__, msg->port); + dbg("%s - Unexpected port number %d", __func__, msg->port); return; } @@ -1140,7 +1154,7 @@ static void usa67_glocont_callback(struct urb *urb) struct keyspan_port_private *p_priv; int i; - dbg ("%s", __func__); + dbg("%s", __func__); serial = urb->context; for (i = 0; i < serial->num_ports; ++i) { @@ -1148,7 +1162,7 @@ static void usa67_glocont_callback(struct urb *urb) p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { - dbg ("%s - sending setup", __func__); + dbg("%s - sending setup", __func__); keyspan_usa67_send_setup(serial, port, p_priv->resend_cont - 1); break; @@ -1171,20 +1185,23 @@ static int keyspan_write_room(struct tty_struct *tty) /* FIXME: locking */ if (d_details->msg_format == msg_usa90) - data_len = 64; + data_len = 64; else data_len = 63; flip = p_priv->out_flip; /* Check both endpoints to see if any are available. */ - if ((this_urb = p_priv->out_urbs[flip]) != NULL) { + this_urb = p_priv->out_urbs[flip]; + if (this_urb != NULL) { if (this_urb->status != -EINPROGRESS) - return (data_len); - flip = (flip + 1) & d_details->outdat_endp_flip; - if ((this_urb = p_priv->out_urbs[flip]) != NULL) + return data_len; + flip = (flip + 1) & d_details->outdat_endp_flip; + this_urb = p_priv->out_urbs[flip]; + if (this_urb != NULL) { if (this_urb->status != -EINPROGRESS) - return (data_len); + return data_len; + } } return 0; } @@ -1222,25 +1239,28 @@ static int keyspan_open(struct tty_struct *tty, /* Reset low level data toggle and start reading from endpoints */ for (i = 0; i < 2; i++) { - if ((urb = p_priv->in_urbs[i]) == NULL) + urb = p_priv->in_urbs[i]; + if (urb == NULL) continue; urb->dev = serial->dev; - /* make sure endpoint data toggle is synchronized with the device */ - + /* make sure endpoint data toggle is synchronized + with the device */ usb_clear_halt(urb->dev, urb->pipe); - - if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { - dbg("%s - submit urb %d failed (%d)", __func__, i, err); - } + err = usb_submit_urb(urb, GFP_KERNEL); + if (err != 0) + dbg("%s - submit urb %d failed (%d)", + __func__, i, err); } /* Reset low level data toggle on out endpoints */ for (i = 0; i < 2; i++) { - if ((urb = p_priv->out_urbs[i]) == NULL) + urb = p_priv->out_urbs[i]; + if (urb == NULL) continue; urb->dev = serial->dev; - /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ + /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), + usb_pipeout(urb->pipe), 0); */ } /* get the terminal config for the setup message now so we don't @@ -1264,8 +1284,8 @@ static int keyspan_open(struct tty_struct *tty, p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; keyspan_send_setup(port, 1); - //mdelay(100); - //keyspan_set_termios(port, NULL); + /* mdelay(100); */ + /* keyspan_set_termios(port, NULL); */ return 0; } @@ -1287,15 +1307,15 @@ static void keyspan_close(struct tty_struct *tty, dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); - + p_priv->rts_state = 0; p_priv->dtr_state = 0; - + if (serial->dev) { keyspan_send_setup(port, 2); /* pilot-xfer seems to work best with this delay */ mdelay(100); - // keyspan_set_termios(port, NULL); + /* keyspan_set_termios(port, NULL); */ } /*while (p_priv->outcont_urb->status == -EINPROGRESS) { @@ -1317,8 +1337,8 @@ static void keyspan_close(struct tty_struct *tty, port->port.tty = NULL; } - /* download the firmware to a pre-renumeration device */ -static int keyspan_fake_startup (struct usb_serial *serial) +/* download the firmware to a pre-renumeration device */ +static int keyspan_fake_startup(struct usb_serial *serial) { int response; const struct ihex_binrec *record; @@ -1328,10 +1348,11 @@ static int keyspan_fake_startup (struct usb_serial *serial) dbg("Keyspan startup version %04x product %04x", le16_to_cpu(serial->dev->descriptor.bcdDevice), le16_to_cpu(serial->dev->descriptor.idProduct)); - - if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) { + + if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) + != 0x8000) { dbg("Firmware already loaded. Quitting."); - return(1); + return 1; } /* Select firmware image on the basis of idProduct */ @@ -1355,11 +1376,11 @@ static int keyspan_fake_startup (struct usb_serial *serial) case keyspan_usa19_pre_product_id: fw_name = "keyspan/usa19.fw"; break; - + case keyspan_usa19qi_pre_product_id: fw_name = "keyspan/usa19qi.fw"; break; - + case keyspan_mpr_pre_product_id: fw_name = "keyspan/mpr.fw"; break; @@ -1367,15 +1388,15 @@ static int keyspan_fake_startup (struct usb_serial *serial) case keyspan_usa19qw_pre_product_id: fw_name = "keyspan/usa19qw.fw"; break; - + case keyspan_usa18x_pre_product_id: fw_name = "keyspan/usa18x.fw"; break; - + case keyspan_usa19w_pre_product_id: fw_name = "keyspan/usa19w.fw"; break; - + case keyspan_usa49w_pre_product_id: fw_name = "keyspan/usa49w.fw"; break; @@ -1407,8 +1428,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) (unsigned char *)record->data, be16_to_cpu(record->len), 0xa0); if (response < 0) { - dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan" - "firmware (%d %04X %p %d)\n", + dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n", response, be32_to_cpu(record->addr), record->data, be16_to_cpu(record->len)); break; @@ -1421,7 +1441,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) response = ezusb_set_reset(serial, 0); /* we don't want this device to have a driver assigned to it. */ - return (1); + return 1; } /* Helper functions used by keyspan_setup_urbs */ @@ -1443,7 +1463,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se return NULL; } -static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, +static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, int dir, void *ctx, char *buf, int len, void (*callback)(struct urb *)) { @@ -1454,10 +1474,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, if (endpoint == -1) return NULL; /* endpoint not needed */ - dbg ("%s - alloc for endpoint %d.", __func__, endpoint); + dbg("%s - alloc for endpoint %d.", __func__, endpoint); urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ if (urb == NULL) { - dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint); + dbg("%s - alloc for endpoint %d failed.", __func__, endpoint); return NULL; } @@ -1530,7 +1550,7 @@ static struct callbacks { }, { /* msg_usa90 callbacks */ .instat_callback = usa90_instat_callback, - .glocont_callback = usa28_glocont_callback, + .glocont_callback = usa28_glocont_callback, .indat_callback = usa90_indat_callback, .outdat_callback = usa2x_outdat_callback, .inack_callback = usa28_inack_callback, @@ -1558,16 +1578,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial) struct callbacks *cback; int endp; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; - /* Setup values for the various callback routines */ + /* Setup values for the various callback routines */ cback = &keyspan_callbacks[d_details->msg_format]; - /* Allocate and set up urbs for each one that is in use, - starting with instat endpoints */ + /* Allocate and set up urbs for each one that is in use, + starting with instat endpoints */ s_priv->instat_urb = keyspan_setup_urb (serial, d_details->instat_endpoint, USB_DIR_IN, serial, s_priv->instat_buf, INSTAT_BUFLEN, @@ -1583,8 +1603,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial) serial, s_priv->glocont_buf, GLOCONT_BUFLEN, cback->glocont_callback); - /* Setup endpoints for each port specific thing */ - for (i = 0; i < d_details->num_ports; i ++) { + /* Setup endpoints for each port specific thing */ + for (i = 0; i < d_details->num_ports; i++) { port = serial->port[i]; p_priv = usb_get_serial_port_data(port); @@ -1620,8 +1640,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) (serial, d_details->outcont_endpoints[i], USB_DIR_OUT, port, p_priv->outcont_buffer, 64, cback->outcont_callback); - } - + } } /* usa19 function doesn't require prescaler */ @@ -1629,46 +1648,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) { u32 b16, /* baud rate times 16 (actual rate used internally) */ - div, /* divisor */ + div, /* divisor */ cnt; /* inverse of divisor (programmed into 8051) */ - - dbg ("%s - %d.", __func__, baud_rate); - /* prevent divide by zero... */ - if( (b16 = (baud_rate * 16L)) == 0) { - return (KEYSPAN_INVALID_BAUD_RATE); - } - - /* Any "standard" rate over 57k6 is marginal on the USA-19 - as we run out of divisor resolution. */ - if (baud_rate > 57600) { - return (KEYSPAN_INVALID_BAUD_RATE); - } - - /* calculate the divisor and the counter (its inverse) */ - if( (div = (baudclk / b16)) == 0) { - return (KEYSPAN_INVALID_BAUD_RATE); - } - else { + dbg("%s - %d.", __func__, baud_rate); + + /* prevent divide by zero... */ + b16 = baud_rate * 16L; + if (b16 == 0) + return KEYSPAN_INVALID_BAUD_RATE; + /* Any "standard" rate over 57k6 is marginal on the USA-19 + as we run out of divisor resolution. */ + if (baud_rate > 57600) + return KEYSPAN_INVALID_BAUD_RATE; + + /* calculate the divisor and the counter (its inverse) */ + div = baudclk / b16; + if (div == 0) + return KEYSPAN_INVALID_BAUD_RATE; + else cnt = 0 - div; - } - if(div > 0xffff) { - return (KEYSPAN_INVALID_BAUD_RATE); - } + if (div > 0xffff) + return KEYSPAN_INVALID_BAUD_RATE; - /* return the counter values if non-null */ - if (rate_low) { + /* return the counter values if non-null */ + if (rate_low) *rate_low = (u8) (cnt & 0xff); - } - if (rate_hi) { + if (rate_hi) *rate_hi = (u8) ((cnt >> 8) & 0xff); - } - if (rate_low && rate_hi) { - dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); - } - - return (KEYSPAN_BAUD_RATE_OK); + if (rate_low && rate_hi) + dbg("%s - %d %02x %02x.", + __func__, baud_rate, *rate_hi, *rate_low); + return KEYSPAN_BAUD_RATE_OK; } /* usa19hs function doesn't require prescaler */ @@ -1676,34 +1688,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) { u32 b16, /* baud rate times 16 (actual rate used internally) */ - div; /* divisor */ - - dbg ("%s - %d.", __func__, baud_rate); + div; /* divisor */ - /* prevent divide by zero... */ - if( (b16 = (baud_rate * 16L)) == 0) - return (KEYSPAN_INVALID_BAUD_RATE); - + dbg("%s - %d.", __func__, baud_rate); + /* prevent divide by zero... */ + b16 = baud_rate * 16L; + if (b16 == 0) + return KEYSPAN_INVALID_BAUD_RATE; - /* calculate the divisor */ - if( (div = (baudclk / b16)) == 0) - return (KEYSPAN_INVALID_BAUD_RATE); + /* calculate the divisor */ + div = baudclk / b16; + if (div == 0) + return KEYSPAN_INVALID_BAUD_RATE; - if(div > 0xffff) - return (KEYSPAN_INVALID_BAUD_RATE); + if (div > 0xffff) + return KEYSPAN_INVALID_BAUD_RATE; - /* return the counter values if non-null */ - if (rate_low) + /* return the counter values if non-null */ + if (rate_low) *rate_low = (u8) (div & 0xff); - - if (rate_hi) + + if (rate_hi) *rate_hi = (u8) ((div >> 8) & 0xff); - - if (rate_low && rate_hi) - dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); - - return (KEYSPAN_BAUD_RATE_OK); + + if (rate_low && rate_hi) + dbg("%s - %d %02x %02x.", + __func__, baud_rate, *rate_hi, *rate_low); + + return KEYSPAN_BAUD_RATE_OK; } static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, @@ -1711,64 +1724,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, { u32 b16, /* baud rate times 16 (actual rate used internally) */ clk, /* clock with 13/8 prescaler */ - div, /* divisor using 13/8 prescaler */ + div, /* divisor using 13/8 prescaler */ res, /* resulting baud rate using 13/8 prescaler */ diff, /* error using 13/8 prescaler */ smallest_diff; u8 best_prescaler; int i; - dbg ("%s - %d.", __func__, baud_rate); + dbg("%s - %d.", __func__, baud_rate); - /* prevent divide by zero */ - if( (b16 = baud_rate * 16L) == 0) { - return (KEYSPAN_INVALID_BAUD_RATE); - } + /* prevent divide by zero */ + b16 = baud_rate * 16L; + if (b16 == 0) + return KEYSPAN_INVALID_BAUD_RATE; - /* Calculate prescaler by trying them all and looking - for best fit */ - - /* start with largest possible difference */ + /* Calculate prescaler by trying them all and looking + for best fit */ + + /* start with largest possible difference */ smallest_diff = 0xffffffff; /* 0 is an invalid prescaler, used as a flag */ best_prescaler = 0; - for(i = 8; i <= 0xff; ++i) { + for (i = 8; i <= 0xff; ++i) { clk = (baudclk * 8) / (u32) i; - - if( (div = clk / b16) == 0) { + + div = clk / b16; + if (div == 0) continue; - } res = clk / div; - diff= (res > b16) ? (res-b16) : (b16-res); + diff = (res > b16) ? (res-b16) : (b16-res); - if(diff < smallest_diff) { + if (diff < smallest_diff) { best_prescaler = i; smallest_diff = diff; } } - if(best_prescaler == 0) { - return (KEYSPAN_INVALID_BAUD_RATE); - } + if (best_prescaler == 0) + return KEYSPAN_INVALID_BAUD_RATE; clk = (baudclk * 8) / (u32) best_prescaler; div = clk / b16; - /* return the divisor and prescaler if non-null */ - if (rate_low) { + /* return the divisor and prescaler if non-null */ + if (rate_low) *rate_low = (u8) (div & 0xff); - } - if (rate_hi) { + if (rate_hi) *rate_hi = (u8) ((div >> 8) & 0xff); - } if (prescaler) { *prescaler = best_prescaler; /* dbg("%s - %d %d", __func__, *prescaler, div); */ } - return (KEYSPAN_BAUD_RATE_OK); + return KEYSPAN_BAUD_RATE_OK; } /* USA-28 supports different maximum baud rates on each port */ @@ -1776,57 +1786,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum) { u32 b16, /* baud rate times 16 (actual rate used internally) */ - div, /* divisor */ + div, /* divisor */ cnt; /* inverse of divisor (programmed into 8051) */ - dbg ("%s - %d.", __func__, baud_rate); + dbg("%s - %d.", __func__, baud_rate); /* prevent divide by zero */ - if ((b16 = baud_rate * 16L) == 0) - return (KEYSPAN_INVALID_BAUD_RATE); - - /* calculate the divisor and the counter (its inverse) */ - if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) { - return (KEYSPAN_INVALID_BAUD_RATE); - } - else { + b16 = baud_rate * 16L; + if (b16 == 0) + return KEYSPAN_INVALID_BAUD_RATE; + + /* calculate the divisor and the counter (its inverse) */ + div = KEYSPAN_USA28_BAUDCLK / b16; + if (div == 0) + return KEYSPAN_INVALID_BAUD_RATE; + else cnt = 0 - div; - } - /* check for out of range, based on portnum, - and return result */ - if(portnum == 0) { - if(div > 0xffff) - return (KEYSPAN_INVALID_BAUD_RATE); - } - else { - if(portnum == 1) { - if(div > 0xff) { - return (KEYSPAN_INVALID_BAUD_RATE); - } - } - else { - return (KEYSPAN_INVALID_BAUD_RATE); - } + /* check for out of range, based on portnum, + and return result */ + if (portnum == 0) { + if (div > 0xffff) + return KEYSPAN_INVALID_BAUD_RATE; + } else { + if (portnum == 1) { + if (div > 0xff) + return KEYSPAN_INVALID_BAUD_RATE; + } else + return KEYSPAN_INVALID_BAUD_RATE; } /* return the counter values if not NULL (port 1 will ignore retHi) */ - if (rate_low) { + if (rate_low) *rate_low = (u8) (cnt & 0xff); - } - if (rate_hi) { + if (rate_hi) *rate_hi = (u8) ((cnt >> 8) & 0xff); - } - dbg ("%s - %d OK.", __func__, baud_rate); - return (KEYSPAN_BAUD_RATE_OK); + dbg("%s - %d OK.", __func__, baud_rate); + return KEYSPAN_BAUD_RATE_OK; } static int keyspan_usa26_send_setup(struct usb_serial *serial, struct usb_serial_port *port, int reset_port) { - struct keyspan_usa26_portControlMessage msg; + struct keyspan_usa26_portControlMessage msg; struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; @@ -1834,7 +1838,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, struct urb *this_urb; int device_port, err; - dbg ("%s reset=%d", __func__, reset_port); + dbg("%s reset=%d", __func__, reset_port); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1857,22 +1861,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __func__); */ + /* dbg("%s - already writing", __func__); */ mdelay(5); - return(-1); + return -1; } - memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage)); - - /* Only set baud rate if it's changed */ + memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage)); + + /* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking = 0xff; if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { + dbg("%s - Invalid baud rate %d requested, using 9600.", + __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ msg.prescaler = 10; @@ -1898,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, if (p_priv->cflag & PARENB) { /* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag & PARODD)? - USA_PARITY_ODD: USA_PARITY_EVEN; + USA_PARITY_ODD : USA_PARITY_EVEN; } msg.setLcr = 0xff; @@ -1939,7 +1943,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, /* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff = 0; msg.txFlush = 0; msg.txBreak = (p_priv->break_on); @@ -1951,23 +1955,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, msg.resetDataToggle = 0x0; } - /* Do handshaking outputs */ + /* Do handshaking outputs */ msg.setTxTriState_setRts = 0xff; msg.txTriState_rts = p_priv->rts_state; msg.setHskoa_setDtr = 0xff; msg.hskoa_dtr = p_priv->dtr_state; - + p_priv->resend_cont = 0; - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); - + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); + /* send the data out the device on control endpoint */ this_urb->transfer_buffer_length = sizeof(msg); this_urb->dev = serial->dev; - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(this_urb, GFP_ATOMIC); + if (err != 0) dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); - } #if 0 else { dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ @@ -1983,14 +1987,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, struct usb_serial_port *port, int reset_port) { - struct keyspan_usa28_portControlMessage msg; + struct keyspan_usa28_portControlMessage msg; struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; struct urb *this_urb; int device_port, err; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -1998,7 +2002,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, device_port = port->number - port->serial->minor; /* only do something if we have a bulk out endpoint */ - if ((this_urb = p_priv->outcont_urb) == NULL) { + this_urb = p_priv->outcont_urb; + if (this_urb == NULL) { dbg("%s - oops no urb.", __func__); return -1; } @@ -2008,17 +2013,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - dbg ("%s already writing", __func__); + dbg("%s already writing", __func__); mdelay(5); - return(-1); + return -1; } - memset(&msg, 0, sizeof (struct keyspan_usa28_portControlMessage)); + memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage)); msg.setBaudRate = 1; if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, - &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud); + &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) { + dbg("%s - Invalid baud rate requested %d.", + __func__, p_priv->baud); msg.baudLo = 0xff; msg.baudHi = 0xb2; /* Values for 9600 baud */ } @@ -2029,7 +2035,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, msg.ctsFlowControl = (p_priv->flow_control == flow_cts); msg.xonFlowControl = 0; - /* Do handshaking outputs, DTR is inverted relative to RTS */ + /* Do handshaking outputs, DTR is inverted relative to RTS */ msg.rts = p_priv->rts_state; msg.dtr = p_priv->dtr_state; @@ -2071,7 +2077,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, } /* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff = 0; msg.txFlush = 0; msg.txForceXoff = 0; @@ -2085,15 +2091,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, } p_priv->resend_cont = 0; - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); /* send the data out the device on control endpoint */ this_urb->transfer_buffer_length = sizeof(msg); this_urb->dev = serial->dev; - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(this_urb, GFP_ATOMIC); + if (err != 0) dbg("%s - usb_submit_urb(setup) failed", __func__); - } #if 0 else { dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, @@ -2116,7 +2122,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, struct urb *this_urb; int err, device_port; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2127,7 +2133,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, /* Work out which port within the device is being setup */ device_port = port->number - port->serial->minor; - dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); + dbg("%s - endpoint %d port %d (%d)", + __func__, usb_pipeendpoint(this_urb->pipe), + port->number, device_port); /* Make sure we have an urb then send the message */ if (this_urb == NULL) { @@ -2141,30 +2149,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __func__); */ + /* dbg("%s - already writing", __func__); */ mdelay(5); - return(-1); + return -1; } - memset(&msg, 0, sizeof (struct keyspan_usa49_portControlMessage)); + memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage)); /*msg.portNumber = port->number;*/ msg.portNumber = device_port; - - /* Only set baud rate if it's changed */ + + /* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking = 0xff; if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { + dbg("%s - Invalid baud rate %d requested, using 9600.", + __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ msg.prescaler = 10; } - //msg.setPrescaler = 0xff; + /* msg.setPrescaler = 0xff; */ } msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1; @@ -2185,19 +2193,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, if (p_priv->cflag & PARENB) { /* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag & PARODD)? - USA_PARITY_ODD: USA_PARITY_EVEN; + USA_PARITY_ODD : USA_PARITY_EVEN; } msg.setLcr = 0xff; msg.ctsFlowControl = (p_priv->flow_control == flow_cts); msg.xonFlowControl = 0; msg.setFlowControl = 0xff; - + msg.forwardingLength = 16; msg.xonChar = 17; msg.xoffChar = 19; - /* Opening port */ + /* Opening port */ if (reset_port == 1) { msg._txOn = 1; msg._txOff = 0; @@ -2229,7 +2237,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, } /* Sending intermediate configs */ else { - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff = 0; msg.txFlush = 0; msg.txBreak = (p_priv->break_on); @@ -2243,16 +2251,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, msg.disablePort = 0; } - /* Do handshaking outputs */ + /* Do handshaking outputs */ msg.setRts = 0xff; msg.rts = p_priv->rts_state; msg.setDtr = 0xff; msg.dtr = p_priv->dtr_state; - + p_priv->resend_cont = 0; - /* if the device is a 49wg, we send control message on usb control EP 0 */ + /* if the device is a 49wg, we send control message on usb + control EP 0 */ if (d_details->product_id == keyspan_usa49wg_product_id) { dr = (void *)(s_priv->ctrl_buf); @@ -2262,23 +2271,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, dr->wIndex = 0; dr->wLength = cpu_to_le16(sizeof(msg)); - memcpy (s_priv->glocont_buf, &msg, sizeof(msg)); + memcpy(s_priv->glocont_buf, &msg, sizeof(msg)); - usb_fill_control_urb(this_urb, serial->dev, usb_sndctrlpipe(serial->dev, 0), - (unsigned char *)dr, s_priv->glocont_buf, sizeof(msg), - usa49_glocont_callback, serial); + usb_fill_control_urb(this_urb, serial->dev, + usb_sndctrlpipe(serial->dev, 0), + (unsigned char *)dr, s_priv->glocont_buf, + sizeof(msg), usa49_glocont_callback, serial); } else { memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); - + /* send the data out the device on control endpoint */ this_urb->transfer_buffer_length = sizeof(msg); this_urb->dev = serial->dev; } - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(this_urb, GFP_ATOMIC); + if (err != 0) dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); - } #if 0 else { dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, @@ -2294,7 +2304,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, struct usb_serial_port *port, int reset_port) { - struct keyspan_usa90_portControlMessage msg; + struct keyspan_usa90_portControlMessage msg; struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; @@ -2302,14 +2312,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, int err; u8 prescaler; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; /* only do something if we have a bulk out endpoint */ - if ((this_urb = p_priv->outcont_urb) == NULL) { + this_urb = p_priv->outcont_urb; + if (this_urb == NULL) { dbg("%s - oops no urb.", __func__); return -1; } @@ -2319,24 +2330,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - dbg ("%s already writing", __func__); + dbg("%s already writing", __func__); mdelay(5); - return(-1); + return -1; } - memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage)); + memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage)); - /* Only set baud rate if it's changed */ + /* Only set baud rate if it's changed */ if (p_priv->old_baud != p_priv->baud) { p_priv->old_baud = p_priv->baud; msg.setClocking = 0x01; if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, - p_priv->baud); + &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) { + dbg("%s - Invalid baud rate %d requested, using 9600.", + __func__, p_priv->baud); p_priv->baud = 9600; - d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, + d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, &msg.baudHi, &msg.baudLo, &prescaler, 0); } msg.setRxMode = 1; @@ -2344,13 +2355,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, } /* modes must always be correctly specified */ - if (p_priv->baud > 57600) - { + if (p_priv->baud > 57600) { msg.rxMode = RXMODE_DMA; msg.txMode = TXMODE_DMA; - } - else - { + } else { msg.rxMode = RXMODE_BYHAND; msg.txMode = TXMODE_BYHAND; } @@ -2373,7 +2381,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, if (p_priv->cflag & PARENB) { /* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag & PARODD)? - USA_PARITY_ODD: USA_PARITY_EVEN; + USA_PARITY_ODD : USA_PARITY_EVEN; } if (p_priv->old_cflag != p_priv->cflag) { p_priv->old_cflag = p_priv->cflag; @@ -2384,23 +2392,22 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, msg.txFlowControl = TXFLOW_CTS; msg.setTxFlowControl = 0x01; msg.setRxFlowControl = 0x01; - + msg.rxForwardingLength = 16; - msg.rxForwardingTimeout = 16; + msg.rxForwardingTimeout = 16; msg.txAckSetting = 0; msg.xonChar = 17; msg.xoffChar = 19; - /* Opening port */ + /* Opening port */ if (reset_port == 1) { msg.portEnabled = 1; msg.rxFlush = 1; msg.txBreak = (p_priv->break_on); } /* Closing port */ - else if (reset_port == 2) { + else if (reset_port == 2) msg.portEnabled = 0; - } /* Sending intermediate configs */ else { if (port->port.count) @@ -2408,23 +2415,23 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, msg.txBreak = (p_priv->break_on); } - /* Do handshaking outputs */ + /* Do handshaking outputs */ msg.setRts = 0x01; msg.rts = p_priv->rts_state; msg.setDtr = 0x01; msg.dtr = p_priv->dtr_state; - + p_priv->resend_cont = 0; - memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); - + memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); + /* send the data out the device on control endpoint */ this_urb->transfer_buffer_length = sizeof(msg); this_urb->dev = serial->dev; - if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { + err = usb_submit_urb(this_urb, GFP_ATOMIC); + if (err != 0) dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); - } return 0; } @@ -2439,7 +2446,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, struct urb *this_urb; int err, device_port; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); @@ -2462,9 +2469,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, if ((reset_port + 1) > p_priv->resend_cont) p_priv->resend_cont = reset_port + 1; if (this_urb->status == -EINPROGRESS) { - /* dbg ("%s - already writing", __func__); */ + /* dbg("%s - already writing", __func__); */ mdelay(5); - return(-1); + return -1; } memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage)); @@ -2477,9 +2484,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, msg.setClocking = 0xff; if (d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, &msg.baudHi, - &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { - dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, - p_priv->baud); + &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { + dbg("%s - Invalid baud rate %d requested, using 9600.", + __func__, p_priv->baud); msg.baudLo = 0; msg.baudHi = 125; /* Values for 9600 baud */ msg.prescaler = 10; @@ -2505,7 +2512,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, if (p_priv->cflag & PARENB) { /* note USA_PARITY_NONE == 0 */ msg.lcr |= (p_priv->cflag & PARODD)? - USA_PARITY_ODD: USA_PARITY_EVEN; + USA_PARITY_ODD : USA_PARITY_EVEN; } msg.setLcr = 0xff; @@ -2542,7 +2549,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, msg.resetDataToggle = 0; } else { /* Sending intermediate configs */ - msg._txOn = (! p_priv->break_on); + msg._txOn = (!p_priv->break_on); msg._txOff = 0; msg.txFlush = 0; msg.txBreak = (p_priv->break_on); @@ -2582,7 +2589,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) struct keyspan_serial_private *s_priv; const struct keyspan_device_details *d_details; - dbg ("%s", __func__); + dbg("%s", __func__); s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; @@ -2609,7 +2616,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) /* Gets called by the "real" driver (ie once firmware is loaded and renumeration has taken place. */ -static int keyspan_startup (struct usb_serial *serial) +static int keyspan_startup(struct usb_serial *serial) { int i, err; struct usb_serial_port *port; @@ -2620,17 +2627,20 @@ static int keyspan_startup (struct usb_serial *serial) dbg("%s", __func__); for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) - if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) + if (d_details->product_id == + le16_to_cpu(serial->dev->descriptor.idProduct)) break; if (d_details == NULL) { - dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); + dev_err(&serial->dev->dev, "%s - unknown product id %x\n", + __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); return 1; } /* Setup private data for serial driver */ s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); if (!s_priv) { - dbg("%s - kmalloc for keyspan_serial_private failed.", __func__); + dbg("%s - kmalloc for keyspan_serial_private failed.", + __func__); return -ENOMEM; } @@ -2640,10 +2650,11 @@ static int keyspan_startup (struct usb_serial *serial) /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); + p_priv = kzalloc(sizeof(struct keyspan_port_private), + GFP_KERNEL); if (!p_priv) { dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); - return (1); + return 1; } p_priv->device_details = d_details; usb_set_serial_port_data(port, p_priv); @@ -2665,11 +2676,11 @@ static int keyspan_startup (struct usb_serial *serial) dbg("%s - submit indat urb failed %d", __func__, err); } - + return 0; } -static void keyspan_shutdown (struct usb_serial *serial) +static void keyspan_shutdown(struct usb_serial *serial) { int i, j; struct usb_serial_port *port; @@ -2721,8 +2732,8 @@ static void keyspan_shutdown (struct usb_serial *serial) } } -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("keyspan/usa28.fw"); -- cgit v1.2.3-70-g09d2 From f035a8ad158f0bdc94125004488b0ea8438edaa9 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:13:32 +0100 Subject: keyspan: Use string flip functions when possible Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/usb/serial/keyspan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 2b1cfcbf8f9..704716f6f6d 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -577,7 +577,7 @@ static void usa26_glocont_callback(struct urb *urb) static void usa28_indat_callback(struct urb *urb) { - int i, err; + int err; struct usb_serial_port *port; struct tty_struct *tty; unsigned char *data; @@ -606,8 +606,7 @@ static void usa28_indat_callback(struct urb *urb) tty = port->port.tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], 0); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } @@ -833,8 +832,8 @@ static void usa49_indat_callback(struct urb *urb) /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no error on any byte */ - for (i = 1; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], 0); + tty_insert_flip_string(tty, data + 1, + urb->actual_length - 1); } else { /* some bytes had errors, every byte has status */ for (i = 0; i + 1 < urb->actual_length; i += 2) { @@ -973,10 +972,9 @@ static void usa90_indat_callback(struct urb *urb) /* if current mode is DMA, looks like usa28 format otherwise looks like usa26 data format */ - if (p_priv->baud > 57600) { - for (i = 0; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], 0); - } else { + if (p_priv->baud > 57600) + tty_insert_flip_string(tty, data, urb->actual_length); + else { /* 0x80 bit is error flag */ if ((data[0] & 0x80) == 0) { /* no errors on individual bytes, only -- cgit v1.2.3-70-g09d2 From 9e70f319d14ac4dd077de7fc835a391ece804500 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:13:42 +0100 Subject: tty-usb-keyspan-pda: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/keyspan_pda.c | 161 ++++++++++++++++++++++----------------- 1 file changed, 91 insertions(+), 70 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 24a08ac2e4e..b60012ce4c9 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -10,8 +10,9 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * See Documentation/usb/usb-serial.txt for more information on using this driver - * + * See Documentation/usb/usb-serial.txt for more information on using this + * driver + * * (09/07/2001) gkh * cleaned up the Xircom support. Added ids for Entregra device which is * the same as the Xircom device. Enabled the code to be compiled for @@ -21,23 +22,24 @@ * support for Xircom PGSDB9 * * (05/31/2001) gkh - * switched from using spinlock to a semaphore, which fixes lots of problems. + * switched from using spinlock to a semaphore, which fixes lots of + * problems. * * (04/08/2001) gb * Identify version on module load. - * + * * (11/01/2000) Adam J. Richter * usb_device_id table support - * + * * (10/05/2000) gkh * Fixed bug with urb->dev not being set properly, now that the usb * core needs it. - * + * * (08/28/2000) gkh * Added locks for SMP safeness. - * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more + * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more * than once. - * + * * (07/20/2000) borchers * - keyspan_pda_write no longer sleeps if it is called on interrupt time; * PPP and the line discipline with stty echo on can call write on @@ -55,14 +57,14 @@ * than done directly from the callback to avoid the race in write_chan * - keyspan_pda_chars_in_buffer also indicates its buffer is full if the * urb status is -EINPROGRESS, meaning it cannot write at the moment - * + * * (07/19/2000) gkh * Added module_init and module_exit functions to handle the fact that this * driver is a loadable module now. * * (03/26/2000) gkh * Split driver up into device specific pieces. - * + * */ @@ -78,7 +80,7 @@ #include #include #include -#include +#include #include #include @@ -135,7 +137,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver keyspan_pda_driver = { .name = "keyspan_pda", @@ -159,9 +161,9 @@ static struct usb_device_id id_table_fake [] = { #ifdef XIRCOM static struct usb_device_id id_table_fake_xircom [] = { - { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, - { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) }, - { } + { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, + { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) }, + { } }; #endif @@ -184,7 +186,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) dbg(" request_unthrottle"); /* ask the device to tell us when the tx buffer becomes sufficiently empty */ - result = usb_control_msg(serial->dev, + result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 7, /* request_unthrottle */ USB_TYPE_VENDOR | USB_RECIP_INTERFACE @@ -195,15 +197,15 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) 0, 2000); if (result < 0) - dbg("%s - error %d from usb_control_msg", + dbg("%s - error %d from usb_control_msg", __func__, result); } -static void keyspan_pda_rx_interrupt (struct urb *urb) +static void keyspan_pda_rx_interrupt(struct urb *urb) { struct usb_serial_port *port = urb->context; - struct tty_struct *tty = port->port.tty; + struct tty_struct *tty = port->port.tty; unsigned char *data = urb->transfer_buffer; int i; int retval; @@ -228,14 +230,13 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) goto exit; } - /* see if the message is data or a status interrupt */ + /* see if the message is data or a status interrupt */ switch (data[0]) { case 0: /* rest of message is rx data */ if (urb->actual_length) { - for (i = 1; i < urb->actual_length ; ++i) { + for (i = 1; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], 0); - } tty_flip_buffer_push(tty); } break; @@ -259,9 +260,9 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) } exit: - retval = usb_submit_urb (urb, GFP_ATOMIC); + retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) - err ("%s - usb_submit_urb failed with result %d", + err("%s - usb_submit_urb failed with result %d", __func__, retval); } @@ -292,32 +293,52 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) } -static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) +static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud) { int rc; int bindex; - switch(baud) { - case 110: bindex = 0; break; - case 300: bindex = 1; break; - case 1200: bindex = 2; break; - case 2400: bindex = 3; break; - case 4800: bindex = 4; break; - case 9600: bindex = 5; break; - case 19200: bindex = 6; break; - case 38400: bindex = 7; break; - case 57600: bindex = 8; break; - case 115200: bindex = 9; break; - default: - bindex = 5; /* Default to 9600 */ - baud = 9600; + switch (baud) { + case 110: + bindex = 0; + break; + case 300: + bindex = 1; + break; + case 1200: + bindex = 2; + break; + case 2400: + bindex = 3; + break; + case 4800: + bindex = 4; + break; + case 9600: + bindex = 5; + break; + case 19200: + bindex = 6; + break; + case 38400: + bindex = 7; + break; + case 57600: + bindex = 8; + break; + case 115200: + bindex = 9; + break; + default: + bindex = 5; /* Default to 9600 */ + baud = 9600; } /* rather than figure out how to sleep while waiting for this to complete, I just use the "legacy" API. */ rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 0, /* set baud */ - USB_TYPE_VENDOR + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, /* type */ bindex, /* value */ @@ -343,11 +364,11 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state) else value = 0; /* clear break */ result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - 4, /* set break */ - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - value, 0, NULL, 0, 2000); + 4, /* set break */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, + value, 0, NULL, 0, 2000); if (result < 0) - dbg("%s - error %d from usb_control_msg", + dbg("%s - error %d from usb_control_msg", __func__, result); /* there is something funky about this.. the TCSBRK that 'cu' performs ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 @@ -490,10 +511,10 @@ static int keyspan_pda_write(struct tty_struct *tty, select() or poll() too) until we receive that unthrottle interrupt. Block if we can't write anything at all, otherwise write as much as we can. */ - dbg("keyspan_pda_write(%d)",count); + dbg("keyspan_pda_write(%d)", count); if (count == 0) { dbg(" write request of 0 bytes"); - return (0); + return 0; } /* we might block because of: @@ -520,7 +541,7 @@ static int keyspan_pda_write(struct tty_struct *tty, scheduler time, since usb_control_msg() sleeps. */ if (count > priv->tx_room && !in_interrupt()) { unsigned char room; - rc = usb_control_msg(serial->dev, + rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 6, /* write_room */ USB_TYPE_VENDOR | USB_RECIP_INTERFACE @@ -551,7 +572,7 @@ static int keyspan_pda_write(struct tty_struct *tty, if (count) { /* now transfer data */ - memcpy (port->write_urb->transfer_buffer, buf, count); + memcpy(port->write_urb->transfer_buffer, buf, count); /* send the data out the bulk port */ port->write_urb->transfer_buffer_length = count; @@ -563,8 +584,7 @@ static int keyspan_pda_write(struct tty_struct *tty, dbg(" usb_submit_urb(write bulk) failed"); goto exit; } - } - else { + } else { /* There wasn't any room left, so we are throttled until the buffer empties a bit */ request_unthrottle = 1; @@ -583,7 +603,7 @@ exit: } -static void keyspan_pda_write_bulk_callback (struct urb *urb) +static void keyspan_pda_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct keyspan_pda_private *priv; @@ -604,7 +624,7 @@ static int keyspan_pda_write_room(struct tty_struct *tty) /* used by n_tty.c for processing of tabs and such. Giving it our conservative guess is probably good enough, but needs testing by running a console through the device. */ - return (priv->tx_room); + return priv->tx_room; } @@ -662,7 +682,7 @@ static int keyspan_pda_open(struct tty_struct *tty, /* the normal serial device seems to always turn on DTR and RTS here, so do the same */ if (tty && (tty->termios->c_cflag & CBAUD)) - keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) ); + keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2)); else keyspan_pda_set_modem_info(serial, 0); @@ -685,7 +705,8 @@ static void keyspan_pda_close(struct tty_struct *tty, struct usb_serial *serial = port->serial; if (serial->dev) { - /* the normal serial device seems to always shut off DTR and RTS now */ + /* the normal serial device seems to always shut + off DTR and RTS now */ if (tty->termios->c_cflag & HUPCL) keyspan_pda_set_modem_info(serial, 0); @@ -697,7 +718,7 @@ static void keyspan_pda_close(struct tty_struct *tty, /* download the firmware to a "fake" device (pre-renumeration) */ -static int keyspan_pda_fake_startup (struct usb_serial *serial) +static int keyspan_pda_fake_startup(struct usb_serial *serial) { int response; const char *fw_name; @@ -746,10 +767,10 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial) response = ezusb_set_reset(serial, 0); /* we want this device to fail to have a driver assigned to it. */ - return (1); + return 1; } -static int keyspan_pda_startup (struct usb_serial *serial) +static int keyspan_pda_startup(struct usb_serial *serial) { struct keyspan_pda_private *priv; @@ -759,20 +780,20 @@ static int keyspan_pda_startup (struct usb_serial *serial) priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); if (!priv) - return (1); /* error */ + return 1; /* error */ usb_set_serial_port_data(serial->port[0], priv); init_waitqueue_head(&serial->port[0]->write_wait); INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); priv->serial = serial; priv->port = serial->port[0]; - return (0); + return 0; } -static void keyspan_pda_shutdown (struct usb_serial *serial) +static void keyspan_pda_shutdown(struct usb_serial *serial) { dbg("%s", __func__); - + kfree(usb_get_serial_port_data(serial->port[0])); } @@ -831,7 +852,7 @@ static struct usb_serial_driver keyspan_pda_device = { }; -static int __init keyspan_pda_init (void) +static int __init keyspan_pda_init(void) { int retval; retval = usb_serial_register(&keyspan_pda_device); @@ -852,7 +873,7 @@ static int __init keyspan_pda_init (void) goto failed_usb_register; info(DRIVER_DESC " " DRIVER_VERSION); return 0; -failed_usb_register: +failed_usb_register: #ifdef XIRCOM usb_serial_deregister(&xircom_pgs_fake_device); failed_xircom_register: @@ -869,15 +890,15 @@ failed_pda_register: } -static void __exit keyspan_pda_exit (void) +static void __exit keyspan_pda_exit(void) { - usb_deregister (&keyspan_pda_driver); - usb_serial_deregister (&keyspan_pda_device); + usb_deregister(&keyspan_pda_driver); + usb_serial_deregister(&keyspan_pda_device); #ifdef KEYSPAN - usb_serial_deregister (&keyspan_pda_fake_device); + usb_serial_deregister(&keyspan_pda_fake_device); #endif #ifdef XIRCOM - usb_serial_deregister (&xircom_pgs_fake_device); + usb_serial_deregister(&xircom_pgs_fake_device); #endif } @@ -885,8 +906,8 @@ static void __exit keyspan_pda_exit (void) module_init(keyspan_pda_init); module_exit(keyspan_pda_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 8dd03a5b2b775b0932c1705dc19298ccda19167d Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:13:51 +0100 Subject: keyspan_pda: Use string flip functions Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/keyspan_pda.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index b60012ce4c9..040040a267d 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -207,7 +207,6 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) struct usb_serial_port *port = urb->context; struct tty_struct *tty = port->port.tty; unsigned char *data = urb->transfer_buffer; - int i; int retval; int status = urb->status; struct keyspan_pda_private *priv; @@ -235,8 +234,8 @@ static void keyspan_pda_rx_interrupt(struct urb *urb) case 0: /* rest of message is rx data */ if (urb->actual_length) { - for (i = 1; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], 0); + tty_insert_flip_string(tty, data + 1, + urb->actual_length - 1); tty_flip_buffer_push(tty); } break; -- cgit v1.2.3-70-g09d2 From 0c265f4e8598e251108759685dbb3789868086b2 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:00 +0100 Subject: tty-usb-kl5kusb105: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/kl5kusb105.c | 389 +++++++++++++++++++--------------------- 1 file changed, 188 insertions(+), 201 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 4a38ec8f5fe..b84dddc7112 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -15,12 +15,12 @@ * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided * information that was not already available. * - * It seems that KLSI bought some silicon-design information from ScanLogic, + * It seems that KLSI bought some silicon-design information from ScanLogic, * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. * KLSI has firmware available for their devices; it is probable that the * firmware differs from that used by KLSI in their products. If you have an - * original KLSI device and can provide some information on it, I would be - * most interested in adding support for it here. If you have any information + * original KLSI device and can provide some information on it, I would be + * most interested in adding support for it here. If you have any information * on the protocol used (or find errors in my reverse-engineered stuff), please * let me know. * @@ -40,7 +40,7 @@ * 0.2 - TIOCMGET works, so autopilot(1) can be used! * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l * - * The driver skeleton is mainly based on mct_u232.c and various other + * The driver skeleton is mainly based on mct_u232.c and various other * pieces of code shamelessly copied from the drivers/usb/serial/ directory. */ @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,37 +72,25 @@ static int debug; /* * Function prototypes */ -static int klsi_105_startup (struct usb_serial *serial); -static void klsi_105_shutdown (struct usb_serial *serial); -static int klsi_105_open (struct tty_struct *tty, - struct usb_serial_port *port, - struct file *filp); -static void klsi_105_close (struct tty_struct *tty, - struct usb_serial_port *port, - struct file *filp); -static int klsi_105_write (struct tty_struct *tty, - struct usb_serial_port *port, - const unsigned char *buf, - int count); -static void klsi_105_write_bulk_callback (struct urb *urb); -static int klsi_105_chars_in_buffer (struct tty_struct *tty); -static int klsi_105_write_room (struct tty_struct *tty); - -static void klsi_105_read_bulk_callback (struct urb *urb); -static void klsi_105_set_termios (struct tty_struct *tty, - struct usb_serial_port *port, - struct ktermios *old); -static void klsi_105_throttle (struct tty_struct *tty); -static void klsi_105_unthrottle (struct tty_struct *tty); -/* -static void klsi_105_break_ctl (struct tty_struct *tty, - int break_state ); - */ -static int klsi_105_tiocmget (struct tty_struct *tty, - struct file *file); -static int klsi_105_tiocmset (struct tty_struct *tty, - struct file *file, unsigned int set, - unsigned int clear); +static int klsi_105_startup(struct usb_serial *serial); +static void klsi_105_shutdown(struct usb_serial *serial); +static int klsi_105_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void klsi_105_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static int klsi_105_write(struct tty_struct *tty, + struct usb_serial_port *port, const unsigned char *buf, int count); +static void klsi_105_write_bulk_callback(struct urb *urb); +static int klsi_105_chars_in_buffer(struct tty_struct *tty); +static int klsi_105_write_room(struct tty_struct *tty); +static void klsi_105_read_bulk_callback(struct urb *urb); +static void klsi_105_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static void klsi_105_throttle(struct tty_struct *tty); +static void klsi_105_unthrottle(struct tty_struct *tty); +static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file); +static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); /* * All of the device info needed for the KLSI converters. @@ -113,7 +101,7 @@ static struct usb_device_id id_table [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver kl5kusb105d_driver = { .name = "kl5kusb105d", @@ -138,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = { .write_bulk_callback = klsi_105_write_bulk_callback, .chars_in_buffer = klsi_105_chars_in_buffer, .write_room = klsi_105_write_room, - .read_bulk_callback =klsi_105_read_bulk_callback, + .read_bulk_callback = klsi_105_read_bulk_callback, .set_termios = klsi_105_set_termios, /*.break_ctl = klsi_105_break_ctl,*/ .tiocmget = klsi_105_tiocmget, @@ -165,7 +153,7 @@ struct klsi_105_private { struct ktermios termios; unsigned long line_state; /* modem line settings */ /* write pool */ - struct urb * write_urb_pool[NUM_URBS]; + struct urb *write_urb_pool[NUM_URBS]; spinlock_t lock; unsigned long bytes_in; unsigned long bytes_out; @@ -184,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, { int rc; - rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_SET_DATA, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, - 0, /* value */ - 0, /* index */ - settings, - sizeof(struct klsi_105_port_settings), - KLSI_TIMEOUT); + rc = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + KL5KUSB105A_SIO_SET_DATA, + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, + 0, /* value */ + 0, /* index */ + settings, + sizeof(struct klsi_105_port_settings), + KLSI_TIMEOUT); if (rc < 0) err("Change port settings failed (error = %d)", rc); info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", @@ -200,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, settings->pktlen, settings->baudrate, settings->databits, settings->unknown1, settings->unknown2); - return rc; + return rc; } /* klsi_105_chg_port_settings */ /* translate a 16-bit status value from the device to linux's TIO bits */ @@ -214,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status) return res; } -/* +/* * Read line control via vendor command and return result through - * *line_state_p + * *line_state_p */ /* It seems that the status buffer has always only 2 bytes length */ #define KLSI_STATUSBUF_LEN 2 @@ -224,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, unsigned long *line_state_p) { int rc; - __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1}; + __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; __u16 status; info("%s - sending SIO Poll request", __func__); - rc = usb_control_msg(port->serial->dev, + rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_POLL, - USB_TYPE_VENDOR | USB_DIR_IN, + USB_TYPE_VENDOR | USB_DIR_IN, 0, /* value */ 0, /* index */ status_buf, KLSI_STATUSBUF_LEN, @@ -247,8 +235,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, *line_state_p = klsi_105_status2linestate(status); } - - return rc; + return rc; } @@ -256,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, * Driver's tty interface functions */ -static int klsi_105_startup (struct usb_serial *serial) +static int klsi_105_startup(struct usb_serial *serial) { struct klsi_105_private *priv; int i, j; @@ -266,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial) */ /* allocate the private data structure */ - for (i=0; inum_ports; i++) { + for (i = 0; i < serial->num_ports; i++) { priv = kmalloc(sizeof(struct klsi_105_private), GFP_KERNEL); if (!priv) { @@ -287,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial) priv->bytes_out = 0; usb_set_serial_port_data(serial->port[i], priv); - spin_lock_init (&priv->lock); - for (j=0; jlock); + for (j = 0; j < NUM_URBS; j++) { + struct urb *urb = usb_alloc_urb(0, GFP_KERNEL); priv->write_urb_pool[j] = urb; if (urb == NULL) { @@ -297,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial) goto err_cleanup; } - urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, - GFP_KERNEL); + urb->transfer_buffer = + kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (!urb->transfer_buffer) { - err("%s - out of memory for urb buffers.", __func__); + err("%s - out of memory for urb buffers.", + __func__); goto err_cleanup; } } @@ -308,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial) /* priv->termios is left uninitalized until port opening */ init_waitqueue_head(&serial->port[i]->write_wait); } - + return 0; err_cleanup: for (; i >= 0; i--) { priv = usb_get_serial_port_data(serial->port[i]); - for (j=0; j < NUM_URBS; j++) { + for (j = 0; j < NUM_URBS; j++) { if (priv->write_urb_pool[j]) { kfree(priv->write_urb_pool[j]->transfer_buffer); usb_free_urb(priv->write_urb_pool[j]); @@ -326,22 +314,23 @@ err_cleanup: } /* klsi_105_startup */ -static void klsi_105_shutdown (struct usb_serial *serial) +static void klsi_105_shutdown(struct usb_serial *serial) { int i; - + dbg("%s", __func__); /* stop reads and writes on all ports */ - for (i=0; i < serial->num_ports; ++i) { - struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]); + for (i = 0; i < serial->num_ports; ++i) { + struct klsi_105_private *priv = + usb_get_serial_port_data(serial->port[i]); unsigned long flags; if (priv) { /* kill our write urb pool */ int j; struct urb **write_urbs = priv->write_urb_pool; - spin_lock_irqsave(&priv->lock,flags); + spin_lock_irqsave(&priv->lock, flags); for (j = 0; j < NUM_URBS; j++) { if (write_urbs[j]) { @@ -353,12 +342,10 @@ static void klsi_105_shutdown (struct usb_serial *serial) * oopses. */ /* usb_kill_urb(write_urbs[j]); */ kfree(write_urbs[j]->transfer_buffer); - usb_free_urb (write_urbs[j]); + usb_free_urb(write_urbs[j]); } } - - spin_unlock_irqrestore (&priv->lock, flags); - + spin_unlock_irqrestore(&priv->lock, flags); kfree(priv); usb_set_serial_port_data(serial->port[i], NULL); } @@ -384,7 +371,7 @@ static int klsi_105_open(struct tty_struct *tty, /* Do a defined restart: * Set up sane default baud rate and send the 'READ_ON' - * vendor command. + * vendor command. * FIXME: set modem line control (how?) * Then read the modem line control and store values in * priv->line_state. @@ -395,24 +382,24 @@ static int klsi_105_open(struct tty_struct *tty, cfg.unknown1 = 0; cfg.unknown2 = 1; klsi_105_chg_port_settings(port, &cfg); - + /* set up termios structure */ - spin_lock_irqsave (&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); priv->termios.c_iflag = tty->termios->c_iflag; priv->termios.c_oflag = tty->termios->c_oflag; priv->termios.c_cflag = tty->termios->c_cflag; priv->termios.c_lflag = tty->termios->c_lflag; - for (i=0; itermios.c_cc[i] = tty->termios->c_cc[i]; priv->cfg.pktlen = cfg.pktlen; priv->cfg.baudrate = cfg.baudrate; priv->cfg.databits = cfg.databits; priv->cfg.unknown1 = cfg.unknown1; priv->cfg.unknown2 = cfg.unknown2; - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); /* READ_ON and urb submission */ - usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -428,7 +415,7 @@ static int klsi_105_open(struct tty_struct *tty, } rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev,0), + usb_sndctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_CONFIGURE, USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, KL5KUSB105A_SIO_CONFIGURE_READ_ON, @@ -439,14 +426,14 @@ static int klsi_105_open(struct tty_struct *tty, if (rc < 0) { err("Enabling read failed (error = %d)", rc); retval = rc; - } else + } else dbg("%s - enabled reading", __func__); rc = klsi_105_get_line_state(port, &line_state); if (rc >= 0) { - spin_lock_irqsave (&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); priv->line_state = line_state; - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); dbg("%s - read line state 0x%lx", __func__, line_state); retval = 0; } else @@ -468,14 +455,14 @@ static void klsi_105_close(struct tty_struct *tty, mutex_lock(&port->serial->disc_mutex); if (!port->serial->disconnected) { /* send READ_OFF */ - rc = usb_control_msg (port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_CONFIGURE, - USB_TYPE_VENDOR | USB_DIR_OUT, - KL5KUSB105A_SIO_CONFIGURE_READ_OFF, - 0, /* index */ - NULL, 0, - KLSI_TIMEOUT); + rc = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + KL5KUSB105A_SIO_CONFIGURE, + USB_TYPE_VENDOR | USB_DIR_OUT, + KL5KUSB105A_SIO_CONFIGURE_READ_OFF, + 0, /* index */ + NULL, 0, + KLSI_TIMEOUT); if (rc < 0) err("Disabling read failed (error = %d)", rc); } @@ -488,12 +475,13 @@ static void klsi_105_close(struct tty_struct *tty, /* FIXME */ /* wgg - do I need this? I think so. */ usb_kill_urb(port->interrupt_in_urb); - info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out); + info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", + priv->bytes_in, priv->bytes_out); } /* klsi_105_close */ /* We need to write a complete 64-byte data block and encode the - * number actually sent in the first double-byte, LSB-order. That + * number actually sent in the first double-byte, LSB-order. That * leaves at most 62 bytes of payload. */ #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ @@ -504,7 +492,7 @@ static int klsi_105_write(struct tty_struct *tty, { struct klsi_105_private *priv = usb_get_serial_port_data(port); int result, size; - int bytes_sent=0; + int bytes_sent = 0; dbg("%s - port %d", __func__, port->number); @@ -513,34 +501,37 @@ static int klsi_105_write(struct tty_struct *tty, struct urb *urb = NULL; unsigned long flags; int i; - /* since the pool is per-port we might not need the spin lock !? */ - spin_lock_irqsave (&priv->lock, flags); - for (i=0; ilock, flags); + for (i = 0; i < NUM_URBS; i++) { if (priv->write_urb_pool[i]->status != -EINPROGRESS) { urb = priv->write_urb_pool[i]; dbg("%s - using pool URB %d", __func__, i); break; } } - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); - if (urb==NULL) { + if (urb == NULL) { dbg("%s - no more free urbs", __func__); goto exit; } if (urb->transfer_buffer == NULL) { - urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); + urb->transfer_buffer = + kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); if (urb->transfer_buffer == NULL) { err("%s - no more kernel memory...", __func__); goto exit; } } - size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET); - size = min (size, URB_TRANSFER_BUFFER_SIZE - KLSI_105_DATA_OFFSET); + size = min(count, port->bulk_out_size - KLSI_105_DATA_OFFSET); + size = min(size, URB_TRANSFER_BUFFER_SIZE - + KLSI_105_DATA_OFFSET); - memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); + memcpy(urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); /* write payload size into transfer buffer */ ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF); @@ -558,7 +549,8 @@ static int klsi_105_write(struct tty_struct *tty, /* send the data out the bulk port */ result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { - err("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); goto exit; } buf += size; @@ -567,12 +559,12 @@ static int klsi_105_write(struct tty_struct *tty, } exit: /* lockless, but it's for debug info only... */ - priv->bytes_out+=bytes_sent; + priv->bytes_out += bytes_sent; return bytes_sent; /* that's how much we wrote */ } /* klsi_105_write */ -static void klsi_105_write_bulk_callback ( struct urb *urb) +static void klsi_105_write_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; int status = urb->status; @@ -590,7 +582,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb) /* return number of characters currently in the writing process */ -static int klsi_105_chars_in_buffer (struct tty_struct *tty) +static int klsi_105_chars_in_buffer(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; int chars = 0; @@ -598,21 +590,20 @@ static int klsi_105_chars_in_buffer (struct tty_struct *tty) unsigned long flags; struct klsi_105_private *priv = usb_get_serial_port_data(port); - spin_lock_irqsave (&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); for (i = 0; i < NUM_URBS; ++i) { - if (priv->write_urb_pool[i]->status == -EINPROGRESS) { + if (priv->write_urb_pool[i]->status == -EINPROGRESS) chars += URB_TRANSFER_BUFFER_SIZE; - } } - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); dbg("%s - returns %d", __func__, chars); - return (chars); + return chars; } -static int klsi_105_write_room (struct tty_struct *tty) +static int klsi_105_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; unsigned long flags; @@ -620,22 +611,21 @@ static int klsi_105_write_room (struct tty_struct *tty) int room = 0; struct klsi_105_private *priv = usb_get_serial_port_data(port); - spin_lock_irqsave (&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); for (i = 0; i < NUM_URBS; ++i) { - if (priv->write_urb_pool[i]->status != -EINPROGRESS) { + if (priv->write_urb_pool[i]->status != -EINPROGRESS) room += URB_TRANSFER_BUFFER_SIZE; - } } - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); dbg("%s - returns %d", __func__, room); - return (room); + return room; } -static void klsi_105_read_bulk_callback (struct urb *urb) +static void klsi_105_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct klsi_105_private *priv = usb_get_serial_port_data(port); @@ -674,7 +664,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) * against re-entry an then mixed-up data because of * intermixed tty_flip_buffer_push()s * FIXME - */ + */ usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); @@ -694,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) priv->bytes_in += bytes_sent; } /* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, @@ -703,13 +693,14 @@ static void klsi_105_read_bulk_callback (struct urb *urb) port); rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (rc) - err("%s - failed resubmitting read urb, error %d", __func__, rc); + err("%s - failed resubmitting read urb, error %d", + __func__, rc); } /* klsi_105_read_bulk_callback */ -static void klsi_105_set_termios (struct tty_struct *tty, - struct usb_serial_port *port, - struct ktermios *old_termios) +static void klsi_105_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, + struct ktermios *old_termios) { struct klsi_105_private *priv = usb_get_serial_port_data(port); unsigned int iflag = tty->termios->c_iflag; @@ -719,65 +710,63 @@ static void klsi_105_set_termios (struct tty_struct *tty, struct klsi_105_port_settings cfg; unsigned long flags; speed_t baud; - + /* lock while we are modifying the settings */ - spin_lock_irqsave (&priv->lock, flags); - + spin_lock_irqsave(&priv->lock, flags); + /* * Update baud rate */ baud = tty_get_baud_rate(tty); - if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { - /* reassert DTR and (maybe) RTS on transition from B0 */ - if( (old_cflag & CBAUD) == B0 ) { + if ((cflag & CBAUD) != (old_cflag & CBAUD)) { + /* reassert DTR and (maybe) RTS on transition from B0 */ + if ((old_cflag & CBAUD) == B0) { dbg("%s: baud was B0", __func__); #if 0 priv->control_state |= TIOCM_DTR; /* don't set RTS if using hardware flow control */ - if (!(old_cflag & CRTSCTS)) { + if (!(old_cflag & CRTSCTS)) priv->control_state |= TIOCM_RTS; - } mct_u232_set_modem_ctrl(serial, priv->control_state); #endif } } - switch(baud) { - case 0: /* handled below */ - break; - case 1200: - priv->cfg.baudrate = kl5kusb105a_sio_b1200; - break; - case 2400: - priv->cfg.baudrate = kl5kusb105a_sio_b2400; - break; - case 4800: - priv->cfg.baudrate = kl5kusb105a_sio_b4800; - break; - case 9600: + switch (baud) { + case 0: /* handled below */ + break; + case 1200: + priv->cfg.baudrate = kl5kusb105a_sio_b1200; + break; + case 2400: + priv->cfg.baudrate = kl5kusb105a_sio_b2400; + break; + case 4800: + priv->cfg.baudrate = kl5kusb105a_sio_b4800; + break; + case 9600: + priv->cfg.baudrate = kl5kusb105a_sio_b9600; + break; + case 19200: + priv->cfg.baudrate = kl5kusb105a_sio_b19200; + break; + case 38400: + priv->cfg.baudrate = kl5kusb105a_sio_b38400; + break; + case 57600: + priv->cfg.baudrate = kl5kusb105a_sio_b57600; + break; + case 115200: + priv->cfg.baudrate = kl5kusb105a_sio_b115200; + break; + default: + dbg("KLSI USB->Serial converter:" + " unsupported baudrate request, using default of 9600"); priv->cfg.baudrate = kl5kusb105a_sio_b9600; - break; - case 19200: - priv->cfg.baudrate = kl5kusb105a_sio_b19200; - break; - case 38400: - priv->cfg.baudrate = kl5kusb105a_sio_b38400; - break; - case 57600: - priv->cfg.baudrate = kl5kusb105a_sio_b57600; - break; - case 115200: - priv->cfg.baudrate = kl5kusb105a_sio_b115200; - break; - default: - dbg("KLSI USB->Serial converter:" - " unsupported baudrate request, using default" - " of 9600"); - priv->cfg.baudrate = kl5kusb105a_sio_b9600; - baud = 9600; - break; + baud = 9600; + break; } - if ((cflag & CBAUD) == B0 ) { + if ((cflag & CBAUD) == B0) { dbg("%s: baud is B0", __func__); /* Drop RTS and DTR */ /* maybe this should be simulated by sending read @@ -786,7 +775,7 @@ static void klsi_105_set_termios (struct tty_struct *tty, ; #if 0 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); - mct_u232_set_modem_ctrl(serial, priv->control_state); + mct_u232_set_modem_ctrl(serial, priv->control_state); #endif } tty_encode_baud_rate(tty, baud, baud); @@ -796,11 +785,11 @@ static void klsi_105_set_termios (struct tty_struct *tty, switch (cflag & CSIZE) { case CS5: dbg("%s - 5 bits/byte not supported", __func__); - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); return ; case CS6: dbg("%s - 6 bits/byte not supported", __func__); - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); return ; case CS7: priv->cfg.databits = kl5kusb105a_dtb_7; @@ -819,8 +808,7 @@ static void klsi_105_set_termios (struct tty_struct *tty, * Update line control register (LCR) */ if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) - || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { - + || (cflag & CSTOPB) != (old_cflag & CSTOPB)) { /* Not currently supported */ tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); #if 0 @@ -841,20 +829,18 @@ static void klsi_105_set_termios (struct tty_struct *tty, #endif ; } - /* * Set flow control: well, I do not really now how to handle DTR/RTS. * Just do what we have seen with SniffUSB on Win98. */ - if( (iflag & IXOFF) != (old_iflag & IXOFF) + if ((iflag & IXOFF) != (old_iflag & IXOFF) || (iflag & IXON) != (old_iflag & IXON) - || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { - + || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { /* Not currently supported */ tty->termios->c_cflag &= ~CRTSCTS; /* Drop DTR/RTS if no flow control otherwise assert */ #if 0 - if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) + if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) priv->control_state |= TIOCM_DTR | TIOCM_RTS; else priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); @@ -862,20 +848,21 @@ static void klsi_105_set_termios (struct tty_struct *tty, #endif ; } - memcpy (&cfg, &priv->cfg, sizeof(cfg)); - spin_unlock_irqrestore (&priv->lock, flags); - + memcpy(&cfg, &priv->cfg, sizeof(cfg)); + spin_unlock_irqrestore(&priv->lock, flags); + /* now commit changes to device */ klsi_105_chg_port_settings(port, &cfg); } /* klsi_105_set_termios */ #if 0 -static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) +static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = + (struct mct_u232_private *)port->private; unsigned char lcr = priv->last_lcr; dbg("%sstate=%d", __func__, break_state); @@ -887,7 +874,7 @@ static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) } /* mct_u232_break_ctl */ #endif -static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file) +static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; struct klsi_105_private *priv = usb_get_serial_port_data(port); @@ -903,18 +890,18 @@ static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file) return rc; } - spin_lock_irqsave (&priv->lock, flags); + spin_lock_irqsave(&priv->lock, flags); priv->line_state = line_state; - spin_unlock_irqrestore (&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); dbg("%s - read line state 0x%lx", __func__, line_state); return (int)line_state; } -static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear) +static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) { int retval = -EINVAL; - + dbg("%s", __func__); /* if this ever gets implemented, it should be done something like this: @@ -939,14 +926,14 @@ static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, return retval; } -static void klsi_105_throttle (struct tty_struct *tty) +static void klsi_105_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); } -static void klsi_105_unthrottle (struct tty_struct *tty) +static void klsi_105_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; int result; @@ -962,7 +949,7 @@ static void klsi_105_unthrottle (struct tty_struct *tty) -static int __init klsi_105_init (void) +static int __init klsi_105_init(void) { int retval; retval = usb_serial_register(&kl5kusb105d_device); @@ -981,19 +968,19 @@ failed_usb_serial_register: } -static void __exit klsi_105_exit (void) +static void __exit klsi_105_exit(void) { - usb_deregister (&kl5kusb105d_driver); - usb_serial_deregister (&kl5kusb105d_device); + usb_deregister(&kl5kusb105d_driver); + usb_serial_deregister(&kl5kusb105d_device); } -module_init (klsi_105_init); -module_exit (klsi_105_exit); +module_init(klsi_105_init); +module_exit(klsi_105_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_LICENSE("GPL"); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From dee0a7ccaa0bcdeebb590879d68739cce4ff1b07 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:10 +0100 Subject: tty-usb-kobil-sct: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/kobil_sct.c | 557 ++++++++++++++++++++++------------------- 1 file changed, 297 insertions(+), 260 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 40c67f0096b..f0f8353ec1a 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -1,7 +1,7 @@ /* * KOBIL USB Smart Card Terminal Driver * - * Copyright (C) 2002 KOBIL Systems GmbH + * Copyright (C) 2002 KOBIL Systems GmbH * Author: Thomas Wahrenbruch * * Contact: linuxusb@kobil.de @@ -20,7 +20,7 @@ * * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus * (Adapter K), B1 Professional and KAAN Professional (Adapter B) - * + * * (21/05/2004) tw * Fix bug with P'n'P readers * @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,13 +68,13 @@ static int debug; /* Function prototypes */ -static int kobil_startup (struct usb_serial *serial); -static void kobil_shutdown (struct usb_serial *serial); -static int kobil_open (struct tty_struct *tty, +static int kobil_startup(struct usb_serial *serial); +static void kobil_shutdown(struct usb_serial *serial); +static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port, +static void kobil_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, +static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); static int kobil_write_room(struct tty_struct *tty); static int kobil_ioctl(struct tty_struct *tty, struct file *file, @@ -82,9 +82,9 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file, static int kobil_tiocmget(struct tty_struct *tty, struct file *file); static int kobil_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void kobil_read_int_callback( struct urb *urb ); -static void kobil_write_callback( struct urb *purb ); -static void kobil_set_termios(struct tty_struct *tty, +static void kobil_read_int_callback(struct urb *urb); +static void kobil_write_callback(struct urb *purb); +static void kobil_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old); @@ -97,7 +97,7 @@ static struct usb_device_id id_table [] = { }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver kobil_driver = { .name = "kobil", @@ -134,14 +134,14 @@ static struct usb_serial_driver kobil_device = { struct kobil_private { int write_int_endpoint_address; int read_int_endpoint_address; - unsigned char buf[KOBIL_BUF_LENGTH]; // buffer for the APDU to send - int filled; // index of the last char in buf - int cur_pos; // index of the next char to send in buf + unsigned char buf[KOBIL_BUF_LENGTH]; /* buffer for the APDU to send */ + int filled; /* index of the last char in buf */ + int cur_pos; /* index of the next char to send in buf */ __u16 device_type; }; -static int kobil_startup (struct usb_serial *serial) +static int kobil_startup(struct usb_serial *serial) { int i; struct kobil_private *priv; @@ -152,20 +152,20 @@ static int kobil_startup (struct usb_serial *serial) struct usb_host_endpoint *endpoint; priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); - if (!priv){ + if (!priv) return -ENOMEM; - } priv->filled = 0; priv->cur_pos = 0; priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); - switch (priv->device_type){ + switch (priv->device_type) { case KOBIL_ADAPTER_B_PRODUCT_ID: printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n"); break; case KOBIL_ADAPTER_K_PRODUCT_ID: - printk(KERN_DEBUG "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); + printk(KERN_DEBUG + "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); break; case KOBIL_USBTWIN_PRODUCT_ID: printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); @@ -176,37 +176,40 @@ static int kobil_startup (struct usb_serial *serial) } usb_set_serial_port_data(serial->port[0], priv); - // search for the necessary endpoints + /* search for the necessary endpoints */ pdev = serial->dev; - actconfig = pdev->actconfig; - interface = actconfig->interface[0]; + actconfig = pdev->actconfig; + interface = actconfig->interface[0]; altsetting = interface->cur_altsetting; - endpoint = altsetting->endpoint; - - for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { + endpoint = altsetting->endpoint; + + for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { endpoint = &altsetting->endpoint[i]; if (usb_endpoint_is_int_out(&endpoint->desc)) { - dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); - priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; - } + dbg("%s Found interrupt out endpoint. Address: %d", + __func__, endpoint->desc.bEndpointAddress); + priv->write_int_endpoint_address = + endpoint->desc.bEndpointAddress; + } if (usb_endpoint_is_int_in(&endpoint->desc)) { - dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); - priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; - } + dbg("%s Found interrupt in endpoint. Address: %d", + __func__, endpoint->desc.bEndpointAddress); + priv->read_int_endpoint_address = + endpoint->desc.bEndpointAddress; + } } return 0; } -static void kobil_shutdown (struct usb_serial *serial) +static void kobil_shutdown(struct usb_serial *serial) { int i; dbg("%s - port %d", __func__, serial->port[0]->number); - for (i=0; i < serial->num_ports; ++i) { - while (serial->port[i]->port.count > 0) { - kobil_close (NULL, serial->port[i], NULL); - } + for (i = 0; i < serial->num_ports; ++i) { + while (serial->port[i]->port.count > 0) + kobil_close(NULL, serial->port[i], NULL); kfree(usb_get_serial_port_data(serial->port[i])); usb_set_serial_port_data(serial->port[i], NULL); } @@ -225,7 +228,7 @@ static int kobil_open(struct tty_struct *tty, dbg("%s - port %d", __func__, port->number); priv = usb_get_serial_port_data(port); - // someone sets the dev to 0 if the close method has been called + /* someone sets the dev to 0 if the close method has been called */ port->interrupt_in_urb->dev = port->serial->dev; @@ -238,96 +241,110 @@ static int kobil_open(struct tty_struct *tty, /* Default to echo off and other sane device settings */ tty->termios->c_lflag = 0; - tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); + tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | + XCASE); tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; - tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) - } - // allocate memory for transfer buffer + /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */ + tty->termios->c_oflag &= ~ONLCR; + } + /* allocate memory for transfer buffer */ transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); - if (! transfer_buffer) { + if (!transfer_buffer) return -ENOMEM; - } - - // allocate write_urb - if (!port->write_urb) { - dbg("%s - port %d Allocating port->write_urb", __func__, port->number); - port->write_urb = usb_alloc_urb(0, GFP_KERNEL); + + /* allocate write_urb */ + if (!port->write_urb) { + dbg("%s - port %d Allocating port->write_urb", + __func__, port->number); + port->write_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port->write_urb) { - dbg("%s - port %d usb_alloc_urb failed", __func__, port->number); + dbg("%s - port %d usb_alloc_urb failed", + __func__, port->number); kfree(transfer_buffer); return -ENOMEM; } } - // allocate memory for write_urb transfer buffer - port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); - if (! port->write_urb->transfer_buffer) { + /* allocate memory for write_urb transfer buffer */ + port->write_urb->transfer_buffer = + kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); + if (!port->write_urb->transfer_buffer) { kfree(transfer_buffer); usb_free_urb(port->write_urb); port->write_urb = NULL; return -ENOMEM; - } - - // get hardware version - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_GetMisc, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, - SUSBCR_MSC_GetHWVersion, - 0, - transfer_buffer, - transfer_buffer_length, - KOBIL_TIMEOUT + } + + /* get hardware version */ + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_GetMisc, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, + SUSBCR_MSC_GetHWVersion, + 0, + transfer_buffer, + transfer_buffer_length, + KOBIL_TIMEOUT + ); + dbg("%s - port %d Send get_HW_version URB returns: %i", + __func__, port->number, result); + dbg("Harware version: %i.%i.%i", + transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); + + /* get firmware version */ + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_GetMisc, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, + SUSBCR_MSC_GetFWVersion, + 0, + transfer_buffer, + transfer_buffer_length, + KOBIL_TIMEOUT + ); + dbg("%s - port %d Send get_FW_version URB returns: %i", + __func__, port->number, result); + dbg("Firmware version: %i.%i.%i", + transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); + + if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || + priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { + /* Setting Baudrate, Parity and Stopbits */ + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_SetBaudRateParityAndStopBits, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | + SUSBCR_SPASB_1StopBit, + 0, + transfer_buffer, + 0, + KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result); - dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); - - // get firmware version - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_GetMisc, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, - SUSBCR_MSC_GetFWVersion, - 0, - transfer_buffer, - transfer_buffer_length, - KOBIL_TIMEOUT + dbg("%s - port %d Send set_baudrate URB returns: %i", + __func__, port->number, result); + + /* reset all queues */ + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_Misc, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + SUSBCR_MSC_ResetAllQueues, + 0, + transfer_buffer, + 0, + KOBIL_TIMEOUT ); - dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result); - dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); - - if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { - // Setting Baudrate, Parity and Stopbits - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_SetBaudRateParityAndStopBits, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | SUSBCR_SPASB_1StopBit, - 0, - transfer_buffer, - 0, - KOBIL_TIMEOUT - ); - dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result); - - // reset all queues - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_Misc, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - SUSBCR_MSC_ResetAllQueues, - 0, - transfer_buffer, - 0, - KOBIL_TIMEOUT - ); - dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result); + dbg("%s - port %d Send reset_all_queues URB returns: %i", + __func__, port->number, result); } - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || + priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { - // start reading (Adapter B 'cause PNP string) - result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); + /* start reading (Adapter B 'cause PNP string) */ + result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); + dbg("%s - port %d Send read URB returns: %i", + __func__, port->number, result); } kfree(transfer_buffer); @@ -342,7 +359,7 @@ static void kobil_close(struct tty_struct *tty, if (port->write_urb) { usb_kill_urb(port->write_urb); - usb_free_urb( port->write_urb ); + usb_free_urb(port->write_urb); port->write_urb = NULL; } usb_kill_urb(port->interrupt_in_urb); @@ -356,7 +373,7 @@ static void kobil_read_int_callback(struct urb *urb) struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int status = urb->status; -// char *dbg_data; +/* char *dbg_data; */ dbg("%s - port %d", __func__, port->number); @@ -369,48 +386,50 @@ static void kobil_read_int_callback(struct urb *urb) tty = port->port.tty; if (urb->actual_length) { - // BEGIN DEBUG + /* BEGIN DEBUG */ /* - dbg_data = kzalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); + dbg_data = kzalloc((3 * purb->actual_length + 10) + * sizeof(char), GFP_KERNEL); if (! dbg_data) { - return; + return; } - for (i = 0; i < purb->actual_length; i++) { - sprintf(dbg_data +3*i, "%02X ", data[i]); + for (i = 0; i < purb->actual_length; i++) { + sprintf(dbg_data +3*i, "%02X ", data[i]); } - dbg(" <-- %s", dbg_data ); + dbg(" <-- %s", dbg_data); kfree(dbg_data); */ - // END DEBUG + /* END DEBUG */ tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } - - // someone sets the dev to 0 if the close method has been called + /* someone sets the dev to 0 if the close method has been called */ port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); + dbg("%s - port %d Send read URB returns: %i", + __func__, port->number, result); } -static void kobil_write_callback( struct urb *purb ) +static void kobil_write_callback(struct urb *purb) { } -static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, +static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { int length = 0; int result = 0; int todo = 0; - struct kobil_private * priv; + struct kobil_private *priv; if (count == 0) { - dbg("%s - port %d write request of 0 bytes", __func__, port->number); + dbg("%s - port %d write request of 0 bytes", + __func__, port->number); return 0; } @@ -421,69 +440,77 @@ static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, return -ENOMEM; } - // Copy data to buffer - memcpy (priv->buf + priv->filled, buf, count); - usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); + /* Copy data to buffer */ + memcpy(priv->buf + priv->filled, buf, count); + usb_serial_debug_data(debug, &port->dev, __func__, count, + priv->buf + priv->filled); priv->filled = priv->filled + count; - // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. - if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || - ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { - - // stop reading (except TWIN and KAAN SIM) - if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) + /* only send complete block. TWIN, KAAN SIM and adapter K + use the same protocol. */ + if (((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || + ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4)))) { + /* stop reading (except TWIN and KAAN SIM) */ + if ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) + || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID)) usb_kill_urb(port->interrupt_in_urb); todo = priv->filled - priv->cur_pos; - while(todo > 0) { - // max 8 byte in one urb (endpoint size) + while (todo > 0) { + /* max 8 byte in one urb (endpoint size) */ length = (todo < 8) ? todo : 8; - // copy data to transfer buffer - memcpy(port->write_urb->transfer_buffer, priv->buf + priv->cur_pos, length ); - usb_fill_int_urb( port->write_urb, - port->serial->dev, - usb_sndintpipe(port->serial->dev, priv->write_int_endpoint_address), - port->write_urb->transfer_buffer, - length, - kobil_write_callback, - port, - 8 - ); + /* copy data to transfer buffer */ + memcpy(port->write_urb->transfer_buffer, + priv->buf + priv->cur_pos, length); + usb_fill_int_urb(port->write_urb, + port->serial->dev, + usb_sndintpipe(port->serial->dev, + priv->write_int_endpoint_address), + port->write_urb->transfer_buffer, + length, + kobil_write_callback, + port, + 8 + ); priv->cur_pos = priv->cur_pos + length; - result = usb_submit_urb( port->write_urb, GFP_NOIO ); - dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result); + result = usb_submit_urb(port->write_urb, GFP_NOIO); + dbg("%s - port %d Send write URB returns: %i", + __func__, port->number, result); todo = priv->filled - priv->cur_pos; - if (todo > 0) { + if (todo > 0) msleep(24); - } + } - } // end while - priv->filled = 0; priv->cur_pos = 0; - // someone sets the dev to 0 if the close method has been called + /* someone sets the dev to 0 if the close method + has been called */ port->interrupt_in_urb->dev = port->serial->dev; - - // start reading (except TWIN and KAAN SIM) - if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) { - // someone sets the dev to 0 if the close method has been called + + /* start reading (except TWIN and KAAN SIM) */ + if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || + priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { + /* someone sets the dev to 0 if the close method has + been called */ port->interrupt_in_urb->dev = port->serial->dev; - - result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); - dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); + + result = usb_submit_urb(port->interrupt_in_urb, + GFP_NOIO); + dbg("%s - port %d Send read URB returns: %i", + __func__, port->number, result); } } return count; } -static int kobil_write_room (struct tty_struct *tty) +static int kobil_write_room(struct tty_struct *tty) { - //dbg("%s - port %d", __func__, port->number); + /* dbg("%s - port %d", __func__, port->number); */ /* FIXME */ return 8; } @@ -492,34 +519,34 @@ static int kobil_write_room (struct tty_struct *tty) static int kobil_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; - struct kobil_private * priv; + struct kobil_private *priv; int result; unsigned char *transfer_buffer; int transfer_buffer_length = 8; priv = usb_get_serial_port_data(port); - if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { - // This device doesn't support ioctl calls + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID + || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { + /* This device doesn't support ioctl calls */ return -EINVAL; } - // allocate memory for transfer buffer + /* allocate memory for transfer buffer */ transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); - if (!transfer_buffer) { + if (!transfer_buffer) return -ENOMEM; - } - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_GetStatusLineState, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, - 0, - 0, - transfer_buffer, - transfer_buffer_length, - KOBIL_TIMEOUT); - - dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_GetStatusLineState, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, + 0, + 0, + transfer_buffer, + transfer_buffer_length, + KOBIL_TIMEOUT); + + dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", __func__, port->number, result, transfer_buffer[0]); result = 0; @@ -533,7 +560,7 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; - struct kobil_private * priv; + struct kobil_private *priv; int result; int dtr = 0; int rts = 0; @@ -542,16 +569,16 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, /* FIXME: locking ? */ priv = usb_get_serial_port_data(port); - if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { - // This device doesn't support ioctl calls + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID + || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { + /* This device doesn't support ioctl calls */ return -EINVAL; } - // allocate memory for transfer buffer + /* allocate memory for transfer buffer */ transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); - if (! transfer_buffer) { + if (!transfer_buffer) return -ENOMEM; - } if (set & TIOCM_RTS) rts = 1; @@ -564,34 +591,39 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { if (dtr != 0) - dbg("%s - port %d Setting DTR", __func__, port->number); + dbg("%s - port %d Setting DTR", + __func__, port->number); else - dbg("%s - port %d Clearing DTR", __func__, port->number); - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_SetStatusLinesOrQueues, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR), - 0, - transfer_buffer, - 0, - KOBIL_TIMEOUT); + dbg("%s - port %d Clearing DTR", + __func__, port->number); + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_SetStatusLinesOrQueues, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR), + 0, + transfer_buffer, + 0, + KOBIL_TIMEOUT); } else { if (rts != 0) - dbg("%s - port %d Setting RTS", __func__, port->number); + dbg("%s - port %d Setting RTS", + __func__, port->number); else - dbg("%s - port %d Clearing RTS", __func__, port->number); - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_SetStatusLinesOrQueues, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS), - 0, - transfer_buffer, - 0, - KOBIL_TIMEOUT); + dbg("%s - port %d Clearing RTS", + __func__, port->number); + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_SetStatusLinesOrQueues, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS), + 0, + transfer_buffer, + 0, + KOBIL_TIMEOUT); } - dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result); + dbg("%s - port %d Send set_status_line URB returns: %i", + __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? result : 0; } @@ -599,32 +631,35 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, static void kobil_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old) { - struct kobil_private * priv; + struct kobil_private *priv; int result; unsigned short urb_val = 0; int c_cflag = tty->termios->c_cflag; speed_t speed; - void * settings; + void *settings; priv = usb_get_serial_port_data(port); - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) - // This device doesn't support ioctl calls + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || + priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) + /* This device doesn't support ioctl calls */ return; - switch (speed = tty_get_baud_rate(tty)) { - case 1200: - urb_val = SUSBCR_SBR_1200; - break; - default: - speed = 9600; - case 9600: - urb_val = SUSBCR_SBR_9600; - break; + speed = tty_get_baud_rate(tty); + switch (speed) { + case 1200: + urb_val = SUSBCR_SBR_1200; + break; + default: + speed = 9600; + case 9600: + urb_val = SUSBCR_SBR_9600; + break; } - urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit; + urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : + SUSBCR_SPASB_1StopBit; settings = kzalloc(50, GFP_KERNEL); - if (! settings) + if (!settings) return; sprintf(settings, "%d ", speed); @@ -644,48 +679,50 @@ static void kobil_set_termios(struct tty_struct *tty, tty->termios->c_cflag &= ~CMSPAR; tty_encode_baud_rate(tty, speed, speed); - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_SetBaudRateParityAndStopBits, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - urb_val, - 0, - settings, - 0, - KOBIL_TIMEOUT + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_SetBaudRateParityAndStopBits, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + urb_val, + 0, + settings, + 0, + KOBIL_TIMEOUT ); kfree(settings); } -static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) +static int kobil_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; - struct kobil_private * priv = usb_get_serial_port_data(port); + struct kobil_private *priv = usb_get_serial_port_data(port); unsigned char *transfer_buffer; int transfer_buffer_length = 8; int result; - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) - // This device doesn't support ioctl calls + if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || + priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) + /* This device doesn't support ioctl calls */ return 0; switch (cmd) { case TCFLSH: transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); - if (! transfer_buffer) - return -ENOBUFS; - - result = usb_control_msg( port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0 ), - SUSBCRequest_Misc, - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, - SUSBCR_MSC_ResetAllQueues, - 0, - NULL,//transfer_buffer, - 0, - KOBIL_TIMEOUT + if (!transfer_buffer) + return -ENOBUFS; + + result = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), + SUSBCRequest_Misc, + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, + SUSBCR_MSC_ResetAllQueues, + 0, + NULL, /* transfer_buffer, */ + 0, + KOBIL_TIMEOUT ); - + dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); kfree(transfer_buffer); return (result < 0) ? -EIO: 0; @@ -694,14 +731,14 @@ static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int } } -static int __init kobil_init (void) +static int __init kobil_init(void) { int retval; retval = usb_serial_register(&kobil_device); if (retval) goto failed_usb_serial_register; retval = usb_register(&kobil_driver); - if (retval) + if (retval) goto failed_usb_register; info(DRIVER_VERSION " " DRIVER_AUTHOR); @@ -715,18 +752,18 @@ failed_usb_serial_register: } -static void __exit kobil_exit (void) +static void __exit kobil_exit(void) { - usb_deregister (&kobil_driver); - usb_serial_deregister (&kobil_device); + usb_deregister(&kobil_driver); + usb_serial_deregister(&kobil_device); } module_init(kobil_init); module_exit(kobil_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_LICENSE( "GPL" ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug enabled or not"); -- cgit v1.2.3-70-g09d2 From b31f658b0bb42b315c22ae2ef814e5fba36ac737 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:22 +0100 Subject: kobil_sct: Fix ioctls Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/kobil_sct.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index f0f8353ec1a..deba28ec77e 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -640,9 +640,11 @@ static void kobil_set_termios(struct tty_struct *tty, priv = usb_get_serial_port_data(port); if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || - priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) + priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { /* This device doesn't support ioctl calls */ + *tty->termios = *old; return; + } speed = tty_get_baud_rate(tty); switch (speed) { @@ -704,7 +706,7 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file, if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) /* This device doesn't support ioctl calls */ - return 0; + return -ENOIOCTLCMD; switch (cmd) { case TCFLSH: -- cgit v1.2.3-70-g09d2 From e19b2560be568301ec4cc486671361ef0471d839 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:30 +0100 Subject: tty-usb-mct-u232: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/mct_u232.c | 273 ++++++++++++++++++++++-------------------- 1 file changed, 141 insertions(+), 132 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 7bce4302a5f..7a804d6b3a4 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -33,10 +33,11 @@ * - Fixed an endianess problem with the baudrate selection for PowerPC. * * 06-Dec-2001 Martin Hamilton - * Added support for the Belkin F5U109 DB9 adaptor + * - Added support for the Belkin F5U109 DB9 adaptor * * 30-May-2001 Greg Kroah-Hartman - * switched from using spinlock to a semaphore, which fixes lots of problems. + * - switched from using spinlock to a semaphore, which fixes lots of + * problems. * * 04-May-2001 Stelian Pop * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes @@ -49,7 +50,7 @@ * 08-Apr-2001 gb * - Identify version on module load. * - * 06-Jan-2001 Cornel Ciocirlan + * 06-Jan-2001 Cornel Ciocirlan * - Added support for Sitecom U232-P25 model (Product Id 0x0230) * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200) * @@ -59,8 +60,8 @@ * (lots of things will change if/when the usb-serial core changes to * handle these issues. * - * 27-Nov-2000 Wolfgang Grandegger - * A version for kernel 2.4.0-test10 released to the Linux community + * 27-Nov-2000 Wolfgang Grandegge + * A version for kernel 2.4.0-test10 released to the Linux community * (via linux-usb-devel). */ @@ -73,7 +74,7 @@ #include #include #include -#include +#include #include #include #include "mct_u232.h" @@ -90,27 +91,21 @@ static int debug; /* * Function prototypes */ -static int mct_u232_startup (struct usb_serial *serial); -static void mct_u232_shutdown (struct usb_serial *serial); -static int mct_u232_open (struct tty_struct *tty, - struct usb_serial_port *port, - struct file *filp); -static void mct_u232_close (struct tty_struct *tty, - struct usb_serial_port *port, - struct file *filp); -static void mct_u232_read_int_callback (struct urb *urb); -static void mct_u232_set_termios (struct tty_struct *tty, - struct usb_serial_port *port, - struct ktermios * old); -static void mct_u232_break_ctl (struct tty_struct *tty, - int break_state ); -static int mct_u232_tiocmget (struct tty_struct *tty, - struct file *file); -static int mct_u232_tiocmset (struct tty_struct *tty, - struct file *file, unsigned int set, - unsigned int clear); -static void mct_u232_throttle (struct tty_struct *tty); -static void mct_u232_unthrottle (struct tty_struct *tty); +static int mct_u232_startup(struct usb_serial *serial); +static void mct_u232_shutdown(struct usb_serial *serial); +static int mct_u232_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void mct_u232_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp); +static void mct_u232_read_int_callback(struct urb *urb); +static void mct_u232_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old); +static void mct_u232_break_ctl(struct tty_struct *tty, int break_state); +static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file); +static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +static void mct_u232_throttle(struct tty_struct *tty); +static void mct_u232_unthrottle(struct tty_struct *tty); /* @@ -124,7 +119,7 @@ static struct usb_device_id id_table_combined [] = { { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver mct_u232_driver = { .name = "mct_u232", @@ -178,23 +173,34 @@ struct mct_u232_private { * Later day 2.6.0-test kernels have new baud rates like B230400 which * we do not know how to support. We ignore them for the moment. */ -static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result) +static int mct_u232_calculate_baud_rate(struct usb_serial *serial, + speed_t value, speed_t *result) { *result = value; if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID - || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { + || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { switch (value) { - case 300: return 0x01; - case 600: return 0x02; /* this one not tested */ - case 1200: return 0x03; - case 2400: return 0x04; - case 4800: return 0x06; - case 9600: return 0x08; - case 19200: return 0x09; - case 38400: return 0x0a; - case 57600: return 0x0b; - case 115200: return 0x0c; + case 300: + return 0x01; + case 600: + return 0x02; /* this one not tested */ + case 1200: + return 0x03; + case 2400: + return 0x04; + case 4800: + return 0x06; + case 9600: + return 0x08; + case 19200: + return 0x09; + case 38400: + return 0x0a; + case 57600: + return 0x0b; + case 115200: + return 0x0c; default: *result = 9600; return 0x08; @@ -226,18 +232,19 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, struct usb_serial *serial, struct usb_serial_port *port, speed_t value) { __le32 divisor; - int rc; - unsigned char zero_byte = 0; - unsigned char cts_enable_byte = 0; - speed_t speed; - - divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed)); - - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - MCT_U232_SET_BAUD_RATE_REQUEST, - MCT_U232_SET_REQUEST_TYPE, - 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, - WDR_TIMEOUT); + int rc; + unsigned char zero_byte = 0; + unsigned char cts_enable_byte = 0; + speed_t speed; + + divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, + &speed)); + + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + MCT_U232_SET_BAUD_RATE_REQUEST, + MCT_U232_SET_REQUEST_TYPE, + 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, + WDR_TIMEOUT); if (rc < 0) /*FIXME: What value speed results */ err("Set BAUD RATE %d failed (error = %d)", value, rc); else @@ -256,55 +263,55 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty, whether data will be transmitted to a device which is not asserting the 'CTS' signal. If the second message's data byte is zero, data will be transmitted even if 'CTS' is not asserted (i.e. no hardware - flow control). if the second message's data byte is nonzero (a value - of 1 is used by this driver), data will not be transmitted to a device - which is not asserting 'CTS'. + flow control). if the second message's data byte is nonzero (a + value of 1 is used by this driver), data will not be transmitted to + a device which is not asserting 'CTS'. */ rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - MCT_U232_SET_UNKNOWN1_REQUEST, - MCT_U232_SET_REQUEST_TYPE, - 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, - WDR_TIMEOUT); + MCT_U232_SET_UNKNOWN1_REQUEST, + MCT_U232_SET_REQUEST_TYPE, + 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, + WDR_TIMEOUT); if (rc < 0) - err("Sending USB device request code %d failed (error = %d)", + err("Sending USB device request code %d failed (error = %d)", MCT_U232_SET_UNKNOWN1_REQUEST, rc); - if (port && C_CRTSCTS(tty)) { + if (port && C_CRTSCTS(tty)) cts_enable_byte = 1; - } - dbg("set_baud_rate: send second control message, data = %02X", cts_enable_byte); + dbg("set_baud_rate: send second control message, data = %02X", + cts_enable_byte); rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - MCT_U232_SET_CTS_REQUEST, - MCT_U232_SET_REQUEST_TYPE, - 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, - WDR_TIMEOUT); + MCT_U232_SET_CTS_REQUEST, + MCT_U232_SET_REQUEST_TYPE, + 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, + WDR_TIMEOUT); if (rc < 0) - err("Sending USB device request code %d failed (error = %d)", - MCT_U232_SET_CTS_REQUEST, rc); + err("Sending USB device request code %d failed (error = %d)", + MCT_U232_SET_CTS_REQUEST, rc); - return rc; + return rc; } /* mct_u232_set_baud_rate */ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) { - int rc; - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - MCT_U232_SET_LINE_CTRL_REQUEST, - MCT_U232_SET_REQUEST_TYPE, - 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, - WDR_TIMEOUT); + int rc; + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + MCT_U232_SET_LINE_CTRL_REQUEST, + MCT_U232_SET_REQUEST_TYPE, + 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, + WDR_TIMEOUT); if (rc < 0) err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc); dbg("set_line_ctrl: 0x%x", lcr); - return rc; + return rc; } /* mct_u232_set_line_ctrl */ static int mct_u232_set_modem_ctrl(struct usb_serial *serial, unsigned int control_state) { - int rc; + int rc; unsigned char mcr = MCT_U232_MCR_NONE; if (control_state & TIOCM_DTR) @@ -312,37 +319,39 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial, if (control_state & TIOCM_RTS) mcr |= MCT_U232_MCR_RTS; - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - MCT_U232_SET_MODEM_CTRL_REQUEST, - MCT_U232_SET_REQUEST_TYPE, - 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, - WDR_TIMEOUT); + rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + MCT_U232_SET_MODEM_CTRL_REQUEST, + MCT_U232_SET_REQUEST_TYPE, + 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, + WDR_TIMEOUT); if (rc < 0) err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc); dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); - return rc; + return rc; } /* mct_u232_set_modem_ctrl */ -static int mct_u232_get_modem_stat(struct usb_serial *serial, unsigned char *msr) +static int mct_u232_get_modem_stat(struct usb_serial *serial, + unsigned char *msr) { - int rc; - rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - MCT_U232_GET_MODEM_STAT_REQUEST, - MCT_U232_GET_REQUEST_TYPE, - 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, - WDR_TIMEOUT); + int rc; + rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), + MCT_U232_GET_MODEM_STAT_REQUEST, + MCT_U232_GET_REQUEST_TYPE, + 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, + WDR_TIMEOUT); if (rc < 0) { err("Get MODEM STATus failed (error = %d)", rc); *msr = 0; } dbg("get_modem_stat: 0x%x", *msr); - return rc; + return rc; } /* mct_u232_get_modem_stat */ -static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr) +static void mct_u232_msr_to_state(unsigned int *control_state, + unsigned char msr) { - /* Translate Control Line states */ + /* Translate Control Line states */ if (msr & MCT_U232_MSR_DSR) *control_state |= TIOCM_DSR; else @@ -359,14 +368,14 @@ static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr *control_state |= TIOCM_CD; else *control_state &= ~TIOCM_CD; - dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); + dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); } /* mct_u232_msr_to_state */ /* * Driver's tty interface functions */ -static int mct_u232_startup (struct usb_serial *serial) +static int mct_u232_startup(struct usb_serial *serial) { struct mct_u232_private *priv; struct usb_serial_port *port, *rport; @@ -388,18 +397,18 @@ static int mct_u232_startup (struct usb_serial *serial) rport->interrupt_in_urb = NULL; port->read_urb->context = port; - return (0); + return 0; } /* mct_u232_startup */ -static void mct_u232_shutdown (struct usb_serial *serial) +static void mct_u232_shutdown(struct usb_serial *serial) { struct mct_u232_private *priv; int i; - + dbg("%s", __func__); - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ priv = usb_get_serial_port_data(serial->port[i]); if (priv) { @@ -409,7 +418,7 @@ static void mct_u232_shutdown (struct usb_serial *serial) } } /* mct_u232_shutdown */ -static int mct_u232_open (struct tty_struct *tty, +static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; @@ -427,10 +436,11 @@ static int mct_u232_open (struct tty_struct *tty, * it seems to be able to accept only 16 bytes (and that's what * SniffUSB says too...) */ - if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID) + if (le16_to_cpu(serial->dev->descriptor.idProduct) + == MCT_U232_SITECOM_PID) port->bulk_out_size = 16; - /* Do a defined restart: the normal serial device seems to + /* Do a defined restart: the normal serial device seems to * always turn on DTR and RTS here, so do the same. I'm not * sure if this is really necessary. But it should not harm * either. @@ -440,8 +450,8 @@ static int mct_u232_open (struct tty_struct *tty, priv->control_state = TIOCM_DTR | TIOCM_RTS; else priv->control_state = 0; - - priv->last_lcr = (MCT_U232_DATA_BITS_8 | + + priv->last_lcr = (MCT_U232_DATA_BITS_8 | MCT_U232_PARITY_NONE | MCT_U232_STOP_BITS_1); control_state = priv->control_state; @@ -488,7 +498,7 @@ static void mct_u232_close(struct tty_struct *tty, struct mct_u232_private *priv = usb_get_serial_port_data(port); dbg("%s port %d", __func__, port->number); - if (tty) { + if (tty) { c_cflag = tty->termios->c_cflag; mutex_lock(&port->serial->disc_mutex); if (c_cflag & HUPCL && !port->serial->disconnected) { @@ -512,7 +522,7 @@ static void mct_u232_close(struct tty_struct *tty, } /* mct_u232_close */ -static void mct_u232_read_int_callback (struct urb *urb) +static void mct_u232_read_int_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; struct mct_u232_private *priv = usb_get_serial_port_data(port); @@ -545,8 +555,9 @@ static void mct_u232_read_int_callback (struct urb *urb) return; } - dbg("%s - port %d", __func__, port->number); - usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); + dbg("%s - port %d", __func__, port->number); + usb_serial_debug_data(debug, &port->dev, __func__, + urb->actual_length, data); /* * Work-a-round: handle the 'usual' bulk-in pipe here @@ -555,26 +566,25 @@ static void mct_u232_read_int_callback (struct urb *urb) int i; tty = port->port.tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) { + for (i = 0; i < urb->actual_length ; ++i) tty_insert_flip_char(tty, data[i], 0); - } tty_flip_buffer_push(tty); } goto exit; } - + /* * The interrupt-in pipe signals exceptional conditions (modem line * signal changes and errors). data[0] holds MSR, data[1] holds LSR. */ spin_lock_irqsave(&priv->lock, flags); priv->last_msr = data[MCT_U232_MSR_INDEX]; - + /* Record Control Line states */ mct_u232_msr_to_state(&priv->control_state, priv->last_msr); #if 0 - /* Not yet handled. See belin_sa.c for further information */ + /* Not yet handled. See belkin_sa.c for further information */ /* Now to report any errors */ priv->last_lsr = data[MCT_U232_LSR_INDEX]; /* @@ -600,15 +610,15 @@ static void mct_u232_read_int_callback (struct urb *urb) #endif spin_unlock_irqrestore(&priv->lock, flags); exit: - retval = usb_submit_urb (urb, GFP_ATOMIC); + retval = usb_submit_urb(urb, GFP_ATOMIC); if (retval) - err ("%s - usb_submit_urb failed with result %d", + err("%s - usb_submit_urb failed with result %d", __func__, retval); } /* mct_u232_read_int_callback */ -static void mct_u232_set_termios (struct tty_struct *tty, - struct usb_serial_port *port, - struct ktermios *old_termios) +static void mct_u232_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, + struct ktermios *old_termios) { struct usb_serial *serial = port->serial; struct mct_u232_private *priv = usb_get_serial_port_data(port); @@ -632,7 +642,7 @@ static void mct_u232_set_termios (struct tty_struct *tty, * Premature optimization is the root of all evil. */ - /* reassert DTR and RTS on transition from B0 */ + /* reassert DTR and RTS on transition from B0 */ if ((old_cflag & CBAUD) == B0) { dbg("%s: baud was B0", __func__); control_state |= TIOCM_DTR | TIOCM_RTS; @@ -641,11 +651,11 @@ static void mct_u232_set_termios (struct tty_struct *tty, mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); - if ((cflag & CBAUD) == B0 ) { + if ((cflag & CBAUD) == B0) { dbg("%s: baud is B0", __func__); /* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR | TIOCM_RTS); - mct_u232_set_modem_ctrl(serial, control_state); + mct_u232_set_modem_ctrl(serial, control_state); } /* @@ -717,7 +727,7 @@ static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file) struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned int control_state; unsigned long flags; - + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); @@ -735,7 +745,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file, struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned int control_state; unsigned long flags; - + dbg("%s", __func__); spin_lock_irqsave(&priv->lock, flags); @@ -798,7 +808,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty) } } -static int __init mct_u232_init (void) +static int __init mct_u232_init(void) { int retval; retval = usb_serial_register(&mct_u232_device); @@ -816,18 +826,17 @@ failed_usb_serial_register: } -static void __exit mct_u232_exit (void) +static void __exit mct_u232_exit(void) { - usb_deregister (&mct_u232_driver); - usb_serial_deregister (&mct_u232_device); + usb_deregister(&mct_u232_driver); + usb_serial_deregister(&mct_u232_device); } - -module_init (mct_u232_init); +module_init(mct_u232_init); module_exit(mct_u232_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From acc80758abc91e5d91f3f4ceb8dd94da2aa7064d Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:40 +0100 Subject: mct_u232: Use flip buffer functions Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/mct_u232.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 7a804d6b3a4..0ded8bd6ec8 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -563,11 +563,9 @@ static void mct_u232_read_int_callback(struct urb *urb) * Work-a-round: handle the 'usual' bulk-in pipe here */ if (urb->transfer_buffer_length > 2) { - int i; tty = port->port.tty; if (urb->actual_length) { - for (i = 0; i < urb->actual_length ; ++i) - tty_insert_flip_char(tty, data[i], 0); + tty_insert_flip_string(tty, data, urb->actual_length); tty_flip_buffer_push(tty); } goto exit; -- cgit v1.2.3-70-g09d2 From 3a0f43e9deffd9619ac34e3b6b9ba7089aa1e511 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:49 +0100 Subject: tty-usb-pl2303: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/pl2303.c | 64 +++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index a0016725d31..2c9c446ad62 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -10,7 +10,8 @@ * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * */ @@ -25,7 +26,7 @@ #include #include #include -#include +#include #include #include #include "pl2303.h" @@ -116,7 +117,7 @@ static struct usb_driver pl2303_driver = { #define CONTROL_RTS 0x02 #define BREAK_REQUEST_TYPE 0x21 -#define BREAK_REQUEST 0x23 +#define BREAK_REQUEST 0x23 #define BREAK_ON 0xffff #define BREAK_OFF 0x0000 @@ -222,7 +223,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb) if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); + return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size; } /* @@ -236,7 +237,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size); + return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size; } /* @@ -395,7 +396,7 @@ static int pl2303_startup(struct usb_serial *serial) cleanup: kfree(buf); - for (--i; i>=0; --i) { + for (--i; i >= 0; --i) { priv = usb_get_serial_port_data(serial->port[i]); pl2303_buf_free(priv->buf); kfree(priv); @@ -407,7 +408,7 @@ cleanup: static int set_control_lines(struct usb_device *dev, u8 value) { int retval; - + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, value, 0, NULL, 0, 100); @@ -452,7 +453,7 @@ static void pl2303_send(struct usb_serial_port *port) dev_err(&port->dev, "%s - failed submitting write urb," " error %d\n", __func__, result); priv->write_urb_in_use = 0; - // TODO: reschedule pl2303_send + /* TODO: reschedule pl2303_send */ } usb_serial_port_softint(port); @@ -561,11 +562,19 @@ static void pl2303_set_termios(struct tty_struct *tty, if (cflag & CSIZE) { switch (cflag & CSIZE) { - case CS5: buf[6] = 5; break; - case CS6: buf[6] = 6; break; - case CS7: buf[6] = 7; break; - default: - case CS8: buf[6] = 8; break; + case CS5: + buf[6] = 5; + break; + case CS6: + buf[6] = 6; + break; + case CS7: + buf[6] = 7; + break; + default: + case CS8: + buf[6] = 8; + break; } dbg("%s - data bits = %d", __func__, buf[6]); } @@ -694,7 +703,7 @@ static void pl2303_close(struct tty_struct *tty, /* that is not unnecessarily long) */ bps = tty_get_baud_rate(tty); if (bps > 1200) - timeout = max((HZ*2560)/bps,HZ/10); + timeout = max((HZ*2560)/bps, HZ/10); else timeout = 2*HZ; schedule_timeout_interruptible(timeout); @@ -740,7 +749,7 @@ static int pl2303_open(struct tty_struct *tty, if (tty) pl2303_set_termios(tty, port, &tmp_termios); - //FIXME: need to assert RTS and DTR if CRTSCTS off + /* FIXME: need to assert RTS and DTR if CRTSCTS off */ dbg("%s - submitting read urb", __func__); port->read_urb->dev = serial->dev; @@ -843,12 +852,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) status = priv->line_status; spin_unlock_irqrestore(&priv->lock, flags); - changed=prevstatus^status; + changed = prevstatus ^ status; if (((arg & TIOCM_RNG) && (changed & UART_RING)) || ((arg & TIOCM_DSR) && (changed & UART_DSR)) || ((arg & TIOCM_CD) && (changed & UART_DCD)) || - ((arg & TIOCM_CTS) && (changed & UART_CTS)) ) { + ((arg & TIOCM_CTS) && (changed & UART_CTS))) { return 0; } prevstatus = status; @@ -864,15 +873,13 @@ static int pl2303_ioctl(struct tty_struct *tty, struct file *file, dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); switch (cmd) { - case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __func__, port->number); - return wait_modem_info(port, arg); - - default: - dbg("%s not supported = 0x%04x", __func__, cmd); - break; + case TIOCMIWAIT: + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); + return wait_modem_info(port, arg); + default: + dbg("%s not supported = 0x%04x", __func__, cmd); + break; } - return -ENOIOCTLCMD; } @@ -889,7 +896,8 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state) state = BREAK_OFF; else state = BREAK_ON; - dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on"); + dbg("%s - turning break %s", __func__, + state == BREAK_OFF ? "off" : "on"); result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), BREAK_REQUEST, BREAK_REQUEST_TYPE, state, @@ -943,7 +951,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port, if (actual_length < length) return; - /* Save off the uart status for others to look at */ + /* Save off the uart status for others to look at */ spin_lock_irqsave(&priv->lock, flags); priv->line_status = data[status_idx]; spin_unlock_irqrestore(&priv->lock, flags); @@ -1042,7 +1050,7 @@ static void pl2303_read_bulk_callback(struct urb *urb) /* break takes precedence over parity, */ /* which takes precedence over framing errors */ - if (line_status & UART_BREAK_ERROR ) + if (line_status & UART_BREAK_ERROR) tty_flag = TTY_BREAK; else if (line_status & UART_PARITY_ERROR) tty_flag = TTY_PARITY; -- cgit v1.2.3-70-g09d2 From 9660ea36bdcd4c33174e912a3e649c048d22a3d6 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:14:59 +0100 Subject: tty-usb-sierra: Coding style - minor Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/sierra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 892020d4855..2f6f1523ec5 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -757,7 +757,7 @@ failed_device_register: static void __exit sierra_exit(void) { - usb_deregister (&sierra_driver); + usb_deregister(&sierra_driver); usb_serial_deregister(&sierra_device); } -- cgit v1.2.3-70-g09d2 From 0487b583f268ea43ededd7897dbf519bdcb395ee Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:08 +0100 Subject: tty-usb-spcp8x5: Minor coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/spcp8x5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 58495f5cca1..283cf6b36b2 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -208,7 +208,7 @@ static inline unsigned int ringbuf_avail_data(struct ringbuf *pb) { if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); + return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size; } /* get the number of space in the pipo */ @@ -216,7 +216,7 @@ static inline unsigned int ringbuf_avail_space(struct ringbuf *pb) { if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size); + return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size; } /* put count data into pipo */ -- cgit v1.2.3-70-g09d2 From a30fa793f35b9a72fdb9ea90a539c8c9cf7bee94 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:17 +0100 Subject: tty-usb-ti-usb: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ti_usb_3410_5052.c | 266 +++++++++++++++++++--------------- 1 file changed, 151 insertions(+), 115 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 48831a755fc..e39c779e416 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -16,7 +16,7 @@ * For questions or problems with this driver, contact Texas Instruments * technical support, or Al Borchers , or * Peter Berger . - * + * * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052 * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device * configuration. @@ -82,7 +82,7 @@ #include #include #include -#include +#include #include #include #include @@ -151,21 +151,22 @@ struct ti_device { static int ti_startup(struct usb_serial *serial); static void ti_shutdown(struct usb_serial *serial); static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, - struct file *file); + struct file *file); static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, - struct file *file); + struct file *file); static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, - const unsigned char *data, int count); + const unsigned char *data, int count); static int ti_write_room(struct tty_struct *tty); static int ti_chars_in_buffer(struct tty_struct *tty); static void ti_throttle(struct tty_struct *tty); static void ti_unthrottle(struct tty_struct *tty); -static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); -static void ti_set_termios(struct tty_struct *tty, struct usb_serial_port *port, - struct ktermios *old_termios); +static int ti_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); +static void ti_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); static int ti_tiocmget(struct tty_struct *tty, struct file *file); static int ti_tiocmset(struct tty_struct *tty, struct file *file, - unsigned int set, unsigned int clear); + unsigned int set, unsigned int clear); static void ti_break(struct tty_struct *tty, int break_state); static void ti_interrupt_callback(struct urb *urb); static void ti_bulk_in_callback(struct urb *urb); @@ -327,19 +328,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); module_param(low_latency, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(low_latency, "TTY low_latency flag, 0=off, 1=on, default is off"); +MODULE_PARM_DESC(low_latency, + "TTY low_latency flag, 0=off, 1=on, default is off"); module_param(closing_wait, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain in close, in .01 secs, default is 4000"); +MODULE_PARM_DESC(closing_wait, + "Maximum wait for data to drain in close, in .01 secs, default is 4000"); module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO); -MODULE_PARM_DESC(vendor_3410, "Vendor ids for 3410 based devices, 1-5 short integers"); +MODULE_PARM_DESC(vendor_3410, + "Vendor ids for 3410 based devices, 1-5 short integers"); module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO); -MODULE_PARM_DESC(product_3410, "Product ids for 3410 based devices, 1-5 short integers"); +MODULE_PARM_DESC(product_3410, + "Product ids for 3410 based devices, 1-5 short integers"); module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO); -MODULE_PARM_DESC(vendor_5052, "Vendor ids for 5052 based devices, 1-5 short integers"); +MODULE_PARM_DESC(vendor_5052, + "Vendor ids for 5052 based devices, 1-5 short integers"); module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO); -MODULE_PARM_DESC(product_5052, "Product ids for 5052 based devices, 1-5 short integers"); +MODULE_PARM_DESC(product_5052, + "Product ids for 5052 based devices, 1-5 short integers"); MODULE_DEVICE_TABLE(usb, ti_id_table_combined); @@ -348,18 +355,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined); static int __init ti_init(void) { - int i,j; + int i, j; int ret; /* insert extra vendor and product ids */ j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; - for (i=0; iinterface, ti_id_table_3410)) tdev->td_is_3410 = 1; - dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052"); + dbg("%s - device type is %s", __func__, + tdev->td_is_3410 ? "3410" : "5052"); /* if we have only 1 configuration, download firmware */ if (dev->descriptor.bNumConfigurations == 1) { @@ -447,7 +455,7 @@ static int ti_startup(struct usb_serial *serial) status = -ENODEV; goto free_tdev; - } + } /* the second configuration must be set (in sysfs by hotplug script) */ if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) { @@ -464,7 +472,8 @@ static int ti_startup(struct usb_serial *serial) goto free_tports; } spin_lock_init(&tport->tp_lock); - tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); + tport->tp_uart_base_addr = (i == 0 ? + TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; tport->tp_closing_wait = closing_wait; init_waitqueue_head(&tport->tp_msr_wait); @@ -481,11 +490,11 @@ static int ti_startup(struct usb_serial *serial) usb_set_serial_port_data(serial->port[i], tport); tport->tp_uart_mode = 0; /* default is RS232 */ } - + return 0; free_tports: - for (--i; i>=0; --i) { + for (--i; i >= 0; --i) { tport = usb_get_serial_port_data(serial->port[i]); ti_buf_free(tport->tp_write_buf); kfree(tport); @@ -506,7 +515,7 @@ static void ti_shutdown(struct usb_serial *serial) dbg("%s", __func__); - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) { tport = usb_get_serial_port_data(serial->port[i]); if (tport) { ti_buf_free(tport->tp_write_buf); @@ -529,8 +538,8 @@ static int ti_open(struct tty_struct *tty, struct urb *urb; int port_number; int status; - __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | - TI_PIPE_TIMEOUT_ENABLE | + __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | + TI_PIPE_TIMEOUT_ENABLE | (TI_TRANSFER_TIMEOUT << 2)); dbg("%s - port %d", __func__, port->number); @@ -561,7 +570,8 @@ static int ti_open(struct tty_struct *tty, dbg("%s - start interrupt in urb", __func__); urb = tdev->td_serial->port[0]->interrupt_in_urb; if (!urb) { - dev_err(&port->dev, "%s - no interrupt urb\n", __func__); + dev_err(&port->dev, "%s - no interrupt urb\n", + __func__); status = -EINVAL; goto release_lock; } @@ -570,7 +580,9 @@ static int ti_open(struct tty_struct *tty, urb->dev = dev; status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status); + dev_err(&port->dev, + "%s - submit interrupt urb failed, %d\n", + __func__, status); goto release_lock; } } @@ -582,7 +594,8 @@ static int ti_open(struct tty_struct *tty, status = ti_command_out_sync(tdev, TI_OPEN_PORT, (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send open command, %d\n", + __func__, status); goto unlink_int_urb; } @@ -590,7 +603,8 @@ static int ti_open(struct tty_struct *tty, status = ti_command_out_sync(tdev, TI_START_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send start command, %d\n", + __func__, status); goto unlink_int_urb; } @@ -598,13 +612,15 @@ static int ti_open(struct tty_struct *tty, status = ti_command_out_sync(tdev, TI_PURGE_PORT, (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", + __func__, status); goto unlink_int_urb; } status = ti_command_out_sync(tdev, TI_PURGE_PORT, (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", + __func__, status); goto unlink_int_urb; } @@ -620,7 +636,8 @@ static int ti_open(struct tty_struct *tty, status = ti_command_out_sync(tdev, TI_OPEN_PORT, (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send open command (2), %d\n", + __func__, status); goto unlink_int_urb; } @@ -628,7 +645,8 @@ static int ti_open(struct tty_struct *tty, status = ti_command_out_sync(tdev, TI_START_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) { - dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot send start command (2), %d\n", + __func__, status); goto unlink_int_urb; } @@ -646,7 +664,8 @@ static int ti_open(struct tty_struct *tty, urb->dev = dev; status = usb_submit_urb(urb, GFP_KERNEL); if (status) { - dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status); + dev_err(&port->dev, "%s - submit read urb failed, %d\n", + __func__, status); goto unlink_int_urb; } @@ -675,7 +694,7 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, int do_unlock; dbg("%s - port %d", __func__, port->number); - + tdev = usb_get_serial_data(port->serial); tport = usb_get_serial_port_data(port); if (tdev == NULL || tport == NULL) @@ -695,7 +714,9 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, status = ti_command_out_sync(tdev, TI_CLOSE_PORT, (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); if (status) - dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status); + dev_err(&port->dev, + "%s - cannot send close port command, %d\n" + , __func__, status); /* if mutex_lock is interrupted, continue anyway */ do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); @@ -749,7 +770,7 @@ static int ti_write_room(struct tty_struct *tty) if (tport == NULL) return -ENODEV; - + spin_lock_irqsave(&tport->tp_lock, flags); room = ti_buf_space_avail(tport->tp_write_buf); spin_unlock_irqrestore(&tport->tp_lock, flags); @@ -810,7 +831,8 @@ static void ti_unthrottle(struct tty_struct *tty) if (I_IXOFF(tty) || C_CRTSCTS(tty)) { status = ti_restart_read(tport, tty); if (status) - dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status); + dev_err(&port->dev, "%s - cannot restart read, %d\n", + __func__, status); } } @@ -829,44 +851,42 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file, return -ENODEV; switch (cmd) { - case TIOCGSERIAL: - dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); - return ti_get_serial_info(tport, (struct serial_struct __user *)arg); - break; - - case TIOCSSERIAL: - dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); - return ti_set_serial_info(tport, (struct serial_struct __user *)arg); - break; - - case TIOCMIWAIT: - dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); - cprev = tport->tp_icount; - while (1) { - interruptible_sleep_on(&tport->tp_msr_wait); - if (signal_pending(current)) - return -ERESTARTSYS; - cnow = tport->tp_icount; - if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) - return -EIO; /* no change => error */ - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || - ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || - ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { - return 0; - } - cprev = cnow; - } - break; - - case TIOCGICOUNT: - dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); - if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount))) - return -EFAULT; - return 0; + case TIOCGSERIAL: + dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); + return ti_get_serial_info(tport, + (struct serial_struct __user *)arg); + case TIOCSSERIAL: + dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); + return ti_set_serial_info(tport, + (struct serial_struct __user *)arg); + case TIOCMIWAIT: + dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); + cprev = tport->tp_icount; + while (1) { + interruptible_sleep_on(&tport->tp_msr_wait); + if (signal_pending(current)) + return -ERESTARTSYS; + cnow = tport->tp_icount; + if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) + return -EIO; /* no change => error */ + if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || + ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || + ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) + return 0; + cprev = cnow; + } + break; + case TIOCGICOUNT: + dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", + __func__, port->number, + tport->tp_icount.rx, tport->tp_icount.tx); + if (copy_to_user((void __user *)arg, &tport->tp_icount, + sizeof(tport->tp_icount))) + return -EFAULT; + return 0; } - return -ENOIOCTLCMD; } @@ -876,7 +896,7 @@ static void ti_set_termios(struct tty_struct *tty, { struct ti_port *tport = usb_get_serial_port_data(port); struct ti_uart_config *config; - tcflag_t cflag,iflag; + tcflag_t cflag, iflag; int baud; int status; int port_number = port->number - port->serial->minor; @@ -888,7 +908,8 @@ static void ti_set_termios(struct tty_struct *tty, iflag = tty->termios->c_iflag; dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); - dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); + dbg("%s - old clfag %08x, old iflag %08x", __func__, + old_termios->c_cflag, old_termios->c_iflag); if (tport == NULL) return; @@ -907,19 +928,19 @@ static void ti_set_termios(struct tty_struct *tty, config->bUartMode = (__u8)(tport->tp_uart_mode); switch (cflag & CSIZE) { - case CS5: - config->bDataBits = TI_UART_5_DATA_BITS; - break; - case CS6: - config->bDataBits = TI_UART_6_DATA_BITS; - break; - case CS7: - config->bDataBits = TI_UART_7_DATA_BITS; - break; - default: - case CS8: - config->bDataBits = TI_UART_8_DATA_BITS; - break; + case CS5: + config->bDataBits = TI_UART_5_DATA_BITS; + break; + case CS6: + config->bDataBits = TI_UART_6_DATA_BITS; + break; + case CS7: + config->bDataBits = TI_UART_7_DATA_BITS; + break; + default: + case CS8: + config->bDataBits = TI_UART_8_DATA_BITS; + break; } /* CMSPAR isn't supported by this driver */ @@ -935,7 +956,7 @@ static void ti_set_termios(struct tty_struct *tty, } } else { config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING; - config->bParity = TI_UART_NO_PARITY; + config->bParity = TI_UART_NO_PARITY; } if (cflag & CSTOPB) @@ -988,7 +1009,8 @@ static void ti_set_termios(struct tty_struct *tty, (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, sizeof(*config)); if (status) - dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status); + dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", + __func__, port_number, status); /* SET_CONFIG asserts RTS and DTR, reset them correctly */ mcr = tport->tp_shadow_mcr; @@ -997,7 +1019,9 @@ static void ti_set_termios(struct tty_struct *tty, mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); status = ti_set_mcr(tport, mcr); if (status) - dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status); + dev_err(&port->dev, + "%s - cannot set modem control on port %d, %d\n", + __func__, port_number, status); kfree(config); } @@ -1139,10 +1163,12 @@ static void ti_interrupt_callback(struct urb *urb) port_number = TI_GET_PORT_FROM_CODE(data[0]); function = TI_GET_FUNC_FROM_CODE(data[0]); - dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]); + dbg("%s - port_number %d, function %d, data 0x%02X", + __func__, port_number, function, data[1]); if (port_number >= serial->num_ports) { - dev_err(dev, "%s - bad port number, %d\n", __func__, port_number); + dev_err(dev, "%s - bad port number, %d\n", + __func__, port_number); goto exit; } @@ -1154,7 +1180,8 @@ static void ti_interrupt_callback(struct urb *urb) switch (function) { case TI_CODE_DATA_ERROR: - dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]); + dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", + __func__, port_number, data[1]); break; case TI_CODE_MODEM_STATUS: @@ -1164,7 +1191,8 @@ static void ti_interrupt_callback(struct urb *urb) break; default: - dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]); + dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", + __func__, data[1]); break; } @@ -1198,7 +1226,7 @@ static void ti_bulk_in_callback(struct urb *urb) return; default: dev_err(dev, "%s - nonzero urb status, %d\n", - __func__, status ); + __func__, status); tport->tp_tdev->td_urb_error = 1; wake_up_interruptible(&tport->tp_write_wait); } @@ -1218,8 +1246,9 @@ static void ti_bulk_in_callback(struct urb *urb) if (!tport->tp_is_open) dbg("%s - port closed, dropping data", __func__); else - ti_recv(&urb->dev->dev, port->port.tty, urb->transfer_buffer, - urb->actual_length); + ti_recv(&urb->dev->dev, port->port.tty, + urb->transfer_buffer, + urb->actual_length); spin_lock(&tport->tp_lock); tport->tp_icount.rx += urb->actual_length; @@ -1283,8 +1312,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, do { cnt = tty_buffer_request_room(tty, length); if (cnt < length) { - dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); - if(cnt == 0) + dev_err(dev, "%s - dropping data, %d bytes lost\n", + __func__, length - cnt); + if (cnt == 0) break; } tty_insert_flip_string(tty, data, cnt); @@ -1326,7 +1356,8 @@ static void ti_send(struct ti_port *tport) spin_unlock_irqrestore(&tport->tp_lock, flags); - usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, + port->write_urb->transfer_buffer); usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, @@ -1336,8 +1367,9 @@ static void ti_send(struct ti_port *tport) result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { - dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result); - tport->tp_write_urb_in_use = 0; + dev_err(&port->dev, "%s - submit write urb failed, %d\n", + __func__, result); + tport->tp_write_urb_in_use = 0; /* TODO: reschedule ti_send */ } else { spin_lock_irqsave(&tport->tp_lock, flags); @@ -1372,7 +1404,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) static int ti_get_lsr(struct ti_port *tport) { - int size,status; + int size, status; struct ti_device *tdev = tport->tp_tdev; struct usb_serial_port *port = tport->tp_port; int port_number = port->number - port->serial->minor; @@ -1390,7 +1422,9 @@ static int ti_get_lsr(struct ti_port *tport) status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); if (status) { - dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status); + dev_err(&port->dev, + "%s - get port status command failed, %d\n", + __func__, status); goto free_data; } @@ -1626,7 +1660,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, struct ti_write_data_bytes *data; struct device *dev = &tdev->td_serial->dev->dev; - dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte); + dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", + __func__, addr, mask, byte); size = sizeof(struct ti_write_data_bytes) + 2; data = kmalloc(size, GFP_KERNEL); @@ -1663,12 +1698,12 @@ static int ti_do_download(struct usb_device *dev, int pipe, struct ti_firmware_header *header; int status; int len; - - for(pos = sizeof(struct ti_firmware_header); pos < size; pos++) + + for (pos = sizeof(struct ti_firmware_header); pos < size; pos++) cs = (__u8)(cs + buffer[pos]); header = (struct ti_firmware_header *)buffer; - header->wLength = cpu_to_le16((__u16)(size + header->wLength = cpu_to_le16((__u16)(size - sizeof(struct ti_firmware_header))); header->bCheckSum = cs; @@ -1714,7 +1749,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type) } release_firmware(fw_p); if (status) { - dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); + dev_err(&dev->dev, "%s - error downloading firmware, %d\n", + __func__, status); return status; } @@ -1786,7 +1822,7 @@ static void ti_buf_clear(struct circ_buf *cb) static int ti_buf_data_avail(struct circ_buf *cb) { - return CIRC_CNT(cb->head,cb->tail,TI_WRITE_BUF_SIZE); + return CIRC_CNT(cb->head, cb->tail, TI_WRITE_BUF_SIZE); } @@ -1799,7 +1835,7 @@ static int ti_buf_data_avail(struct circ_buf *cb) static int ti_buf_space_avail(struct circ_buf *cb) { - return CIRC_SPACE(cb->head,cb->tail,TI_WRITE_BUF_SIZE); + return CIRC_SPACE(cb->head, cb->tail, TI_WRITE_BUF_SIZE); } -- cgit v1.2.3-70-g09d2 From 43c8f435b2ca39f12ad89d91d9ee2be04a196f93 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:26 +0100 Subject: tty-usb-safe-serial: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/safe_serial.c | 290 +++++++++++++++++++++------------------ 1 file changed, 157 insertions(+), 133 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index f823e4dcea1..def52d07a4e 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -13,24 +13,25 @@ * Stuart Lynne , Tom Rushworth */ -/* - * The encapsultaion is designed to overcome difficulties with some USB hardware. +/* + * The encapsultaion is designed to overcome difficulties with some USB + * hardware. * * While the USB protocol has a CRC over the data while in transit, i.e. while - * being carried over the bus, there is no end to end protection. If the hardware - * has any problems getting the data into or out of the USB transmit and receive - * FIFO's then data can be lost. + * being carried over the bus, there is no end to end protection. If the + * hardware has any problems getting the data into or out of the USB transmit + * and receive FIFO's then data can be lost. * - * This protocol adds a two byte trailer to each USB packet to specify the number - * of bytes of valid data and a 10 bit CRC that will allow the receiver to verify - * that the entire USB packet was received without error. + * This protocol adds a two byte trailer to each USB packet to specify the + * number of bytes of valid data and a 10 bit CRC that will allow the receiver + * to verify that the entire USB packet was received without error. * - * Because in this case the sender and receiver are the class and function drivers - * there is now end to end protection. + * Because in this case the sender and receiver are the class and function + * drivers there is now end to end protection. * - * There is an additional option that can be used to force all transmitted packets - * to be padded to the maximum packet size. This provides a work around for some - * devices which have problems with small USB packets. + * There is an additional option that can be used to force all transmitted + * packets to be padded to the maximum packet size. This provides a work + * around for some devices which have problems with small USB packets. * * Assuming a packetsize of N: * @@ -44,11 +45,12 @@ * | Data Length | 10 bit CRC | * + 7 . 6 . 5 . 4 . 3 . 2 . 1 . 0 | 7 . 6 . 5 . 4 . 3 . 2 . 1 . 0 + * - * The 10 bit CRC is computed across the sent data, followed by the trailer with - * the length set and the CRC set to zero. The CRC is then OR'd into the trailer. + * The 10 bit CRC is computed across the sent data, followed by the trailer + * with the length set and the CRC set to zero. The CRC is then OR'd into + * the trailer. * - * When received a 10 bit CRC is computed over the entire frame including the trailer - * and should be equal to zero. + * When received a 10 bit CRC is computed over the entire frame including + * the trailer and should be equal to zero. * * Two module parameters are used to control the encapsulation, if both are * turned of the module works as a simple serial device with NO @@ -69,7 +71,7 @@ #include #include #include -#include +#include #include #include @@ -86,12 +88,12 @@ static int padded = CONFIG_USB_SERIAL_SAFE_PADDED; #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com" #define DRIVER_DESC "USB Safe Encapsulated Serial" -MODULE_AUTHOR (DRIVER_AUTHOR); -MODULE_DESCRIPTION (DRIVER_DESC); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); -static __u16 vendor; // no default -static __u16 product; // no default +static __u16 vendor; /* no default */ +static __u16 product; /* no default */ module_param(vendor, ushort, 0); MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)"); module_param(product, ushort, 0); @@ -122,30 +124,31 @@ MODULE_PARM_DESC(padded, "Pad to full wMaxPacketSize On/Off"); #define LINEO_SAFESERIAL_CRC_PADDED 0x02 -#define MY_USB_DEVICE(vend,prod,dc,ic,isc) \ - .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS | \ - USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, \ - .idVendor = (vend), \ - .idProduct = (prod),\ - .bDeviceClass = (dc),\ - .bInterfaceClass = (ic), \ - .bInterfaceSubClass = (isc), +#define MY_USB_DEVICE(vend, prod, dc, ic, isc) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ + USB_DEVICE_ID_MATCH_DEV_CLASS | \ + USB_DEVICE_ID_MATCH_INT_CLASS | \ + USB_DEVICE_ID_MATCH_INT_SUBCLASS, \ + .idVendor = (vend), \ + .idProduct = (prod),\ + .bDeviceClass = (dc),\ + .bInterfaceClass = (ic), \ + .bInterfaceSubClass = (isc), static struct usb_device_id id_table[] = { - {MY_USB_DEVICE (0x49f, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Itsy - {MY_USB_DEVICE (0x3f0, 0x2101, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Calypso - {MY_USB_DEVICE (0x4dd, 0x8001, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Iris - {MY_USB_DEVICE (0x4dd, 0x8002, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie - {MY_USB_DEVICE (0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie - {MY_USB_DEVICE (0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie - {MY_USB_DEVICE (0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Sharp tmp - // extra null entry for module - // vendor/produc parameters - {MY_USB_DEVICE (0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, - {} // terminating entry + {MY_USB_DEVICE(0x49f, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Itsy */ + {MY_USB_DEVICE(0x3f0, 0x2101, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Calypso */ + {MY_USB_DEVICE(0x4dd, 0x8001, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Iris */ + {MY_USB_DEVICE(0x4dd, 0x8002, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Collie */ + {MY_USB_DEVICE(0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Collie */ + {MY_USB_DEVICE(0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Collie */ + {MY_USB_DEVICE(0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, /* Sharp tmp */ + /* extra null entry for module vendor/produc parameters */ + {MY_USB_DEVICE(0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, + {} /* terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver safe_driver = { .name = "safe_serial", @@ -156,29 +159,45 @@ static struct usb_driver safe_driver = { }; static const __u16 crc10_table[256] = { - 0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe, - 0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf, - 0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c, - 0x053, 0x260, 0x206, 0x035, 0x2ca, 0x0f9, 0x09f, 0x2ac, 0x352, 0x161, 0x107, 0x334, 0x1cb, 0x3f8, 0x39e, 0x1ad, - 0x0c4, 0x2f7, 0x291, 0x0a2, 0x25d, 0x06e, 0x008, 0x23b, 0x3c5, 0x1f6, 0x190, 0x3a3, 0x15c, 0x36f, 0x309, 0x13a, - 0x0f5, 0x2c6, 0x2a0, 0x093, 0x26c, 0x05f, 0x039, 0x20a, 0x3f4, 0x1c7, 0x1a1, 0x392, 0x16d, 0x35e, 0x338, 0x10b, - 0x0a6, 0x295, 0x2f3, 0x0c0, 0x23f, 0x00c, 0x06a, 0x259, 0x3a7, 0x194, 0x1f2, 0x3c1, 0x13e, 0x30d, 0x36b, 0x158, - 0x097, 0x2a4, 0x2c2, 0x0f1, 0x20e, 0x03d, 0x05b, 0x268, 0x396, 0x1a5, 0x1c3, 0x3f0, 0x10f, 0x33c, 0x35a, 0x169, - 0x188, 0x3bb, 0x3dd, 0x1ee, 0x311, 0x122, 0x144, 0x377, 0x289, 0x0ba, 0x0dc, 0x2ef, 0x010, 0x223, 0x245, 0x076, - 0x1b9, 0x38a, 0x3ec, 0x1df, 0x320, 0x113, 0x175, 0x346, 0x2b8, 0x08b, 0x0ed, 0x2de, 0x021, 0x212, 0x274, 0x047, - 0x1ea, 0x3d9, 0x3bf, 0x18c, 0x373, 0x140, 0x126, 0x315, 0x2eb, 0x0d8, 0x0be, 0x28d, 0x072, 0x241, 0x227, 0x014, - 0x1db, 0x3e8, 0x38e, 0x1bd, 0x342, 0x171, 0x117, 0x324, 0x2da, 0x0e9, 0x08f, 0x2bc, 0x043, 0x270, 0x216, 0x025, - 0x14c, 0x37f, 0x319, 0x12a, 0x3d5, 0x1e6, 0x180, 0x3b3, 0x24d, 0x07e, 0x018, 0x22b, 0x0d4, 0x2e7, 0x281, 0x0b2, - 0x17d, 0x34e, 0x328, 0x11b, 0x3e4, 0x1d7, 0x1b1, 0x382, 0x27c, 0x04f, 0x029, 0x21a, 0x0e5, 0x2d6, 0x2b0, 0x083, - 0x12e, 0x31d, 0x37b, 0x148, 0x3b7, 0x184, 0x1e2, 0x3d1, 0x22f, 0x01c, 0x07a, 0x249, 0x0b6, 0x285, 0x2e3, 0x0d0, - 0x11f, 0x32c, 0x34a, 0x179, 0x386, 0x1b5, 0x1d3, 0x3e0, 0x21e, 0x02d, 0x04b, 0x278, 0x087, 0x2b4, 0x2d2, 0x0e1, + 0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, + 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe, + 0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, + 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf, + 0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, + 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c, + 0x053, 0x260, 0x206, 0x035, 0x2ca, 0x0f9, 0x09f, 0x2ac, + 0x352, 0x161, 0x107, 0x334, 0x1cb, 0x3f8, 0x39e, 0x1ad, + 0x0c4, 0x2f7, 0x291, 0x0a2, 0x25d, 0x06e, 0x008, 0x23b, + 0x3c5, 0x1f6, 0x190, 0x3a3, 0x15c, 0x36f, 0x309, 0x13a, + 0x0f5, 0x2c6, 0x2a0, 0x093, 0x26c, 0x05f, 0x039, 0x20a, + 0x3f4, 0x1c7, 0x1a1, 0x392, 0x16d, 0x35e, 0x338, 0x10b, + 0x0a6, 0x295, 0x2f3, 0x0c0, 0x23f, 0x00c, 0x06a, 0x259, + 0x3a7, 0x194, 0x1f2, 0x3c1, 0x13e, 0x30d, 0x36b, 0x158, + 0x097, 0x2a4, 0x2c2, 0x0f1, 0x20e, 0x03d, 0x05b, 0x268, + 0x396, 0x1a5, 0x1c3, 0x3f0, 0x10f, 0x33c, 0x35a, 0x169, + 0x188, 0x3bb, 0x3dd, 0x1ee, 0x311, 0x122, 0x144, 0x377, + 0x289, 0x0ba, 0x0dc, 0x2ef, 0x010, 0x223, 0x245, 0x076, + 0x1b9, 0x38a, 0x3ec, 0x1df, 0x320, 0x113, 0x175, 0x346, + 0x2b8, 0x08b, 0x0ed, 0x2de, 0x021, 0x212, 0x274, 0x047, + 0x1ea, 0x3d9, 0x3bf, 0x18c, 0x373, 0x140, 0x126, 0x315, + 0x2eb, 0x0d8, 0x0be, 0x28d, 0x072, 0x241, 0x227, 0x014, + 0x1db, 0x3e8, 0x38e, 0x1bd, 0x342, 0x171, 0x117, 0x324, + 0x2da, 0x0e9, 0x08f, 0x2bc, 0x043, 0x270, 0x216, 0x025, + 0x14c, 0x37f, 0x319, 0x12a, 0x3d5, 0x1e6, 0x180, 0x3b3, + 0x24d, 0x07e, 0x018, 0x22b, 0x0d4, 0x2e7, 0x281, 0x0b2, + 0x17d, 0x34e, 0x328, 0x11b, 0x3e4, 0x1d7, 0x1b1, 0x382, + 0x27c, 0x04f, 0x029, 0x21a, 0x0e5, 0x2d6, 0x2b0, 0x083, + 0x12e, 0x31d, 0x37b, 0x148, 0x3b7, 0x184, 0x1e2, 0x3d1, + 0x22f, 0x01c, 0x07a, 0x249, 0x0b6, 0x285, 0x2e3, 0x0d0, + 0x11f, 0x32c, 0x34a, 0x179, 0x386, 0x1b5, 0x1d3, 0x3e0, + 0x21e, 0x02d, 0x04b, 0x278, 0x087, 0x2b4, 0x2d2, 0x0e1, }; -#define CRC10_INITFCS 0x000 // Initial FCS value -#define CRC10_GOODFCS 0x000 // Good final FCS value -#define CRC10_FCS(fcs, c) ( (((fcs) << 8) & 0x3ff) ^ crc10_table[((fcs) >> 2) & 0xff] ^ (c)) +#define CRC10_INITFCS 0x000 /* Initial FCS value */ +#define CRC10_GOODFCS 0x000 /* Good final FCS value */ +#define CRC10_FCS(fcs, c) ((((fcs) << 8) & 0x3ff) ^ crc10_table[((fcs) >> 2) & 0xff] ^ (c)) -/** +/** * fcs_compute10 - memcpy and calculate 10 bit CRC across buffer * @sp: pointer to buffer * @len: number of bytes @@ -187,13 +206,13 @@ static const __u16 crc10_table[256] = { * Perform a memcpy and calculate fcs using ppp 10bit CRC algorithm. Return * new 10 bit FCS. */ -static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs) +static __u16 __inline__ fcs_compute10(unsigned char *sp, int len, __u16 fcs) { - for (; len-- > 0; fcs = CRC10_FCS (fcs, *sp++)); + for (; len-- > 0; fcs = CRC10_FCS(fcs, *sp++)); return fcs; } -static void safe_read_bulk_callback (struct urb *urb) +static void safe_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; @@ -201,7 +220,7 @@ static void safe_read_bulk_callback (struct urb *urb) int result; int status = urb->status; - dbg ("%s", __func__); + dbg("%s", __func__); if (status) { dbg("%s - nonzero read bulk status received: %d", @@ -209,50 +228,55 @@ static void safe_read_bulk_callback (struct urb *urb) return; } - dbg ("safe_read_bulk_callback length: %d", port->read_urb->actual_length); + dbg("safe_read_bulk_callback length: %d", + port->read_urb->actual_length); #ifdef ECHO_RCV { int i; unsigned char *cp = port->read_urb->transfer_buffer; for (i = 0; i < port->read_urb->actual_length; i++) { - if ((i % 32) == 0) { - printk ("\nru[%02x] ", i); - } - printk ("%02x ", *cp++); + if ((i % 32) == 0) + printk("\nru[%02x] ", i); + printk("%02x ", *cp++); } - printk ("\n"); + printk("\n"); } #endif if (safe) { __u16 fcs; - if (!(fcs = fcs_compute10 (data, length, CRC10_INITFCS))) { + fcs = fcs_compute10(data, length, CRC10_INITFCS); + if (!fcs) { int actual_length = data[length - 2] >> 2; if (actual_length <= (length - 2)) { - info ("%s - actual: %d", __func__, actual_length); - tty_insert_flip_string(port->port.tty, data, actual_length); - tty_flip_buffer_push (port->port.tty); + info("%s - actual: %d", __func__, + actual_length); + tty_insert_flip_string(port->port.tty, + data, actual_length); + tty_flip_buffer_push(port->port.tty); } else { - err ("%s - inconsistent lengths %d:%d", __func__, - actual_length, length); + err("%s - inconsistent lengths %d:%d", + __func__, actual_length, length); } } else { - err ("%s - bad CRC %x", __func__, fcs); + err("%s - bad CRC %x", __func__, fcs); } } else { tty_insert_flip_string(port->port.tty, data, length); - tty_flip_buffer_push (port->port.tty); + tty_flip_buffer_push(port->port.tty); } /* Continue trying to always read */ - usb_fill_bulk_urb (urb, port->serial->dev, - usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), - urb->transfer_buffer, urb->transfer_buffer_length, - safe_read_bulk_callback, port); - - if ((result = usb_submit_urb (urb, GFP_ATOMIC))) { - err ("%s - failed resubmitting read urb, error %d", __func__, result); + usb_fill_bulk_urb(urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), + urb->transfer_buffer, urb->transfer_buffer_length, + safe_read_bulk_callback, port); + + result = usb_submit_urb(urb, GFP_ATOMIC); + if (result) + err("%s - failed resubmitting read urb, error %d", + __func__, result); /* FIXME: Need a mechanism to retry later if this happens */ - } } static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, @@ -263,23 +287,23 @@ static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, int i; int packet_length; - dbg ("safe_write port: %p %d urb: %p count: %d", port, port->number, port->write_urb, - count); + dbg("safe_write port: %p %d urb: %p count: %d", + port, port->number, port->write_urb, count); if (!port->write_urb) { - dbg ("%s - write urb NULL", __func__); + dbg("%s - write urb NULL", __func__); return 0; } - dbg ("safe_write write_urb: %d transfer_buffer_length", + dbg("safe_write write_urb: %d transfer_buffer_length", port->write_urb->transfer_buffer_length); if (!port->write_urb->transfer_buffer_length) { - dbg ("%s - write urb transfer_buffer_length zero", __func__); + dbg("%s - write urb transfer_buffer_length zero", __func__); return 0; } if (count == 0) { - dbg ("%s - write request of 0 bytes", __func__); + dbg("%s - write request of 0 bytes", __func__); return 0; } spin_lock_bh(&port->lock); @@ -291,63 +315,64 @@ static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, port->write_urb_busy = 1; spin_unlock_bh(&port->lock); - packet_length = port->bulk_out_size; // get max packetsize + packet_length = port->bulk_out_size; /* get max packetsize */ - i = packet_length - (safe ? 2 : 0); // get bytes to send + i = packet_length - (safe ? 2 : 0); /* get bytes to send */ count = (count > i) ? i : count; - // get the data into the transfer buffer + /* get the data into the transfer buffer */ data = port->write_urb->transfer_buffer; - memset (data, '0', packet_length); + memset(data, '0', packet_length); - memcpy (data, buf, count); + memcpy(data, buf, count); if (safe) { __u16 fcs; - // pad if necessary - if (!padded) { + /* pad if necessary */ + if (!padded) packet_length = count + 2; - } - // set count + /* set count */ data[packet_length - 2] = count << 2; data[packet_length - 1] = 0; - // compute fcs and insert into trailer - fcs = fcs_compute10 (data, packet_length, CRC10_INITFCS); + /* compute fcs and insert into trailer */ + fcs = fcs_compute10(data, packet_length, CRC10_INITFCS); data[packet_length - 2] |= fcs >> 8; data[packet_length - 1] |= fcs & 0xff; - // set length to send + /* set length to send */ port->write_urb->transfer_buffer_length = packet_length; } else { port->write_urb->transfer_buffer_length = count; } - usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, + port->write_urb->transfer_buffer); #ifdef ECHO_TX { int i; unsigned char *cp = port->write_urb->transfer_buffer; for (i = 0; i < port->write_urb->transfer_buffer_length; i++) { - if ((i % 32) == 0) { - printk ("\nsu[%02x] ", i); - } - printk ("%02x ", *cp++); + if ((i % 32) == 0) + printk("\nsu[%02x] ", i); + printk("%02x ", *cp++); } - printk ("\n"); + printk("\n"); } #endif port->write_urb->dev = port->serial->dev; - if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) { + result = usb_submit_urb(port->write_urb, GFP_KERNEL); + if (result) { port->write_urb_busy = 0; - err ("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); return 0; } - dbg ("%s urb: %p submitted", __func__, port->write_urb); + dbg("%s urb: %p submitted", __func__, port->write_urb); - return (count); + return count; } static int safe_write_room(struct tty_struct *tty) @@ -356,21 +381,19 @@ static int safe_write_room(struct tty_struct *tty) int room = 0; /* Default: no room */ unsigned long flags; - dbg ("%s", __func__); + dbg("%s", __func__); spin_lock_irqsave(&port->lock, flags); if (port->write_urb_busy) room = port->bulk_out_size - (safe ? 2 : 0); spin_unlock_irqrestore(&port->lock, flags); - if (room) { - dbg ("safe_write_room returns %d", room); - } - + if (room) + dbg("safe_write_room returns %d", room); return room; } -static int safe_startup (struct usb_serial *serial) +static int safe_startup(struct usb_serial *serial) { switch (serial->interface->cur_altsetting->desc.bInterfaceProtocol) { case LINEO_SAFESERIAL_CRC: @@ -398,17 +421,18 @@ static struct usb_serial_driver safe_device = { .attach = safe_startup, }; -static int __init safe_init (void) +static int __init safe_init(void) { int i, retval; - info (DRIVER_VERSION " " DRIVER_AUTHOR); - info (DRIVER_DESC); - info ("vendor: %x product: %x safe: %d padded: %d\n", vendor, product, safe, padded); + info(DRIVER_VERSION " " DRIVER_AUTHOR); + info(DRIVER_DESC); + info("vendor: %x product: %x safe: %d padded: %d\n", + vendor, product, safe, padded); - // if we have vendor / product parameters patch them into id list + /* if we have vendor / product parameters patch them into id list */ if (vendor || product) { - info ("vendor: %x product: %x\n", vendor, product); + info("vendor: %x product: %x\n", vendor, product); for (i = 0; i < ARRAY_SIZE(id_table); i++) { if (!id_table[i].idVendor && !id_table[i].idProduct) { @@ -433,11 +457,11 @@ failed_usb_serial_register: return retval; } -static void __exit safe_exit (void) +static void __exit safe_exit(void) { - usb_deregister (&safe_driver); - usb_serial_deregister (&safe_device); + usb_deregister(&safe_driver); + usb_serial_deregister(&safe_device); } -module_init (safe_init); -module_exit (safe_exit); +module_init(safe_init); +module_exit(safe_exit); -- cgit v1.2.3-70-g09d2 From 2a77c8144992e21367cc15956b0ff295f1112c85 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:36 +0100 Subject: tty-usb-oti6858: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/oti6858.c | 136 ++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 66 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 069d276a527..81db5715ee2 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c @@ -25,7 +25,8 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * TODO: * - implement correct flushing for ioctls and oti6858_close() @@ -49,7 +50,7 @@ #include #include #include -#include +#include #include "oti6858.h" #define OTI6858_DESCRIPTION \ @@ -135,9 +136,9 @@ struct oti6858_control_pkt { #define OTI6858_CTRL_PKT_SIZE sizeof(struct oti6858_control_pkt) #define OTI6858_CTRL_EQUALS_PENDING(a, priv) \ - ( ((a)->divisor == (priv)->pending_setup.divisor) \ + (((a)->divisor == (priv)->pending_setup.divisor) \ && ((a)->control == (priv)->pending_setup.control) \ - && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) ) + && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt)) /* function prototypes */ static int oti6858_open(struct tty_struct *tty, @@ -220,7 +221,7 @@ struct oti6858_private { struct delayed_work delayed_setup_work; wait_queue_head_t intr_wait; - struct usb_serial_port *port; /* USB port with which associated */ + struct usb_serial_port *port; /* USB port with which associated */ }; #undef dbg @@ -229,7 +230,8 @@ struct oti6858_private { static void setup_line(struct work_struct *work) { - struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_setup_work.work); + struct oti6858_private *priv = container_of(work, + struct oti6858_private, delayed_setup_work.work); struct usb_serial_port *port = priv->port; struct oti6858_control_pkt *new_setup; unsigned long flags; @@ -237,10 +239,12 @@ static void setup_line(struct work_struct *work) dbg("%s(port = %d)", __func__, port->number); - if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { + new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); + if (new_setup == NULL) { dev_err(&port->dev, "%s(): out of memory!\n", __func__); /* we will try again */ - schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); + schedule_delayed_work(&priv->delayed_setup_work, + msecs_to_jiffies(2)); return; } @@ -256,7 +260,8 @@ static void setup_line(struct work_struct *work) dev_err(&port->dev, "%s(): error reading status\n", __func__); kfree(new_setup); /* we will try again */ - schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); + schedule_delayed_work(&priv->delayed_setup_work, + msecs_to_jiffies(2)); return; } @@ -297,7 +302,8 @@ static void setup_line(struct work_struct *work) void send_data(struct work_struct *work) { - struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_write_work.work); + struct oti6858_private *priv = container_of(work, + struct oti6858_private, delayed_write_work.work); struct usb_serial_port *port = priv->port; int count = 0, result; unsigned long flags; @@ -308,7 +314,8 @@ void send_data(struct work_struct *work) spin_lock_irqsave(&priv->lock, flags); if (priv->flags.write_urb_in_use) { spin_unlock_irqrestore(&priv->lock, flags); - schedule_delayed_work(&priv->delayed_write_work, msecs_to_jiffies(2)); + schedule_delayed_work(&priv->delayed_write_work, + msecs_to_jiffies(2)); return; } priv->flags.write_urb_in_use = 1; @@ -359,8 +366,8 @@ void send_data(struct work_struct *work) static int oti6858_startup(struct usb_serial *serial) { - struct usb_serial_port *port = serial->port[0]; - struct oti6858_private *priv; + struct usb_serial_port *port = serial->port[0]; + struct oti6858_private *priv; int i; for (i = 0; i < serial->num_ports; ++i) { @@ -375,8 +382,8 @@ static int oti6858_startup(struct usb_serial *serial) spin_lock_init(&priv->lock); init_waitqueue_head(&priv->intr_wait); -// INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); -// INIT_WORK(&priv->write_work, send_data, serial->port[i]); +/* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */ +/* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */ priv->port = port; INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); @@ -482,19 +489,19 @@ static void oti6858_set_termios(struct tty_struct *tty, frame_fmt &= ~FMT_DATA_BITS_MASK; switch (cflag & CSIZE) { - case CS5: - frame_fmt |= FMT_DATA_BITS_5; - break; - case CS6: - frame_fmt |= FMT_DATA_BITS_6; - break; - case CS7: - frame_fmt |= FMT_DATA_BITS_7; - break; - default: - case CS8: - frame_fmt |= FMT_DATA_BITS_8; - break; + case CS5: + frame_fmt |= FMT_DATA_BITS_5; + break; + case CS6: + frame_fmt |= FMT_DATA_BITS_6; + break; + case CS7: + frame_fmt |= FMT_DATA_BITS_7; + break; + default: + case CS8: + frame_fmt |= FMT_DATA_BITS_8; + break; } /* manufacturer claims that this device can work with baud rates @@ -517,19 +524,17 @@ static void oti6858_set_termios(struct tty_struct *tty, } frame_fmt &= ~FMT_STOP_BITS_MASK; - if ((cflag & CSTOPB) != 0) { + if ((cflag & CSTOPB) != 0) frame_fmt |= FMT_STOP_BITS_2; - } else { + else frame_fmt |= FMT_STOP_BITS_1; - } frame_fmt &= ~FMT_PARITY_MASK; if ((cflag & PARENB) != 0) { - if ((cflag & PARODD) != 0) { + if ((cflag & PARODD) != 0) frame_fmt |= FMT_PARITY_ODD; - } else { + else frame_fmt |= FMT_PARITY_EVEN; - } } else { frame_fmt |= FMT_PARITY_NONE; } @@ -584,7 +589,8 @@ static int oti6858_open(struct tty_struct *tty, if (port->port.count != 1) return 0; - if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { + buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); + if (buf == NULL) { dev_err(&port->dev, "%s(): out of memory!\n", __func__); return -ENOMEM; } @@ -729,11 +735,10 @@ static int oti6858_tiocmset(struct tty_struct *tty, struct file *file, if ((clear & TIOCM_DTR) != 0) control &= ~CONTROL_DTR_HIGH; - if (control != priv->pending_setup.control) { + if (control != priv->pending_setup.control) priv->pending_setup.control = control; - } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); return 0; } @@ -785,7 +790,8 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) spin_unlock_irqrestore(&priv->lock, flags); while (1) { - wait_event_interruptible(priv->intr_wait, priv->status.pin_state != prev); + wait_event_interruptible(priv->intr_wait, + priv->status.pin_state != prev); if (signal_pending(current)) return -ERESTARTSYS; @@ -795,12 +801,11 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) changed = prev ^ status; /* FIXME: check if this is correct (active high/low) */ - if ( ((arg & TIOCM_RNG) && (changed & PIN_RI)) || - ((arg & TIOCM_DSR) && (changed & PIN_DSR)) || - ((arg & TIOCM_CD) && (changed & PIN_DCD)) || - ((arg & TIOCM_CTS) && (changed & PIN_CTS))) { - return 0; - } + if (((arg & TIOCM_RNG) && (changed & PIN_RI)) || + ((arg & TIOCM_DSR) && (changed & PIN_DSR)) || + ((arg & TIOCM_CD) && (changed & PIN_DCD)) || + ((arg & TIOCM_CTS) && (changed & PIN_CTS))) + return 0; prev = status; } @@ -817,15 +822,13 @@ static int oti6858_ioctl(struct tty_struct *tty, struct file *file, __func__, port->number, cmd, arg); switch (cmd) { - case TIOCMIWAIT: - dbg("%s(): TIOCMIWAIT", __func__); - return wait_modem_info(port, arg); - - default: - dbg("%s(): 0x%04x not supported", __func__, cmd); - break; + case TIOCMIWAIT: + dbg("%s(): TIOCMIWAIT", __func__); + return wait_modem_info(port, arg); + default: + dbg("%s(): 0x%04x not supported", __func__, cmd); + break; } - return -ENOIOCTLCMD; } @@ -941,7 +944,7 @@ static void oti6858_read_int_callback(struct urb *urb) spin_lock_irqsave(&priv->lock, flags); if (priv->flags.write_urb_in_use == 0 && oti6858_buf_data_avail(priv->buf) != 0) { - schedule_delayed_work(&priv->delayed_write_work,0); + schedule_delayed_work(&priv->delayed_write_work, 0); resubmit = 0; } spin_unlock_irqrestore(&priv->lock, flags); @@ -950,7 +953,7 @@ static void oti6858_read_int_callback(struct urb *urb) if (resubmit) { int result; -// dbg("%s(): submitting interrupt urb", __func__); +/* dbg("%s(): submitting interrupt urb", __func__); */ urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result != 0) { @@ -985,8 +988,10 @@ static void oti6858_read_bulk_callback(struct urb *urb) } /* if (status == -EPROTO) { - // PL2303 mysteriously fails with -EPROTO reschedule the read - dbg("%s - caught -EPROTO, resubmitting the urb", __func__); + * PL2303 mysteriously fails with -EPROTO reschedule + the read * + dbg("%s - caught -EPROTO, resubmitting the urb", + __func__); result = usb_submit_urb(urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); @@ -1003,7 +1008,7 @@ static void oti6858_read_bulk_callback(struct urb *urb) tty_flip_buffer_push(tty); } - // schedule the interrupt urb if we are still open */ + /* schedule the interrupt urb if we are still open */ if (port->port.count != 0) { port->interrupt_in_urb->dev = port->serial->dev; result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); @@ -1055,7 +1060,7 @@ static void oti6858_write_bulk_callback(struct urb *urb) priv->flags.write_urb_in_use = 0; - // schedule the interrupt urb if we are still open */ + /* schedule the interrupt urb if we are still open */ port->interrupt_in_urb->dev = port->serial->dev; dbg("%s(): submitting interrupt urb", __func__); result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); @@ -1130,7 +1135,7 @@ static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb) { if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); + return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size; } /* @@ -1143,7 +1148,7 @@ static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb) { if (pb == NULL) return 0; - return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size); + return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size; } /* @@ -1230,13 +1235,12 @@ static int __init oti6858_init(void) { int retval; - if ((retval = usb_serial_register(&oti6858_device)) == 0) { - if ((retval = usb_register(&oti6858_driver)) != 0) + retval = usb_serial_register(&oti6858_device); + if (retval == 0) { + retval = usb_register(&oti6858_driver); + if (retval) usb_serial_deregister(&oti6858_device); - else - return 0; } - return retval; } -- cgit v1.2.3-70-g09d2 From 19e58fae0c8f197d80fcea338b94fb5740369bc1 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:45 +0100 Subject: tty-usb-option: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/option.c | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 4350990abf1..e4eca95f2b0 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -43,8 +43,10 @@ #include /* Function prototypes */ -static int option_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void option_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); +static int option_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void option_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); static int option_startup(struct usb_serial *serial); static void option_shutdown(struct usb_serial *serial); static int option_write_room(struct tty_struct *tty); @@ -393,15 +395,15 @@ static int __init option_init(void) return 0; failed_driver_register: - usb_serial_deregister (&option_1port_device); + usb_serial_deregister(&option_1port_device); failed_1port_device_register: return retval; } static void __exit option_exit(void) { - usb_deregister (&option_driver); - usb_serial_deregister (&option_1port_device); + usb_deregister(&option_driver); + usb_serial_deregister(&option_1port_device); } module_init(option_init); @@ -471,7 +473,7 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port, i = 0; left = count; - for (i=0; left > 0 && i < N_OUT_URB; i++) { + for (i = 0; left > 0 && i < N_OUT_URB; i++) { todo = left; if (todo > OUT_BUFLEN) todo = OUT_BUFLEN; @@ -492,7 +494,7 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port, usb_pipeendpoint(this_urb->pipe), i); /* send the data */ - memcpy (this_urb->transfer_buffer, buf, todo); + memcpy(this_urb->transfer_buffer, buf, todo); this_urb->transfer_buffer_length = todo; this_urb->dev = port->serial->dev; @@ -583,7 +585,7 @@ static void option_instat_callback(struct urb *urb) struct usb_serial *serial = port->serial; dbg("%s", __func__); - dbg("%s: urb %p port %p has data %p", __func__,urb,port,portdata); + dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); if (status == 0) { struct usb_ctrlrequest *req_pkt = @@ -613,7 +615,7 @@ static void option_instat_callback(struct urb *urb) tty_hangup(port->port.tty); } else { dbg("%s: type %x req %x", __func__, - req_pkt->bRequestType,req_pkt->bRequest); + req_pkt->bRequestType, req_pkt->bRequest); } } else dbg("%s: error %d", __func__, status); @@ -639,7 +641,7 @@ static int option_write_room(struct tty_struct *tty) portdata = usb_get_serial_port_data(port); - for (i=0; i < N_OUT_URB; i++) { + for (i = 0; i < N_OUT_URB; i++) { this_urb = portdata->out_urbs[i]; if (this_urb && !test_bit(i, &portdata->out_busy)) data_len += OUT_BUFLEN; @@ -659,7 +661,7 @@ static int option_chars_in_buffer(struct tty_struct *tty) portdata = usb_get_serial_port_data(port); - for (i=0; i < N_OUT_URB; i++) { + for (i = 0; i < N_OUT_URB; i++) { this_urb = portdata->out_urbs[i]; /* FIXME: This locking is insufficient as this_urb may go unused during the test */ @@ -689,7 +691,7 @@ static int option_open(struct tty_struct *tty, /* Reset low level data toggle and start reading from endpoints */ for (i = 0; i < N_IN_URB; i++) { urb = portdata->in_urbs[i]; - if (! urb) + if (!urb) continue; if (urb->dev != serial->dev) { dbg("%s: dev %p != %p", __func__, @@ -714,7 +716,7 @@ static int option_open(struct tty_struct *tty, /* Reset low level data toggle on out endpoints */ for (i = 0; i < N_OUT_URB; i++) { urb = portdata->out_urbs[i]; - if (! urb) + if (!urb) continue; urb->dev = serial->dev; /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), @@ -726,7 +728,7 @@ static int option_open(struct tty_struct *tty, option_send_setup(tty, port); - return (0); + return 0; } static void option_close(struct tty_struct *tty, @@ -784,7 +786,7 @@ static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, /* Setup urbs */ static void option_setup_urbs(struct usb_serial *serial) { - int i,j; + int i, j; struct usb_serial_port *port; struct option_port_private *portdata; @@ -794,18 +796,22 @@ static void option_setup_urbs(struct usb_serial *serial) port = serial->port[i]; portdata = usb_get_serial_port_data(port); - /* Do indat endpoints first */ + /* Do indat endpoints first */ for (j = 0; j < N_IN_URB; ++j) { - portdata->in_urbs[j] = option_setup_urb (serial, - port->bulk_in_endpointAddress, USB_DIR_IN, port, - portdata->in_buffer[j], IN_BUFLEN, option_indat_callback); + portdata->in_urbs[j] = option_setup_urb(serial, + port->bulk_in_endpointAddress, + USB_DIR_IN, port, + portdata->in_buffer[j], + IN_BUFLEN, option_indat_callback); } /* outdat endpoints */ for (j = 0; j < N_OUT_URB; ++j) { - portdata->out_urbs[j] = option_setup_urb (serial, - port->bulk_out_endpointAddress, USB_DIR_OUT, port, - portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback); + portdata->out_urbs[j] = option_setup_urb(serial, + port->bulk_out_endpointAddress, + USB_DIR_OUT, port, + portdata->out_buffer[j], + OUT_BUFLEN, option_outdat_callback); } } } @@ -834,8 +840,8 @@ static int option_send_setup(struct tty_struct *tty, val |= 0x02; return usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT); + usb_rcvctrlpipe(serial->dev, 0), + 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT); } return 0; } @@ -856,7 +862,7 @@ static int option_startup(struct usb_serial *serial) if (!portdata) { dbg("%s: kmalloc for option_port_private (%d) failed!.", __func__, i); - return (1); + return 1; } for (j = 0; j < N_IN_URB; j++) { @@ -875,17 +881,15 @@ static int option_startup(struct usb_serial *serial) usb_set_serial_port_data(port, portdata); - if (! port->interrupt_in_urb) + if (!port->interrupt_in_urb) continue; err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (err) dbg("%s: submit irq_in urb failed %d", __func__, err); } - option_setup_urbs(serial); - - return (0); + return 0; bail_out_error2: for (j = 0; j < N_OUT_URB; j++) @@ -924,7 +928,8 @@ static void option_shutdown(struct usb_serial *serial) for (j = 0; j < N_IN_URB; j++) { if (portdata->in_urbs[j]) { usb_free_urb(portdata->in_urbs[j]); - free_page((unsigned long)portdata->in_buffer[j]); + free_page((unsigned long) + portdata->in_buffer[j]); portdata->in_urbs[j] = NULL; } } -- cgit v1.2.3-70-g09d2 From f89d0dff2507b6bd486b7db59a5f6a733fbfaa12 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:15:54 +0100 Subject: tty-usb-omninet: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/omninet.c | 160 +++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 73 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 5a2d045562f..5a76f327ef5 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -5,26 +5,28 @@ * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * - * See Documentation/usb/usb-serial.txt for more information on using this driver + * See Documentation/usb/usb-serial.txt for more information on using this + * driver * * Please report both successes and troubles to the author at omninet@kroah.com - * + * * (05/30/2001) gkh - * switched from using spinlock to a semaphore, which fixes lots of problems. + * switched from using spinlock to a semaphore, which fixes lots of + * problems. * * (04/08/2001) gb * Identify version on module load. * * (11/01/2000) Adam J. Richter * usb_device_id table support - * + * * (10/05/2000) gkh * Fixed bug with urb->dev not being set properly, now that the usb * core needs it. - * + * * (08/28/2000) gkh * Added locks for SMP safeness. - * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more + * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more * than once. * Fixed potential race in omninet_write_bulk_callback * @@ -43,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -58,25 +60,29 @@ static int debug; #define ZYXEL_VENDOR_ID 0x0586 #define ZYXEL_OMNINET_ID 0x1000 -#define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */ +/* This one seems to be a re-branded ZyXEL device */ +#define BT_IGNITIONPRO_ID 0x2000 /* function prototypes */ -static int omninet_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void omninet_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void omninet_read_bulk_callback (struct urb *urb); -static void omninet_write_bulk_callback (struct urb *urb); -static int omninet_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int omninet_write_room (struct tty_struct *tty); -static void omninet_shutdown (struct usb_serial *serial); -static int omninet_attach (struct usb_serial *serial); - -static struct usb_device_id id_table [] = { +static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void omninet_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void omninet_read_bulk_callback(struct urb *urb); +static void omninet_write_bulk_callback(struct urb *urb); +static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static int omninet_write_room(struct tty_struct *tty); +static void omninet_shutdown(struct usb_serial *serial); +static int omninet_attach(struct usb_serial *serial); + +static struct usb_device_id id_table[] = { { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver omninet_driver = { .name = "omninet", @@ -130,27 +136,26 @@ static struct usb_serial_driver zyxel_omninet_device = { * */ -struct omninet_header -{ +struct omninet_header { __u8 oh_seq; __u8 oh_len; __u8 oh_xxx; __u8 oh_pad; }; -struct omninet_data -{ - __u8 od_outseq; // Sequence number for bulk_out URBs +struct omninet_data { + __u8 od_outseq; /* Sequence number for bulk_out URBs */ }; -static int omninet_attach (struct usb_serial *serial) +static int omninet_attach(struct usb_serial *serial) { struct omninet_data *od; struct usb_serial_port *port = serial->port[0]; - od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); - if( !od ) { - err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data)); + od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); + if (!od) { + err("%s- kmalloc(%Zd) failed.", + __func__, sizeof(struct omninet_data)); return -ENOMEM; } usb_set_serial_port_data(port, od); @@ -170,20 +175,21 @@ static int omninet_open(struct tty_struct *tty, wport->port.tty = tty; /* FIXME */ /* Start reading from the device */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), - port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, - omninet_read_bulk_callback, port); + usb_fill_bulk_urb(port->read_urb, serial->dev, + usb_rcvbulkpipe(serial->dev, + port->bulk_in_endpointAddress), + port->read_urb->transfer_buffer, + port->read_urb->transfer_buffer_length, + omninet_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); - if (result) { - err("%s - failed submitting read urb, error %d", __func__, result); - } - + if (result) + err("%s - failed submitting read urb, error %d", + __func__, result); return result; } static void omninet_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { dbg("%s - port %d", __func__, port->number); usb_kill_urb(port->read_urb); @@ -194,7 +200,7 @@ static void omninet_close(struct tty_struct *tty, #define OMNINET_HEADERLEN sizeof(struct omninet_header) #define OMNINET_BULKOUTSIZE (64 - OMNINET_HEADERLEN) -static void omninet_read_bulk_callback (struct urb *urb) +static void omninet_read_bulk_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; unsigned char *data = urb->transfer_buffer; @@ -211,31 +217,34 @@ static void omninet_read_bulk_callback (struct urb *urb) return; } - if ((debug) && (header->oh_xxx != 0x30)) { + if (debug && header->oh_xxx != 0x30) { if (urb->actual_length) { - printk (KERN_DEBUG __FILE__ ": omninet_read %d: ", header->oh_len); - for (i = 0; i < (header->oh_len + OMNINET_HEADERLEN); i++) { - printk ("%.2x ", data[i]); - } - printk ("\n"); + printk(KERN_DEBUG __FILE__ + ": omninet_read %d: ", header->oh_len); + for (i = 0; i < (header->oh_len + + OMNINET_HEADERLEN); i++) + printk("%.2x ", data[i]); + printk("\n"); } } if (urb->actual_length && header->oh_len) { - for (i = 0; i < header->oh_len; i++) { - tty_insert_flip_char(port->port.tty, data[OMNINET_DATAOFFSET + i], 0); - } - tty_flip_buffer_push(port->port.tty); + for (i = 0; i < header->oh_len; i++) + tty_insert_flip_char(port->port.tty, + data[OMNINET_DATAOFFSET + i], 0); + tty_flip_buffer_push(port->port.tty); } /* Continue trying to always read */ - usb_fill_bulk_urb(urb, port->serial->dev, - usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), - urb->transfer_buffer, urb->transfer_buffer_length, - omninet_read_bulk_callback, port); + usb_fill_bulk_urb(urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), + urb->transfer_buffer, urb->transfer_buffer_length, + omninet_read_bulk_callback, port); result = usb_submit_urb(urb, GFP_ATOMIC); if (result) - err("%s - failed resubmitting read urb, error %d", __func__, result); + err("%s - failed resubmitting read urb, error %d", + __func__, result); return; } @@ -243,11 +252,12 @@ static void omninet_read_bulk_callback (struct urb *urb) static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { - struct usb_serial *serial = port->serial; - struct usb_serial_port *wport = serial->port[1]; + struct usb_serial *serial = port->serial; + struct usb_serial_port *wport = serial->port[1]; - struct omninet_data *od = usb_get_serial_port_data(port); - struct omninet_header *header = (struct omninet_header *) wport->write_urb->transfer_buffer; + struct omninet_data *od = usb_get_serial_port_data(port); + struct omninet_header *header = (struct omninet_header *) + wport->write_urb->transfer_buffer; int result; @@ -255,7 +265,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, if (count == 0) { dbg("%s - write request of 0 bytes", __func__); - return (0); + return 0; } spin_lock_bh(&wport->lock); @@ -269,9 +279,11 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; - memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count); + memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, + buf, count); - usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer); + usb_serial_debug_data(debug, &port->dev, __func__, count, + wport->write_urb->transfer_buffer); header->oh_seq = od->od_outseq++; header->oh_len = count; @@ -285,7 +297,8 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); if (result) { wport->write_urb_busy = 0; - err("%s - failed submitting write urb, error %d", __func__, result); + err("%s - failed submitting write urb, error %d", + __func__, result); } else result = count; @@ -293,7 +306,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, } -static int omninet_write_room (struct tty_struct *tty) +static int omninet_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; @@ -307,12 +320,13 @@ static int omninet_write_room (struct tty_struct *tty) dbg("%s - returns %d", __func__, room); - return (room); + return room; } -static void omninet_write_bulk_callback (struct urb *urb) +static void omninet_write_bulk_callback(struct urb *urb) { -/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */ +/* struct omninet_header *header = (struct omninet_header *) + urb->transfer_buffer; */ struct usb_serial_port *port = urb->context; int status = urb->status; @@ -329,18 +343,18 @@ static void omninet_write_bulk_callback (struct urb *urb) } -static void omninet_shutdown (struct usb_serial *serial) +static void omninet_shutdown(struct usb_serial *serial) { struct usb_serial_port *wport = serial->port[1]; struct usb_serial_port *port = serial->port[0]; - dbg ("%s", __func__); + dbg("%s", __func__); usb_kill_urb(wport->write_urb); kfree(usb_get_serial_port_data(port)); } -static int __init omninet_init (void) +static int __init omninet_init(void) { int retval; retval = usb_serial_register(&zyxel_omninet_device); @@ -358,18 +372,18 @@ failed_usb_serial_register: } -static void __exit omninet_exit (void) +static void __exit omninet_exit(void) { - usb_deregister (&omninet_driver); - usb_serial_deregister (&zyxel_omninet_device); + usb_deregister(&omninet_driver); + usb_serial_deregister(&zyxel_omninet_device); } module_init(omninet_init); module_exit(omninet_exit); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 4944d40054d73b2f8d7d546f55c206eb3baf2710 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:16:03 +0100 Subject: omninet: Use string flip functions Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/omninet.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 5a76f327ef5..ae8e227f3db 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -206,8 +206,8 @@ static void omninet_read_bulk_callback(struct urb *urb) unsigned char *data = urb->transfer_buffer; struct omninet_header *header = (struct omninet_header *) &data[0]; int status = urb->status; - int i; int result; + int i; dbg("%s - port %d", __func__, port->number); @@ -229,9 +229,8 @@ static void omninet_read_bulk_callback(struct urb *urb) } if (urb->actual_length && header->oh_len) { - for (i = 0; i < header->oh_len; i++) - tty_insert_flip_char(port->port.tty, - data[OMNINET_DATAOFFSET + i], 0); + tty_insert_flip_string(port->port.tty, + data + OMNINET_DATAOFFSET, header->oh_len); tty_flip_buffer_push(port->port.tty); } -- cgit v1.2.3-70-g09d2 From 880af9db2c35c5fedaef0de89473f202329934db Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:16:12 +0100 Subject: mos7840: remove loads of bogus assignments to status Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/mos7840.c | 400 ++++++++++++++++++------------------------- 1 file changed, 164 insertions(+), 236 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 2b1fded6619..09d82062b97 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include /* * Version Information @@ -82,8 +82,8 @@ * Defines used for sending commands to port */ -#define WAIT_FOR_EVER (HZ * 0 ) /* timeout urb is wait for ever */ -#define MOS_WDR_TIMEOUT (HZ * 5 ) /* default urb timeout */ +#define WAIT_FOR_EVER (HZ * 0) /* timeout urb is wait for ever */ +#define MOS_WDR_TIMEOUT (HZ * 5) /* default urb timeout */ #define MOS_PORT1 0x0200 #define MOS_PORT2 0x0300 @@ -102,8 +102,8 @@ #define MAX_NAME_LEN 64 -#define ZLP_REG1 0x3A //Zero_Flag_Reg1 58 -#define ZLP_REG5 0x3E //Zero_Flag_Reg5 62 +#define ZLP_REG1 0x3A /* Zero_Flag_Reg1 58 */ +#define ZLP_REG5 0x3E /* Zero_Flag_Reg5 62 */ /* For higher baud Rates use TIOCEXBAUD */ #define TIOCEXBAUD 0x5462 @@ -142,7 +142,7 @@ #define MOS_MSR_DELTA_RI 0x40 #define MOS_MSR_DELTA_CD 0x80 -// Serial Port register Address +/* Serial Port register Address */ #define INTERRUPT_ENABLE_REGISTER ((__u16)(0x01)) #define FIFO_CONTROL_REGISTER ((__u16)(0x02)) #define LINE_CONTROL_REGISTER ((__u16)(0x03)) @@ -201,11 +201,11 @@ struct moschip_port { struct async_icount icount; struct usb_serial_port *port; /* loop back to the owner of this object */ - /*Offsets */ + /* Offsets */ __u8 SpRegOffset; __u8 ControlRegOffset; __u8 DcrRegOffset; - //for processing control URBS in interrupt context + /* for processing control URBS in interrupt context */ struct urb *control_urb; struct usb_ctrlrequest *dr; char *ctrl_buf; @@ -244,7 +244,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg, */ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg, - __u16 * val) + __u16 *val) { struct usb_device *dev = port->serial->dev; int ret = 0; @@ -269,16 +269,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, struct usb_device *dev = port->serial->dev; val = val & 0x00ff; - // For the UART control registers, the application number need to be Or'ed + /* For the UART control registers, the application number need + to be Or'ed */ if (port->serial->num_ports == 4) { - val |= - (((__u16) port->number - (__u16) (port->serial->minor)) + - 1) << 8; + val |= (((__u16) port->number - + (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_set_uart_reg application number is %x\n", val); } else { if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { - val |= - (((__u16) port->number - + val |= (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_set_uart_reg application number is %x\n", val); @@ -302,14 +301,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, * by passing usb_rcvctrlpipe function as parameter. */ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, - __u16 * val) + __u16 *val) { struct usb_device *dev = port->serial->dev; int ret = 0; __u16 Wval; - //dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); - /*Wval is same as application number */ + /* dbg("application number is %4x \n", + (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ + /* Wval is same as application number */ if (port->serial->num_ports == 4) { Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + @@ -317,14 +317,12 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, dbg("mos7840_get_uart_reg application number is %x\n", Wval); } else { if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { - Wval = - (((__u16) port->number - + Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_get_uart_reg application number is %x\n", Wval); } else { - Wval = - (((__u16) port->number - + Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + 2) << 8; dbg("mos7840_get_uart_reg application number is %x\n", Wval); @@ -406,11 +404,11 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) dbg("%s - %02x", __func__, new_lsr); if (new_lsr & SERIAL_LSR_BI) { - // - // Parity and Framing errors only count if they - // occur exclusive of a break being - // received. - // + /* + * Parity and Framing errors only count if they + * occur exclusive of a break being + * received. + */ new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI); } @@ -492,7 +490,7 @@ exit: } static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, - __u16 * val) + __u16 *val) { struct usb_device *dev = mcs->port->serial->dev; struct usb_ctrlrequest *dr = mcs->dr; @@ -501,7 +499,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, dr->bRequestType = MCS_RD_RTYPE; dr->bRequest = MCS_RDREQ; - dr->wValue = cpu_to_le16(Wval); //0; + dr->wValue = cpu_to_le16(Wval); /* 0 */ dr->wIndex = cpu_to_le16(reg); dr->wLength = cpu_to_le16(2); @@ -607,7 +605,8 @@ static void mos7840_interrupt_callback(struct urb *urb) } } } - if (!(rv < 0)) /* the completion handler for the control urb will resubmit */ + if (!(rv < 0)) + /* the completion handler for the control urb will resubmit */ return; exit: result = usb_submit_urb(urb, GFP_ATOMIC); @@ -656,8 +655,8 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port, if (!port || mos7840_port_paranoia_check(port, function) || mos7840_serial_paranoia_check(port->serial, function)) { - /* then say that we don't have a valid usb_serial thing, which will - * end up genrating -ENODEV return values */ + /* then say that we don't have a valid usb_serial thing, + * which will end up genrating -ENODEV return values */ return NULL; } @@ -741,8 +740,8 @@ static void mos7840_bulk_in_callback(struct urb *urb) /***************************************************************************** * mos7840_bulk_out_data_callback - * this is the callback function for when we have finished sending serial data - * on the bulk out endpoint. + * this is the callback function for when we have finished sending + * serial data on the bulk out endpoint. *****************************************************************************/ static void mos7840_bulk_out_data_callback(struct urb *urb) @@ -848,7 +847,8 @@ static int mos7840_open(struct tty_struct *tty, continue; } - urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); + urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, + GFP_KERNEL); if (!urb->transfer_buffer) { usb_free_urb(urb); mos7840_port->write_urb_pool[j] = NULL; @@ -869,9 +869,8 @@ static int mos7840_open(struct tty_struct *tty, * 0x08 : SP1/2 Control Reg *****************************************************************************/ -//NEED to check the following Block + /* NEED to check the following Block */ - status = 0; Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); if (status < 0) { @@ -891,36 +890,35 @@ static int mos7840_open(struct tty_struct *tty, dbg("writing Spreg failed\n"); return -1; } -//End of block to be checked + /* End of block to be checked */ - status = 0; Data = 0x0; - status = - mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); + status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, + &Data); if (status < 0) { dbg("Reading Controlreg failed\n"); return -1; } - Data |= 0x08; //Driver done bit - Data |= 0x20; //rx_disable - status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); + Data |= 0x08; /* Driver done bit */ + Data |= 0x20; /* rx_disable */ + status = mos7840_set_reg_sync(port, + mos7840_port->ControlRegOffset, Data); if (status < 0) { dbg("writing Controlreg failed\n"); return -1; } - //do register settings here - // Set all regs to the device default values. - //////////////////////////////////// - // First Disable all interrupts. - //////////////////////////////////// - + /* do register settings here */ + /* Set all regs to the device default values. */ + /*********************************** + * First Disable all interrupts. + ***********************************/ Data = 0x00; status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); if (status < 0) { dbg("disableing interrupts failed\n"); return -1; } - // Set FIFO_CONTROL_REGISTER to the default value + /* Set FIFO_CONTROL_REGISTER to the default value */ Data = 0x00; status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); if (status < 0) { @@ -947,90 +945,73 @@ static int mos7840_open(struct tty_struct *tty, status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); mos7840_port->shadowLCR = Data; - Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80 + Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */ status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); Data = 0x0c; - status = 0; status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); Data = 0x0; - status = 0; status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); Data = 0x00; - status = 0; status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); Data = Data & ~SERIAL_LCR_DLAB; - status = 0; status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); mos7840_port->shadowLCR = Data; - //clearing Bulkin and Bulkout Fifo + /* clearing Bulkin and Bulkout Fifo */ Data = 0x0; - status = 0; status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); Data = Data | 0x0c; - status = 0; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); Data = Data & ~0x0c; - status = 0; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); - //Finally enable all interrupts - Data = 0x0; + /* Finally enable all interrupts */ Data = 0x0c; - status = 0; status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); - //clearing rx_disable + /* clearing rx_disable */ Data = 0x0; - status = 0; - status = - mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); + status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, + &Data); Data = Data & ~0x20; - status = 0; - status = - mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); + status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, + Data); - // rx_negate + /* rx_negate */ Data = 0x0; - status = 0; - status = - mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); + status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, + &Data); Data = Data | 0x10; - status = 0; - status = - mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); + status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, + Data); /* force low_latency on so that our tty_push actually forces * * the data through,otherwise it is scheduled, and with * * high data rates (like with OHCI) data can get lost. */ - if (tty) tty->low_latency = 1; -/* Check to see if we've set up our endpoint info yet * - * (can't set it up in mos7840_startup as the structures * - * were not set up at that time.) */ + + /* Check to see if we've set up our endpoint info yet * + * (can't set it up in mos7840_startup as the structures * + * were not set up at that time.) */ if (port0->open_ports == 1) { if (serial->port[0]->interrupt_in_buffer == NULL) { - /* set up interrupt urb */ - usb_fill_int_urb(serial->port[0]->interrupt_in_urb, - serial->dev, - usb_rcvintpipe(serial->dev, - serial->port[0]-> - interrupt_in_endpointAddress), - serial->port[0]->interrupt_in_buffer, - serial->port[0]->interrupt_in_urb-> - transfer_buffer_length, - mos7840_interrupt_callback, - serial, - serial->port[0]->interrupt_in_urb-> - interval); + serial->dev, + usb_rcvintpipe(serial->dev, + serial->port[0]->interrupt_in_endpointAddress), + serial->port[0]->interrupt_in_buffer, + serial->port[0]->interrupt_in_urb-> + transfer_buffer_length, + mos7840_interrupt_callback, + serial, + serial->port[0]->interrupt_in_urb->interval); /* start interrupt read for mos7840 * * will continue as long as mos7840 is connected */ @@ -1085,14 +1066,16 @@ static int mos7840_open(struct tty_struct *tty, memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount)); /* initialize our port settings */ - mos7840_port->shadowMCR = MCR_MASTER_IE; /* Must set to enable ints! */ + /* Must set to enable ints! */ + mos7840_port->shadowMCR = MCR_MASTER_IE; /* send a open port command */ mos7840_port->open = 1; - //mos7840_change_port_settings(mos7840_port,old_termios); + /* mos7840_change_port_settings(mos7840_port,old_termios); */ mos7840_port->icount.tx = 0; mos7840_port->icount.rx = 0; - dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", serial, mos7840_port, port); + dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", + serial, mos7840_port, port); return 0; @@ -1129,11 +1112,11 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty) return 0; } - spin_lock_irqsave(&mos7840_port->pool_lock,flags); + spin_lock_irqsave(&mos7840_port->pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) if (mos7840_port->busy[i]) chars += URB_TRANSFER_BUFFER_SIZE; - spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); + spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); dbg("%s - returns %d", __func__, chars); return chars; @@ -1161,9 +1144,8 @@ static void mos7840_block_until_tx_empty(struct tty_struct *tty, count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ - if (count <= 0) { + if (count <= 0) return; - } /* Block the thread for a while */ interruptible_sleep_on_timeout(&mos7840_port->wait_chase, @@ -1245,11 +1227,11 @@ static void mos7840_close(struct tty_struct *tty, } if ((&mos7840_port->control_urb)) { dbg("%s", "Shutdown control read\n"); - // usb_kill_urb (mos7840_port->control_urb); + /*/ usb_kill_urb (mos7840_port->control_urb); */ } } -// if(mos7840_port->ctrl_buf != NULL) -// kfree(mos7840_port->ctrl_buf); +/* if(mos7840_port->ctrl_buf != NULL) */ +/* kfree(mos7840_port->ctrl_buf); */ port0->open_ports--; dbg("mos7840_num_open_ports in close%d:in port%d\n", port0->open_ports, port->number); @@ -1262,10 +1244,8 @@ static void mos7840_close(struct tty_struct *tty, if (mos7840_port->write_urb) { /* if this urb had a transfer buffer already (old tx) free it */ - - if (mos7840_port->write_urb->transfer_buffer != NULL) { + if (mos7840_port->write_urb->transfer_buffer != NULL) kfree(mos7840_port->write_urb->transfer_buffer); - } usb_free_urb(mos7840_port->write_urb); } @@ -1302,9 +1282,8 @@ static void mos7840_block_until_chase_response(struct tty_struct *tty, count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ - if (count <= 0) { + if (count <= 0) return; - } /* Block the thread for a while */ interruptible_sleep_on_timeout(&mos7840_port->wait_chase, @@ -1349,9 +1328,8 @@ static void mos7840_break(struct tty_struct *tty, int break_state) mos7840_port = mos7840_get_port_private(port); - if (mos7840_port == NULL) { + if (mos7840_port == NULL) return; - } if (serial->dev) /* flush and block until tx is empty */ @@ -1403,9 +1381,8 @@ static int mos7840_write_room(struct tty_struct *tty) spin_lock_irqsave(&mos7840_port->pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { - if (!mos7840_port->busy[i]) { + if (!mos7840_port->busy[i]) room += URB_TRANSFER_BUFFER_SIZE; - } } spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); @@ -1435,45 +1412,41 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, struct moschip_port *mos7840_port; struct usb_serial *serial; struct urb *urb; - //__u16 Data; + /* __u16 Data; */ const unsigned char *current_position = data; unsigned char *data1; dbg("%s \n", "entering ..........."); - //dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",mos7840_port->shadowLCR); + /* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", + mos7840_port->shadowLCR); */ #ifdef NOTMOS7840 Data = 0x00; - status = 0; status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); mos7840_port->shadowLCR = Data; dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data); dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); - //Data = 0x03; - //status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); - //mos7840_port->shadowLCR=Data;//Need to add later + /* Data = 0x03; */ + /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ + /* mos7840_port->shadowLCR=Data;//Need to add later */ - Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80 - status = 0; + Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */ status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); - //Data = 0x0c; - //status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); + /* Data = 0x0c; */ + /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ Data = 0x00; - status = 0; status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); dbg("mos7840_write:DLL value is %x\n", Data); Data = 0x0; - status = 0; status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); dbg("mos7840_write:DLM value is %x\n", Data); Data = Data & ~SERIAL_LCR_DLAB; dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); - status = 0; status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); #endif @@ -1598,7 +1571,6 @@ static void mos7840_throttle(struct tty_struct *tty) /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR &= ~MCR_RTS; - status = 0; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); if (status < 0) @@ -1610,8 +1582,9 @@ static void mos7840_throttle(struct tty_struct *tty) /***************************************************************************** * mos7840_unthrottle - * this function is called by the tty driver when it wants to resume the data - * being read from the port (called after SerialThrottle is called) + * this function is called by the tty driver when it wants to resume + * the data being read from the port (called after mos7840_throttle is + * called) *****************************************************************************/ static void mos7840_unthrottle(struct tty_struct *tty) { @@ -1645,7 +1618,6 @@ static void mos7840_unthrottle(struct tty_struct *tty) /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR |= MCR_RTS; - status = 0; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); if (status < 0) @@ -1660,7 +1632,7 @@ static int mos7840_tiocmget(struct tty_struct *tty, struct file *file) unsigned int result; __u16 msr; __u16 mcr; - int status = 0; + int status; mos7840_port = mos7840_get_port_private(port); dbg("%s - port %d", __func__, port->number); @@ -1731,7 +1703,7 @@ static int mos7840_tiocmset(struct tty_struct *tty, struct file *file, * baud rate. *****************************************************************************/ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, - __u16 * clk_sel_val) + __u16 *clk_sel_val) { dbg("%s - %d", __func__, baudRate); @@ -1783,9 +1755,8 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, /* Check for round off */ round1 = (__u16) (2304000L / baudrate); round = (__u16) (round1 - (custom * 10)); - if (round > 4) { + if (round > 4) custom++; - } *divisor = custom; dbg(" Baud %d = %d\n", baudrate, custom); @@ -1833,16 +1804,15 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, dbg("%s - port = %d, baud = %d", __func__, mos7840_port->port->number, baudRate); - //reset clk_uart_sel in spregOffset + /* reset clk_uart_sel in spregOffset */ if (baudRate > 115200) { #ifdef HW_flow_control - //NOTE: need to see the pther register to modify - //setting h/w flow control bit to 1; - status = 0; + /* NOTE: need to see the pther register to modify */ + /* setting h/w flow control bit to 1 */ Data = 0x2b; mos7840_port->shadowMCR = Data; - status = - mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); + status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, + Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; @@ -1851,12 +1821,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, } else { #ifdef HW_flow_control - //setting h/w flow control bit to 0; - status = 0; + / *setting h/w flow control bit to 0 */ Data = 0xb; mos7840_port->shadowMCR = Data; - status = - mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); + status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, + Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; @@ -1865,25 +1834,20 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, } - if (1) //baudRate <= 115200) - { + if (1) { /* baudRate <= 115200) */ clk_sel_val = 0x0; Data = 0x0; - status = 0; - status = - mos7840_calc_baud_rate_divisor(baudRate, &divisor, + status = mos7840_calc_baud_rate_divisor(baudRate, &divisor, &clk_sel_val); - status = - mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, - &Data); + status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, + &Data); if (status < 0) { dbg("reading spreg failed in set_serial_baud\n"); return -1; } Data = (Data & 0x8f) | clk_sel_val; - status = 0; - status = - mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); + status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, + Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; @@ -1915,7 +1879,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); } - return status; } @@ -2006,9 +1969,8 @@ static void mos7840_change_port_settings(struct tty_struct *tty, dbg("%s - parity = none", __func__); } - if (cflag & CMSPAR) { + if (cflag & CMSPAR) lParity = lParity | 0x20; - } /* Change the Stop bit */ if (cflag & CSTOPB) { @@ -2050,16 +2012,13 @@ static void mos7840_change_port_settings(struct tty_struct *tty, /* set up the MCR register and send it to the mos7840 */ mos7840_port->shadowMCR = MCR_MASTER_IE; - if (cflag & CBAUD) { + if (cflag & CBAUD) mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS); - } - if (cflag & CRTSCTS) { + if (cflag & CRTSCTS) mos7840_port->shadowMCR |= (MCR_XON_ANY); - - } else { + else mos7840_port->shadowMCR &= ~(MCR_XON_ANY); - } Data = mos7840_port->shadowMCR; mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); @@ -2255,7 +2214,6 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port, mos7840_port->shadowMCR = mcr; Data = mos7840_port->shadowMCR; - status = 0; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); if (status < 0) { dbg("setting MODEM_CONTROL_REGISTER Failed\n"); @@ -2276,8 +2234,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port, unsigned int result = 0; __u16 msr; unsigned int mcr = mos7840_port->shadowMCR; - int status = 0; - status = mos7840_get_uart_reg(mos7840_port->port, + mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER, &msr); result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ @@ -2389,7 +2346,7 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file, dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = mos7840_port->icount; while (1) { - //interruptible_sleep_on(&mos7840_port->delta_msr_wait); + /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ mos7840_port->delta_msr_cond = 0; wait_event_interruptible(mos7840_port->delta_msr_wait, (mos7840_port-> @@ -2494,8 +2451,9 @@ static int mos7840_startup(struct usb_serial *serial) goto error; } - /* Initialize all port interrupt end point to port 0 int endpoint * - * Our device has only one interrupt end point comman to all port */ + /* Initialize all port interrupt end point to port 0 int + * endpoint. Our device has only one interrupt end point + * common to all port */ mos7840_port->port = serial->port[i]; mos7840_set_port_private(serial->port[i], mos7840_port); @@ -2531,27 +2489,23 @@ static int mos7840_startup(struct usb_serial *serial) mos7840_port->DcrRegOffset = 0x1c; } mos7840_dump_serial_port(mos7840_port); - mos7840_set_port_private(serial->port[i], mos7840_port); - //enable rx_disable bit in control register - - status = - mos7840_get_reg_sync(serial->port[i], - mos7840_port->ControlRegOffset, &Data); + /* enable rx_disable bit in control register */ + status = mos7840_get_reg_sync(serial->port[i], + mos7840_port->ControlRegOffset, &Data); if (status < 0) { dbg("Reading ControlReg failed status-0x%x\n", status); break; } else dbg("ControlReg Reading success val is %x, status%d\n", Data, status); - Data |= 0x08; //setting driver done bit - Data |= 0x04; //sp1_bit to have cts change reflect in modem status reg + Data |= 0x08; /* setting driver done bit */ + Data |= 0x04; /* sp1_bit to have cts change reflect in + modem status reg */ - //Data |= 0x20; //rx_disable bit - status = 0; - status = - mos7840_set_reg_sync(serial->port[i], + /* Data |= 0x20; //rx_disable bit */ + status = mos7840_set_reg_sync(serial->port[i], mos7840_port->ControlRegOffset, Data); if (status < 0) { dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status); @@ -2560,13 +2514,11 @@ static int mos7840_startup(struct usb_serial *serial) dbg("ControlReg Writing success(rx_disable) status%d\n", status); - //Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 and 0x24 in DCR3 + /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 + and 0x24 in DCR3 */ Data = 0x01; - status = 0; - status = - mos7840_set_reg_sync(serial->port[i], - (__u16) (mos7840_port->DcrRegOffset + - 0), Data); + status = mos7840_set_reg_sync(serial->port[i], + (__u16) (mos7840_port->DcrRegOffset + 0), Data); if (status < 0) { dbg("Writing DCR0 failed status-0x%x\n", status); break; @@ -2574,11 +2526,8 @@ static int mos7840_startup(struct usb_serial *serial) dbg("DCR0 Writing success status%d\n", status); Data = 0x05; - status = 0; - status = - mos7840_set_reg_sync(serial->port[i], - (__u16) (mos7840_port->DcrRegOffset + - 1), Data); + status = mos7840_set_reg_sync(serial->port[i], + (__u16) (mos7840_port->DcrRegOffset + 1), Data); if (status < 0) { dbg("Writing DCR1 failed status-0x%x\n", status); break; @@ -2586,22 +2535,17 @@ static int mos7840_startup(struct usb_serial *serial) dbg("DCR1 Writing success status%d\n", status); Data = 0x24; - status = 0; - status = - mos7840_set_reg_sync(serial->port[i], - (__u16) (mos7840_port->DcrRegOffset + - 2), Data); + status = mos7840_set_reg_sync(serial->port[i], + (__u16) (mos7840_port->DcrRegOffset + 2), Data); if (status < 0) { dbg("Writing DCR2 failed status-0x%x\n", status); break; } else dbg("DCR2 Writing success status%d\n", status); - // write values in clkstart0x0 and clkmulti 0x20 + /* write values in clkstart0x0 and clkmulti 0x20 */ Data = 0x0; - status = 0; - status = - mos7840_set_reg_sync(serial->port[i], + status = mos7840_set_reg_sync(serial->port[i], CLK_START_VALUE_REGISTER, Data); if (status < 0) { dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); @@ -2610,9 +2554,8 @@ static int mos7840_startup(struct usb_serial *serial) dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status); Data = 0x20; - status = - mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER, - Data); + status = mos7840_set_reg_sync(serial->port[i], + CLK_MULTI_REGISTER, Data); if (status < 0) { dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n", status); @@ -2621,11 +2564,10 @@ static int mos7840_startup(struct usb_serial *serial) dbg("CLK_MULTI_REGISTER Writing success status%d\n", status); - //write value 0x0 to scratchpad register + /* write value 0x0 to scratchpad register */ Data = 0x00; - status = - mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER, - Data); + status = mos7840_set_uart_reg(serial->port[i], + SCRATCH_PAD_REGISTER, Data); if (status < 0) { dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status); @@ -2634,21 +2576,17 @@ static int mos7840_startup(struct usb_serial *serial) dbg("SCRATCH_PAD_REGISTER Writing success status%d\n", status); - //Zero Length flag register + /* Zero Length flag register */ if ((mos7840_port->port_num != 1) && (serial->num_ports == 2)) { Data = 0xff; - status = 0; status = mos7840_set_reg_sync(serial->port[i], - (__u16) (ZLP_REG1 + - ((__u16) - mos7840_port-> - port_num)), - Data); + (__u16) (ZLP_REG1 + + ((__u16)mos7840_port->port_num)), Data); dbg("ZLIP offset%x\n", (__u16) (ZLP_REG1 + - ((__u16) mos7840_port->port_num))); + ((__u16) mos7840_port->port_num))); if (status < 0) { dbg("Writing ZLP_REG%d failed status-0x%x\n", i + 2, status); @@ -2658,13 +2596,9 @@ static int mos7840_startup(struct usb_serial *serial) i + 2, status); } else { Data = 0xff; - status = 0; status = mos7840_set_reg_sync(serial->port[i], - (__u16) (ZLP_REG1 + - ((__u16) - mos7840_port-> - port_num) - - 0x1), Data); + (__u16) (ZLP_REG1 + + ((__u16)mos7840_port->port_num) - 0x1), Data); dbg("ZLIP offset%x\n", (__u16) (ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1)); @@ -2679,14 +2613,16 @@ static int mos7840_startup(struct usb_serial *serial) } mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); - mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); - if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || !mos7840_port->dr) { + mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), + GFP_KERNEL); + if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || + !mos7840_port->dr) { status = -ENOMEM; goto error; } } - //Zero Length flag enable + /* Zero Length flag enable */ Data = 0x0f; status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); if (status < 0) { @@ -2729,7 +2665,7 @@ static void mos7840_shutdown(struct usb_serial *serial) return; } - /* check for the ports to be closed,close the ports and disconnect */ + /* check for the ports to be closed,close the ports and disconnect */ /* free private structure allocated for serial port * * stop reads and writes on all ports */ @@ -2810,20 +2746,12 @@ static int __init moschip7840_init(void) /* Register with the usb */ retval = usb_register(&io_driver); - - if (retval) - goto failed_usb_register; - if (retval == 0) { dbg("%s\n", "Leaving..."); return 0; } - - failed_usb_register: usb_serial_deregister(&moschip7840_4port_device); - - failed_port_device_register: - +failed_port_device_register: return retval; } -- cgit v1.2.3-70-g09d2 From 4da1a17dbc5211ac90264cfc4f0e076c8bdc1732 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:16:21 +0100 Subject: tty-usb-mos7720: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/mos7720.c | 227 ++++++++++++++++++++++--------------------- 1 file changed, 116 insertions(+), 111 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index d47f0814ce2..7c4917d77c0 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include /* @@ -64,8 +64,7 @@ #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ /* This structure holds all of the local port information */ -struct moschip_port -{ +struct moschip_port { __u8 shadowLCR; /* last LCR value received */ __u8 shadowMCR; /* last MCR value received */ __u8 shadowMSR; /* last MSR value received */ @@ -76,8 +75,7 @@ struct moschip_port }; /* This structure holds all of the individual serial device information */ -struct moschip_serial -{ +struct moschip_serial { int interrupt_started; }; @@ -88,7 +86,7 @@ static int debug; #define MOSCHIP_DEVICE_ID_7715 0x7715 static struct usb_device_id moschip_port_id_table [] = { - { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) }, + { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, { } /* terminating entry */ }; MODULE_DEVICE_TABLE(usb, moschip_port_id_table); @@ -108,7 +106,7 @@ static void mos7720_interrupt_callback(struct urb *urb) __u8 sp1; __u8 sp2; - dbg("%s"," : Entering\n"); + dbg("%s", " : Entering\n"); switch (status) { case 0: @@ -208,7 +206,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) mos7720_port = urb->context; if (!mos7720_port) { - dbg("%s","NULL mos7720_port pointer \n"); + dbg("%s", "NULL mos7720_port pointer \n"); return ; } @@ -284,17 +282,16 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, __u16 size = 0x0000; if (value < MOS_MAX_PORT) { - if (product == MOSCHIP_DEVICE_ID_7715) { + if (product == MOSCHIP_DEVICE_ID_7715) value = value*0x100+0x100; - } else { + else value = value*0x100+0x200; - } } else { value = 0x0000; if ((product == MOSCHIP_DEVICE_ID_7715) && (index != 0x08)) { dbg("serial->product== MOSCHIP_DEVICE_ID_7715"); - //index = 0x01 ; + /* index = 0x01 ; */ } } @@ -308,20 +305,20 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, request = (__u8)MOS_READ; requesttype = (__u8)0xC0; size = 0x01; - pipe = usb_rcvctrlpipe(serial->dev,0); + pipe = usb_rcvctrlpipe(serial->dev, 0); } status = usb_control_msg(serial->dev, pipe, request, requesttype, value, index, data, size, MOS_WDR_TIMEOUT); if (status < 0) - dbg("Command Write failed Value %x index %x\n",value,index); + dbg("Command Write failed Value %x index %x\n", value, index); return status; } static int mos7720_open(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; struct usb_serial_port *port0; @@ -352,7 +349,7 @@ static int mos7720_open(struct tty_struct *tty, /* Initialising the write urb pool */ for (j = 0; j < NUM_URBS; ++j) { - urb = usb_alloc_urb(0,GFP_KERNEL); + urb = usb_alloc_urb(0, GFP_KERNEL); mos7720_port->write_urb_pool[j] = urb; if (urb == NULL) { @@ -386,7 +383,7 @@ static int mos7720_open(struct tty_struct *tty, */ port_number = port->number - port->serial->minor; send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); - dbg("SS::%p LSR:%x\n",mos7720_port, data); + dbg("SS::%p LSR:%x\n", mos7720_port, data); dbg("Check:Sending Command .........."); @@ -403,10 +400,10 @@ static int mos7720_open(struct tty_struct *tty, data = 0xCF; send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data); data = 0x03; - mos7720_port->shadowLCR = data; + mos7720_port->shadowLCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); data = 0x0b; - mos7720_port->shadowMCR = data; + mos7720_port->shadowMCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); data = 0x0b; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); @@ -421,7 +418,8 @@ static int mos7720_open(struct tty_struct *tty, data = 0x03; send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); data = 0x00; - send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); + send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, + port_number + 1, &data); */ data = 0x00; send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); @@ -430,14 +428,14 @@ static int mos7720_open(struct tty_struct *tty, send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); data = 0x83; - mos7720_port->shadowLCR = data; + mos7720_port->shadowLCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); data = 0x0c; send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); data = 0x00; send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); data = 0x03; - mos7720_port->shadowLCR = data; + mos7720_port->shadowLCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); data = 0x0c; send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); @@ -464,15 +462,15 @@ static int mos7720_open(struct tty_struct *tty, /* set up our interrupt urb */ usb_fill_int_urb(port0->interrupt_in_urb, serial->dev, - usb_rcvintpipe(serial->dev, - port->interrupt_in_endpointAddress), - port0->interrupt_in_buffer, - port0->interrupt_in_urb->transfer_buffer_length, - mos7720_interrupt_callback, mos7720_port, - port0->interrupt_in_urb->interval); + usb_rcvintpipe(serial->dev, + port->interrupt_in_endpointAddress), + port0->interrupt_in_buffer, + port0->interrupt_in_urb->transfer_buffer_length, + mos7720_interrupt_callback, mos7720_port, + port0->interrupt_in_urb->interval); /* start interrupt read for this mos7720 this interrupt * - * will continue as long as the mos7720 is connected */ + * will continue as long as the mos7720 is connected */ dbg("Submit URB over !!!"); response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL); if (response) @@ -484,14 +482,14 @@ static int mos7720_open(struct tty_struct *tty, /* set up our bulk in urb */ usb_fill_bulk_urb(port->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, - port->bulk_in_endpointAddress), + port->bulk_in_endpointAddress), port->bulk_in_buffer, port->read_urb->transfer_buffer_length, mos7720_bulk_in_callback, mos7720_port); response = usb_submit_urb(port->read_urb, GFP_KERNEL); if (response) - dev_err(&port->dev, - "%s - Error %d submitting read urb\n", __func__, response); + dev_err(&port->dev, "%s - Error %d submitting read urb\n", + __func__, response); /* initialize our icount structure */ memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); @@ -530,7 +528,8 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty) } for (i = 0; i < NUM_URBS; ++i) { - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) + if (mos7720_port->write_urb_pool[i] && + mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) chars += URB_TRANSFER_BUFFER_SIZE; } dbg("%s - returns %d", __func__, chars); @@ -576,12 +575,12 @@ static void mos7720_close(struct tty_struct *tty, * been disconnected */ if (!serial->disconnected) { data = 0x00; - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, - 0x04, &data); + send_mos_cmd(serial, MOS_WRITE, + port->number - port->serial->minor, 0x04, &data); data = 0x00; - send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, - 0x01, &data); + send_mos_cmd(serial, MOS_WRITE, + port->number - port->serial->minor, 0x01, &data); } mutex_unlock(&serial->disc_mutex); mos7720_port->open = 0; @@ -592,7 +591,7 @@ static void mos7720_close(struct tty_struct *tty, static void mos7720_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; - unsigned char data; + unsigned char data; struct usb_serial *serial; struct moschip_port *mos7720_port; @@ -640,7 +639,8 @@ static int mos7720_write_room(struct tty_struct *tty) /* FIXME: Locking */ for (i = 0; i < NUM_URBS; ++i) { - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) + if (mos7720_port->write_urb_pool[i] && + mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) room += URB_TRANSFER_BUFFER_SIZE; } @@ -675,9 +675,10 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, urb = NULL; for (i = 0; i < NUM_URBS; ++i) { - if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { + if (mos7720_port->write_urb_pool[i] && + mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { urb = mos7720_port->write_urb_pool[i]; - dbg("URB:%d",i); + dbg("URB:%d", i); break; } } @@ -695,7 +696,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, goto exit; } } - transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); + transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); memcpy(urb->transfer_buffer, current_position, transfer_size); usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, @@ -704,12 +705,12 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, /* fill urb with data and submit */ usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, - port->bulk_out_endpointAddress), + port->bulk_out_endpointAddress), urb->transfer_buffer, transfer_size, mos7720_bulk_out_data_callback, mos7720_port); /* send it down the pipe */ - status = usb_submit_urb(urb,GFP_ATOMIC); + status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { err("%s - usb_submit_urb(write bulk) failed with status = %d", __func__, status); @@ -810,9 +811,9 @@ static int set_higher_rates(struct moschip_port *mos7720_port, port = mos7720_port->port; serial = port->serial; - /*********************************************** - * Init Sequence for higher rates - ***********************************************/ + /*********************************************** + * Init Sequence for higher rates + ***********************************************/ dbg("Sending Setting Commands .........."); port_number = port->number - port->serial->minor; @@ -823,7 +824,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port, data = 0x0CF; send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data); data = 0x00b; - mos7720_port->shadowMCR = data; + mos7720_port->shadowMCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); data = 0x00b; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); @@ -834,12 +835,12 @@ static int set_higher_rates(struct moschip_port *mos7720_port, send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); - /*********************************************** - * Set for higher rates * - ***********************************************/ + /*********************************************** + * Set for higher rates * + ***********************************************/ data = baud * 0x10; - send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data); + send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); data = 0x003; send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); @@ -847,34 +848,33 @@ static int set_higher_rates(struct moschip_port *mos7720_port, send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); data = 0x02b; - mos7720_port->shadowMCR = data; + mos7720_port->shadowMCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); data = 0x02b; send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); - /*********************************************** - * Set DLL/DLM - ***********************************************/ + /*********************************************** + * Set DLL/DLM + ***********************************************/ data = mos7720_port->shadowLCR | UART_LCR_DLAB; - mos7720_port->shadowLCR = data; + mos7720_port->shadowLCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); data = 0x001; /* DLL */ - send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); + send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); data = 0x000; /* DLM */ - send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); + send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; - mos7720_port->shadowLCR = data; + mos7720_port->shadowLCR = data; send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); return 0; } /* baud rate information */ -struct divisor_table_entry -{ +struct divisor_table_entry { __u32 baudrate; __u16 divisor; }; @@ -923,8 +923,8 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) } } - /* After trying for all the standard baud rates * - * Try calculating the divisor for this baud rate */ + /* After trying for all the standard baud rates * + * Try calculating the divisor for this baud rate */ if (baudrate > 75 && baudrate < 230400) { /* get the divisor */ custom = (__u16)(230400L / baudrate); @@ -936,7 +936,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) custom++; *divisor = custom; - dbg("Baud %d = %d",baudrate, custom); + dbg("Baud %d = %d", baudrate, custom); return 0; } @@ -970,29 +970,29 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, number = port->number - port->serial->minor; dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); - /* Calculate the Divisor */ + /* Calculate the Divisor */ status = calc_baud_rate_divisor(baudrate, &divisor); if (status) { err("%s - bad baud rate", __func__); return status; } - /* Enable access to divisor latch */ - data = mos7720_port->shadowLCR | UART_LCR_DLAB; - mos7720_port->shadowLCR = data; - send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); + /* Enable access to divisor latch */ + data = mos7720_port->shadowLCR | UART_LCR_DLAB; + mos7720_port->shadowLCR = data; + send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); /* Write the divisor */ data = ((unsigned char)(divisor & 0xff)); - send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); + send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); data = ((unsigned char)((divisor & 0xff00) >> 8)); - send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); + send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); - /* Disable access to divisor latch */ - data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; - mos7720_port->shadowLCR = data; - send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); + /* Disable access to divisor latch */ + data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; + mos7720_port->shadowLCR = data; + send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); return status; } @@ -1095,29 +1095,31 @@ static void change_port_settings(struct tty_struct *tty, #define LCR_PAR_MASK 0x38 /* Mask for parity field */ /* Update the LCR with the correct value */ - mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); + mos7720_port->shadowLCR &= + ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); mos7720_port->shadowLCR |= (lData | lParity | lStop); /* Disable Interrupts */ data = 0x00; - send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data); + send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, + UART_IER, &data); data = 0x00; - send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); + send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); data = 0xcf; - send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); + send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); /* Send the updated LCR value to the mos7720 */ data = mos7720_port->shadowLCR; - send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); + send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); - data = 0x00b; - mos7720_port->shadowMCR = data; - send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); - data = 0x00b; - send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); + data = 0x00b; + mos7720_port->shadowMCR = data; + send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); + data = 0x00b; + send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); /* set up the MCR register and send it to the mos7720 */ mos7720_port->shadowMCR = UART_MCR_OUT2; @@ -1126,9 +1128,8 @@ static void change_port_settings(struct tty_struct *tty, if (cflag & CRTSCTS) { mos7720_port->shadowMCR |= (UART_MCR_XONANY); - - /* To set hardware flow control to the specified * - * serial port, in SP1/2_CONTROL_REG */ + /* To set hardware flow control to the specified * + * serial port, in SP1/2_CONTROL_REG */ if (port->number) { data = 0x001; send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, @@ -1207,7 +1208,7 @@ static void mos7720_set_termios(struct tty_struct *tty, return; } - dbg("%s\n","setting termios - ASPIRE"); + dbg("%s\n", "setting termios - ASPIRE"); cflag = tty->termios->c_cflag; @@ -1224,12 +1225,12 @@ static void mos7720_set_termios(struct tty_struct *tty, /* change the port settings to the new ones specified */ change_port_settings(tty, mos7720_port, old_termios); - if(!port->read_urb) { - dbg("%s","URB KILLED !!!!!\n"); + if (!port->read_urb) { + dbg("%s", "URB KILLED !!!!!\n"); return; } - if(port->read_urb->status != -EINPROGRESS) { + if (port->read_urb->status != -EINPROGRESS) { port->read_urb->dev = serial->dev; status = usb_submit_urb(port->read_urb, GFP_ATOMIC); if (status) @@ -1249,8 +1250,8 @@ static void mos7720_set_termios(struct tty_struct *tty, * transmit holding register is empty. This functionality * allows an RS485 driver to be written in user space. */ -static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port, - unsigned int __user *value) +static int get_lsr_info(struct tty_struct *tty, + struct moschip_port *mos7720_port, unsigned int __user *value) { int count; unsigned int result = 0; @@ -1301,7 +1302,7 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, if (mos7720_port == NULL) return -1; - port = (struct usb_serial_port*)mos7720_port->port; + port = (struct usb_serial_port *)mos7720_port->port; mcr = mos7720_port->shadowMCR; if (copy_from_user(&arg, value, sizeof(int))) @@ -1382,7 +1383,7 @@ static int get_serial_info(struct moschip_port *mos7720_port, tmp.port = mos7720_port->port->number; tmp.irq = 0; tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; - tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; + tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; tmp.baud_base = 9600; tmp.close_delay = 5*HZ; tmp.closing_wait = 30*HZ; @@ -1417,15 +1418,16 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, case TIOCSERGETLSR: dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); - return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg); + return get_lsr_info(tty, mos7720_port, + (unsigned int __user *)arg); return 0; /* FIXME: These should be using the mode methods */ case TIOCMBIS: case TIOCMBIC: case TIOCMSET: - dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, - port->number); + dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", + __func__, port->number); return set_modem_info(mos7720_port, cmd, (unsigned int __user *)arg); @@ -1452,7 +1454,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { return 0; } cprev = cnow; @@ -1475,7 +1477,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, icount.buf_overrun = cnow.buf_overrun; dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, - port->number, icount.rx, icount.tx ); + port->number, icount.rx, icount.tx); if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) return -EFAULT; return 0; @@ -1526,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial) /* Initialize all port interrupt end point to port 0 int * endpoint. Our device has only one interrupt endpoint * comman to all ports */ - serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress; + serial->port[i]->interrupt_in_endpointAddress = + serial->port[0]->interrupt_in_endpointAddress; mos7720_port->port = serial->port[i]; usb_set_serial_port_data(serial->port[i], mos7720_port); @@ -1538,13 +1541,15 @@ static int mos7720_startup(struct usb_serial *serial) /* setting configuration feature to one */ usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ); + (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ); - send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1 - dbg("LSR:%x",data); + /* LSR For Port 1 */ + send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data); + dbg("LSR:%x", data); - send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2 - dbg("LSR:%x",data); + /* LSR For Port 2 */ + send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data); + dbg("LSR:%x", data); return 0; } @@ -1554,7 +1559,7 @@ static void mos7720_shutdown(struct usb_serial *serial) int i; /* free private structure allocated for serial port */ - for (i=0; i < serial->num_ports; ++i) { + for (i = 0; i < serial->num_ports; ++i) { kfree(usb_get_serial_port_data(serial->port[i])); usb_set_serial_port_data(serial->port[i], NULL); } @@ -1634,8 +1639,8 @@ module_init(moschip7720_init); module_exit(moschip7720_exit); /* Module information */ -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); -- cgit v1.2.3-70-g09d2 From 03f0dbf74c7a117c270e63d62d5e4927af6f295b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:16:34 +0100 Subject: tty-usb-io_edgeport: Coding style Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/io_edgeport.c | 1823 +++++++++++++++++++++----------------- drivers/usb/serial/io_tables.h | 6 +- 2 files changed, 1023 insertions(+), 806 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 29346d79df7..b4bd6847a96 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include "io_edgeport.h" @@ -66,16 +66,16 @@ /* receive port state */ enum RXSTATE { - EXPECT_HDR1 = 0, /* Expect header byte 1 */ - EXPECT_HDR2 = 1, /* Expect header byte 2 */ - EXPECT_DATA = 2, /* Expect 'RxBytesRemaining' data */ - EXPECT_HDR3 = 3, /* Expect header byte 3 (for status hdrs only) */ + EXPECT_HDR1 = 0, /* Expect header byte 1 */ + EXPECT_HDR2 = 1, /* Expect header byte 2 */ + EXPECT_DATA = 2, /* Expect 'RxBytesRemaining' data */ + EXPECT_HDR3 = 3, /* Expect header byte 3 (for status hdrs only) */ }; -/* Transmit Fifo - * This Transmit queue is an extension of the edgeport Rx buffer. - * The maximum amount of data buffered in both the edgeport +/* Transmit Fifo + * This Transmit queue is an extension of the edgeport Rx buffer. + * The maximum amount of data buffered in both the edgeport * Rx buffer (maxTxCredits) and this buffer will never exceed maxTxCredits. */ struct TxFifo { @@ -132,12 +132,12 @@ struct edgeport_serial { int is_epic; /* flag if EPiC device or not */ __u8 interrupt_in_endpoint; /* the interrupt endpoint handle */ - unsigned char * interrupt_in_buffer; /* the buffer we use for the interrupt endpoint */ - struct urb * interrupt_read_urb; /* our interrupt urb */ + unsigned char *interrupt_in_buffer; /* the buffer we use for the interrupt endpoint */ + struct urb *interrupt_read_urb; /* our interrupt urb */ __u8 bulk_in_endpoint; /* the bulk in endpoint handle */ - unsigned char * bulk_in_buffer; /* the buffer we use for the bulk in endpoint */ - struct urb * read_urb; /* our bulk read urb */ + unsigned char *bulk_in_buffer; /* the buffer we use for the bulk in endpoint */ + struct urb *read_urb; /* our bulk read urb */ bool read_in_progress; spinlock_t es_lock; @@ -162,16 +162,17 @@ struct divisor_table_entry { __u16 Divisor; }; -// -// Define table of divisors for Rev A EdgePort/4 hardware -// These assume a 3.6864MHz crystal, the standard /16, and -// MCR.7 = 0. -// +/* + * Define table of divisors for Rev A EdgePort/4 hardware + * These assume a 3.6864MHz crystal, the standard /16, and + * MCR.7 = 0. + */ + static const struct divisor_table_entry divisor_table[] = { - { 50, 4608}, - { 75, 3072}, - { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */ - { 134, 1713}, /* 1713.011152 => 230398.5 => .00065% under */ + { 50, 4608}, + { 75, 3072}, + { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */ + { 134, 1713}, /* 1713.011152 => 230398.5 => .00065% under */ { 150, 1536}, { 300, 768}, { 600, 384}, @@ -194,65 +195,86 @@ static int debug; static int low_latency = 1; /* tty low latency flag, on by default */ -static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ +static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ /* local function prototypes */ /* function prototypes for all URB callbacks */ -static void edge_interrupt_callback (struct urb *urb); -static void edge_bulk_in_callback (struct urb *urb); -static void edge_bulk_out_data_callback (struct urb *urb); -static void edge_bulk_out_cmd_callback (struct urb *urb); +static void edge_interrupt_callback(struct urb *urb); +static void edge_bulk_in_callback(struct urb *urb); +static void edge_bulk_out_data_callback(struct urb *urb); +static void edge_bulk_out_cmd_callback(struct urb *urb); /* function prototypes for the usbserial callbacks */ -static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); -static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); -static int edge_write_room (struct tty_struct *tty); -static int edge_chars_in_buffer (struct tty_struct *tty); -static void edge_throttle (struct tty_struct *tty); -static void edge_unthrottle (struct tty_struct *tty); -static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); -static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); -static void edge_break (struct tty_struct *tty, int break_state); -static int edge_tiocmget (struct tty_struct *tty, struct file *file); -static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static int edge_startup (struct usb_serial *serial); -static void edge_shutdown (struct usb_serial *serial); - +static int edge_open(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static void edge_close(struct tty_struct *tty, struct usb_serial_port *port, + struct file *filp); +static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count); +static int edge_write_room(struct tty_struct *tty); +static int edge_chars_in_buffer(struct tty_struct *tty); +static void edge_throttle(struct tty_struct *tty); +static void edge_unthrottle(struct tty_struct *tty); +static void edge_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, + struct ktermios *old_termios); +static int edge_ioctl(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); +static void edge_break(struct tty_struct *tty, int break_state); +static int edge_tiocmget(struct tty_struct *tty, struct file *file); +static int edge_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear); +static int edge_startup(struct usb_serial *serial); +static void edge_shutdown(struct usb_serial *serial); #include "io_tables.h" /* all of the devices that this driver supports */ /* function prototypes for all of our local functions */ -static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength); -static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3); -static void edge_tty_recv (struct device *dev, struct tty_struct *tty, unsigned char *data, int length); -static void handle_new_msr (struct edgeport_port *edge_port, __u8 newMsr); -static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data); -static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param); -static int calc_baud_rate_divisor (int baud_rate, int *divisor); -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate); -static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port, - struct ktermios *old_termios); -static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue); -static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength); -static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); - -static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data); -static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data); -static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data); -static void get_manufacturing_desc (struct edgeport_serial *edge_serial); -static void get_boot_desc (struct edgeport_serial *edge_serial); -static void load_application_firmware (struct edgeport_serial *edge_serial); - -static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size); - - -// ************************************************************************ -// ************************************************************************ -// ************************************************************************ -// ************************************************************************ + +static void process_rcvd_data(struct edgeport_serial *edge_serial, + unsigned char *buffer, __u16 bufferLength); +static void process_rcvd_status(struct edgeport_serial *edge_serial, + __u8 byte2, __u8 byte3); +static void edge_tty_recv(struct device *dev, struct tty_struct *tty, + unsigned char *data, int length); +static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); +static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, + __u8 lsr, __u8 data); +static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command, + __u8 param); +static int calc_baud_rate_divisor(int baud_rate, int *divisor); +static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, + int baudRate); +static void change_port_settings(struct tty_struct *tty, + struct edgeport_port *edge_port, + struct ktermios *old_termios); +static int send_cmd_write_uart_register(struct edgeport_port *edge_port, + __u8 regNum, __u8 regValue); +static int write_cmd_usb(struct edgeport_port *edge_port, + unsigned char *buffer, int writeLength); +static void send_more_port_data(struct edgeport_serial *edge_serial, + struct edgeport_port *edge_port); + +static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, + __u16 length, const __u8 *data); +static int rom_read(struct usb_serial *serial, __u16 extAddr, __u16 addr, + __u16 length, __u8 *data); +static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, + __u16 length, const __u8 *data); +static void get_manufacturing_desc(struct edgeport_serial *edge_serial); +static void get_boot_desc(struct edgeport_serial *edge_serial); +static void load_application_firmware(struct edgeport_serial *edge_serial); + +static void unicode_to_ascii(char *string, int buflen, + __le16 *unicode, int unicode_size); + + +/* ************************************************************************ */ +/* ************************************************************************ */ +/* ************************************************************************ */ +/* ************************************************************************ */ /************************************************************************ * * @@ -262,7 +284,7 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic * embedded in this driver * * * ************************************************************************/ -static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) +static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) { __u32 BootCurVer; __u32 BootNewVer; @@ -276,16 +298,14 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) int response; switch (edge_serial->product_info.iDownloadFile) { - case EDGE_DOWNLOAD_FILE_I930: - fw_name = "edgeport/boot.fw"; - break; - - case EDGE_DOWNLOAD_FILE_80251: - fw_name = "edgeport/boot2.fw"; - break; - - default: - return; + case EDGE_DOWNLOAD_FILE_I930: + fw_name = "edgeport/boot.fw"; + break; + case EDGE_DOWNLOAD_FILE_80251: + fw_name = "edgeport/boot2.fw"; + break; + default: + return; } response = request_ihex_firmware(&fw, fw_name, @@ -301,7 +321,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) BootMinorVersion = rec->data[1]; BootBuildNumber = (rec->data[2] << 8) | rec->data[3]; - // Check Boot Image Version + /* Check Boot Image Version */ BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) + (edge_serial->boot_descriptor.MinorVersion << 16) + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber); @@ -353,29 +373,29 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial) * Get string descriptor from device * * * ************************************************************************/ -static int get_string (struct usb_device *dev, int Id, char *string, int buflen) +static int get_string(struct usb_device *dev, int Id, char *string, int buflen) { struct usb_string_descriptor StringDesc; struct usb_string_descriptor *pStringDesc; - dbg("%s - USB String ID = %d", __func__, Id ); + dbg("%s - USB String ID = %d", __func__, Id); - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, + &StringDesc, sizeof(StringDesc))) return 0; - } - - pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL); - if (!pStringDesc) { + pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL); + if (!pStringDesc) return 0; - } - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) { + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, + pStringDesc, StringDesc.bLength)) { kfree(pStringDesc); return 0; } - unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2); + unicode_to_ascii(string, buflen, + pStringDesc->wData, pStringDesc->bLength/2); kfree(pStringDesc); dbg("%s - USB String %s", __func__, string); @@ -389,24 +409,24 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen) * Get string descriptor from device * ************************************************************************/ -static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_descriptor **pRetDesc) +static int get_string_desc(struct usb_device *dev, int Id, + struct usb_string_descriptor **pRetDesc) { struct usb_string_descriptor StringDesc; struct usb_string_descriptor *pStringDesc; - dbg("%s - USB String ID = %d", __func__, Id ); + dbg("%s - USB String ID = %d", __func__, Id); - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) { + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, + sizeof(StringDesc))) return 0; - } - - pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL); - if (!pStringDesc) { + pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL); + if (!pStringDesc) return -1; - } - if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) { + if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, + StringDesc.bLength)) { kfree(pStringDesc); return -1; } @@ -418,25 +438,30 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_de static void dump_product_info(struct edgeport_product_info *product_info) { - // Dump Product Info structure + /* Dump Product Info structure */ dbg("**Product Information:"); - dbg(" ProductId %x", product_info->ProductId ); - dbg(" NumPorts %d", product_info->NumPorts ); - dbg(" ProdInfoVer %d", product_info->ProdInfoVer ); + dbg(" ProductId %x", product_info->ProductId); + dbg(" NumPorts %d", product_info->NumPorts); + dbg(" ProdInfoVer %d", product_info->ProdInfoVer); dbg(" IsServer %d", product_info->IsServer); - dbg(" IsRS232 %d", product_info->IsRS232 ); - dbg(" IsRS422 %d", product_info->IsRS422 ); - dbg(" IsRS485 %d", product_info->IsRS485 ); - dbg(" RomSize %d", product_info->RomSize ); - dbg(" RamSize %d", product_info->RamSize ); - dbg(" CpuRev %x", product_info->CpuRev ); + dbg(" IsRS232 %d", product_info->IsRS232); + dbg(" IsRS422 %d", product_info->IsRS422); + dbg(" IsRS485 %d", product_info->IsRS485); + dbg(" RomSize %d", product_info->RomSize); + dbg(" RamSize %d", product_info->RamSize); + dbg(" CpuRev %x", product_info->CpuRev); dbg(" BoardRev %x", product_info->BoardRev); dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion, product_info->BootMinorVersion, le16_to_cpu(product_info->BootBuildNumber)); - dbg(" ManufactureDescDate %d/%d/%d", product_info->ManufactureDescDate[0], - product_info->ManufactureDescDate[1], - product_info->ManufactureDescDate[2]+1900); + dbg(" FirmwareMajorVersion %d.%d.%d", + product_info->FirmwareMajorVersion, + product_info->FirmwareMinorVersion, + le16_to_cpu(product_info->FirmwareBuildNumber)); + dbg(" ManufactureDescDate %d/%d/%d", + product_info->ManufactureDescDate[0], + product_info->ManufactureDescDate[1], + product_info->ManufactureDescDate[2]+1900); dbg(" iDownloadFile 0x%x", product_info->iDownloadFile); dbg(" EpicVer %d", product_info->EpicVer); } @@ -445,55 +470,60 @@ static void get_product_info(struct edgeport_serial *edge_serial) { struct edgeport_product_info *product_info = &edge_serial->product_info; - memset (product_info, 0, sizeof(struct edgeport_product_info)); - - product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP); - product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; - product_info->ProdInfoVer = 0; - - product_info->RomSize = edge_serial->manuf_descriptor.RomSize; - product_info->RamSize = edge_serial->manuf_descriptor.RamSize; - product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev; - product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev; - - product_info->BootMajorVersion = edge_serial->boot_descriptor.MajorVersion; - product_info->BootMinorVersion = edge_serial->boot_descriptor.MinorVersion; - product_info->BootBuildNumber = edge_serial->boot_descriptor.BuildNumber; - - memcpy(product_info->ManufactureDescDate, edge_serial->manuf_descriptor.DescDate, sizeof(edge_serial->manuf_descriptor.DescDate)); - - // check if this is 2nd generation hardware - if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ION_DEVICE_ID_80251_NETCHIP) { - product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; - } else { - product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; - } - - // Determine Product type and set appropriate flags + memset(product_info, 0, sizeof(struct edgeport_product_info)); + + product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP); + product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; + product_info->ProdInfoVer = 0; + + product_info->RomSize = edge_serial->manuf_descriptor.RomSize; + product_info->RamSize = edge_serial->manuf_descriptor.RamSize; + product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev; + product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev; + + product_info->BootMajorVersion = + edge_serial->boot_descriptor.MajorVersion; + product_info->BootMinorVersion = + edge_serial->boot_descriptor.MinorVersion; + product_info->BootBuildNumber = + edge_serial->boot_descriptor.BuildNumber; + + memcpy(product_info->ManufactureDescDate, + edge_serial->manuf_descriptor.DescDate, + sizeof(edge_serial->manuf_descriptor.DescDate)); + + /* check if this is 2nd generation hardware */ + if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) + & ION_DEVICE_ID_80251_NETCHIP) + product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; + else + product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; + + /* Determine Product type and set appropriate flags */ switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) { - case ION_DEVICE_ID_EDGEPORT_COMPATIBLE: - case ION_DEVICE_ID_EDGEPORT_4T: - case ION_DEVICE_ID_EDGEPORT_4: - case ION_DEVICE_ID_EDGEPORT_2: - case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU: - case ION_DEVICE_ID_EDGEPORT_8: - case ION_DEVICE_ID_EDGEPORT_421: - case ION_DEVICE_ID_EDGEPORT_21: - case ION_DEVICE_ID_EDGEPORT_2_DIN: - case ION_DEVICE_ID_EDGEPORT_4_DIN: - case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU: - product_info->IsRS232 = 1; - break; + case ION_DEVICE_ID_EDGEPORT_COMPATIBLE: + case ION_DEVICE_ID_EDGEPORT_4T: + case ION_DEVICE_ID_EDGEPORT_4: + case ION_DEVICE_ID_EDGEPORT_2: + case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU: + case ION_DEVICE_ID_EDGEPORT_8: + case ION_DEVICE_ID_EDGEPORT_421: + case ION_DEVICE_ID_EDGEPORT_21: + case ION_DEVICE_ID_EDGEPORT_2_DIN: + case ION_DEVICE_ID_EDGEPORT_4_DIN: + case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU: + product_info->IsRS232 = 1; + break; - case ION_DEVICE_ID_EDGEPORT_2I: // Edgeport/2 RS422/RS485 - product_info->IsRS422 = 1; - product_info->IsRS485 = 1; - break; + case ION_DEVICE_ID_EDGEPORT_2I: /* Edgeport/2 RS422/RS485 */ + product_info->IsRS422 = 1; + product_info->IsRS485 = 1; + break; - case ION_DEVICE_ID_EDGEPORT_8I: // Edgeport/4 RS422 - case ION_DEVICE_ID_EDGEPORT_4I: // Edgeport/4 RS422 - product_info->IsRS422 = 1; - break; + case ION_DEVICE_ID_EDGEPORT_8I: /* Edgeport/4 RS422 */ + case ION_DEVICE_ID_EDGEPORT_4I: /* Edgeport/4 RS422 */ + product_info->IsRS422 = 1; + break; } dump_product_info(product_info); @@ -521,32 +551,32 @@ static int get_epic_descriptor(struct edgeport_serial *ep) ep->is_epic = 1; memset(product_info, 0, sizeof(struct edgeport_product_info)); - product_info->NumPorts = epic->NumPorts; - product_info->ProdInfoVer = 0; - product_info->FirmwareMajorVersion = epic->MajorVersion; - product_info->FirmwareMinorVersion = epic->MinorVersion; - product_info->FirmwareBuildNumber = epic->BuildNumber; - product_info->iDownloadFile = epic->iDownloadFile; - product_info->EpicVer = epic->EpicVer; - product_info->Epic = epic->Supports; - product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; + product_info->NumPorts = epic->NumPorts; + product_info->ProdInfoVer = 0; + product_info->FirmwareMajorVersion = epic->MajorVersion; + product_info->FirmwareMinorVersion = epic->MinorVersion; + product_info->FirmwareBuildNumber = epic->BuildNumber; + product_info->iDownloadFile = epic->iDownloadFile; + product_info->EpicVer = epic->EpicVer; + product_info->Epic = epic->Supports; + product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; dump_product_info(product_info); bits = &ep->epic_descriptor.Supports; dbg("**EPIC descriptor:"); dbg(" VendEnableSuspend: %s", bits->VendEnableSuspend ? "TRUE": "FALSE"); - dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE" ); - dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE" ); - dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE" ); - dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE" ); - dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE" ); - dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE" ); - dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE" ); - dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE" ); - dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE" ); - dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE" ); - dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE" ); - dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE" ); + dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE"); + dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE"); + dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE"); + dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE"); + dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE"); + dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE"); + dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE"); + dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE"); + dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE"); + dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE"); + dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); + dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE"); } return result; @@ -562,10 +592,10 @@ static int get_epic_descriptor(struct edgeport_serial *ep) /***************************************************************************** * edge_interrupt_callback - * this is the callback function for when we have received data on the + * this is the callback function for when we have received data on the * interrupt endpoint. *****************************************************************************/ -static void edge_interrupt_callback (struct urb *urb) +static void edge_interrupt_callback(struct urb *urb) { struct edgeport_serial *edge_serial = urb->context; struct edgeport_port *edge_port; @@ -590,17 +620,17 @@ static void edge_interrupt_callback (struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", - __func__, status); + __func__, status); return; default: - dbg("%s - nonzero urb status received: %d", - __func__, status); + dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } - // process this interrupt-read even if there are no ports open + /* process this interrupt-read even if there are no ports open */ if (length) { - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data); + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, + __func__, length, data); if (length > 1) { bytes_avail = data[0] | (data[1] << 8); @@ -614,7 +644,8 @@ static void edge_interrupt_callback (struct urb *urb) dbg("%s - posting a read", __func__); edge_serial->read_in_progress = true; - /* we have pending bytes on the bulk in pipe, send a request */ + /* we have pending bytes on the + bulk in pipe, send a request */ edge_serial->read_urb->dev = edge_serial->serial->dev; result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); if (result) { @@ -628,7 +659,8 @@ static void edge_interrupt_callback (struct urb *urb) /* grab the txcredits for the ports if available */ position = 2; portNumber = 0; - while ((position < length) && (portNumber < edge_serial->serial->num_ports)) { + while ((position < length) && + (portNumber < edge_serial->serial->num_ports)) { txCredits = data[position] | (data[position+1] << 8); if (txCredits) { port = edge_serial->serial->port[portNumber]; @@ -637,14 +669,19 @@ static void edge_interrupt_callback (struct urb *urb) spin_lock(&edge_port->ep_lock); edge_port->txCredits += txCredits; spin_unlock(&edge_port->ep_lock); - dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); + dbg("%s - txcredits for port%d = %d", + __func__, portNumber, + edge_port->txCredits); - /* tell the tty driver that something has changed */ + /* tell the tty driver that something + has changed */ if (edge_port->port->port.tty) tty_wakeup(edge_port->port->port.tty); - // Since we have more credit, check if more data can be sent - send_more_port_data(edge_serial, edge_port); + /* Since we have more credit, check + if more data can be sent */ + send_more_port_data(edge_serial, + edge_port); } } position += 2; @@ -653,19 +690,20 @@ static void edge_interrupt_callback (struct urb *urb) } exit: - result = usb_submit_urb (urb, GFP_ATOMIC); - if (result) { - dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __func__, result); - } + result = usb_submit_urb(urb, GFP_ATOMIC); + if (result) + dev_err(&urb->dev->dev, + "%s - Error %d submitting control urb\n", + __func__, result); } /***************************************************************************** * edge_bulk_in_callback - * this is the callback function for when we have received data on the + * this is the callback function for when we have received data on the * bulk in endpoint. *****************************************************************************/ -static void edge_bulk_in_callback (struct urb *urb) +static void edge_bulk_in_callback(struct urb *urb) { struct edgeport_serial *edge_serial = urb->context; unsigned char *data = urb->transfer_buffer; @@ -690,16 +728,18 @@ static void edge_bulk_in_callback (struct urb *urb) raw_data_length = urb->actual_length; - usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data); + usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, + __func__, raw_data_length, data); spin_lock(&edge_serial->es_lock); /* decrement our rxBytes available by the number that we just got */ edge_serial->rxBytesAvail -= raw_data_length; - dbg("%s - Received = %d, rxBytesAvail %d", __func__, raw_data_length, edge_serial->rxBytesAvail); + dbg("%s - Received = %d, rxBytesAvail %d", __func__, + raw_data_length, edge_serial->rxBytesAvail); - process_rcvd_data (edge_serial, data, urb->actual_length); + process_rcvd_data(edge_serial, data, urb->actual_length); /* check to see if there's any more data for us to read */ if (edge_serial->rxBytesAvail > 0) { @@ -722,10 +762,10 @@ static void edge_bulk_in_callback (struct urb *urb) /***************************************************************************** * edge_bulk_out_data_callback - * this is the callback function for when we have finished sending serial data - * on the bulk out endpoint. + * this is the callback function for when we have finished sending + * serial data on the bulk out endpoint. *****************************************************************************/ -static void edge_bulk_out_data_callback (struct urb *urb) +static void edge_bulk_out_data_callback(struct urb *urb) { struct edgeport_port *edge_port = urb->context; struct tty_struct *tty; @@ -741,24 +781,26 @@ static void edge_bulk_out_data_callback (struct urb *urb) tty = edge_port->port->port.tty; if (tty && edge_port->open) { - /* let the tty driver wakeup if it has a special write_wakeup function */ + /* let the tty driver wakeup if it has a special + write_wakeup function */ tty_wakeup(tty); } - // Release the Write URB + /* Release the Write URB */ edge_port->write_in_progress = false; - // Check if more data needs to be sent - send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port); + /* Check if more data needs to be sent */ + send_more_port_data((struct edgeport_serial *) + (usb_get_serial_data(edge_port->port->serial)), edge_port); } /***************************************************************************** * BulkOutCmdCallback - * this is the callback function for when we have finished sending a command - * on the bulk out endpoint. + * this is the callback function for when we have finished sending a + * command on the bulk out endpoint. *****************************************************************************/ -static void edge_bulk_out_cmd_callback (struct urb *urb) +static void edge_bulk_out_cmd_callback(struct urb *urb) { struct edgeport_port *edge_port = urb->context; struct tty_struct *tty; @@ -767,17 +809,19 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) dbg("%s", __func__); atomic_dec(&CmdUrbs); - dbg("%s - FREE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs)); + dbg("%s - FREE URB %p (outstanding %d)", __func__, + urb, atomic_read(&CmdUrbs)); /* clean up the transfer buffer */ kfree(urb->transfer_buffer); /* Free the command urb */ - usb_free_urb (urb); + usb_free_urb(urb); if (status) { - dbg("%s - nonzero write bulk status received: %d", __func__, status); + dbg("%s - nonzero write bulk status received: %d", + __func__, status); return; } @@ -805,7 +849,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) * Otherwise we return a negative error number. *****************************************************************************/ static int edge_open(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct usb_serial *serial; @@ -820,51 +864,59 @@ static int edge_open(struct tty_struct *tty, if (tty) tty->low_latency = low_latency; - /* see if we've set up our endpoint info yet (can't set it up in edge_startup - as the structures were not set up at that time.) */ + /* see if we've set up our endpoint info yet (can't set it up + in edge_startup as the structures were not set up at that time.) */ serial = port->serial; edge_serial = usb_get_serial_data(serial); if (edge_serial == NULL) return -ENODEV; if (edge_serial->interrupt_in_buffer == NULL) { struct usb_serial_port *port0 = serial->port[0]; - + /* not set up yet, so do it now */ - edge_serial->interrupt_in_buffer = port0->interrupt_in_buffer; - edge_serial->interrupt_in_endpoint = port0->interrupt_in_endpointAddress; + edge_serial->interrupt_in_buffer = + port0->interrupt_in_buffer; + edge_serial->interrupt_in_endpoint = + port0->interrupt_in_endpointAddress; edge_serial->interrupt_read_urb = port0->interrupt_in_urb; edge_serial->bulk_in_buffer = port0->bulk_in_buffer; - edge_serial->bulk_in_endpoint = port0->bulk_in_endpointAddress; + edge_serial->bulk_in_endpoint = + port0->bulk_in_endpointAddress; edge_serial->read_urb = port0->read_urb; - edge_serial->bulk_out_endpoint = port0->bulk_out_endpointAddress; - + edge_serial->bulk_out_endpoint = + port0->bulk_out_endpointAddress; + /* set up our interrupt urb */ usb_fill_int_urb(edge_serial->interrupt_read_urb, - serial->dev, - usb_rcvintpipe(serial->dev, - port0->interrupt_in_endpointAddress), - port0->interrupt_in_buffer, - edge_serial->interrupt_read_urb->transfer_buffer_length, - edge_interrupt_callback, edge_serial, - edge_serial->interrupt_read_urb->interval); - + serial->dev, + usb_rcvintpipe(serial->dev, + port0->interrupt_in_endpointAddress), + port0->interrupt_in_buffer, + edge_serial->interrupt_read_urb->transfer_buffer_length, + edge_interrupt_callback, edge_serial, + edge_serial->interrupt_read_urb->interval); + /* set up our bulk in urb */ usb_fill_bulk_urb(edge_serial->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, - port0->bulk_in_endpointAddress), - port0->bulk_in_buffer, - edge_serial->read_urb->transfer_buffer_length, - edge_bulk_in_callback, edge_serial); + usb_rcvbulkpipe(serial->dev, + port0->bulk_in_endpointAddress), + port0->bulk_in_buffer, + edge_serial->read_urb->transfer_buffer_length, + edge_bulk_in_callback, edge_serial); edge_serial->read_in_progress = false; /* start interrupt read for this edgeport - * this interrupt will continue as long as the edgeport is connected */ - response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL); + * this interrupt will continue as long + * as the edgeport is connected */ + response = usb_submit_urb(edge_serial->interrupt_read_urb, + GFP_KERNEL); if (response) { - dev_err(&port->dev, "%s - Error %d submitting control urb\n", __func__, response); + dev_err(&port->dev, + "%s - Error %d submitting control urb\n", + __func__, response); } } - + /* initialize our wait queues */ init_waitqueue_head(&edge_port->wait_open); init_waitqueue_head(&edge_port->wait_chase); @@ -872,26 +924,29 @@ static int edge_open(struct tty_struct *tty, init_waitqueue_head(&edge_port->wait_command); /* initialize our icount structure */ - memset (&(edge_port->icount), 0x00, sizeof(edge_port->icount)); + memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount)); /* initialize our port settings */ - edge_port->txCredits = 0; /* Can't send any data yet */ - edge_port->shadowMCR = MCR_MASTER_IE; /* Must always set this bit to enable ints! */ + edge_port->txCredits = 0; /* Can't send any data yet */ + /* Must always set this bit to enable ints! */ + edge_port->shadowMCR = MCR_MASTER_IE; edge_port->chaseResponsePending = false; /* send a open port command */ edge_port->openPending = true; edge_port->open = false; - response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0); + response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0); if (response < 0) { - dev_err(&port->dev, "%s - error sending open port command\n", __func__); + dev_err(&port->dev, "%s - error sending open port command\n", + __func__); edge_port->openPending = false; return -ENODEV; } /* now wait for the port to be completely opened */ - wait_event_timeout(edge_port->wait_open, !edge_port->openPending, OPEN_TIMEOUT); + wait_event_timeout(edge_port->wait_open, !edge_port->openPending, + OPEN_TIMEOUT); if (!edge_port->open) { /* open timed out */ @@ -905,25 +960,26 @@ static int edge_open(struct tty_struct *tty, edge_port->txfifo.tail = 0; edge_port->txfifo.count = 0; edge_port->txfifo.size = edge_port->maxTxCredits; - edge_port->txfifo.fifo = kmalloc (edge_port->maxTxCredits, GFP_KERNEL); + edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL); if (!edge_port->txfifo.fifo) { dbg("%s - no memory", __func__); - edge_close (tty, port, filp); + edge_close(tty, port, filp); return -ENOMEM; } /* Allocate a URB for the write */ - edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL); + edge_port->write_urb = usb_alloc_urb(0, GFP_KERNEL); edge_port->write_in_progress = false; if (!edge_port->write_urb) { dbg("%s - no memory", __func__); - edge_close (tty, port, filp); + edge_close(tty, port, filp); return -ENOMEM; } - dbg("%s(%d) - Initialize TX fifo to %d bytes", __func__, port->number, edge_port->maxTxCredits); + dbg("%s(%d) - Initialize TX fifo to %d bytes", + __func__, port->number, edge_port->maxTxCredits); dbg("%s exited", __func__); @@ -949,27 +1005,28 @@ static void block_until_chase_response(struct edgeport_port *edge_port) int loop = 10; while (1) { - // Save Last credits + /* Save Last credits */ lastCredits = edge_port->txCredits; - // Did we get our Chase response + /* Did we get our Chase response */ if (!edge_port->chaseResponsePending) { dbg("%s - Got Chase Response", __func__); - // did we get all of our credit back? - if (edge_port->txCredits == edge_port->maxTxCredits ) { + /* did we get all of our credit back? */ + if (edge_port->txCredits == edge_port->maxTxCredits) { dbg("%s - Got all credits", __func__); return; } } - // Block the thread for a while - prepare_to_wait(&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE); + /* Block the thread for a while */ + prepare_to_wait(&edge_port->wait_chase, &wait, + TASK_UNINTERRUPTIBLE); schedule_timeout(timeout); finish_wait(&edge_port->wait_chase, &wait); if (lastCredits == edge_port->txCredits) { - // No activity.. count down. + /* No activity.. count down. */ loop--; if (loop == 0) { edge_port->chaseResponsePending = false; @@ -977,8 +1034,9 @@ static void block_until_chase_response(struct edgeport_port *edge_port) return; } } else { - // Reset timeout value back to 10 seconds - dbg("%s - Last %d, Current %d", __func__, lastCredits, edge_port->txCredits); + /* Reset timeout value back to 10 seconds */ + dbg("%s - Last %d, Current %d", __func__, + lastCredits, edge_port->txCredits); loop = 10; } } @@ -995,7 +1053,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port) * 3. A timeout of 3 seconds without activity has expired * ************************************************************************/ -static void block_until_tx_empty (struct edgeport_port *edge_port) +static void block_until_tx_empty(struct edgeport_port *edge_port) { DEFINE_WAIT(wait); struct TxFifo *fifo = &edge_port->txfifo; @@ -1004,31 +1062,32 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) int loop = 30; while (1) { - // Save Last count + /* Save Last count */ lastCount = fifo->count; - // Is the Edgeport Buffer empty? + /* Is the Edgeport Buffer empty? */ if (lastCount == 0) { dbg("%s - TX Buffer Empty", __func__); return; } - // Block the thread for a while - prepare_to_wait (&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE); + /* Block the thread for a while */ + prepare_to_wait(&edge_port->wait_chase, &wait, + TASK_UNINTERRUPTIBLE); schedule_timeout(timeout); finish_wait(&edge_port->wait_chase, &wait); dbg("%s wait", __func__); if (lastCount == fifo->count) { - // No activity.. count down. + /* No activity.. count down. */ loop--; if (loop == 0) { dbg("%s - TIMEOUT", __func__); return; } } else { - // Reset timeout value back to seconds + /* Reset timeout value back to seconds */ loop = 30; } } @@ -1040,20 +1099,20 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) * this function is called by the tty driver when a port is closed *****************************************************************************/ static void edge_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file * filp) + struct usb_serial_port *port, struct file *filp) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; int status; dbg("%s - port %d", __func__, port->number); - + edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); - if ((edge_serial == NULL) || (edge_port == NULL)) + if (edge_serial == NULL || edge_port == NULL) return; - - // block until tx is empty + + /* block until tx is empty */ block_until_tx_empty(edge_port); edge_port->closePending = true; @@ -1065,13 +1124,12 @@ static void edge_close(struct tty_struct *tty, edge_port->chaseResponsePending = true; dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); - if (status == 0) { - // block until chase finished + status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); + if (status == 0) + /* block until chase finished */ block_until_chase_response(edge_port); - } else { + else edge_port->chaseResponsePending = false; - } } if ((!edge_serial->is_epic) || @@ -1079,10 +1137,10 @@ static void edge_close(struct tty_struct *tty, (edge_serial->epic_descriptor.Supports.IOSPClose))) { /* close the port */ dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__); - send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); + send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0); } - //port->close = true; + /* port->close = true; */ edge_port->closePending = false; edge_port->open = false; edge_port->openPending = false; @@ -1090,7 +1148,8 @@ static void edge_close(struct tty_struct *tty, usb_kill_urb(edge_port->write_urb); if (edge_port->write_urb) { - /* if this urb had a transfer buffer already (old transfer) free it */ + /* if this urb had a transfer buffer already + (old transfer) free it */ kfree(edge_port->write_urb->transfer_buffer); usb_free_urb(edge_port->write_urb); edge_port->write_urb = NULL; @@ -1099,14 +1158,14 @@ static void edge_close(struct tty_struct *tty, edge_port->txfifo.fifo = NULL; dbg("%s exited", __func__); -} +} /***************************************************************************** * SerialWrite - * this function is called by the tty driver when data should be written to - * the port. - * If successful, we return the number of bytes written, otherwise we return - * a negative error number. + * this function is called by the tty driver when data should be written + * to the port. + * If successful, we return the number of bytes written, otherwise we + * return a negative error number. *****************************************************************************/ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *data, int count) @@ -1124,66 +1183,76 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, if (edge_port == NULL) return -ENODEV; - // get a pointer to the Tx fifo + /* get a pointer to the Tx fifo */ fifo = &edge_port->txfifo; spin_lock_irqsave(&edge_port->ep_lock, flags); - // calculate number of bytes to put in fifo - copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count)); + /* calculate number of bytes to put in fifo */ + copySize = min((unsigned int)count, + (edge_port->txCredits - fifo->count)); - dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", __func__, - port->number, count, edge_port->txCredits - fifo->count, copySize); + dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", + __func__, port->number, count, + edge_port->txCredits - fifo->count, copySize); - /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */ + /* catch writes of 0 bytes which the tty driver likes to give us, + and when txCredits is empty */ if (copySize == 0) { dbg("%s - copySize = Zero", __func__); goto finish_write; } - // queue the data - // since we can never overflow the buffer we do not have to check for full condition - - // the copy is done is two parts -- first fill to the end of the buffer - // then copy the reset from the start of the buffer - + /* queue the data + * since we can never overflow the buffer we do not have to check for a + * full condition + * + * the copy is done is two parts -- first fill to the end of the buffer + * then copy the reset from the start of the buffer + */ bytesleft = fifo->size - fifo->head; - firsthalf = min (bytesleft, copySize); - dbg("%s - copy %d bytes of %d into fifo ", __func__, firsthalf, bytesleft); + firsthalf = min(bytesleft, copySize); + dbg("%s - copy %d bytes of %d into fifo ", __func__, + firsthalf, bytesleft); /* now copy our data */ memcpy(&fifo->fifo[fifo->head], data, firsthalf); - usb_serial_debug_data(debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]); + usb_serial_debug_data(debug, &port->dev, __func__, + firsthalf, &fifo->fifo[fifo->head]); - // update the index and size + /* update the index and size */ fifo->head += firsthalf; fifo->count += firsthalf; - // wrap the index - if (fifo->head == fifo->size) { + /* wrap the index */ + if (fifo->head == fifo->size) fifo->head = 0; - } secondhalf = copySize-firsthalf; if (secondhalf) { dbg("%s - copy rest of data %d", __func__, secondhalf); memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); - usb_serial_debug_data(debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]); - // update the index and size + usb_serial_debug_data(debug, &port->dev, __func__, + secondhalf, &fifo->fifo[fifo->head]); + /* update the index and size */ fifo->count += secondhalf; fifo->head += secondhalf; - // No need to check for wrap since we can not get to end of fifo in this part + /* No need to check for wrap since we can not get to end of + * the fifo in this part + */ } finish_write: spin_unlock_irqrestore(&edge_port->ep_lock, flags); - send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port); + send_more_port_data((struct edgeport_serial *) + usb_get_serial_data(port->serial), edge_port); - dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, copySize, edge_port->txCredits, fifo->count); + dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, + copySize, edge_port->txCredits, fifo->count); - return copySize; + return copySize; } @@ -1200,7 +1269,8 @@ finish_write: * can transmit more. * ************************************************************************/ -static void send_more_port_data(struct edgeport_serial *edge_serial, struct edgeport_port *edge_port) +static void send_more_port_data(struct edgeport_serial *edge_serial, + struct edgeport_port *edge_port) { struct TxFifo *fifo = &edge_port->txfifo; struct urb *urb; @@ -1219,67 +1289,78 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge if (edge_port->write_in_progress || !edge_port->open || (fifo->count == 0)) { - dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress); + dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", + __func__, edge_port->port->number, + fifo->count, edge_port->write_in_progress); goto exit_send; } - // since the amount of data in the fifo will always fit into the - // edgeport buffer we do not need to check the write length - - // Do we have enough credits for this port to make it worthwhile - // to bother queueing a write. If it's too small, say a few bytes, - // it's better to wait for more credits so we can do a larger - // write. - if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) { - dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __func__, edge_port->port->number, fifo->count, edge_port->txCredits ); + /* since the amount of data in the fifo will always fit into the + * edgeport buffer we do not need to check the write length + * + * Do we have enough credits for this port to make it worthwhile + * to bother queueing a write. If it's too small, say a few bytes, + * it's better to wait for more credits so we can do a larger write. + */ + if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) { + dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", + __func__, edge_port->port->number, fifo->count, + edge_port->txCredits); goto exit_send; } - // lock this write + /* lock this write */ edge_port->write_in_progress = true; - // get a pointer to the write_urb + /* get a pointer to the write_urb */ urb = edge_port->write_urb; /* make sure transfer buffer is freed */ kfree(urb->transfer_buffer); urb->transfer_buffer = NULL; - /* build the data header for the buffer and port that we are about to send out */ + /* build the data header for the buffer and port that we are about + to send out */ count = fifo->count; - buffer = kmalloc (count+2, GFP_ATOMIC); + buffer = kmalloc(count+2, GFP_ATOMIC); if (buffer == NULL) { - dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __func__); + dev_err(&edge_port->port->dev, + "%s - no more kernel memory...\n", __func__); edge_port->write_in_progress = false; goto exit_send; } - buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count); - buffer[1] = IOSP_BUILD_DATA_HDR2 (edge_port->port->number - edge_port->port->serial->minor, count); + buffer[0] = IOSP_BUILD_DATA_HDR1(edge_port->port->number + - edge_port->port->serial->minor, count); + buffer[1] = IOSP_BUILD_DATA_HDR2(edge_port->port->number + - edge_port->port->serial->minor, count); /* now copy our data */ bytesleft = fifo->size - fifo->tail; - firsthalf = min (bytesleft, count); + firsthalf = min(bytesleft, count); memcpy(&buffer[2], &fifo->fifo[fifo->tail], firsthalf); fifo->tail += firsthalf; fifo->count -= firsthalf; - if (fifo->tail == fifo->size) { + if (fifo->tail == fifo->size) fifo->tail = 0; - } secondhalf = count-firsthalf; if (secondhalf) { - memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail], secondhalf); + memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail], + secondhalf); fifo->tail += secondhalf; fifo->count -= secondhalf; } if (count) - usb_serial_debug_data(debug, &edge_port->port->dev, __func__, count, &buffer[2]); + usb_serial_debug_data(debug, &edge_port->port->dev, + __func__, count, &buffer[2]); /* fill up the urb with all of our data and submit it */ - usb_fill_bulk_urb (urb, edge_serial->serial->dev, - usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), - buffer, count+2, edge_bulk_out_data_callback, edge_port); + usb_fill_bulk_urb(urb, edge_serial->serial->dev, + usb_sndbulkpipe(edge_serial->serial->dev, + edge_serial->bulk_out_endpoint), + buffer, count+2, + edge_bulk_out_data_callback, edge_port); /* decrement the number of credits we have by the number we just sent */ edge_port->txCredits -= count; @@ -1289,14 +1370,17 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { /* something went wrong */ - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __func__, status); + dev_err(&edge_port->port->dev, + "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", + __func__, status); edge_port->write_in_progress = false; /* revert the credits as something bad happened. */ edge_port->txCredits += count; edge_port->icount.tx -= count; } - dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __func__, count, edge_port->txCredits, fifo->count); + dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", + __func__, count, edge_port->txCredits, fifo->count); exit_send: spin_unlock_irqrestore(&edge_port->ep_lock, flags); @@ -1305,11 +1389,10 @@ exit_send: /***************************************************************************** * edge_write_room - * this function is called by the tty driver when it wants to know how many - * bytes of data we can accept for a specific port. - * If successful, we return the amount of room that we have for this port - * (the txCredits), - * Otherwise we return a negative error number. + * this function is called by the tty driver when it wants to know how + * many bytes of data we can accept for a specific port. If successful, + * we return the amount of room that we have for this port (the txCredits) + * otherwise we return a negative error number. *****************************************************************************/ static int edge_write_room(struct tty_struct *tty) { @@ -1332,7 +1415,7 @@ static int edge_write_room(struct tty_struct *tty) return -EINVAL; } - // total of both buffers is still txCredit + /* total of both buffers is still txCredit */ spin_lock_irqsave(&edge_port->ep_lock, flags); room = edge_port->txCredits - edge_port->txfifo.count; spin_unlock_irqrestore(&edge_port->ep_lock, flags); @@ -1344,11 +1427,11 @@ static int edge_write_room(struct tty_struct *tty) /***************************************************************************** * edge_chars_in_buffer - * this function is called by the tty driver when it wants to know how many - * bytes of data we currently have outstanding in the port (data that has - * been written, but hasn't made it out the port yet) - * If successful, we return the number of bytes left to be written in the - * system, + * this function is called by the tty driver when it wants to know how + * many bytes of data we currently have outstanding in the port (data that + * has been written, but hasn't made it out the port yet) + * If successful, we return the number of bytes left to be written in the + * system, * Otherwise we return a negative error number. *****************************************************************************/ static int edge_chars_in_buffer(struct tty_struct *tty) @@ -1371,10 +1454,12 @@ static int edge_chars_in_buffer(struct tty_struct *tty) } spin_lock_irqsave(&edge_port->ep_lock, flags); - num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count; + num_chars = edge_port->maxTxCredits - edge_port->txCredits + + edge_port->txfifo.count; spin_unlock_irqrestore(&edge_port->ep_lock, flags); if (num_chars) { - dbg("%s(port %d) - returns %d", __func__, port->number, num_chars); + dbg("%s(port %d) - returns %d", __func__, + port->number, num_chars); } return num_chars; @@ -1405,19 +1490,18 @@ static void edge_throttle(struct tty_struct *tty) /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); - status = edge_write (tty, port, &stop_char, 1); - if (status <= 0) { + status = edge_write(tty, port, &stop_char, 1); + if (status <= 0) return; - } } /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { edge_port->shadowMCR &= ~MCR_RTS; - status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); - if (status != 0) { + status = send_cmd_write_uart_register(edge_port, MCR, + edge_port->shadowMCR); + if (status != 0) return; - } } return; @@ -1426,8 +1510,8 @@ static void edge_throttle(struct tty_struct *tty) /***************************************************************************** * edge_unthrottle - * this function is called by the tty driver when it wants to resume the data - * being read from the port (called after SerialThrottle is called) + * this function is called by the tty driver when it wants to resume the + * data being read from the port (called after SerialThrottle is called) *****************************************************************************/ static void edge_unthrottle(struct tty_struct *tty) { @@ -1455,14 +1539,16 @@ static void edge_unthrottle(struct tty_struct *tty) /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { edge_port->shadowMCR |= MCR_RTS; - send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); + send_cmd_write_uart_register(edge_port, MCR, + edge_port->shadowMCR); } } /***************************************************************************** * SerialSetTermios - * this function is called by the tty driver when it wants to change the termios structure + * this function is called by the tty driver when it wants to change + * the termios structure *****************************************************************************/ static void edge_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) @@ -1499,9 +1585,10 @@ static void edge_set_termios(struct tty_struct *tty, * release the bus after transmitting. This must be done when * the transmit shift register is empty, not be done when the * transmit holding register is empty. This functionality - * allows an RS485 driver to be written in user space. + * allows an RS485 driver to be written in user space. *****************************************************************************/ -static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *value) +static int get_lsr_info(struct edgeport_port *edge_port, + unsigned int __user *value) { unsigned int result = 0; unsigned long flags; @@ -1519,7 +1606,8 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va return 0; } -static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) +static int edge_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); @@ -1574,7 +1662,8 @@ static int edge_tiocmget(struct tty_struct *tty, struct file *file) return result; } -static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct __user *retinfo) +static int get_serial_info(struct edgeport_port *edge_port, + struct serial_struct __user *retinfo) { struct serial_struct tmp; @@ -1617,60 +1706,61 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file, dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { - case TIOCSERGETLSR: - dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); - return get_lsr_info(edge_port, (unsigned int __user *) arg); - - case TIOCGSERIAL: - dbg("%s (%d) TIOCGSERIAL", __func__, port->number); - return get_serial_info(edge_port, (struct serial_struct __user *) arg); - - case TIOCMIWAIT: - dbg("%s (%d) TIOCMIWAIT", __func__, port->number); - cprev = edge_port->icount; - while (1) { - prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(&edge_port->delta_msr_wait, &wait); - /* see if a signal did it */ - if (signal_pending(current)) - return -ERESTARTSYS; - cnow = edge_port->icount; - if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) - return -EIO; /* no change => error */ - if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || - ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || - ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || - ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { - return 0; - } - cprev = cnow; + case TIOCSERGETLSR: + dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); + return get_lsr_info(edge_port, (unsigned int __user *) arg); + + case TIOCGSERIAL: + dbg("%s (%d) TIOCGSERIAL", __func__, port->number); + return get_serial_info(edge_port, (struct serial_struct __user *) arg); + + case TIOCMIWAIT: + dbg("%s (%d) TIOCMIWAIT", __func__, port->number); + cprev = edge_port->icount; + while (1) { + prepare_to_wait(&edge_port->delta_msr_wait, + &wait, TASK_INTERRUPTIBLE); + schedule(); + finish_wait(&edge_port->delta_msr_wait, &wait); + /* see if a signal did it */ + if (signal_pending(current)) + return -ERESTARTSYS; + cnow = edge_port->icount; + if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && + cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) + return -EIO; /* no change => error */ + if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || + ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || + ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || + ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { + return 0; } - /* NOTREACHED */ - break; + cprev = cnow; + } + /* NOTREACHED */ + break; - case TIOCGICOUNT: - cnow = edge_port->icount; - memset(&icount, 0, sizeof(icount)); - icount.cts = cnow.cts; - icount.dsr = cnow.dsr; - icount.rng = cnow.rng; - icount.dcd = cnow.dcd; - icount.rx = cnow.rx; - icount.tx = cnow.tx; - icount.frame = cnow.frame; - icount.overrun = cnow.overrun; - icount.parity = cnow.parity; - icount.brk = cnow.brk; - icount.buf_overrun = cnow.buf_overrun; - - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx ); - if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) - return -EFAULT; - return 0; + case TIOCGICOUNT: + cnow = edge_port->icount; + memset(&icount, 0, sizeof(icount)); + icount.cts = cnow.cts; + icount.dsr = cnow.dsr; + icount.rng = cnow.rng; + icount.dcd = cnow.dcd; + icount.rx = cnow.rx; + icount.tx = cnow.tx; + icount.frame = cnow.frame; + icount.overrun = cnow.overrun; + icount.parity = cnow.parity; + icount.brk = cnow.brk; + icount.buf_overrun = cnow.buf_overrun; + + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", + __func__, port->number, icount.rx, icount.tx); + if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) + return -EFAULT; + return 0; } - return -ENOIOCTLCMD; } @@ -1679,7 +1769,7 @@ static int edge_ioctl(struct tty_struct *tty, struct file *file, * SerialBreak * this function sends a break to the port *****************************************************************************/ -static void edge_break (struct tty_struct *tty, int break_state) +static void edge_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; struct edgeport_port *edge_port = usb_get_serial_port_data(port); @@ -1693,9 +1783,9 @@ static void edge_break (struct tty_struct *tty, int break_state) edge_port->chaseResponsePending = true; dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); + status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); if (status == 0) { - // block until chase finished + /* block until chase finished */ block_until_chase_response(edge_port); } else { edge_port->chaseResponsePending = false; @@ -1707,14 +1797,16 @@ static void edge_break (struct tty_struct *tty, int break_state) (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { if (break_state == -1) { dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__); - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0); + status = send_iosp_ext_cmd(edge_port, + IOSP_CMD_SET_BREAK, 0); } else { dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__); - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0); - } - if (status) { - dbg("%s - error sending break set/clear command.", __func__); + status = send_iosp_ext_cmd(edge_port, + IOSP_CMD_CLEAR_BREAK, 0); } + if (status) + dbg("%s - error sending break set/clear command.", + __func__); } return; @@ -1725,7 +1817,8 @@ static void edge_break (struct tty_struct *tty, int break_state) * process_rcvd_data * this function handles the data received on the bulk in pipe. *****************************************************************************/ -static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char * buffer, __u16 bufferLength) +static void process_rcvd_data(struct edgeport_serial *edge_serial, + unsigned char *buffer, __u16 bufferLength) { struct usb_serial_port *port; struct edgeport_port *edge_port; @@ -1746,105 +1839,123 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha lastBufferLength = bufferLength; switch (edge_serial->rxState) { - case EXPECT_HDR1: - edge_serial->rxHeader1 = *buffer; - ++buffer; - --bufferLength; + case EXPECT_HDR1: + edge_serial->rxHeader1 = *buffer; + ++buffer; + --bufferLength; - if (bufferLength == 0) { - edge_serial->rxState = EXPECT_HDR2; + if (bufferLength == 0) { + edge_serial->rxState = EXPECT_HDR2; + break; + } + /* otherwise, drop on through */ + case EXPECT_HDR2: + edge_serial->rxHeader2 = *buffer; + ++buffer; + --bufferLength; + + dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, + edge_serial->rxHeader1, edge_serial->rxHeader2); + /* Process depending on whether this header is + * data or status */ + + if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) { + /* Decode this status header and go to + * EXPECT_HDR1 (if we can process the status + * with only 2 bytes), or go to EXPECT_HDR3 to + * get the third byte. */ + edge_serial->rxPort = + IOSP_GET_HDR_PORT(edge_serial->rxHeader1); + edge_serial->rxStatusCode = + IOSP_GET_STATUS_CODE( + edge_serial->rxHeader1); + + if (!IOSP_STATUS_IS_2BYTE( + edge_serial->rxStatusCode)) { + /* This status needs additional bytes. + * Save what we have and then wait for + * more data. + */ + edge_serial->rxStatusParam + = edge_serial->rxHeader2; + edge_serial->rxState = EXPECT_HDR3; break; } - /* otherwise, drop on through */ - - case EXPECT_HDR2: - edge_serial->rxHeader2 = *buffer; - ++buffer; - --bufferLength; - - dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, edge_serial->rxHeader1, edge_serial->rxHeader2); - - // Process depending on whether this header is - // data or status - - if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) { - // Decode this status header and goto EXPECT_HDR1 (if we - // can process the status with only 2 bytes), or goto - // EXPECT_HDR3 to get the third byte. - - edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1); - edge_serial->rxStatusCode = IOSP_GET_STATUS_CODE(edge_serial->rxHeader1); - - if (!IOSP_STATUS_IS_2BYTE(edge_serial->rxStatusCode)) { - // This status needs additional bytes. Save what we have - // and then wait for more data. - edge_serial->rxStatusParam = edge_serial->rxHeader2; - - edge_serial->rxState = EXPECT_HDR3; - break; - } + /* We have all the header bytes, process the + status now */ + process_rcvd_status(edge_serial, + edge_serial->rxHeader2, 0); + edge_serial->rxState = EXPECT_HDR1; + break; + } else { + edge_serial->rxPort = + IOSP_GET_HDR_PORT(edge_serial->rxHeader1); + edge_serial->rxBytesRemaining = + IOSP_GET_HDR_DATA_LEN( + edge_serial->rxHeader1, + edge_serial->rxHeader2); + dbg("%s - Data for Port %u Len %u", + __func__, + edge_serial->rxPort, + edge_serial->rxBytesRemaining); + + /* ASSERT(DevExt->RxPort < DevExt->NumPorts); + * ASSERT(DevExt->RxBytesRemaining < + * IOSP_MAX_DATA_LENGTH); + */ - // We have all the header bytes, process the status now - process_rcvd_status (edge_serial, edge_serial->rxHeader2, 0); - edge_serial->rxState = EXPECT_HDR1; + if (bufferLength == 0) { + edge_serial->rxState = EXPECT_DATA; break; - } else { - edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1); - edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2); - - dbg("%s - Data for Port %u Len %u", __func__, edge_serial->rxPort, edge_serial->rxBytesRemaining); - - //ASSERT( DevExt->RxPort < DevExt->NumPorts ); - //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH ); - - if (bufferLength == 0 ) { - edge_serial->rxState = EXPECT_DATA; - break; - } - // Else, drop through } + /* Else, drop through */ + } + case EXPECT_DATA: /* Expect data */ + if (bufferLength < edge_serial->rxBytesRemaining) { + rxLen = bufferLength; + /* Expect data to start next buffer */ + edge_serial->rxState = EXPECT_DATA; + } else { + /* BufLen >= RxBytesRemaining */ + rxLen = edge_serial->rxBytesRemaining; + /* Start another header next time */ + edge_serial->rxState = EXPECT_HDR1; + } - case EXPECT_DATA: // Expect data - - if (bufferLength < edge_serial->rxBytesRemaining) { - rxLen = bufferLength; - edge_serial->rxState = EXPECT_DATA; // Expect data to start next buffer - } else { - // BufLen >= RxBytesRemaining - rxLen = edge_serial->rxBytesRemaining; - edge_serial->rxState = EXPECT_HDR1; // Start another header next time - } + bufferLength -= rxLen; + edge_serial->rxBytesRemaining -= rxLen; - bufferLength -= rxLen; - edge_serial->rxBytesRemaining -= rxLen; - - /* spit this data back into the tty driver if this port is open */ - if (rxLen) { - port = edge_serial->serial->port[edge_serial->rxPort]; - edge_port = usb_get_serial_port_data(port); - if (edge_port->open) { - tty = edge_port->port->port.tty; - if (tty) { - dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); - edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); - } - edge_port->icount.rx += rxLen; + /* spit this data back into the tty driver if this + port is open */ + if (rxLen) { + port = edge_serial->serial->port[ + edge_serial->rxPort]; + edge_port = usb_get_serial_port_data(port); + if (edge_port->open) { + tty = edge_port->port->port.tty; + if (tty) { + dbg("%s - Sending %d bytes to TTY for port %d", + __func__, rxLen, edge_serial->rxPort); + edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); } - buffer += rxLen; + edge_port->icount.rx += rxLen; } + buffer += rxLen; + } + break; - break; - - case EXPECT_HDR3: // Expect 3rd byte of status header - edge_serial->rxHeader3 = *buffer; - ++buffer; - --bufferLength; - - // We have all the header bytes, process the status now - process_rcvd_status (edge_serial, edge_serial->rxStatusParam, edge_serial->rxHeader3); - edge_serial->rxState = EXPECT_HDR1; - break; - + case EXPECT_HDR3: /* Expect 3rd byte of status header */ + edge_serial->rxHeader3 = *buffer; + ++buffer; + --bufferLength; + + /* We have all the header bytes, process the + status now */ + process_rcvd_status(edge_serial, + edge_serial->rxStatusParam, + edge_serial->rxHeader3); + edge_serial->rxState = EXPECT_HDR1; + break; } } } @@ -1852,9 +1963,11 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha /***************************************************************************** * process_rcvd_status - * this function handles the any status messages received on the bulk in pipe. + * this function handles the any status messages received on the + * bulk in pipe. *****************************************************************************/ -static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3) +static void process_rcvd_status(struct edgeport_serial *edge_serial, + __u8 byte2, __u8 byte3) { struct usb_serial_port *port; struct edgeport_port *edge_port; @@ -1864,7 +1977,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 port = edge_serial->serial->port[edge_serial->rxPort]; edge_port = usb_get_serial_port_data(port); if (edge_port == NULL) { - dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __func__, edge_serial->rxPort); + dev_err(&edge_serial->serial->dev->dev, + "%s - edge_port == NULL for port %d\n", + __func__, edge_serial->rxPort); return; } @@ -1872,22 +1987,28 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 if (code == IOSP_EXT_STATUS) { switch (byte2) { - case IOSP_EXT_STATUS_CHASE_RSP: - // we want to do EXT status regardless of port open/closed - dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __func__, edge_serial->rxPort, byte3 ); - // Currently, the only EXT_STATUS is Chase, so process here instead of one more call - // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do. - // Also, we currently clear flag and close the port regardless of content of above's Byte3. - // We could choose to do something else when Byte3 says Timeout on Chase from Edgeport, - // like wait longer in block_until_chase_response, but for now we don't. - edge_port->chaseResponsePending = false; - wake_up (&edge_port->wait_chase); - return; + case IOSP_EXT_STATUS_CHASE_RSP: + /* we want to do EXT status regardless of port + * open/closed */ + dbg("%s - Port %u EXT CHASE_RSP Data = %02x", + __func__, edge_serial->rxPort, byte3); + /* Currently, the only EXT_STATUS is Chase, so process + * here instead of one more call to one more subroutine + * If/when more EXT_STATUS, there'll be more work to do + * Also, we currently clear flag and close the port + * regardless of content of above's Byte3. + * We could choose to do something else when Byte3 says + * Timeout on Chase from Edgeport, like wait longer in + * block_until_chase_response, but for now we don't. + */ + edge_port->chaseResponsePending = false; + wake_up(&edge_port->wait_chase); + return; - case IOSP_EXT_STATUS_RX_CHECK_RSP: - dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3 ); - //Port->RxCheckRsp = true; - return; + case IOSP_EXT_STATUS_RX_CHECK_RSP: + dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3); + /* Port->RxCheckRsp = true; */ + return; } } @@ -1895,12 +2016,14 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); edge_port->maxTxCredits = edge_port->txCredits; dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits); - handle_new_msr (edge_port, byte2); + handle_new_msr(edge_port, byte2); - /* send the current line settings to the port so we are in sync with any further termios calls */ + /* send the current line settings to the port so we are + in sync with any further termios calls */ /* FIXME: locking on tty */ if (edge_port->port->port.tty) - change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios); + change_port_settings(edge_port->port->port.tty, + edge_port, edge_port->port->port.tty->termios); /* we have completed the open */ edge_port->openPending = false; @@ -1909,45 +2032,49 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 return; } - // If port is closed, silently discard all rcvd status. We can - // have cases where buffered status is received AFTER the close - // port command is sent to the Edgeport. - if (!edge_port->open || edge_port->closePending) { + /* If port is closed, silently discard all rcvd status. We can + * have cases where buffered status is received AFTER the close + * port command is sent to the Edgeport. + */ + if (!edge_port->open || edge_port->closePending) return; - } switch (code) { - // Not currently sent by Edgeport - case IOSP_STATUS_LSR: - dbg("%s - Port %u LSR Status = %02x", __func__, edge_serial->rxPort, byte2); - handle_new_lsr(edge_port, false, byte2, 0); - break; + /* Not currently sent by Edgeport */ + case IOSP_STATUS_LSR: + dbg("%s - Port %u LSR Status = %02x", + __func__, edge_serial->rxPort, byte2); + handle_new_lsr(edge_port, false, byte2, 0); + break; - case IOSP_STATUS_LSR_DATA: - dbg("%s - Port %u LSR Status = %02x, Data = %02x", __func__, edge_serial->rxPort, byte2, byte3); - // byte2 is LSR Register - // byte3 is broken data byte - handle_new_lsr(edge_port, true, byte2, byte3); - break; - // - // case IOSP_EXT_4_STATUS: - // dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3); - // break; - // - case IOSP_STATUS_MSR: - dbg("%s - Port %u MSR Status = %02x", __func__, edge_serial->rxPort, byte2); - - // Process this new modem status and generate appropriate - // events, etc, based on the new status. This routine - // also saves the MSR in Port->ShadowMsr. - handle_new_msr(edge_port, byte2); - break; + case IOSP_STATUS_LSR_DATA: + dbg("%s - Port %u LSR Status = %02x, Data = %02x", + __func__, edge_serial->rxPort, byte2, byte3); + /* byte2 is LSR Register */ + /* byte3 is broken data byte */ + handle_new_lsr(edge_port, true, byte2, byte3); + break; + /* + * case IOSP_EXT_4_STATUS: + * dbg("%s - Port %u LSR Status = %02x Data = %02x", + * __func__, edge_serial->rxPort, byte2, byte3); + * break; + */ + case IOSP_STATUS_MSR: + dbg("%s - Port %u MSR Status = %02x", + __func__, edge_serial->rxPort, byte2); + /* + * Process this new modem status and generate appropriate + * events, etc, based on the new status. This routine + * also saves the MSR in Port->ShadowMsr. + */ + handle_new_msr(edge_port, byte2); + break; - default: - dbg("%s - Unrecognized IOSP status code %u\n", __func__, code); - break; + default: + dbg("%s - Unrecognized IOSP status code %u\n", __func__, code); + break; } - return; } @@ -1956,7 +2083,8 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 * edge_tty_recv * this function passes data on to the tty flip buffer *****************************************************************************/ -static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length) +static void edge_tty_recv(struct device *dev, struct tty_struct *tty, + unsigned char *data, int length) { int cnt; @@ -1965,7 +2093,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c if (cnt < length) { dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); - if(cnt == 0) + if (cnt == 0) break; } tty_insert_flip_string(tty, data, cnt); @@ -1987,22 +2115,19 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr) dbg("%s %02x", __func__, newMsr); - if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { + if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | + EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { icount = &edge_port->icount; /* update input line counters */ - if (newMsr & EDGEPORT_MSR_DELTA_CTS) { + if (newMsr & EDGEPORT_MSR_DELTA_CTS) icount->cts++; - } - if (newMsr & EDGEPORT_MSR_DELTA_DSR) { + if (newMsr & EDGEPORT_MSR_DELTA_DSR) icount->dsr++; - } - if (newMsr & EDGEPORT_MSR_DELTA_CD) { + if (newMsr & EDGEPORT_MSR_DELTA_CD) icount->dcd++; - } - if (newMsr & EDGEPORT_MSR_DELTA_RI) { + if (newMsr & EDGEPORT_MSR_DELTA_RI) icount->rng++; - } wake_up_interruptible(&edge_port->delta_msr_wait); } @@ -2017,42 +2142,41 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr) * handle_new_lsr * this function handles any change to the lsr register for a port. *****************************************************************************/ -static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data) +static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, + __u8 lsr, __u8 data) { - __u8 newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); - struct async_icount *icount; + __u8 newLsr = (__u8) (lsr & (__u8) + (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); + struct async_icount *icount; dbg("%s - %02x", __func__, newLsr); edge_port->shadowLSR = lsr; if (newLsr & LSR_BREAK) { - // - // Parity and Framing errors only count if they - // occur exclusive of a break being - // received. - // + /* + * Parity and Framing errors only count if they + * occur exclusive of a break being + * received. + */ newLsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); } /* Place LSR data byte into Rx buffer */ if (lsrData && edge_port->port->port.tty) - edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1); + edge_tty_recv(&edge_port->port->dev, + edge_port->port->port.tty, &data, 1); /* update input line counters */ icount = &edge_port->icount; - if (newLsr & LSR_BREAK) { + if (newLsr & LSR_BREAK) icount->brk++; - } - if (newLsr & LSR_OVER_ERR) { + if (newLsr & LSR_OVER_ERR) icount->overrun++; - } - if (newLsr & LSR_PAR_ERR) { + if (newLsr & LSR_PAR_ERR) icount->parity++; - } - if (newLsr & LSR_FRM_ERR) { + if (newLsr & LSR_FRM_ERR) icount->frame++; - } return; } @@ -2060,12 +2184,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l /**************************************************************************** * sram_write - * writes a number of bytes to the Edgeport device's sram starting at the + * writes a number of bytes to the Edgeport device's sram starting at the * given address. * If successful returns the number of bytes written, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data) +static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, + __u16 length, const __u8 *data) { int result; __u16 current_length; @@ -2073,32 +2198,37 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); - transfer_buffer = kmalloc (64, GFP_KERNEL); + transfer_buffer = kmalloc(64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", + __func__, 64); return -ENOMEM; } /* need to split these writes up into 64 byte chunks */ result = 0; while (length > 0) { - if (length > 64) { + if (length > 64) current_length = 64; - } else { + else current_length = length; - } -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); - memcpy (transfer_buffer, data, current_length); - result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM, - 0x40, addr, extAddr, transfer_buffer, current_length, 300); + +/* dbg("%s - writing %x, %x, %d", __func__, + extAddr, addr, current_length); */ + memcpy(transfer_buffer, data, current_length); + result = usb_control_msg(serial->dev, + usb_sndctrlpipe(serial->dev, 0), + USB_REQUEST_ION_WRITE_RAM, + 0x40, addr, extAddr, transfer_buffer, + current_length, 300); if (result < 0) break; length -= current_length; addr += current_length; data += current_length; - } + } - kfree (transfer_buffer); + kfree(transfer_buffer); return result; } @@ -2110,40 +2240,45 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1 * If successful returns the number of bytes written, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data) +static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, + __u16 length, const __u8 *data) { int result; __u16 current_length; unsigned char *transfer_buffer; -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); +/* dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */ - transfer_buffer = kmalloc (64, GFP_KERNEL); + transfer_buffer = kmalloc(64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); + dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", + __func__, 64); return -ENOMEM; } /* need to split these writes up into 64 byte chunks */ result = 0; while (length > 0) { - if (length > 64) { + if (length > 64) current_length = 64; - } else { + else current_length = length; - } -// dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length); - memcpy (transfer_buffer, data, current_length); - result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM, - 0x40, addr, extAddr, transfer_buffer, current_length, 300); +/* dbg("%s - writing %x, %x, %d", __func__, + extAddr, addr, current_length); */ + memcpy(transfer_buffer, data, current_length); + result = usb_control_msg(serial->dev, + usb_sndctrlpipe(serial->dev, 0), + USB_REQUEST_ION_WRITE_ROM, 0x40, + addr, extAddr, + transfer_buffer, current_length, 300); if (result < 0) break; length -= current_length; addr += current_length; data += current_length; - } + } - kfree (transfer_buffer); + kfree(transfer_buffer); return result; } @@ -2155,7 +2290,8 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 * If successful returns the number of bytes read, otherwise it returns * a negative error number of the problem. ****************************************************************************/ -static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data) +static int rom_read(struct usb_serial *serial, __u16 extAddr, + __u16 addr, __u16 length, __u8 *data) { int result; __u16 current_length; @@ -2163,32 +2299,36 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); - transfer_buffer = kmalloc (64, GFP_KERNEL); + transfer_buffer = kmalloc(64, GFP_KERNEL); if (!transfer_buffer) { - dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64); + dev_err(&serial->dev->dev, + "%s - kmalloc(%d) failed.\n", __func__, 64); return -ENOMEM; } /* need to split these reads up into 64 byte chunks */ result = 0; while (length > 0) { - if (length > 64) { + if (length > 64) current_length = 64; - } else { + else current_length = length; - } -// dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length); - result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM, - 0xC0, addr, extAddr, transfer_buffer, current_length, 300); +/* dbg("%s - %x, %x, %d", __func__, + extAddr, addr, current_length); */ + result = usb_control_msg(serial->dev, + usb_rcvctrlpipe(serial->dev, 0), + USB_REQUEST_ION_READ_ROM, + 0xC0, addr, extAddr, transfer_buffer, + current_length, 300); if (result < 0) break; - memcpy (data, transfer_buffer, current_length); + memcpy(data, transfer_buffer, current_length); length -= current_length; addr += current_length; data += current_length; - } + } - kfree (transfer_buffer); + kfree(transfer_buffer); return result; } @@ -2197,7 +2337,8 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 * send_iosp_ext_cmd * Is used to send a IOSP message to the Edgeport device ****************************************************************************/ -static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param) +static int send_iosp_ext_cmd(struct edgeport_port *edge_port, + __u8 command, __u8 param) { unsigned char *buffer; unsigned char *currentCommand; @@ -2206,19 +2347,20 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u dbg("%s - %d, %d", __func__, command, param); - buffer = kmalloc (10, GFP_ATOMIC); + buffer = kmalloc(10, GFP_ATOMIC); if (!buffer) { - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 10); + dev_err(&edge_port->port->dev, + "%s - kmalloc(%d) failed.\n", __func__, 10); return -ENOMEM; } currentCommand = buffer; - MAKE_CMD_EXT_CMD (¤tCommand, &length, - edge_port->port->number - edge_port->port->serial->minor, - command, param); + MAKE_CMD_EXT_CMD(¤tCommand, &length, + edge_port->port->number - edge_port->port->serial->minor, + command, param); - status = write_cmd_usb (edge_port, buffer, length); + status = write_cmd_usb(edge_port, buffer, length); if (status) { /* something bad happened, let's free up the memory */ kfree(buffer); @@ -2232,43 +2374,50 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u * write_cmd_usb * this function writes the given buffer out to the bulk write endpoint. *****************************************************************************/ -static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length) +static int write_cmd_usb(struct edgeport_port *edge_port, + unsigned char *buffer, int length) { - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); + struct edgeport_serial *edge_serial = + usb_get_serial_data(edge_port->port->serial); int status = 0; struct urb *urb; int timeout; - usb_serial_debug_data(debug, &edge_port->port->dev, __func__, length, buffer); + usb_serial_debug_data(debug, &edge_port->port->dev, + __func__, length, buffer); /* Allocate our next urb */ - urb = usb_alloc_urb (0, GFP_ATOMIC); + urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) return -ENOMEM; atomic_inc(&CmdUrbs); - dbg("%s - ALLOCATE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs)); + dbg("%s - ALLOCATE URB %p (outstanding %d)", + __func__, urb, atomic_read(&CmdUrbs)); - usb_fill_bulk_urb (urb, edge_serial->serial->dev, - usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint), - buffer, length, edge_bulk_out_cmd_callback, edge_port); + usb_fill_bulk_urb(urb, edge_serial->serial->dev, + usb_sndbulkpipe(edge_serial->serial->dev, + edge_serial->bulk_out_endpoint), + buffer, length, edge_bulk_out_cmd_callback, edge_port); edge_port->commandPending = true; status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { /* something went wrong */ - dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __func__, status); + dev_err(&edge_port->port->dev, + "%s - usb_submit_urb(write command) failed, status = %d\n", + __func__, status); usb_kill_urb(urb); usb_free_urb(urb); atomic_dec(&CmdUrbs); return status; } - // wait for command to finish + /* wait for command to finish */ timeout = COMMAND_TIMEOUT; #if 0 - wait_event (&edge_port->wait_command, !edge_port->commandPending); + wait_event(&edge_port->wait_command, !edge_port->commandPending); if (edge_port->commandPending) { /* command timed out */ @@ -2285,15 +2434,18 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer * this function sends the proper command to change the baud rate of the * specified port. *****************************************************************************/ -static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate) +static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, + int baudRate) { - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); + struct edgeport_serial *edge_serial = + usb_get_serial_data(edge_port->port->serial); unsigned char *cmdBuffer; unsigned char *currCmd; int cmdLen = 0; int divisor; int status; - unsigned char number = edge_port->port->number - edge_port->port->serial->minor; + unsigned char number = + edge_port->port->number - edge_port->port->serial->minor; if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { @@ -2302,36 +2454,40 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa return 0; } - dbg("%s - port = %d, baud = %d", __func__, edge_port->port->number, baudRate); + dbg("%s - port = %d, baud = %d", __func__, + edge_port->port->number, baudRate); - status = calc_baud_rate_divisor (baudRate, &divisor); + status = calc_baud_rate_divisor(baudRate, &divisor); if (status) { - dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __func__); + dev_err(&edge_port->port->dev, "%s - bad baud rate\n", + __func__); return status; } - // Alloc memory for the string of commands. - cmdBuffer = kmalloc (0x100, GFP_ATOMIC); + /* Alloc memory for the string of commands. */ + cmdBuffer = kmalloc(0x100, GFP_ATOMIC); if (!cmdBuffer) { - dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100); + dev_err(&edge_port->port->dev, + "%s - kmalloc(%d) failed.\n", __func__, 0x100); return -ENOMEM; } currCmd = cmdBuffer; - // Enable access to divisor latch - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE ); + /* Enable access to divisor latch */ + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE); - // Write the divisor itself - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLL, LOW8 (divisor) ); - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLM, HIGH8(divisor) ); + /* Write the divisor itself */ + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLL, LOW8(divisor)); + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLM, HIGH8(divisor)); - // Restore original value to disable access to divisor latch - MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, edge_port->shadowLCR); + /* Restore original value to disable access to divisor latch */ + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR, + edge_port->shadowLCR); - status = write_cmd_usb(edge_port, cmdBuffer, cmdLen ); + status = write_cmd_usb(edge_port, cmdBuffer, cmdLen); if (status) { /* something bad happened, let's free up the memory */ - kfree (cmdBuffer); + kfree(cmdBuffer); } return status; @@ -2343,7 +2499,7 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa * this function calculates the proper baud rate divisor for the specified * baud rate. *****************************************************************************/ -static int calc_baud_rate_divisor (int baudrate, int *divisor) +static int calc_baud_rate_divisor(int baudrate, int *divisor) { int i; __u16 custom; @@ -2352,17 +2508,17 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor) dbg("%s - %d", __func__, baudrate); for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { - if ( divisor_table[i].BaudRate == baudrate ) { + if (divisor_table[i].BaudRate == baudrate) { *divisor = divisor_table[i].Divisor; return 0; } } - // We have tried all of the standard baud rates - // lets try to calculate the divisor for this baud rate - // Make sure the baud rate is reasonable + /* We have tried all of the standard baud rates + * lets try to calculate the divisor for this baud rate + * Make sure the baud rate is reasonable */ if (baudrate > 50 && baudrate < 230400) { - // get divisor + /* get divisor */ custom = (__u16)((230400L + baudrate/2) / baudrate); *divisor = custom; @@ -2377,17 +2533,20 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor) /***************************************************************************** * send_cmd_write_uart_register - * this function builds up a uart register message and sends to to the device. + * this function builds up a uart register message and sends to to the device. *****************************************************************************/ -static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue) +static int send_cmd_write_uart_register(struct edgeport_port *edge_port, + __u8 regNum, __u8 regValue) { - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); + struct edgeport_serial *edge_serial = + usb_get_serial_data(edge_port->port->serial); unsigned char *cmdBuffer; unsigned char *currCmd; unsigned long cmdLen = 0; int status; - dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); + dbg("%s - write to %s register 0x%02x", + (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && @@ -2399,27 +2558,26 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r if (edge_serial->is_epic && !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && regNum == LCR) { - dbg ("SendCmdWriteUartReg - Not writing to LCR Register"); + dbg("SendCmdWriteUartReg - Not writing to LCR Register"); return 0; } - // Alloc memory for the string of commands. - cmdBuffer = kmalloc (0x10, GFP_ATOMIC); - if (cmdBuffer == NULL ) { + /* Alloc memory for the string of commands. */ + cmdBuffer = kmalloc(0x10, GFP_ATOMIC); + if (cmdBuffer == NULL) return -ENOMEM; - } currCmd = cmdBuffer; - // Build a cmd in the buffer to write the given register - MAKE_CMD_WRITE_REG (&currCmd, &cmdLen, - edge_port->port->number - edge_port->port->serial->minor, - regNum, regValue); + /* Build a cmd in the buffer to write the given register */ + MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, + edge_port->port->number - edge_port->port->serial->minor, + regNum, regValue); status = write_cmd_usb(edge_port, cmdBuffer, cmdLen); if (status) { /* something bad happened, let's free up the memory */ - kfree (cmdBuffer); + kfree(cmdBuffer); } return status; @@ -2428,14 +2586,15 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r /***************************************************************************** * change_port_settings - * This routine is called to set the UART on the device to match the specified - * new settings. + * This routine is called to set the UART on the device to match the + * specified new settings. *****************************************************************************/ static void change_port_settings(struct tty_struct *tty, struct edgeport_port *edge_port, struct ktermios *old_termios) { - struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); + struct edgeport_serial *edge_serial = + usb_get_serial_data(edge_port->port->serial); int baud; unsigned cflag; __u8 mask = 0xff; @@ -2457,11 +2616,23 @@ static void change_port_settings(struct tty_struct *tty, cflag = tty->termios->c_cflag; switch (cflag & CSIZE) { - case CS5: lData = LCR_BITS_5; mask = 0x1f; dbg("%s - data bits = 5", __func__); break; - case CS6: lData = LCR_BITS_6; mask = 0x3f; dbg("%s - data bits = 6", __func__); break; - case CS7: lData = LCR_BITS_7; mask = 0x7f; dbg("%s - data bits = 7", __func__); break; - default: - case CS8: lData = LCR_BITS_8; dbg("%s - data bits = 8", __func__); break; + case CS5: + lData = LCR_BITS_5; mask = 0x1f; + dbg("%s - data bits = 5", __func__); + break; + case CS6: + lData = LCR_BITS_6; mask = 0x3f; + dbg("%s - data bits = 6", __func__); + break; + case CS7: + lData = LCR_BITS_7; mask = 0x7f; + dbg("%s - data bits = 7", __func__); + break; + default: + case CS8: + lData = LCR_BITS_8; + dbg("%s - data bits = 8", __func__); + break; } lParity = LCR_PAR_NONE; @@ -2503,7 +2674,8 @@ static void change_port_settings(struct tty_struct *tty, dbg("%s - RTS/CTS is disabled", __func__); } - /* if we are implementing XON/XOFF, set the start and stop character in the device */ + /* if we are implementing XON/XOFF, set the start and stop character + in the device */ if (I_IXOFF(tty) || I_IXON(tty)) { unsigned char stop_char = STOP_CHAR(tty); unsigned char start_char = START_CHAR(tty); @@ -2511,14 +2683,17 @@ static void change_port_settings(struct tty_struct *tty, if ((!edge_serial->is_epic) || ((edge_serial->is_epic) && (edge_serial->epic_descriptor.Supports.IOSPSetXChar))) { - send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XON_CHAR, start_char); - send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XOFF_CHAR, stop_char); + send_iosp_ext_cmd(edge_port, + IOSP_CMD_SET_XON_CHAR, start_char); + send_iosp_ext_cmd(edge_port, + IOSP_CMD_SET_XOFF_CHAR, stop_char); } /* if we are implementing INBOUND XON/XOFF */ if (I_IXOFF(tty)) { rxFlow |= IOSP_RX_FLOW_XON_XOFF; - dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char); + dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", + __func__, start_char, stop_char); } else { dbg("%s - INBOUND XON/XOFF is disabled", __func__); } @@ -2526,7 +2701,8 @@ static void change_port_settings(struct tty_struct *tty, /* if we are implementing OUTBOUND XON/XOFF */ if (I_IXON(tty)) { txFlow |= IOSP_TX_FLOW_XON_XOFF; - dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char); + dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", + __func__, start_char, stop_char); } else { dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); } @@ -2549,20 +2725,20 @@ static void change_port_settings(struct tty_struct *tty, edge_port->validDataMask = mask; /* Send the updated LCR value to the EdgePort */ - status = send_cmd_write_uart_register(edge_port, LCR, edge_port->shadowLCR); - if (status != 0) { + status = send_cmd_write_uart_register(edge_port, LCR, + edge_port->shadowLCR); + if (status != 0) return; - } /* set up the MCR register and send it to the EdgePort */ edge_port->shadowMCR = MCR_MASTER_IE; - if (cflag & CBAUD) { + if (cflag & CBAUD) edge_port->shadowMCR |= (MCR_DTR | MCR_RTS); - } - status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); - if (status != 0) { + + status = send_cmd_write_uart_register(edge_port, MCR, + edge_port->shadowMCR); + if (status != 0) return; - } /* Determine divisor based on baud rate */ baud = tty_get_baud_rate(tty); @@ -2572,7 +2748,7 @@ static void change_port_settings(struct tty_struct *tty, } dbg("%s - baud rate = %d", __func__, baud); - status = send_cmd_write_baud_rate (edge_port, baud); + status = send_cmd_write_baud_rate(edge_port, baud); if (status == -1) { /* Speed change was not possible - put back the old speed */ baud = tty_termios_baud_rate(old_termios); @@ -2589,7 +2765,8 @@ static void change_port_settings(struct tty_struct *tty, * ASCII range, but it's only for debugging... * NOTE: expects the unicode in LE format ****************************************************************************/ -static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size) +static void unicode_to_ascii(char *string, int buflen, + __le16 *unicode, int unicode_size) { int i; @@ -2608,75 +2785,99 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic /**************************************************************************** * get_manufacturing_desc - * reads in the manufacturing descriptor and stores it into the serial + * reads in the manufacturing descriptor and stores it into the serial * structure. ****************************************************************************/ -static void get_manufacturing_desc (struct edgeport_serial *edge_serial) +static void get_manufacturing_desc(struct edgeport_serial *edge_serial) { int response; dbg("getting manufacturer descriptor"); - response = rom_read (edge_serial->serial, (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, - (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff), EDGE_MANUF_DESC_LEN, - (__u8 *)(&edge_serial->manuf_descriptor)); + response = rom_read(edge_serial->serial, + (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, + (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff), + EDGE_MANUF_DESC_LEN, + (__u8 *)(&edge_serial->manuf_descriptor)); - if (response < 1) { - dev_err(&edge_serial->serial->dev->dev, "error in getting manufacturer descriptor\n"); - } else { + if (response < 1) + dev_err(&edge_serial->serial->dev->dev, + "error in getting manufacturer descriptor\n"); + else { char string[30]; dbg("**Manufacturer Descriptor"); - dbg(" RomSize: %dK", edge_serial->manuf_descriptor.RomSize); - dbg(" RamSize: %dK", edge_serial->manuf_descriptor.RamSize); - dbg(" CpuRev: %d", edge_serial->manuf_descriptor.CpuRev); - dbg(" BoardRev: %d", edge_serial->manuf_descriptor.BoardRev); - dbg(" NumPorts: %d", edge_serial->manuf_descriptor.NumPorts); - dbg(" DescDate: %d/%d/%d", edge_serial->manuf_descriptor.DescDate[0], edge_serial->manuf_descriptor.DescDate[1], edge_serial->manuf_descriptor.DescDate[2]+1900); + dbg(" RomSize: %dK", + edge_serial->manuf_descriptor.RomSize); + dbg(" RamSize: %dK", + edge_serial->manuf_descriptor.RamSize); + dbg(" CpuRev: %d", + edge_serial->manuf_descriptor.CpuRev); + dbg(" BoardRev: %d", + edge_serial->manuf_descriptor.BoardRev); + dbg(" NumPorts: %d", + edge_serial->manuf_descriptor.NumPorts); + dbg(" DescDate: %d/%d/%d", + edge_serial->manuf_descriptor.DescDate[0], + edge_serial->manuf_descriptor.DescDate[1], + edge_serial->manuf_descriptor.DescDate[2]+1900); unicode_to_ascii(string, sizeof(string), - edge_serial->manuf_descriptor.SerialNumber, - edge_serial->manuf_descriptor.SerNumLength/2); + edge_serial->manuf_descriptor.SerialNumber, + edge_serial->manuf_descriptor.SerNumLength/2); dbg(" SerialNumber: %s", string); unicode_to_ascii(string, sizeof(string), - edge_serial->manuf_descriptor.AssemblyNumber, - edge_serial->manuf_descriptor.AssemblyNumLength/2); + edge_serial->manuf_descriptor.AssemblyNumber, + edge_serial->manuf_descriptor.AssemblyNumLength/2); dbg(" AssemblyNumber: %s", string); unicode_to_ascii(string, sizeof(string), edge_serial->manuf_descriptor.OemAssyNumber, edge_serial->manuf_descriptor.OemAssyNumLength/2); dbg(" OemAssyNumber: %s", string); - dbg(" UartType: %d", edge_serial->manuf_descriptor.UartType); - dbg(" IonPid: %d", edge_serial->manuf_descriptor.IonPid); - dbg(" IonConfig: %d", edge_serial->manuf_descriptor.IonConfig); + dbg(" UartType: %d", + edge_serial->manuf_descriptor.UartType); + dbg(" IonPid: %d", + edge_serial->manuf_descriptor.IonPid); + dbg(" IonConfig: %d", + edge_serial->manuf_descriptor.IonConfig); } } /**************************************************************************** * get_boot_desc - * reads in the bootloader descriptor and stores it into the serial + * reads in the bootloader descriptor and stores it into the serial * structure. ****************************************************************************/ -static void get_boot_desc (struct edgeport_serial *edge_serial) +static void get_boot_desc(struct edgeport_serial *edge_serial) { int response; dbg("getting boot descriptor"); - response = rom_read (edge_serial->serial, (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, - (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff), EDGE_BOOT_DESC_LEN, - (__u8 *)(&edge_serial->boot_descriptor)); + response = rom_read(edge_serial->serial, + (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, + (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff), + EDGE_BOOT_DESC_LEN, + (__u8 *)(&edge_serial->boot_descriptor)); - if (response < 1) { - dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n"); - } else { + if (response < 1) + dev_err(&edge_serial->serial->dev->dev, + "error in getting boot descriptor\n"); + else { dbg("**Boot Descriptor:"); - dbg(" BootCodeLength: %d", le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); - dbg(" MajorVersion: %d", edge_serial->boot_descriptor.MajorVersion); - dbg(" MinorVersion: %d", edge_serial->boot_descriptor.MinorVersion); - dbg(" BuildNumber: %d", le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); - dbg(" Capabilities: 0x%x", le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); - dbg(" UConfig0: %d", edge_serial->boot_descriptor.UConfig0); - dbg(" UConfig1: %d", edge_serial->boot_descriptor.UConfig1); + dbg(" BootCodeLength: %d", + le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); + dbg(" MajorVersion: %d", + edge_serial->boot_descriptor.MajorVersion); + dbg(" MinorVersion: %d", + edge_serial->boot_descriptor.MinorVersion); + dbg(" BuildNumber: %d", + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); + dbg(" Capabilities: 0x%x", + le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); + dbg(" UConfig0: %d", + edge_serial->boot_descriptor.UConfig0); + dbg(" UConfig1: %d", + edge_serial->boot_descriptor.UConfig1); } } @@ -2685,7 +2886,7 @@ static void get_boot_desc (struct edgeport_serial *edge_serial) * load_application_firmware * This is called to load the application firmware to the device ****************************************************************************/ -static void load_application_firmware (struct edgeport_serial *edge_serial) +static void load_application_firmware(struct edgeport_serial *edge_serial) { const struct ihex_binrec *rec; const struct firmware *fw; @@ -2762,7 +2963,7 @@ static void load_application_firmware (struct edgeport_serial *edge_serial) /**************************************************************************** * edge_startup ****************************************************************************/ -static int edge_startup (struct usb_serial *serial) +static int edge_startup(struct usb_serial *serial) { struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; @@ -2804,10 +3005,10 @@ static int edge_startup (struct usb_serial *serial) sizeof(struct edge_compatibility_bits)); /* get the manufacturing descriptor for this device */ - get_manufacturing_desc (edge_serial); + get_manufacturing_desc(edge_serial); /* get the boot descriptor */ - get_boot_desc (edge_serial); + get_boot_desc(edge_serial); get_product_info(edge_serial); } @@ -2828,41 +3029,43 @@ static int edge_startup (struct usb_serial *serial) /* If not an EPiC device */ if (!edge_serial->is_epic) { /* now load the application firmware into this device */ - load_application_firmware (edge_serial); + load_application_firmware(edge_serial); dbg("%s - time 2 %ld", __func__, jiffies); /* Check current Edgeport EEPROM and update if necessary */ - update_edgeport_E2PROM (edge_serial); + update_edgeport_E2PROM(edge_serial); dbg("%s - time 3 %ld", __func__, jiffies); /* set the configuration to use #1 */ -// dbg("set_configuration 1"); -// usb_set_configuration (dev, 1); +/* dbg("set_configuration 1"); */ +/* usb_set_configuration (dev, 1); */ } dbg(" FirmwareMajorVersion %d.%d.%d", edge_serial->product_info.FirmwareMajorVersion, edge_serial->product_info.FirmwareMinorVersion, le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber)); - /* we set up the pointers to the endpoints in the edge_open function, + /* we set up the pointers to the endpoints in the edge_open function, * as the structures aren't created yet. */ /* set up our port private structures */ for (i = 0; i < serial->num_ports; ++i) { - edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); + edge_port = kmalloc(sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { - dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); + dev_err(&serial->dev->dev, "%s - Out of memory\n", + __func__); for (j = 0; j < i; ++j) { - kfree (usb_get_serial_port_data(serial->port[j])); - usb_set_serial_port_data(serial->port[j], NULL); + kfree(usb_get_serial_port_data(serial->port[j])); + usb_set_serial_port_data(serial->port[j], + NULL); } usb_set_serial_data(serial, NULL); kfree(edge_serial); return -ENOMEM; } - memset (edge_port, 0, sizeof(struct edgeport_port)); + memset(edge_port, 0, sizeof(struct edgeport_port)); spin_lock_init(&edge_port->ep_lock); edge_port->port = serial->port[i]; usb_set_serial_port_data(serial->port[i], edge_port); @@ -2871,14 +3074,16 @@ static int edge_startup (struct usb_serial *serial) response = 0; if (edge_serial->is_epic) { - /* EPIC thing, set up our interrupt polling now and our read urb, so - * that the device knows it really is connected. */ + /* EPIC thing, set up our interrupt polling now and our read + * urb, so that the device knows it really is connected. */ interrupt_in_found = bulk_in_found = bulk_out_found = false; - for (i = 0; i < serial->interface->altsetting[0].desc.bNumEndpoints; ++i) { + for (i = 0; i < serial->interface->altsetting[0] + .desc.bNumEndpoints; ++i) { struct usb_endpoint_descriptor *endpoint; int buffer_size; - endpoint = &serial->interface->altsetting[0].endpoint[i].desc; + endpoint = &serial->interface->altsetting[0]. + endpoint[i].desc; buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); if (!interrupt_in_found && (usb_endpoint_is_int_in(endpoint))) { @@ -2886,58 +3091,67 @@ static int edge_startup (struct usb_serial *serial) dbg("found interrupt in"); /* not set up yet, so do it now */ - edge_serial->interrupt_read_urb = usb_alloc_urb(0, GFP_KERNEL); + edge_serial->interrupt_read_urb = + usb_alloc_urb(0, GFP_KERNEL); if (!edge_serial->interrupt_read_urb) { err("out of memory"); return -ENOMEM; } - edge_serial->interrupt_in_buffer = kmalloc(buffer_size, GFP_KERNEL); + edge_serial->interrupt_in_buffer = + kmalloc(buffer_size, GFP_KERNEL); if (!edge_serial->interrupt_in_buffer) { err("out of memory"); usb_free_urb(edge_serial->interrupt_read_urb); return -ENOMEM; } - edge_serial->interrupt_in_endpoint = endpoint->bEndpointAddress; + edge_serial->interrupt_in_endpoint = + endpoint->bEndpointAddress; /* set up our interrupt urb */ - usb_fill_int_urb(edge_serial->interrupt_read_urb, - dev, - usb_rcvintpipe(dev, endpoint->bEndpointAddress), - edge_serial->interrupt_in_buffer, - buffer_size, - edge_interrupt_callback, - edge_serial, - endpoint->bInterval); + usb_fill_int_urb( + edge_serial->interrupt_read_urb, + dev, + usb_rcvintpipe(dev, + endpoint->bEndpointAddress), + edge_serial->interrupt_in_buffer, + buffer_size, + edge_interrupt_callback, + edge_serial, + endpoint->bInterval); interrupt_in_found = true; } if (!bulk_in_found && - (usb_endpoint_is_bulk_in(endpoint))) { + (usb_endpoint_is_bulk_in(endpoint))) { /* we found a bulk in endpoint */ dbg("found bulk in"); /* not set up yet, so do it now */ - edge_serial->read_urb = usb_alloc_urb(0, GFP_KERNEL); + edge_serial->read_urb = + usb_alloc_urb(0, GFP_KERNEL); if (!edge_serial->read_urb) { err("out of memory"); return -ENOMEM; } - edge_serial->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); + edge_serial->bulk_in_buffer = + kmalloc(buffer_size, GFP_KERNEL); if (!edge_serial->bulk_in_buffer) { - err ("out of memory"); + err("out of memory"); usb_free_urb(edge_serial->read_urb); return -ENOMEM; } - edge_serial->bulk_in_endpoint = endpoint->bEndpointAddress; + edge_serial->bulk_in_endpoint = + endpoint->bEndpointAddress; /* set up our bulk in urb */ usb_fill_bulk_urb(edge_serial->read_urb, dev, - usb_rcvbulkpipe(dev, endpoint->bEndpointAddress), - edge_serial->bulk_in_buffer, - le16_to_cpu(endpoint->wMaxPacketSize), - edge_bulk_in_callback, - edge_serial); + usb_rcvbulkpipe(dev, + endpoint->bEndpointAddress), + edge_serial->bulk_in_buffer, + le16_to_cpu(endpoint->wMaxPacketSize), + edge_bulk_in_callback, + edge_serial); bulk_in_found = true; } @@ -2945,21 +3159,24 @@ static int edge_startup (struct usb_serial *serial) (usb_endpoint_is_bulk_out(endpoint))) { /* we found a bulk out endpoint */ dbg("found bulk out"); - edge_serial->bulk_out_endpoint = endpoint->bEndpointAddress; + edge_serial->bulk_out_endpoint = + endpoint->bEndpointAddress; bulk_out_found = true; } } if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { - err ("Error - the proper endpoints were not found!"); + err("Error - the proper endpoints were not found!"); return -ENODEV; } /* start interrupt read for this edgeport this interrupt will * continue as long as the edgeport is connected */ - response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL); + response = usb_submit_urb(edge_serial->interrupt_read_urb, + GFP_KERNEL); if (response) - err("%s - Error %d submitting control urb", __func__, response); + err("%s - Error %d submitting control urb", + __func__, response); } return response; } @@ -2969,7 +3186,7 @@ static int edge_startup (struct usb_serial *serial) * edge_shutdown * This function is called whenever the device is removed from the usb bus. ****************************************************************************/ -static void edge_shutdown (struct usb_serial *serial) +static void edge_shutdown(struct usb_serial *serial) { struct edgeport_serial *edge_serial = usb_get_serial_data(serial); int i; @@ -2977,8 +3194,8 @@ static void edge_shutdown (struct usb_serial *serial) dbg("%s", __func__); /* stop reads and writes on all ports */ - for (i=0; i < serial->num_ports; ++i) { - kfree (usb_get_serial_port_data(serial->port[i])); + for (i = 0; i < serial->num_ports; ++i) { + kfree(usb_get_serial_port_data(serial->port[i])); usb_set_serial_port_data(serial->port[i], NULL); } /* free up our endpoint stuff */ @@ -3018,7 +3235,7 @@ static int __init edgeport_init(void) if (retval) goto failed_epic_device_register; retval = usb_register(&io_driver); - if (retval) + if (retval) goto failed_usb_register; atomic_set(&CmdUrbs, 0); info(DRIVER_DESC " " DRIVER_VERSION); @@ -3043,19 +3260,19 @@ failed_2port_device_register: ****************************************************************************/ static void __exit edgeport_exit (void) { - usb_deregister (&io_driver); - usb_serial_deregister (&edgeport_2port_device); - usb_serial_deregister (&edgeport_4port_device); - usb_serial_deregister (&edgeport_8port_device); - usb_serial_deregister (&epic_device); + usb_deregister(&io_driver); + usb_serial_deregister(&edgeport_2port_device); + usb_serial_deregister(&edgeport_4port_device); + usb_serial_deregister(&edgeport_8port_device); + usb_serial_deregister(&epic_device); } module_init(edgeport_init); module_exit(edgeport_exit); /* Module information */ -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("edgeport/boot.fw"); MODULE_FIRMWARE("edgeport/boot2.fw"); diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 2ec85893f27..7eb9d67b81b 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h @@ -8,7 +8,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * */ #ifndef IO_TABLES_H @@ -90,10 +90,10 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A758) }, { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A794) }, { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A225) }, - { } /* Terminating entry */ + { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE(usb, id_table_combined); static struct usb_driver io_driver = { .name = "io_edgeport", -- cgit v1.2.3-70-g09d2 From d76f2f4462bbb2cf7bc83a35c5278177aa627e89 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:16:42 +0100 Subject: io_edgeport: Fix various bogus returns to the tty layer The edgeport reports negative error codes to functions that do not expect them. This can cause ports to jam forever Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/io_edgeport.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index b4bd6847a96..bfa508ddb0f 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1404,15 +1404,15 @@ static int edge_write_room(struct tty_struct *tty) dbg("%s", __func__); if (edge_port == NULL) - return -ENODEV; + return 0; if (edge_port->closePending) - return -ENODEV; + return 0; dbg("%s - port %d", __func__, port->number); if (!edge_port->open) { dbg("%s - port not opened", __func__); - return -EINVAL; + return 0; } /* total of both buffers is still txCredit */ @@ -1444,13 +1444,13 @@ static int edge_chars_in_buffer(struct tty_struct *tty) dbg("%s", __func__); if (edge_port == NULL) - return -ENODEV; + return 0; if (edge_port->closePending) - return -ENODEV; + return 0; if (!edge_port->open) { dbg("%s - port not opened", __func__); - return -EINVAL; + return 0; } spin_lock_irqsave(&edge_port->ep_lock, flags); -- cgit v1.2.3-70-g09d2 From 9e98966c7bb94355689478bc84cc3e0c190f977e Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:18:03 +0100 Subject: tty: rework break handling Some hardware needs to do break handling itself and may have partial support only. Make break_ctl return an error code. Add a tty driver flag so you can indicate driver hardware side break support. Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 2 +- drivers/char/amiserial.c | 3 +- drivers/char/cyclades.c | 8 ++--- drivers/char/esp.c | 5 +-- drivers/char/istallion.c | 11 +++--- drivers/char/moxa.c | 3 +- drivers/char/mxser.c | 3 +- drivers/char/pcmcia/synclink_cs.c | 5 +-- drivers/char/rocket.c | 5 +-- drivers/char/sx.c | 3 +- drivers/char/synclink.c | 7 ++-- drivers/char/synclink_gt.c | 9 ++--- drivers/char/synclinkmp.c | 9 ++--- drivers/char/tty_io.c | 71 +++++++++++++++------------------------ drivers/char/vme_scc.c | 5 +-- drivers/isdn/capi/capi.c | 3 +- drivers/serial/serial_core.c | 3 +- drivers/usb/class/cdc-acm.c | 9 +++-- drivers/usb/serial/usb-serial.c | 3 +- include/linux/tty_driver.h | 14 ++++++-- 20 files changed, 97 insertions(+), 84 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index ba8782b9c21..a185263b586 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -218,7 +218,7 @@ config MOXA_SMARTIO config ISI tristate "Multi-Tech multiport card support (EXPERIMENTAL)" - depends on SERIAL_NONSTANDARD && PCI + depends on SERIAL_NONSTANDARD && PCI && BROKEN select FW_LOADER help This is a driver for the Multi-Tech cards which provide several diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 37457e5a4f2..3530ff417a5 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c @@ -1248,7 +1248,7 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file, /* * rs_break() --- routine which turns the break handling on or off */ -static void rs_break(struct tty_struct *tty, int break_state) +static int rs_break(struct tty_struct *tty, int break_state) { struct async_struct * info = (struct async_struct *)tty->driver_data; unsigned long flags; @@ -1263,6 +1263,7 @@ static void rs_break(struct tty_struct *tty, int break_state) custom.adkcon = AC_UARTBRK; mb(); local_irq_restore(flags); + return 0; } diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index e991dc85f2f..fe6d774fe2e 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -3700,14 +3700,15 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, /* * cy_break() --- routine which turns the break handling on or off */ -static void cy_break(struct tty_struct *tty, int break_state) +static int cy_break(struct tty_struct *tty, int break_state) { struct cyclades_port *info = tty->driver_data; struct cyclades_card *card; unsigned long flags; + int retval = 0; if (serial_paranoia_check(info, tty->name, "cy_break")) - return; + return -EINVAL; card = info->card; @@ -3736,8 +3737,6 @@ static void cy_break(struct tty_struct *tty, int break_state) } } } else { - int retval; - if (break_state == -1) { retval = cyz_issue_cmd(card, info->line - card->first_line, @@ -3758,6 +3757,7 @@ static void cy_break(struct tty_struct *tty, int break_state) } } spin_unlock_irqrestore(&card->card_lock, flags); + return retval; } /* cy_break */ static int get_mon_info(struct cyclades_port *info, diff --git a/drivers/char/esp.c b/drivers/char/esp.c index 2eaf09f93e3..7f077c0097f 100644 --- a/drivers/char/esp.c +++ b/drivers/char/esp.c @@ -1725,13 +1725,13 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file, /* * rs_break() --- routine which turns the break handling on or off */ -static void esp_break(struct tty_struct *tty, int break_state) +static int esp_break(struct tty_struct *tty, int break_state) { struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "esp_break")) - return; + return -EINVAL; if (break_state == -1) { spin_lock_irqsave(&info->lock, flags); @@ -1747,6 +1747,7 @@ static void esp_break(struct tty_struct *tty, int break_state) serial_out(info, UART_ESI_CMD2, 0x00); spin_unlock_irqrestore(&info->lock, flags); } + return 0; } static int rs_ioctl(struct tty_struct *tty, struct file *file, diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 7930fba4baf..63d22b5ebc0 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -609,7 +609,7 @@ static void stli_unthrottle(struct tty_struct *tty); static void stli_stop(struct tty_struct *tty); static void stli_start(struct tty_struct *tty); static void stli_flushbuffer(struct tty_struct *tty); -static void stli_breakctl(struct tty_struct *tty, int state); +static int stli_breakctl(struct tty_struct *tty, int state); static void stli_waituntilsent(struct tty_struct *tty, int timeout); static void stli_sendxchar(struct tty_struct *tty, char ch); static void stli_hangup(struct tty_struct *tty); @@ -1909,7 +1909,7 @@ static void stli_flushbuffer(struct tty_struct *tty) /*****************************************************************************/ -static void stli_breakctl(struct tty_struct *tty, int state) +static int stli_breakctl(struct tty_struct *tty, int state) { struct stlibrd *brdp; struct stliport *portp; @@ -1917,15 +1917,16 @@ static void stli_breakctl(struct tty_struct *tty, int state) portp = tty->driver_data; if (portp == NULL) - return; + return -EINVAL; if (portp->brdnr >= stli_nrbrds) - return; + return -EINVAL; brdp = stli_brds[portp->brdnr]; if (brdp == NULL) - return; + return -EINVAL; arg = (state == -1) ? BREAKON : BREAKOFF; stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); + return 0; } /*****************************************************************************/ diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 2bba250ffc8..d3d7864e0c1 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -374,12 +374,13 @@ copy: return ret; } -static void moxa_break_ctl(struct tty_struct *tty, int state) +static int moxa_break_ctl(struct tty_struct *tty, int state) { struct moxa_port *port = tty->driver_data; moxafunc(port->tableAddr, state ? FC_SendBreak : FC_StopBreak, Magic_code); + return 0; } static const struct tty_operations moxa_ops = { diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 1fb25571bf8..f04c3c58a05 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -2183,7 +2183,7 @@ static void mxser_hangup(struct tty_struct *tty) /* * mxser_rs_break() --- routine which turns the break handling on or off */ -static void mxser_rs_break(struct tty_struct *tty, int break_state) +static int mxser_rs_break(struct tty_struct *tty, int break_state) { struct mxser_port *info = tty->driver_data; unsigned long flags; @@ -2196,6 +2196,7 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state) outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC, info->ioaddr + UART_LCR); spin_unlock_irqrestore(&info->slock, flags); + return 0; } static void mxser_receive_chars(struct mxser_port *port, int *status) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index b694d430f10..d1fceabe3ae 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -2230,7 +2230,7 @@ static int tiocmset(struct tty_struct *tty, struct file *file, * Arguments: tty pointer to tty instance data * break_state -1=set break condition, 0=clear */ -static void mgslpc_break(struct tty_struct *tty, int break_state) +static int mgslpc_break(struct tty_struct *tty, int break_state) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; @@ -2240,7 +2240,7 @@ static void mgslpc_break(struct tty_struct *tty, int break_state) __FILE__,__LINE__, info->device_name, break_state); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) - return; + return -EINVAL; spin_lock_irqsave(&info->lock,flags); if (break_state == -1) @@ -2248,6 +2248,7 @@ static void mgslpc_break(struct tty_struct *tty, int break_state) else clear_reg_bits(info, CHA+DAFO, BIT6); spin_unlock_irqrestore(&info->lock,flags); + return 0; } /* Service an IOCTL request diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index e670eae2f51..584d791e84a 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -1236,13 +1236,13 @@ static void rp_set_termios(struct tty_struct *tty, } } -static void rp_break(struct tty_struct *tty, int break_state) +static int rp_break(struct tty_struct *tty, int break_state) { struct r_port *info = (struct r_port *) tty->driver_data; unsigned long flags; if (rocket_paranoia_check(info, "rp_break")) - return; + return -EINVAL; spin_lock_irqsave(&info->slock, flags); if (break_state == -1) @@ -1250,6 +1250,7 @@ static void rp_break(struct tty_struct *tty, int break_state) else sClrBreak(&info->channel); spin_unlock_irqrestore(&info->slock, flags); + return 0; } /* diff --git a/drivers/char/sx.c b/drivers/char/sx.c index d5cffcd6a57..2162439bbe4 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -1840,7 +1840,7 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp, return rc; } -static void sx_break(struct tty_struct *tty, int flag) +static int sx_break(struct tty_struct *tty, int flag) { struct sx_port *port = tty->driver_data; int rv; @@ -1857,6 +1857,7 @@ static void sx_break(struct tty_struct *tty, int flag) read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat))); unlock_kernel(); func_exit(); + return 0; } static int sx_tiocmget(struct tty_struct *tty, struct file *file) diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 527d220aa4a..ef6706f0906 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -2897,9 +2897,9 @@ static int tiocmset(struct tty_struct *tty, struct file *file, * * Arguments: tty pointer to tty instance data * break_state -1=set break condition, 0=clear - * Return Value: None + * Return Value: error code */ -static void mgsl_break(struct tty_struct *tty, int break_state) +static int mgsl_break(struct tty_struct *tty, int break_state) { struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; unsigned long flags; @@ -2909,7 +2909,7 @@ static void mgsl_break(struct tty_struct *tty, int break_state) __FILE__,__LINE__, info->device_name, break_state); if (mgsl_paranoia_check(info, tty->name, "mgsl_break")) - return; + return -EINVAL; spin_lock_irqsave(&info->irq_spinlock,flags); if (break_state == -1) @@ -2917,6 +2917,7 @@ static void mgsl_break(struct tty_struct *tty, int break_state) else usc_OutReg(info,IOCR,(u16)(usc_InReg(info,IOCR) & ~BIT7)); spin_unlock_irqrestore(&info->irq_spinlock,flags); + return 0; } /* end of mgsl_break() */ diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 2c3e43bb2cc..cf87bb89a77 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -165,7 +165,7 @@ static int read_proc(char *page, char **start, off_t off, int count,int *eof, v static int chars_in_buffer(struct tty_struct *tty); static void throttle(struct tty_struct * tty); static void unthrottle(struct tty_struct * tty); -static void set_break(struct tty_struct *tty, int break_state); +static int set_break(struct tty_struct *tty, int break_state); /* * generic HDLC support and callbacks @@ -513,7 +513,7 @@ static int wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); static int tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void set_break(struct tty_struct *tty, int break_state); +static int set_break(struct tty_struct *tty, int break_state); static int get_interface(struct slgt_info *info, int __user *if_mode); static int set_interface(struct slgt_info *info, int if_mode); static int set_gpio(struct slgt_info *info, struct gpio_desc __user *gpio); @@ -1452,14 +1452,14 @@ static void unthrottle(struct tty_struct * tty) * set or clear transmit break condition * break_state -1=set break condition, 0=clear */ -static void set_break(struct tty_struct *tty, int break_state) +static int set_break(struct tty_struct *tty, int break_state) { struct slgt_info *info = tty->driver_data; unsigned short value; unsigned long flags; if (sanity_check(info, tty->name, "set_break")) - return; + return -EINVAL; DBGINFO(("%s set_break(%d)\n", info->device_name, break_state)); spin_lock_irqsave(&info->lock,flags); @@ -1470,6 +1470,7 @@ static void set_break(struct tty_struct *tty, int break_state) value &= ~BIT6; wr_reg16(info, TCR, value); spin_unlock_irqrestore(&info->lock,flags); + return 0; } #if SYNCLINK_GENERIC_HDLC diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 5768c413634..c0490cbd0db 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -527,7 +527,7 @@ static int read_proc(char *page, char **start, off_t off, int count,int *eof, v static int chars_in_buffer(struct tty_struct *tty); static void throttle(struct tty_struct * tty); static void unthrottle(struct tty_struct * tty); -static void set_break(struct tty_struct *tty, int break_state); +static int set_break(struct tty_struct *tty, int break_state); #if SYNCLINK_GENERIC_HDLC #define dev_to_port(D) (dev_to_hdlc(D)->priv) @@ -552,7 +552,7 @@ static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); static int tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); -static void set_break(struct tty_struct *tty, int break_state); +static int set_break(struct tty_struct *tty, int break_state); static void add_device(SLMP_INFO *info); static void device_init(int adapter_num, struct pci_dev *pdev); @@ -1587,7 +1587,7 @@ static void unthrottle(struct tty_struct * tty) /* set or clear transmit break condition * break_state -1=set break condition, 0=clear */ -static void set_break(struct tty_struct *tty, int break_state) +static int set_break(struct tty_struct *tty, int break_state) { unsigned char RegValue; SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; @@ -1598,7 +1598,7 @@ static void set_break(struct tty_struct *tty, int break_state) __FILE__,__LINE__, info->device_name, break_state); if (sanity_check(info, tty->name, "set_break")) - return; + return -EINVAL; spin_lock_irqsave(&info->lock,flags); RegValue = read_reg(info, CTL); @@ -1608,6 +1608,7 @@ static void set_break(struct tty_struct *tty, int break_state) RegValue &= ~BIT3; write_reg(info, CTL, RegValue); spin_unlock_irqrestore(&info->lock,flags); + return 0; } #if SYNCLINK_GENERIC_HDLC diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index d27a08b374d..d94cd8410c5 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2849,16 +2849,29 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) static int send_break(struct tty_struct *tty, unsigned int duration) { - if (tty_write_lock(tty, 0) < 0) - return -EINTR; - tty->ops->break_ctl(tty, -1); - if (!signal_pending(current)) - msleep_interruptible(duration); - tty->ops->break_ctl(tty, 0); - tty_write_unlock(tty); - if (signal_pending(current)) - return -EINTR; - return 0; + int retval; + + if (tty->ops->break_ctl == NULL) + return 0; + + if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK) + retval = tty->ops->break_ctl(tty, duration); + else { + /* Do the work ourselves */ + if (tty_write_lock(tty, 0) < 0) + return -EINTR; + retval = tty->ops->break_ctl(tty, -1); + if (retval) + goto out; + if (!signal_pending(current)) + msleep_interruptible(duration); + retval = tty->ops->break_ctl(tty, 0); +out: + tty_write_unlock(tty); + if (signal_pending(current)) + retval = -EINTR; + } + return retval; } /** @@ -2949,36 +2962,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) tty->driver->subtype == PTY_TYPE_MASTER) real_tty = tty->link; - /* - * Break handling by driver - */ - - retval = -EINVAL; - - if (!tty->ops->break_ctl) { - switch (cmd) { - case TIOCSBRK: - case TIOCCBRK: - if (tty->ops->ioctl) - retval = tty->ops->ioctl(tty, file, cmd, arg); - if (retval != -EINVAL && retval != -ENOIOCTLCMD) - printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name); - return retval; - - /* These two ioctl's always return success; even if */ - /* the driver doesn't support them. */ - case TCSBRK: - case TCSBRKP: - if (!tty->ops->ioctl) - return 0; - retval = tty->ops->ioctl(tty, file, cmd, arg); - if (retval != -EINVAL && retval != -ENOIOCTLCMD) - printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name); - if (retval == -ENOIOCTLCMD) - retval = 0; - return retval; - } - } /* * Factor out some common prep work @@ -3000,6 +2983,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } + /* + * Now do the stuff. + */ switch (cmd) { case TIOCSTI: return tiocsti(tty, p); @@ -3043,12 +3029,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) */ case TIOCSBRK: /* Turn break on, unconditionally */ if (tty->ops->break_ctl) - tty->ops->break_ctl(tty, -1); + return tty->ops->break_ctl(tty, -1); return 0; - case TIOCCBRK: /* Turn break off, unconditionally */ if (tty->ops->break_ctl) - tty->ops->break_ctl(tty, 0); + return tty->ops->break_ctl(tty, 0); return 0; case TCSBRK: /* SVID version: non-zero arg --> no break */ /* non-zero arg means wait for all output data diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index f17ac043b55..69c5afe97f1 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c @@ -85,7 +85,7 @@ static irqreturn_t scc_rx_int(int irq, void *data); static irqreturn_t scc_stat_int(int irq, void *data); static irqreturn_t scc_spcond_int(int irq, void *data); static void scc_setsignals(struct scc_port *port, int dtr, int rts); -static void scc_break_ctl(struct tty_struct *tty, int break_state); +static int scc_break_ctl(struct tty_struct *tty, int break_state); static struct tty_driver *scc_driver; @@ -942,7 +942,7 @@ static int scc_ioctl(struct tty_struct *tty, struct file *file, } -static void scc_break_ctl(struct tty_struct *tty, int break_state) +static int scc_break_ctl(struct tty_struct *tty, int break_state) { struct scc_port *port = (struct scc_port *)tty->driver_data; unsigned long flags; @@ -952,6 +952,7 @@ static void scc_break_ctl(struct tty_struct *tty, int break_state) SCCmod(TX_CTRL_REG, ~TCR_SEND_BREAK, break_state ? TCR_SEND_BREAK : 0); local_irq_restore(flags); + return 0; } diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 8a35029caca..19e005e81fe 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -1302,11 +1302,12 @@ static void capinc_tty_hangup(struct tty_struct *tty) #endif } -static void capinc_tty_break_ctl(struct tty_struct *tty, int state) +static int capinc_tty_break_ctl(struct tty_struct *tty, int state) { #ifdef _DEBUG_TTYFUNCS printk(KERN_DEBUG "capinc_tty_break_ctl(%d)\n", state); #endif + return 0; } static void capinc_tty_flush_buffer(struct tty_struct *tty) diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 0bce1fe2c62..f977c98cfa9 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -934,7 +934,7 @@ uart_tiocmset(struct tty_struct *tty, struct file *file, return ret; } -static void uart_break_ctl(struct tty_struct *tty, int break_state) +static int uart_break_ctl(struct tty_struct *tty, int break_state) { struct uart_state *state = tty->driver_data; struct uart_port *port = state->port; @@ -945,6 +945,7 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state) port->ops->break_ctl(port, break_state); mutex_unlock(&state->mutex); + return 0; } static int uart_do_autoconfig(struct uart_state *state) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 95ae6377d7e..0725b1871f2 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -732,13 +732,16 @@ static void acm_tty_unthrottle(struct tty_struct *tty) tasklet_schedule(&acm->urb_task); } -static void acm_tty_break_ctl(struct tty_struct *tty, int state) +static int acm_tty_break_ctl(struct tty_struct *tty, int state) { struct acm *acm = tty->driver_data; + int retval; if (!ACM_READY(acm)) - return; - if (acm_send_break(acm, state ? 0xffff : 0)) + return -EINVAL; + retval = acm_send_break(acm, state ? 0xffff : 0); + if (retval < 0) dbg("send break failed"); + return retval; } static int acm_tty_tiocmget(struct tty_struct *tty, struct file *file) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 51917b0f079..8c2d531eede 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -395,7 +395,7 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) tty_termios_copy_hw(tty->termios, old); } -static void serial_break(struct tty_struct *tty, int break_state) +static int serial_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; @@ -409,6 +409,7 @@ static void serial_break(struct tty_struct *tty, int break_state) port->serial->type->break_ctl(tty, break_state); unlock_kernel(); } + return 0; } static int serial_read_proc(char *page, char **start, off_t off, int count, diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index d2a00358676..e1065ac0d92 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -135,7 +135,7 @@ * * Optional: * - * void (*break_ctl)(struct tty_stuct *tty, int state); + * int (*break_ctl)(struct tty_stuct *tty, int state); * * This optional routine requests the tty driver to turn on or * off BREAK status on the RS-232 port. If state is -1, @@ -146,6 +146,10 @@ * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, * TIOCCBRK. * + * If the driver sets TTY_DRIVER_HARDWARE_BREAK then the interface + * will also be called with actual times and the hardware is expected + * to do the delay work itself. 0 and -1 are still used for on/off. + * * Optional: Required for TCSBRK/BRKP/etc handling. * * void (*wait_until_sent)(struct tty_struct *tty, int timeout); @@ -192,7 +196,7 @@ struct tty_operations { void (*stop)(struct tty_struct *tty); void (*start)(struct tty_struct *tty); void (*hangup)(struct tty_struct *tty); - void (*break_ctl)(struct tty_struct *tty, int state); + int (*break_ctl)(struct tty_struct *tty, int state); void (*flush_buffer)(struct tty_struct *tty); void (*set_ldisc)(struct tty_struct *tty); void (*wait_until_sent)(struct tty_struct *tty, int timeout); @@ -285,12 +289,18 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line); * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead * use dynamic memory keyed through the devpts filesystem. This * is only applicable to the pty driver. + * + * TTY_DRIVER_HARDWARE_BREAK -- hardware handles break signals. Pass + * the requested timeout to the caller instead of using a simple + * on/off interface. + * */ #define TTY_DRIVER_INSTALLED 0x0001 #define TTY_DRIVER_RESET_TERMIOS 0x0002 #define TTY_DRIVER_REAL_RAW 0x0004 #define TTY_DRIVER_DYNAMIC_DEV 0x0008 #define TTY_DRIVER_DEVPTS_MEM 0x0010 +#define TTY_DRIVER_HARDWARE_BREAK 0x0020 /* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001 -- cgit v1.2.3-70-g09d2 From 6069fb2ef5d4f47432359c97f350e0cfcc4d208e Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 22 Jul 2008 19:06:00 -0700 Subject: Re-delete zombie 'drivers/usb/serial/airprime.c' file Stephen Rothwell points out that this file got deleted (on purpose) by commit 640c1bce86d1e11ee6a1263fdf6170d3210b1684 ("USB: delete airprime driver"), but then almost immediately incorrectly resurrected by commit 95da310e66ee8090119596c70ca8432e57f9a97f ("usb_serial: API all change"). Delete it again. If it comes back, we'll need to drive a stake through its heart. Reported-by: Stephen Rothwell Acked-by: Greg KH Cc: Alan Cox Cc: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/usb/serial/airprime.c | 355 ------------------------------------------ 1 file changed, 355 deletions(-) delete mode 100644 drivers/usb/serial/airprime.c (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c deleted file mode 100644 index b3f1d1e8246..00000000000 --- a/drivers/usb/serial/airprime.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * AirPrime CDMA Wireless Serial USB driver - * - * Copyright (C) 2005-2006 Greg Kroah-Hartman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include - -static struct usb_device_id id_table [] = { - { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ - { }, -}; -MODULE_DEVICE_TABLE(usb, id_table); - -#define URB_TRANSFER_BUFFER_SIZE 4096 -#define NUM_READ_URBS 4 -#define NUM_WRITE_URBS 4 -#define NUM_BULK_EPS 3 -#define MAX_BULK_EPS 6 - -/* if overridden by the user, then use their value for the size of the - * read and write urbs, and the number of endpoints */ -static int buffer_size = URB_TRANSFER_BUFFER_SIZE; -static int endpoints = NUM_BULK_EPS; -static int debug; -struct airprime_private { - spinlock_t lock; - int outstanding_urbs; - int throttled; - struct urb *read_urbp[NUM_READ_URBS]; - - /* Settings for the port */ - int rts_state; /* Handshaking pins (outputs) */ - int dtr_state; - int cts_state; /* Handshaking pins (inputs) */ - int dsr_state; - int dcd_state; - int ri_state; -}; - -static int airprime_send_setup(struct usb_serial_port *port) -{ - struct usb_serial *serial = port->serial; - struct airprime_private *priv; - - dbg("%s", __func__); - - if (port->number != 0) - return 0; - - priv = usb_get_serial_port_data(port); - - if (port->port.tty) { - int val = 0; - if (priv->dtr_state) - val |= 0x01; - if (priv->rts_state) - val |= 0x02; - - return usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - 0x22, 0x21, val, 0, NULL, 0, - USB_CTRL_SET_TIMEOUT); - } - - return 0; -} - -static void airprime_read_bulk_callback(struct urb *urb) -{ - struct usb_serial_port *port = urb->context; - unsigned char *data = urb->transfer_buffer; - struct tty_struct *tty; - int result; - int status = urb->status; - - dbg("%s - port %d", __func__, port->number); - - if (status) { - dbg("%s - nonzero read bulk status received: %d", - __func__, status); - return; - } - usb_serial_debug_data(debug, &port->dev, __func__, - urb->actual_length, data); - - tty = port->port.tty; - if (tty && urb->actual_length) { - tty_insert_flip_string(tty, data, urb->actual_length); - tty_flip_buffer_push(tty); - } - - result = usb_submit_urb(urb, GFP_ATOMIC); - if (result) - dev_err(&port->dev, - "%s - failed resubmitting read urb, error %d\n", - __func__, result); - return; -} - -static void airprime_write_bulk_callback(struct urb *urb) -{ - struct usb_serial_port *port = urb->context; - struct airprime_private *priv = usb_get_serial_port_data(port); - int status = urb->status; - unsigned long flags; - - dbg("%s - port %d", __func__, port->number); - - /* free up the transfer buffer, as usb_free_urb() does not do this */ - kfree(urb->transfer_buffer); - - if (status) - dbg("%s - nonzero write bulk status received: %d", - __func__, status); - spin_lock_irqsave(&priv->lock, flags); - --priv->outstanding_urbs; - spin_unlock_irqrestore(&priv->lock, flags); - - usb_serial_port_softint(port); -} - -static int airprime_open(struct tty_struct *tty, struct usb_serial_port *port, - struct file *filp) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - struct urb *urb; - char *buffer = NULL; - int i; - int result = 0; - - dbg("%s - port %d", __func__, port->number); - - /* initialize our private data structure if it isn't already created */ - if (!priv) { - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) { - result = -ENOMEM; - goto out; - } - spin_lock_init(&priv->lock); - usb_set_serial_port_data(port, priv); - } - - /* Set some sane defaults */ - priv->rts_state = 1; - priv->dtr_state = 1; - - for (i = 0; i < NUM_READ_URBS; ++i) { - buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!buffer) { - dev_err(&port->dev, "%s - out of memory.\n", - __func__); - result = -ENOMEM; - goto errout; - } - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) { - kfree(buffer); - dev_err(&port->dev, "%s - no more urbs?\n", - __func__); - result = -ENOMEM; - goto errout; - } - usb_fill_bulk_urb(urb, serial->dev, - usb_rcvbulkpipe(serial->dev, - port->bulk_out_endpointAddress), - buffer, buffer_size, - airprime_read_bulk_callback, port); - result = usb_submit_urb(urb, GFP_KERNEL); - if (result) { - usb_free_urb(urb); - kfree(buffer); - dev_err(&port->dev, - "%s - failed submitting read urb %d for port %d, error %d\n", - __func__, i, port->number, result); - goto errout; - } - /* remember this urb so we can kill it when the - port is closed */ - priv->read_urbp[i] = urb; - } - - airprime_send_setup(port); - - goto out; - - errout: - /* some error happened, cancel any submitted urbs and clean up - anything that got allocated successfully */ - - while (i-- != 0) { - urb = priv->read_urbp[i]; - buffer = urb->transfer_buffer; - usb_kill_urb(urb); - usb_free_urb(urb); - kfree(buffer); - } - - out: - return result; -} - -static void airprime_close(struct tty_struct *tty, - struct usb_serial_port *port, struct file *filp) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - int i; - - dbg("%s - port %d", __func__, port->number); - - priv->rts_state = 0; - priv->dtr_state = 0; - - mutex_lock(&port->serial->disc_mutex); - if (!port->serial->disconnected) - airprime_send_setup(port); - mutex_unlock(&port->serial->disc_mutex); - - for (i = 0; i < NUM_READ_URBS; ++i) { - usb_kill_urb(priv->read_urbp[i]); - kfree(priv->read_urbp[i]->transfer_buffer); - usb_free_urb(priv->read_urbp[i]); - } - - /* free up private structure */ - kfree(priv); - usb_set_serial_port_data(port, NULL); -} - -static int airprime_write(struct tty_struct *tty, struct usb_serial_port *port, - const unsigned char *buf, int count) -{ - struct airprime_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - struct urb *urb; - unsigned char *buffer; - unsigned long flags; - int status; - dbg("%s - port %d", __func__, port->number); - - spin_lock_irqsave(&priv->lock, flags); - if (priv->outstanding_urbs > NUM_WRITE_URBS) { - spin_unlock_irqrestore(&priv->lock, flags); - dbg("%s - write limit hit\n", __func__); - return 0; - } - spin_unlock_irqrestore(&priv->lock, flags); - buffer = kmalloc(count, GFP_ATOMIC); - if (!buffer) { - dev_err(&port->dev, "out of memory\n"); - return -ENOMEM; - } - urb = usb_alloc_urb(0, GFP_ATOMIC); - if (!urb) { - dev_err(&port->dev, "no more free urbs\n"); - kfree(buffer); - return -ENOMEM; - } - memcpy(buffer, buf, count); - - usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); - - usb_fill_bulk_urb(urb, serial->dev, - usb_sndbulkpipe(serial->dev, - port->bulk_out_endpointAddress), - buffer, count, - airprime_write_bulk_callback, port); - - /* send it down the pipe */ - status = usb_submit_urb(urb, GFP_ATOMIC); - if (status) { - dev_err(&port->dev, - "%s - usb_submit_urb(write bulk) failed with status = %d\n", - __func__, status); - count = status; - kfree(buffer); - } else { - spin_lock_irqsave(&priv->lock, flags); - ++priv->outstanding_urbs; - spin_unlock_irqrestore(&priv->lock, flags); - } - /* we are done with this urb, so let the host driver - * really free it when it is finished with it */ - usb_free_urb(urb); - return count; -} - -static struct usb_driver airprime_driver = { - .name = "airprime", - .probe = usb_serial_probe, - .disconnect = usb_serial_disconnect, - .id_table = id_table, - .no_dynamic_id = 1, -}; - -static struct usb_serial_driver airprime_device = { - .driver = { - .owner = THIS_MODULE, - .name = "airprime", - }, - .usb_driver = &airprime_driver, - .id_table = id_table, - .open = airprime_open, - .close = airprime_close, - .write = airprime_write, -}; - -static int __init airprime_init(void) -{ - int retval; - - airprime_device.num_ports = endpoints; - if (endpoints < 0 || endpoints >= MAX_BULK_EPS) - airprime_device.num_ports = NUM_BULK_EPS; - - retval = usb_serial_register(&airprime_device); - if (retval) - return retval; - retval = usb_register(&airprime_driver); - if (retval) - usb_serial_deregister(&airprime_device); - return retval; -} - -static void __exit airprime_exit(void) -{ - dbg("%s", __func__); - - usb_deregister(&airprime_driver); - usb_serial_deregister(&airprime_device); -} - -module_init(airprime_init); -module_exit(airprime_exit); -MODULE_LICENSE("GPL"); - -module_param(debug, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "Debug enabled"); -module_param(buffer_size, int, 0); -MODULE_PARM_DESC(buffer_size, - "Size of the transfer buffers in bytes (default 4096)"); -module_param(endpoints, int, 0); -MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); -- cgit v1.2.3-70-g09d2 From 852fef69c0d9510a28a70221cfddd004efa02552 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Sat, 26 Jul 2008 22:42:42 +0200 Subject: fix for a memory leak in an error case introduced by fix for double free The fix NULLed a pointer without freeing it. Signed-off-by: Oliver Neukum Reported-by: Juha Motorsportcom Signed-off-by: Linus Torvalds --- drivers/usb/serial/ipaq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 832a5a4f3cb..cd9a2e138c8 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -651,15 +651,17 @@ static int ipaq_open(struct tty_struct *tty, */ kfree(port->bulk_in_buffer); + kfree(port->bulk_out_buffer); + /* make sure the generic serial code knows */ + port->bulk_out_buffer = NULL; + port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); - if (port->bulk_in_buffer == NULL) { - port->bulk_out_buffer = NULL; /* prevent double free */ + if (port->bulk_in_buffer == NULL) goto enomem; - } - kfree(port->bulk_out_buffer); port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); if (port->bulk_out_buffer == NULL) { + /* the buffer is useless, free it */ kfree(port->bulk_in_buffer); port->bulk_in_buffer = NULL; goto enomem; -- cgit v1.2.3-70-g09d2 From b5894a500127fce1db1309db5f9ca8b77a2ac266 Mon Sep 17 00:00:00 2001 From: André Schenk Date: Mon, 28 Jul 2008 15:48:46 +0200 Subject: USB: ftdi_sio: Add USB Product Id for ELV HS485 USB product id registration for the ELV HS485 USB adapter (www.elv.de) to their home automation bus system. Applies to 2.6.26. Signed-off-by: Andre Schenk Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 83871725014..974e0eb5e75 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -563,6 +563,7 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_ELV_HS485_PID) }, { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index a577ea44dcf..68927107cd9 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -524,6 +524,7 @@ #define FTDI_ELV_WS300PC_PID 0xE0F6 /* PC-Wetterstation (WS 300 PC) */ #define FTDI_ELV_FHZ1300PC_PID 0xE0E8 /* FHZ 1300 PC */ #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ +#define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */ #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ /* -- cgit v1.2.3-70-g09d2 From a00c3cadc2bf50b3c925acdb3d0e5789b1650498 Mon Sep 17 00:00:00 2001 From: Frederik Kriewitz Date: Wed, 30 Jul 2008 16:53:41 +0200 Subject: USB: ftdi_sio: add support for Luminance Stellaris Evaluation/Development Kits The Patch adds support for Luminance Stellaris Evaluation/Development Kits (FTDI 2232C based). The PIDs were missing. Successfully tested with a Stellaris LM3S8962 Evaluation kit. Signed-off-by: Frederik Kriewitz Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 4 ++++ drivers/usb/serial/ftdi_sio.h | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 974e0eb5e75..54407351d7e 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -647,6 +647,10 @@ static struct usb_device_id id_table_combined [] = { .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, + { USB_DEVICE(FTDI_VID, LMI_LM3S_DEVEL_BOARD_PID), + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, + { USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID), + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, { }, /* Optional parameter entry */ diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 68927107cd9..7ca2ad0157f 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -816,6 +816,11 @@ #define OLIMEX_VID 0x15BA #define OLIMEX_ARM_USB_OCD_PID 0x0003 +/* Luminary Micro Stellaris Boards, VID = FTDI_VID */ +/* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */ +#define LMI_LM3S_DEVEL_BOARD_PID 0xbcd8 +#define LMI_LM3S_EVAL_BOARD_PID 0xbcd9 + /* www.elsterelectricity.com Elster Unicom III Optical Probe */ #define FTDI_ELSTER_UNICOM_PID 0xE700 /* Product Id */ -- cgit v1.2.3-70-g09d2 From 0282b7f2a874e72c18fcd5a112ccf67f71ba7f5c Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 29 Jul 2008 12:01:04 -0400 Subject: usb-serial: don't release unregistered minors This patch (as1121) fixes a bug in the USB serial core. When a device is unregistered, the core will give back its minors -- even if the device hasn't been assigned any! The patch reserves the highest minor value (255) to mean that no minor was assigned. It also removes some dead code and does a small style fixup. Signed-off-by: Alan Stern Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 7 +++---- include/linux/usb/serial.h | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 8c2d531eede..b157c48e8b7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -122,9 +122,6 @@ static void return_serial(struct usb_serial *serial) dbg("%s", __func__); - if (serial == NULL) - return; - for (i = 0; i < serial->num_ports; ++i) serial_table[serial->minor + i] = NULL; } @@ -142,7 +139,8 @@ static void destroy_serial(struct kref *kref) serial->type->shutdown(serial); /* return the minor range that this device had */ - return_serial(serial); + if (serial->minor != SERIAL_TTY_NO_MINOR) + return_serial(serial); for (i = 0; i < serial->num_ports; ++i) serial->port[i]->port.count = 0; @@ -575,6 +573,7 @@ static struct usb_serial *create_serial(struct usb_device *dev, serial->interface = interface; kref_init(&serial->kref); mutex_init(&serial->disc_mutex); + serial->minor = SERIAL_TTY_NO_MINOR; return serial; } diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 09a3e6a7518..655341d0f53 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -17,7 +17,8 @@ #include #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ -#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ +#define SERIAL_TTY_MINORS 254 /* loads of devices :) */ +#define SERIAL_TTY_NO_MINOR 255 /* No minor was assigned */ /* The maximum number of ports one device can grab at once */ #define MAX_NUM_PORTS 8 -- cgit v1.2.3-70-g09d2 From 8c809681ba0289afd0ed7bbb63679a0568dd441d Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Tue, 22 Jul 2008 09:28:05 +0200 Subject: USB: pl2023: Remove USB id (4348:5523) handled by ch341 USB ID 4348:5523 is handled by the ch341 driver. Remove it from the pl2023 driver. Reverts 002e8f2c80c6be76bb312940bc278fc10b2b2487. Signed-off-by: Tollef Fog Heen Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/pl2303.c | 1 - drivers/usb/serial/pl2303.h | 4 ---- 2 files changed, 5 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 2c9c446ad62..1ede1441cb1 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -90,7 +90,6 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, - { USB_DEVICE(HL340_VENDOR_ID, HL340_PRODUCT_ID) }, { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, { } /* Terminating entry */ }; diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index 6ac3bbcf7a2..a3bd039c78e 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h @@ -107,10 +107,6 @@ #define COREGA_VENDOR_ID 0x07aa #define COREGA_PRODUCT_ID 0x002a -/* HL HL-340 (ID: 4348:5523) */ -#define HL340_VENDOR_ID 0x4348 -#define HL340_PRODUCT_ID 0x5523 - /* Y.C. Cable U.S.A., Inc - USB to RS-232 */ #define YCCABLE_VENDOR_ID 0x05ad #define YCCABLE_PRODUCT_ID 0x0fba -- cgit v1.2.3-70-g09d2 From 4e0fee82619937acb13806ffc901d3920b947286 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Date: Thu, 10 Jul 2008 14:14:47 -0700 Subject: USB Serial Sierra: clean-up Very minor changes to clean up sierra code. Adds a prefix to debug messages so that Sierra messages are easily recognized. Removes extraneous code. This targets kernel 2.6.26-rc9 Signed-off-by: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 56 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 2f6f1523ec5..a3aaf08e56d 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -51,7 +51,7 @@ enum devicetype { static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) { int result; - dev_dbg(&udev->dev, "%s", "SET POWER STATE\n"); + dev_dbg(&udev->dev, "%s", __func__); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetPower, /* __u8 request */ USB_TYPE_VENDOR, /* __u8 request type */ @@ -66,7 +66,7 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) { int result; - dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH\n"); + dev_dbg(&udev->dev, "%s", __func__); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetMode, /* __u8 request */ USB_TYPE_VENDOR, /* __u8 request type */ @@ -81,7 +81,7 @@ static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) { int result; - dev_dbg(&udev->dev, "%s", "NMEA Enable sent\n"); + dev_dbg(&udev->dev, "%s", __func__); result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), SWIMS_USB_REQUEST_SetNmea, /* __u8 request */ USB_TYPE_VENDOR, /* __u8 request type */ @@ -97,6 +97,7 @@ static int sierra_calc_num_ports(struct usb_serial *serial) { int result; int *num_ports = usb_get_serial_data(serial); + dev_dbg(&serial->dev->dev, "%s", __func__); result = *num_ports; @@ -110,22 +111,23 @@ static int sierra_calc_num_ports(struct usb_serial *serial) static int sierra_calc_interface(struct usb_serial *serial) { - int interface; - struct usb_interface *p_interface; - struct usb_host_interface *p_host_interface; + int interface; + struct usb_interface *p_interface; + struct usb_host_interface *p_host_interface; + dev_dbg(&serial->dev->dev, "%s", __func__); - /* Get the interface structure pointer from the serial struct */ - p_interface = serial->interface; + /* Get the interface structure pointer from the serial struct */ + p_interface = serial->interface; - /* Get a pointer to the host interface structure */ - p_host_interface = p_interface->cur_altsetting; + /* Get a pointer to the host interface structure */ + p_host_interface = p_interface->cur_altsetting; - /* read the interface descriptor for this active altsetting - * to find out the interface number we are on - */ - interface = p_host_interface->desc.bInterfaceNumber; + /* read the interface descriptor for this active altsetting + * to find out the interface number we are on + */ + interface = p_host_interface->desc.bInterfaceNumber; - return interface; + return interface; } static int sierra_probe(struct usb_serial *serial, @@ -135,6 +137,7 @@ static int sierra_probe(struct usb_serial *serial, struct usb_device *udev; int *num_ports; u8 ifnum; + dev_dbg(&serial->dev->dev, "%s", __func__); num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); if (!num_ports) @@ -187,24 +190,26 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ + { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ - { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, /* Sierra Wireless C597 */ + /* Sierra Wireless C597 */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ - { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ + { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Lenovo) */ { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */ { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */ { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ - { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ - { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ - { USB_DEVICE(0x1199, 0x683B), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless MC8785 Composite*/ + { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ + { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ + { USB_DEVICE(0x1199, 0x683B), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless MC8785 Composite */ { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ @@ -214,9 +219,6 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x6859), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ { USB_DEVICE(0x1199, 0x685A), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ - { USB_DEVICE(0x1199, 0x6468) }, /* Sierra Wireless MP3G - EVDO */ - { USB_DEVICE(0x1199, 0x6469) }, /* Sierra Wireless MP3G - UMTS/HSPA */ - { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ @@ -713,7 +715,7 @@ static void sierra_shutdown(struct usb_serial *serial) static struct usb_serial_driver sierra_device = { .driver = { .owner = THIS_MODULE, - .name = "sierra1", + .name = "sierra", }, .description = "Sierra USB modem", .id_table = id_table, @@ -769,14 +771,10 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); -module_param(truinstall, bool, 0); -MODULE_PARM_DESC(truinstall, "TRU-Install support"); - -module_param(nmea, bool, 0); +module_param(nmea, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(nmea, "NMEA streaming"); #ifdef CONFIG_USB_DEBUG module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug messages"); #endif - -- cgit v1.2.3-70-g09d2 From e3173b22eb7b50a23af60e12bab7a29d4b24f284 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Date: Thu, 10 Jul 2008 14:14:51 -0700 Subject: USB Serial Sierra: Dynamic interface detection This patch changes the method by which the number of ports per interface is assigned so that it is more dynamic and calculated on the fly (as opposed to hard coding it). This will allow for faster and easier addition of products. Signed-off-by: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 83 ++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 31 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index a3aaf08e56d..e2a7463346f 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -137,6 +137,8 @@ static int sierra_probe(struct usb_serial *serial, struct usb_device *udev; int *num_ports; u8 ifnum; + u8 numendpoints; + dev_dbg(&serial->dev->dev, "%s", __func__); num_ports = kmalloc(sizeof(*num_ports), GFP_KERNEL); @@ -144,23 +146,22 @@ static int sierra_probe(struct usb_serial *serial, return -ENOMEM; ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; + numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints; udev = serial->dev; - /* Figure out the interface number from the serial structure */ - ifnum = sierra_calc_interface(serial); - - /* - * If this interface supports more than 1 alternate - * select the 2nd one - */ - if (serial->interface->num_altsetting == 2) { - dev_dbg(&udev->dev, - "Selecting alt setting for interface %d\n", - ifnum); + /* Figure out the interface number from the serial structure */ + ifnum = sierra_calc_interface(serial); - /* We know the alternate setting is 1 for the MC8785 */ - usb_set_interface(udev, ifnum, 1); - } + /* + * If this interface supports more than 1 alternate + * select the 2nd one + */ + if (serial->interface->num_altsetting == 2) { + dev_dbg(&udev->dev, "Selecting alt setting for interface %d\n", + ifnum); + /* We know the alternate setting is 1 for the MC8785 */ + usb_set_interface(udev, ifnum, 1); + } /* Check if in installer mode */ if (truinstall && id->driver_info == DEVICE_INSTALLER) { @@ -169,12 +170,14 @@ static int sierra_probe(struct usb_serial *serial, /* Don't bind to the device when in installer mode */ kfree(num_ports); return -EIO; - } else if (id->driver_info == DEVICE_1_PORT) - *num_ports = 1; - else if (ifnum == 0x99) + /* Dummy interface present on some SKUs should be ignored */ + } else if (ifnum == 0x99) *num_ports = 0; + else if (numendpoints <= 3) + *num_ports = 1; else - *num_ports = 3; + *num_ports = (numendpoints-1)/2; + /* * save off our num_ports info so that we can use it in the * calc_num_ports callback @@ -197,6 +200,9 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ /* Sierra Wireless C597 */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, + /* Sierra Wireless Device */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, + { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ @@ -209,18 +215,27 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ - { USB_DEVICE(0x1199, 0x683B), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless MC8785 Composite */ + { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ + { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ + { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ + { USB_DEVICE(0x1199, 0x683E) }, /* Sierra Wireless MC8790 */ { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */ { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */ - { USB_DEVICE(0x1199, 0x6859), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ - { USB_DEVICE(0x1199, 0x685A), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 885 E */ - - { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ - { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ + { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */ + { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */ + /* Sierra Wireless C885 */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)}, + /* Sierra Wireless Device */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, + /* Sierra Wireless Device */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, + + { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ + { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, { } @@ -270,13 +285,19 @@ static int sierra_send_setup(struct tty_struct *tty, if (portdata->rts_state) val |= 0x02; - /* Determine which port is targeted */ - if (port->bulk_out_endpointAddress == 2) - interface = 0; - else if (port->bulk_out_endpointAddress == 4) - interface = 1; - else if (port->bulk_out_endpointAddress == 5) - interface = 2; + /* If composite device then properly report interface */ + if (serial->num_ports == 1) + interface = sierra_calc_interface(serial); + + /* Otherwise the need to do non-composite mapping */ + else { + if (port->bulk_out_endpointAddress == 2) + interface = 0; + else if (port->bulk_out_endpointAddress == 4) + interface = 1; + else if (port->bulk_out_endpointAddress == 5) + interface = 2; + } return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), -- cgit v1.2.3-70-g09d2 From 0585e4dfe5670d3ccb77bf86551a657699e9e52e Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Date: Thu, 10 Jul 2008 14:14:54 -0700 Subject: USB Serial Sierra: TRU-Install feature update Moves responsbility of TRU-Install (i.e. ZeroCD) to the usb-storage driver. See patch 04/04 of this set. Signed-off-by: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/Kconfig | 7 ++++--- drivers/usb/serial/sierra.c | 35 +++-------------------------------- 2 files changed, 7 insertions(+), 35 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 8878c1767fc..70338f4ec91 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -499,9 +499,10 @@ config USB_SERIAL_SAFE_PADDED config USB_SERIAL_SIERRAWIRELESS tristate "USB Sierra Wireless Driver" help - Say M here if you want to use a Sierra Wireless device (if - using an PC 5220 or AC580 please use the Airprime driver - instead). + Say M here if you want to use Sierra Wireless devices. + + Many deviecs have a feature known as TRU-Install, for those devices + to work properly the USB Storage Sierra feature must be enabled. To compile this driver as a module, choose M here: the module will be called sierra. diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index e2a7463346f..6b7ed333386 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -14,7 +14,7 @@ Whom based his on the Keyspan driver by Hugh Blemings */ -#define DRIVER_VERSION "v.1.2.9c" +#define DRIVER_VERSION "v.1.2.13a" #define DRIVER_AUTHOR "Kevin Lloyd " #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" @@ -31,6 +31,7 @@ #define SWIMS_USB_REQUEST_SetPower 0x00 #define SWIMS_USB_REQUEST_SetNmea 0x07 #define SWIMS_USB_REQUEST_SetMode 0x0B +#define SWIMS_USB_REQUEST_GetSwocInfo 0x0A #define SWIMS_SET_MODE_Modem 0x0001 /* per port private data */ @@ -40,13 +41,6 @@ static int debug; static int nmea; -static int truinstall = 1; - -enum devicetype { - DEVICE_3_PORT = 0, - DEVICE_1_PORT = 1, - DEVICE_INSTALLER = 2, -}; static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) { @@ -63,21 +57,6 @@ static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) return result; } -static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSWocMode) -{ - int result; - dev_dbg(&udev->dev, "%s", __func__); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - SWIMS_USB_REQUEST_SetMode, /* __u8 request */ - USB_TYPE_VENDOR, /* __u8 request type */ - eSWocMode, /* __u16 value */ - 0x0000, /* __u16 index */ - NULL, /* void *data */ - 0, /* __u16 size */ - USB_CTRL_SET_TIMEOUT); /* int timeout */ - return result; -} - static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable) { int result; @@ -163,15 +142,8 @@ static int sierra_probe(struct usb_serial *serial, usb_set_interface(udev, ifnum, 1); } - /* Check if in installer mode */ - if (truinstall && id->driver_info == DEVICE_INSTALLER) { - dev_dbg(&udev->dev, "%s", "FOUND TRU-INSTALL DEVICE(SW)\n"); - result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); - /* Don't bind to the device when in installer mode */ - kfree(num_ports); - return -EIO; /* Dummy interface present on some SKUs should be ignored */ - } else if (ifnum == 0x99) + if (ifnum == 0x99) *num_ports = 0; else if (numendpoints <= 3) *num_ports = 1; @@ -237,7 +209,6 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ - { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, { } }; MODULE_DEVICE_TABLE(usb, id_table); -- cgit v1.2.3-70-g09d2 From a5f6239949de78a9f33120d76f084928cb234a15 Mon Sep 17 00:00:00 2001 From: Lex Ross Date: Wed, 6 Aug 2008 16:25:08 +0400 Subject: USB: ftdi_sio: add support for PHI Fisco data cable (FT232BM based, VID/PID 0403:e40b) Support for PHI Fisco USB to Serial data cable (FTDI FT232BM based). PHI Fisco cable is supplied for connecting Philips Xenium 9@9++ mobile phones. PIDs were missing. Tested successfully with PHI Fisco Data Cable (VID/PID 0403:e40b) Signed-off-by: Lex V. Ross Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 54407351d7e..984f6eff4c4 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -638,6 +638,7 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ELSTER_UNICOM_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PROPOX_JTAGCABLEII_PID) }, diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 7ca2ad0157f..382265bba96 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -526,6 +526,7 @@ #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */ #define FTDI_ELV_HS485_PID 0xE0EA /* USB to RS-485 adapter */ #define FTDI_ELV_EM1010PC_PID 0xE0EF /* Engery monitor EM 1010 PC */ +#define FTDI_PHI_FISCO_PID 0xE40B /* PHI Fisco USB to Serial cable */ /* * Definitions for ID TECH (www.idt-net.com) devices -- cgit v1.2.3-70-g09d2 From bf3fc82895f4f501da9daef44d057749fe900c3e Mon Sep 17 00:00:00 2001 From: Leon Leong Date: Fri, 1 Aug 2008 11:40:12 +0800 Subject: USB: BandRich BandLuxe C150/C250 HSPA Data Card Driver This patch adds the Product ID for the BandLuxe C150/C250 3.5G data card series from BandRich Inc. After detection, the data card works fine. It was patched against kernel 2.6.27-rc1 with -mm patch Signed-off-by: Leon Leong Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e4eca95f2b0..e7753ccaf70 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -186,6 +186,23 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po #define BANDRICH_VENDOR_ID 0x1A8D #define BANDRICH_PRODUCT_C100_1 0x1002 #define BANDRICH_PRODUCT_C100_2 0x1003 +#define BANDRICH_PRODUCT_1004 0x1004 +#define BANDRICH_PRODUCT_1005 0x1005 +#define BANDRICH_PRODUCT_1006 0x1006 +#define BANDRICH_PRODUCT_1007 0x1007 +#define BANDRICH_PRODUCT_1008 0x1008 +#define BANDRICH_PRODUCT_1009 0x1009 +#define BANDRICH_PRODUCT_100A 0x100a + +#define BANDRICH_PRODUCT_100B 0x100b +#define BANDRICH_PRODUCT_100C 0x100c +#define BANDRICH_PRODUCT_100D 0x100d +#define BANDRICH_PRODUCT_100E 0x100e + +#define BANDRICH_PRODUCT_100F 0x100f +#define BANDRICH_PRODUCT_1010 0x1010 +#define BANDRICH_PRODUCT_1011 0x1011 +#define BANDRICH_PRODUCT_1012 0x1012 #define AMOI_VENDOR_ID 0x1614 #define AMOI_PRODUCT_9508 0x0800 @@ -302,6 +319,21 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011) }, + { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012) }, { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ -- cgit v1.2.3-70-g09d2 From 6188a83f7264edebe9b8ee10ad7b2136d3531ea6 Mon Sep 17 00:00:00 2001 From: Oliver Martin Date: Sat, 9 Aug 2008 04:49:26 +0200 Subject: USB: Add vendor/product id of ZTE MF628 to option This adds the vendor and product id (19d2:0015) of the ZTE MF628 HSDPA modem to the option driver. It still needs a mode switch command issued beforehand, this is currently handled by a userspace tool. Signed-off-by: Oliver Martin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e7753ccaf70..df472c7480a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -214,6 +214,10 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po #define TELIT_VENDOR_ID 0x1bc7 #define TELIT_PRODUCT_UC864E 0x1003 +/* ZTE PRODUCTS */ +#define ZTE_VENDOR_ID 0x19d2 +#define ZTE_PRODUCT_MF628 0x0015 + static struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, @@ -340,6 +344,7 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, + { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE(usb, option_ids); -- cgit v1.2.3-70-g09d2 From f331e40ee8e4861e1d82310b1af7cf75de7370ac Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 12 Aug 2008 12:04:50 +0700 Subject: USB: serial: remove CONFIG_USB_DEBUG from sierra and option drivers These drivers should not be relying on CONFIG_USB_DEBUG. By doing this, it prevents users of kernels that do not enable this option from enabling debugging in these drivers, unlike all other usb-serial drivers. Cc: Matthias Urlichs Cc: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 7 ------- drivers/usb/serial/sierra.c | 2 -- 2 files changed, 9 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index df472c7480a..e143198aeb0 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -383,11 +383,7 @@ static struct usb_serial_driver option_1port_device = { .read_int_callback = option_instat_callback, }; -#ifdef CONFIG_USB_DEBUG static int debug; -#else -#define debug 0 -#endif /* per port private data */ @@ -991,8 +987,5 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); -#ifdef CONFIG_USB_DEBUG module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug messages"); -#endif - diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 6b7ed333386..706033753ad 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -766,7 +766,5 @@ MODULE_LICENSE("GPL"); module_param(nmea, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(nmea, "NMEA streaming"); -#ifdef CONFIG_USB_DEBUG module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug messages"); -#endif -- cgit v1.2.3-70-g09d2 From f8033827d8e92db6159d34ed45c608522674ecd8 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Tue, 19 Aug 2008 10:58:25 +0200 Subject: usb-serial: option support HSDPA modem A2502 This patch support NTT DoCoMo A2502 3G/HSDPA modem on option driver. It is produced by AnyDATA Corp. and also sold as KT Freetelecom (Korea) ADU 620UW. It support 3.6Mbps/7.2Mbps hight speed communication. I have tested A2502 with NTT DoCoMo MoperaU ISP service. Signed-off-by: Hiroshi Miura Signed-off-by: Matthias Urlichs Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index e143198aeb0..9f9cd36455f 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -173,6 +173,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po #define KYOCERA_PRODUCT_KPC680 0x180a #define ANYDATA_VENDOR_ID 0x16d5 +#define ANYDATA_PRODUCT_ADU_620UW 0x6202 #define ANYDATA_PRODUCT_ADU_E100A 0x6501 #define ANYDATA_PRODUCT_ADU_500A 0x6502 @@ -318,6 +319,7 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, + { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) }, { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, -- cgit v1.2.3-70-g09d2 From 7a8fc9b248e77a4eab0613acf30a6811799786b3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 17 Aug 2008 17:36:59 +0300 Subject: removed unused #include 's This patch lets the files using linux/version.h match the files that #include it. Signed-off-by: Adrian Bunk Signed-off-by: Linus Torvalds --- arch/arm/plat-omap/clock.c | 1 - arch/cris/arch-v32/kernel/fasttimer.c | 2 -- arch/mn10300/kernel/mn10300-serial.c | 1 - arch/powerpc/sysdev/bestcomm/gen_bd.c | 1 - arch/x86/mach-rdc321x/platform.c | 1 - drivers/atm/adummy.c | 1 - drivers/char/xilinx_hwicap/buffer_icap.h | 1 - drivers/char/xilinx_hwicap/fifo_icap.h | 1 - drivers/char/xilinx_hwicap/xilinx_hwicap.h | 1 - drivers/edac/edac_core.h | 1 - drivers/i2c/busses/i2c-at91.c | 1 - drivers/infiniband/hw/ehca/ehca_tools.h | 1 - drivers/infiniband/hw/ipath/ipath_fs.c | 1 - drivers/infiniband/hw/nes/nes.h | 1 - drivers/infiniband/ulp/iser/iser_verbs.c | 1 - drivers/input/keyboard/bf54x-keys.c | 1 - drivers/input/touchscreen/mainstone-wm97xx.c | 1 - drivers/mfd/asic3.c | 1 - drivers/misc/eeprom_93cx6.c | 1 - drivers/mtd/maps/amd76xrom.c | 1 - drivers/mtd/maps/ck804xrom.c | 1 - drivers/mtd/maps/esb2rom.c | 1 - drivers/mtd/nand/au1550nd.c | 1 - drivers/net/myri10ge/myri10ge.c | 1 - drivers/net/netxen/netxen_nic.h | 1 - drivers/net/netxen/netxen_nic_ethtool.c | 1 - drivers/net/netxen/netxen_nic_hdr.h | 2 -- drivers/net/tokenring/lanstreamer.c | 1 - drivers/net/tokenring/lanstreamer.h | 2 -- drivers/net/wireless/b43legacy/main.c | 1 - drivers/net/wireless/iwlwifi/iwl-3945-led.c | 1 - drivers/net/wireless/iwlwifi/iwl-led.c | 1 - drivers/net/wireless/iwlwifi/iwl-rfkill.c | 1 - drivers/rtc/rtc-max6902.c | 2 -- drivers/rtc/rtc-r9701.c | 1 - drivers/s390/net/ctcm_mpc.c | 1 - drivers/scsi/dpt/dpti_i2o.h | 1 - drivers/scsi/ips.c | 1 - drivers/scsi/ips.h | 1 - drivers/scsi/lpfc/lpfc_debugfs.c | 1 - drivers/scsi/nsp32.c | 1 - drivers/scsi/nsp32.h | 1 - drivers/scsi/pcmcia/nsp_cs.c | 1 - drivers/scsi/qla2xxx/qla_mid.c | 1 - drivers/usb/atm/ueagle-atm.c | 1 - drivers/usb/gadget/amd5536udc.c | 1 - drivers/usb/gadget/s3c2410_udc.c | 1 - drivers/usb/misc/iowarrior.c | 1 - drivers/usb/serial/garmin_gps.c | 2 -- drivers/video/arkfb.c | 1 - drivers/video/s3fb.c | 1 - drivers/video/vermilion/vermilion.h | 1 - drivers/video/vt8623fb.c | 1 - drivers/video/xilinxfb.c | 1 - fs/jffs2/jffs2_fs_i.h | 1 - fs/xfs/xfs_dmapi.h | 1 - include/asm-x86/xen/hypervisor.h | 1 - include/linux/fs_uart_pd.h | 1 - kernel/nsproxy.c | 1 - kernel/power/swap.c | 1 - kernel/user_namespace.c | 1 - kernel/utsname.c | 1 - kernel/utsname_sysctl.c | 1 - sound/mips/au1x00.c | 1 - sound/soc/at91/eti_b1_wm8731.c | 1 - sound/soc/codecs/wm8753.c | 1 - sound/soc/codecs/wm9712.c | 1 - 67 files changed, 72 deletions(-) (limited to 'drivers/usb/serial') diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c index 23a07059999..197974defbe 100644 --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -10,7 +10,6 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include #include #include #include diff --git a/arch/cris/arch-v32/kernel/fasttimer.c b/arch/cris/arch-v32/kernel/fasttimer.c index 2de9d5849ef..111caa1a2ef 100644 --- a/arch/cris/arch-v32/kernel/fasttimer.c +++ b/arch/cris/arch-v32/kernel/fasttimer.c @@ -19,8 +19,6 @@ #include #include -#include - #include #include #include diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c index 8b054e7a8ae..aa07d0cd190 100644 --- a/arch/mn10300/kernel/mn10300-serial.c +++ b/arch/mn10300/kernel/mn10300-serial.c @@ -17,7 +17,6 @@ static const char serial_revdate[] = "2007-11-06"; #define SUPPORT_SYSRQ #endif -#include #include #include #include diff --git a/arch/powerpc/sysdev/bestcomm/gen_bd.c b/arch/powerpc/sysdev/bestcomm/gen_bd.c index a3a134c35b0..e0a53e3147b 100644 --- a/arch/powerpc/sysdev/bestcomm/gen_bd.c +++ b/arch/powerpc/sysdev/bestcomm/gen_bd.c @@ -11,7 +11,6 @@ * */ -#include #include #include #include diff --git a/arch/x86/mach-rdc321x/platform.c b/arch/x86/mach-rdc321x/platform.c index a037041817c..4f4e50c3ad3 100644 --- a/arch/x86/mach-rdc321x/platform.c +++ b/arch/x86/mach-rdc321x/platform.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c index 2ebd07f2ef8..5effec6f545 100644 --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c @@ -3,7 +3,6 @@ */ #include -#include #include #include #include diff --git a/drivers/char/xilinx_hwicap/buffer_icap.h b/drivers/char/xilinx_hwicap/buffer_icap.h index c5b1840906b..8b0252bf06e 100644 --- a/drivers/char/xilinx_hwicap/buffer_icap.h +++ b/drivers/char/xilinx_hwicap/buffer_icap.h @@ -38,7 +38,6 @@ #include #include -#include #include #include diff --git a/drivers/char/xilinx_hwicap/fifo_icap.h b/drivers/char/xilinx_hwicap/fifo_icap.h index ffabd3ba2bd..62bda453c90 100644 --- a/drivers/char/xilinx_hwicap/fifo_icap.h +++ b/drivers/char/xilinx_hwicap/fifo_icap.h @@ -38,7 +38,6 @@ #include #include -#include #include #include diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h index 1f9c8b082db..24d0d9b938f 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h @@ -38,7 +38,6 @@ #include #include -#include #include #include diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index b27b13c5eb5..4b55ec607a8 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h @@ -34,7 +34,6 @@ #include #include #include -#include #define EDAC_MC_LABEL_LEN 31 #define EDAC_DEVICE_NAME_LEN 31 diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index c1adcdbf797..9efb0213725 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include diff --git a/drivers/infiniband/hw/ehca/ehca_tools.h b/drivers/infiniband/hw/ehca/ehca_tools.h index ec950bf8c47..21f7d06f14a 100644 --- a/drivers/infiniband/hw/ehca/ehca_tools.h +++ b/drivers/infiniband/hw/ehca/ehca_tools.h @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c index 23faba9d21e..8bb5170b4e4 100644 --- a/drivers/infiniband/hw/ipath/ipath_fs.c +++ b/drivers/infiniband/hw/ipath/ipath_fs.c @@ -31,7 +31,6 @@ * SOFTWARE. */ -#include #include #include #include diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h index 39bd897b40c..8eb7ae96974 100644 --- a/drivers/infiniband/hw/nes/nes.h +++ b/drivers/infiniband/hw/nes/nes.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 63462ecca14..26ff6214a81 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "iscsi_iser.h" diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index 54ed8e2e1c0..6f227d3dbda 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c @@ -29,7 +29,6 @@ */ #include -#include #include #include diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c index 283f93a0cee..37a555f3730 100644 --- a/drivers/input/touchscreen/mainstone-wm97xx.c +++ b/drivers/input/touchscreen/mainstone-wm97xx.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index c6408a62d95..bc2a807f210 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -16,7 +16,6 @@ * */ -#include #include #include #include diff --git a/drivers/misc/eeprom_93cx6.c b/drivers/misc/eeprom_93cx6.c index ea55654e594..15b1780025c 100644 --- a/drivers/misc/eeprom_93cx6.c +++ b/drivers/misc/eeprom_93cx6.c @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c index 948b86f35ef..d1eec7d3243 100644 --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c index effaf7cdefa..1a6feb4474d 100644 --- a/drivers/mtd/maps/ck804xrom.c +++ b/drivers/mtd/maps/ck804xrom.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c index aa64a475278..bbbcdd4c8d1 100644 --- a/drivers/mtd/maps/esb2rom.c +++ b/drivers/mtd/maps/esb2rom.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index 761946ea45b..92c334ff450 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 5d76cd09e24..54cd89cb083 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index ab871df6b1d..244ab49c433 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -45,7 +45,6 @@ #include #include #include -#include #include #include diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 4ad3e0844b9..b974ca0fc53 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -38,7 +38,6 @@ #include #include #include -#include #include "netxen_nic.h" #include "netxen_nic_hw.h" diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index e8e8d73f6ed..e80f9e3e597 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h @@ -32,8 +32,6 @@ #include #include -#include - #include #include #include diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c index 47d84cd2809..59d1673f938 100644 --- a/drivers/net/tokenring/lanstreamer.c +++ b/drivers/net/tokenring/lanstreamer.c @@ -119,7 +119,6 @@ #include #include #include -#include #include #include diff --git a/drivers/net/tokenring/lanstreamer.h b/drivers/net/tokenring/lanstreamer.h index e7bb3494afc..13ccee6449c 100644 --- a/drivers/net/tokenring/lanstreamer.h +++ b/drivers/net/tokenring/lanstreamer.h @@ -60,8 +60,6 @@ * */ -#include - /* MAX_INTR - the maximum number of times we can loop * inside the interrupt function before returning * control to the OS (maximum value is 256) diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 2541c81932f..1cb77db5c29 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c index d3336966b6b..705c65bed9f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index cb11c4a4d69..4eee1b163cd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/drivers/net/wireless/iwlwifi/iwl-rfkill.c b/drivers/net/wireless/iwlwifi/iwl-rfkill.c index e5e5846e9f2..5d642298f04 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rfkill.c +++ b/drivers/net/wireless/iwlwifi/iwl-rfkill.c @@ -27,7 +27,6 @@ *****************************************************************************/ #include #include -#include #include #include diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 12f0310ae89..78b2551fb19 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c @@ -20,8 +20,6 @@ */ #include -#include - #include #include #include diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c index b35f9bfa2af..395985b339c 100644 --- a/drivers/rtc/rtc-r9701.c +++ b/drivers/rtc/rtc-r9701.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 49ae1cd25ca..2de1e2fccbf 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -19,7 +19,6 @@ #undef DEBUGDATA #undef DEBUGCCW -#include #include #include #include diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h index 19406cea6d6..179ad77f6cc 100644 --- a/drivers/scsi/dpt/dpti_i2o.h +++ b/drivers/scsi/dpt/dpti_i2o.h @@ -21,7 +21,6 @@ #include -#include #include #include diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 7c615c70ec5..bc9e6ddf41d 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -165,7 +165,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h index e0657b6f009..4e49fbcfe8a 100644 --- a/drivers/scsi/ips.h +++ b/drivers/scsi/ips.h @@ -50,7 +50,6 @@ #ifndef _IPS_H_ #define _IPS_H_ -#include #include #include #include diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 90272e65957..094b47e94b2 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index edf9fdb3cb3..22052bb7bec 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -23,7 +23,6 @@ * 1.2: PowerPC (big endian) support. */ -#include #include #include #include diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index 6715ecb3bfc..9565acf1aa7 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h @@ -16,7 +16,6 @@ #ifndef _NSP32_H #define _NSP32_H -#include //#define NSP32_DEBUG 9 /* diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index a221b6ef9fa..24e6cb8396e 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -25,7 +25,6 @@ ***********************************************************************/ -#include #include #include #include diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 50baf6a1d67..93560cd7278 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -6,7 +6,6 @@ */ #include "qla_def.h" -#include #include #include #include diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index cb01b5106ef..b6483dd98ac 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -64,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index 1500e1b3c30..abf8192f89e 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 53880738459..29d13ebe750 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index e6ca9979e3a..a4ef77ef917 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -19,7 +19,6 @@ #include #include #include -#include #include /* Version Information */ diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 2e663f1afd5..d9538208807 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -38,8 +38,6 @@ #include #include -#include - /* the mode to be set when the port ist opened */ static int initial_mode = 1; diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c index 4bd569e479a..314d18694b6 100644 --- a/drivers/video/arkfb.c +++ b/drivers/video/arkfb.c @@ -11,7 +11,6 @@ * Code is based on s3fb */ -#include #include #include #include diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c index 8361bd0e3df..4dcec48a1d7 100644 --- a/drivers/video/s3fb.c +++ b/drivers/video/s3fb.c @@ -11,7 +11,6 @@ * which is based on the code of neofb. */ -#include #include #include #include diff --git a/drivers/video/vermilion/vermilion.h b/drivers/video/vermilion/vermilion.h index c4aba59d480..7491abfcf1f 100644 --- a/drivers/video/vermilion/vermilion.h +++ b/drivers/video/vermilion/vermilion.h @@ -30,7 +30,6 @@ #define _VERMILION_H_ #include -#include #include #include #include diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c index 34aae7a2a62..3df17dc8c3d 100644 --- a/drivers/video/vt8623fb.c +++ b/drivers/video/vt8623fb.c @@ -12,7 +12,6 @@ * (http://davesdomain.org.uk/viafb/) */ -#include #include #include #include diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c index 7b3a8423f48..5da3d2423cc 100644 --- a/drivers/video/xilinxfb.c +++ b/drivers/video/xilinxfb.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h index 31559f45fdd..4c41db91eaa 100644 --- a/fs/jffs2/jffs2_fs_i.h +++ b/fs/jffs2/jffs2_fs_i.h @@ -12,7 +12,6 @@ #ifndef _JFFS2_FS_I #define _JFFS2_FS_I -#include #include #include #include diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h index cdc2d3464a1..2813cdd7237 100644 --- a/fs/xfs/xfs_dmapi.h +++ b/fs/xfs/xfs_dmapi.h @@ -18,7 +18,6 @@ #ifndef __XFS_DMAPI_H__ #define __XFS_DMAPI_H__ -#include /* Values used to define the on-disk version of dm_attrname_t. All * on-disk attribute names start with the 8-byte string "SGI_DMI_". * diff --git a/include/asm-x86/xen/hypervisor.h b/include/asm-x86/xen/hypervisor.h index 8e15dd28c91..04ee0610014 100644 --- a/include/asm-x86/xen/hypervisor.h +++ b/include/asm-x86/xen/hypervisor.h @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/include/linux/fs_uart_pd.h b/include/linux/fs_uart_pd.h index 809bb9ffc78..36b61ff3927 100644 --- a/include/linux/fs_uart_pd.h +++ b/include/linux/fs_uart_pd.h @@ -12,7 +12,6 @@ #ifndef FS_UART_PD_H #define FS_UART_PD_H -#include #include enum fs_uart_id { diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 21575fc46d0..1d3ef29a258 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include diff --git a/kernel/power/swap.c b/kernel/power/swap.c index a0abf9a463f..80ccac849e4 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index a9ab0596de4..532858fa5b8 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -6,7 +6,6 @@ */ #include -#include #include #include #include diff --git a/kernel/utsname.c b/kernel/utsname.c index 64d398f1244..815237a55af 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index fe3a56c2256..4ab9659d269 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c @@ -12,7 +12,6 @@ #include #include #include -#include #include static void *get_uts(ctl_table *table, int write) diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index ee0741f9eb5..fbef38a9604 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c index b081e83766b..b81d6b2cfa1 100644 --- a/sound/soc/at91/eti_b1_wm8731.c +++ b/sound/soc/at91/eti_b1_wm8731.c @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 8604809f0c3..dc7b18fd278 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -34,7 +34,6 @@ #include #include -#include #include #include #include diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 1fb7f9a7aec..2f1c91b1d55 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3-70-g09d2 From 06dd881f59b3c07a430cdcbef2197f9b6dc79ae8 Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Mon, 8 Sep 2008 14:53:37 +0100 Subject: usb: fix null deferences in low level usb serial The hw interface drivers for the usb serial devices deference the tty structure to set up the parameters for the initial console. The tty structure should be passed as a parameter to the set_termios() call. Signed-off-by: Jason Wessel Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/usb/serial/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 7b74238ad1c..e980766bb84 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -161,7 +161,7 @@ static int usb_console_setup(struct console *co, char *options) if (serial->type->set_termios) { termios->c_cflag = cflag; tty_termios_encode_baud_rate(termios, baud, baud); - serial->type->set_termios(NULL, port, &dummy); + serial->type->set_termios(tty, port, &dummy); port->port.tty = NULL; kfree(termios); -- cgit v1.2.3-70-g09d2 From 73b2c2057579314c4fea1a37e35a501fbb8b9916 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Date: Mon, 25 Aug 2008 19:20:40 -0700 Subject: USB Serial: Sierra: Device addition & version rev This patch adds devices to the sierra driver and rev's the driver version. Signed-off-by: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 706033753ad..396f099ba9f 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -14,7 +14,7 @@ Whom based his on the Keyspan driver by Hugh Blemings */ -#define DRIVER_VERSION "v.1.2.13a" +#define DRIVER_VERSION "v.1.3.2" #define DRIVER_AUTHOR "Kevin Lloyd " #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" @@ -30,9 +30,6 @@ #define SWIMS_USB_REQUEST_SetPower 0x00 #define SWIMS_USB_REQUEST_SetNmea 0x07 -#define SWIMS_USB_REQUEST_SetMode 0x0B -#define SWIMS_USB_REQUEST_GetSwocInfo 0x0A -#define SWIMS_SET_MODE_Modem 0x0001 /* per port private data */ #define N_IN_URB 4 @@ -175,6 +172,8 @@ static struct usb_device_id id_table [] = { /* Sierra Wireless Device */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ + { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */ + { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */ { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ @@ -204,6 +203,8 @@ static struct usb_device_id id_table [] = { /* Sierra Wireless Device */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, /* Sierra Wireless Device */ + { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)}, + /* Sierra Wireless Device */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ -- cgit v1.2.3-70-g09d2 From f8834f1febb8f56cdcfeb35485e0cc7a8d547818 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Aug 2008 17:30:44 -0500 Subject: USB: Correct Sierra Wireless USB EVDO Modem Device ID I was trying to figure out why my device wasn't supported by the drivers/usb/serial/sierra.c driver, while looking throught the device IDs I spotted what I believe to be a typo in the device IDs. Please apply the following patch If you look down further, there is another HP wireless broadband card, which has a vendor ID of 03f0, like my device. Below is my "lsusb -v -d 03f0:1b1d". Bus 001 Device 005: ID 03f0:1b1d Hewlett-Packard Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x03f0 Hewlett-Packard idProduct 0x1b1d bcdDevice 0.01 iManufacturer 1 HP iProduct 2 HP ev2200 1xEV-DO Broadband Wireless Module iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 67 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 7 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass bInterfaceProtocol 255 Vendor Specific Protocol iInterface 3 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 128 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x84 EP 4 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x04 EP 4 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x85 EP 5 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x05 EP 5 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Device Status: 0x0000 (Bus Powered) From: Tony Murray Cc: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 396f099ba9f..eb87640f362 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -160,7 +160,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ - { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ + { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */ { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ -- cgit v1.2.3-70-g09d2 From ce816cf9c917435cd2e3b68acc7cfe2c1f4a814f Mon Sep 17 00:00:00 2001 From: Andreas Bombe Date: Sun, 14 Sep 2008 01:58:55 +0200 Subject: usb-serial: Add Siemens EF81 to PL-2303 hack triggers This hardware needs the pl2303 hack in order to work properly :( Signed-off-by: Andreas Bombe Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index b157c48e8b7..4f7f9e3ae0a 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -733,7 +733,9 @@ int usb_serial_probe(struct usb_interface *interface, ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && - (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) { + (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) || + ((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && + (le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) { if (interface != dev->actconfig->interface[0]) { /* check out the endpoints of the other interface*/ iface_desc = dev->actconfig->interface[0]->cur_altsetting; -- cgit v1.2.3-70-g09d2 From ba0f332c413796925ce322d311d75269689a9e5d Mon Sep 17 00:00:00 2001 From: Craig Shelley Date: Thu, 4 Sep 2008 21:28:21 +0100 Subject: USB: SERIAL CP2101 add device IDs Signed-off-by: Craig Shelley Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/cp2101.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 442cba69cce..1279553381e 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -72,6 +72,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */ { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ + { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */ { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ @@ -83,6 +84,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ + { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ @@ -93,6 +95,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ + { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ { } /* Terminating Entry */ }; -- cgit v1.2.3-70-g09d2 From 2bcbe4c199ec012169f938d2c6b543f50c4925ed Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 10 Sep 2008 14:11:38 -0700 Subject: usb serial: ti_usb_3410_5052 obviously broken by firmware changes While making some other changes to ti_usb_3410_5052, I noticed that the changes made to move the firmware loading to a separate function are broken (in ti_download_firmware(), status is set to -ENOMEM and never changed). This means the driver will never initialize the device properly. It looks like status was supposed to get the result of ti_do_download(). Signed-off-by: Chris Adams Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ti_usb_3410_5052.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index e39c779e416..9a3e495c769 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -1744,7 +1744,7 @@ static int ti_download_firmware(struct ti_device *tdev, int type) if (buffer) { memcpy(buffer, fw_p->data, fw_p->size); memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); - ti_do_download(dev, pipe, buffer, fw_p->size); + status = ti_do_download(dev, pipe, buffer, fw_p->size); kfree(buffer); } release_firmware(fw_p); -- cgit v1.2.3-70-g09d2 From a18f80b4e2fdbc7b88d412c3deb533b9f1f30c30 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 16 Sep 2008 15:46:50 +0200 Subject: USB: ftdi_sio: Add 0x5050/0x0900 USB IDs (Papouch Quido USB 4/4) USB: ftdi_sio: Add 0x5050/0x0900 USB IDs (Papouch Quido USB 4/4) Signed-off-by: Jaroslav Kysela Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 984f6eff4c4..8ff8d0a1bae 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -654,6 +654,7 @@ static struct usb_device_id id_table_combined [] = { .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, + { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, { }, /* Optional parameter entry */ { } /* Terminating entry */ }; diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 382265bba96..ad41287ac2c 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -750,6 +750,7 @@ #define PAPOUCH_VID 0x5050 /* Vendor ID */ #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ +#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */ /* * ACG Identification Technologies GmbH products (http://www.acg.de/). -- cgit v1.2.3-70-g09d2 From 884579d03a3e1e9ac8b7f32a1c36387cac3eb80b Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Wed, 17 Sep 2008 14:40:46 -0300 Subject: USB: serial: add ZTE CDMA Tech id to option driver Signed-off-by: Otavio Salvador Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 9f9cd36455f..73f8277f88f 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -218,6 +218,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po /* ZTE PRODUCTS */ #define ZTE_VENDOR_ID 0x19d2 #define ZTE_PRODUCT_MF628 0x0015 +#define ZTE_PRODUCT_CDMA_TECH 0xfffe static struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, @@ -347,6 +348,7 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, + { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE(usb, option_ids); -- cgit v1.2.3-70-g09d2 From b77a5c7040643e658622148bb7d7dad63e8d0158 Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Date: Wed, 17 Sep 2008 09:03:38 -0700 Subject: USB Serial: Sierra: Add MC8785 VID/PID Add another MC8785 VID/PID Signed-off-by: Kevin Lloyd Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index eb87640f362..ea1a103c99b 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -186,6 +186,7 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ + { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */ { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ -- cgit v1.2.3-70-g09d2 From 96285cb885b445b03b22849f2536af23c7454a11 Mon Sep 17 00:00:00 2001 From: Gaetan Carlier Date: Mon, 22 Sep 2008 15:00:09 -0700 Subject: usb: ftdi_sio: add support for Domintell devices Support for Domintell devices (FTDI FT232BM based) : DGQG and DUSB01 module. PIDs were missing. Signed-off-by: Gaetan Carlier Cc: Greg Kroah-Hartman Cc: Ian Abbott Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio.h | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'drivers/usb/serial') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8ff8d0a1bae..3dc93b542b3 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -655,6 +655,8 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, { }, /* Optional parameter entry */ { } /* Terminating entry */ }; diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index ad41287ac2c..8a5b6df3a97 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -839,6 +839,10 @@ /* Rig Expert Ukraine devices */ #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ +/* Domintell products http://www.domintell.com */ +#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */ +#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */ + /* Commands */ #define FTDI_SIO_RESET 0 /* Reset the port */ #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ -- cgit v1.2.3-70-g09d2