Commit c4d0f8cb authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

usb_serial: some coding style fixes

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e5430f88
...@@ -147,7 +147,7 @@ static void serial_buf_free(struct circ_buf *cb) ...@@ -147,7 +147,7 @@ static void serial_buf_free(struct circ_buf *cb)
*/ */
static int serial_buf_data_avail(struct circ_buf *cb) static int serial_buf_data_avail(struct circ_buf *cb)
{ {
return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE); return CIRC_CNT(cb->head, cb->tail, AIRCABLE_BUF_SIZE);
} }
/* /*
...@@ -171,7 +171,7 @@ static int serial_buf_put(struct circ_buf *cb, const char *buf, int count) ...@@ -171,7 +171,7 @@ static int serial_buf_put(struct circ_buf *cb, const char *buf, int count)
cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1);
buf += c; buf += c;
count -= c; count -= c;
ret= c; ret = c;
} }
return ret; return ret;
} }
...@@ -197,7 +197,7 @@ static int serial_buf_get(struct circ_buf *cb, char *buf, int count) ...@@ -197,7 +197,7 @@ static int serial_buf_get(struct circ_buf *cb, char *buf, int count)
cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1);
buf += c; buf += c;
count -= c; count -= c;
ret= c; ret = c;
} }
return ret; return ret;
} }
...@@ -208,7 +208,7 @@ static void aircable_send(struct usb_serial_port *port) ...@@ -208,7 +208,7 @@ static void aircable_send(struct usb_serial_port *port)
{ {
int count, result; int count, result;
struct aircable_private *priv = usb_get_serial_port_data(port); struct aircable_private *priv = usb_get_serial_port_data(port);
unsigned char* buf; unsigned char *buf;
__le16 *dbuf; __le16 *dbuf;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (port->write_urb_busy) if (port->write_urb_busy)
...@@ -229,7 +229,8 @@ static void aircable_send(struct usb_serial_port *port) ...@@ -229,7 +229,8 @@ static void aircable_send(struct usb_serial_port *port)
buf[1] = TX_HEADER_1; buf[1] = TX_HEADER_1;
dbuf = (__le16 *)&buf[2]; dbuf = (__le16 *)&buf[2];
*dbuf = cpu_to_le16((u16)count); *dbuf = cpu_to_le16((u16)count);
serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE); serial_buf_get(priv->tx_buf, buf + HCI_HEADER_LENGTH,
MAX_HCI_FRAMESIZE);
memcpy(port->write_urb->transfer_buffer, buf, memcpy(port->write_urb->transfer_buffer, buf,
count + HCI_HEADER_LENGTH); count + HCI_HEADER_LENGTH);
...@@ -261,7 +262,7 @@ static void aircable_read(struct work_struct *work) ...@@ -261,7 +262,7 @@ static void aircable_read(struct work_struct *work)
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data; unsigned char *data;
int count; int count;
if (priv->rx_flags & THROTTLED){ if (priv->rx_flags & THROTTLED) {
if (priv->rx_flags & ACTUALLY_THROTTLED) if (priv->rx_flags & ACTUALLY_THROTTLED)
schedule_work(&priv->rx_work); schedule_work(&priv->rx_work);
return; return;
...@@ -282,10 +283,10 @@ static void aircable_read(struct work_struct *work) ...@@ -282,10 +283,10 @@ static void aircable_read(struct work_struct *work)
count = min(64, serial_buf_data_avail(priv->rx_buf)); count = min(64, serial_buf_data_avail(priv->rx_buf));
if (count <= 0) if (count <= 0)
return; //We have finished sending everything. return; /* We have finished sending everything. */
tty_prepare_flip_string(tty, &data, count); tty_prepare_flip_string(tty, &data, count);
if (!data){ if (!data) {
err("%s- kzalloc(%d) failed.", __func__, count); err("%s- kzalloc(%d) failed.", __func__, count);
return; return;
} }
...@@ -304,9 +305,10 @@ static void aircable_read(struct work_struct *work) ...@@ -304,9 +305,10 @@ static void aircable_read(struct work_struct *work)
static int aircable_probe(struct usb_serial *serial, static int aircable_probe(struct usb_serial *serial,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_host_interface *iface_desc = serial->interface->cur_altsetting; struct usb_host_interface *iface_desc = serial->interface->
cur_altsetting;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
int num_bulk_out=0; int num_bulk_out = 0;
int i; int i;
for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
...@@ -325,13 +327,13 @@ static int aircable_probe(struct usb_serial *serial, ...@@ -325,13 +327,13 @@ static int aircable_probe(struct usb_serial *serial,
return 0; return 0;
} }
static int aircable_attach (struct usb_serial *serial) static int aircable_attach(struct usb_serial *serial)
{ {
struct usb_serial_port *port = serial->port[0]; struct usb_serial_port *port = serial->port[0];
struct aircable_private *priv; struct aircable_private *priv;
priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL);
if (!priv){ if (!priv) {
err("%s- kmalloc(%Zd) failed.", __func__, err("%s- kmalloc(%Zd) failed.", __func__,
sizeof(struct aircable_private)); sizeof(struct aircable_private));
return -ENOMEM; return -ENOMEM;
...@@ -392,7 +394,7 @@ static int aircable_write(struct usb_serial_port *port, ...@@ -392,7 +394,7 @@ static int aircable_write(struct usb_serial_port *port,
usb_serial_debug_data(debug, &port->dev, __func__, count, source); usb_serial_debug_data(debug, &port->dev, __func__, count, source);
if (!count){ if (!count) {
dbg("%s - write request of 0 bytes", __func__); dbg("%s - write request of 0 bytes", __func__);
return count; return count;
} }
...@@ -490,7 +492,7 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -490,7 +492,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
} }
usb_serial_debug_data(debug, &port->dev, __func__, usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length,urb->transfer_buffer); urb->actual_length, urb->transfer_buffer);
tty = port->tty; tty = port->tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
...@@ -507,9 +509,9 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -507,9 +509,9 @@ static void aircable_read_bulk_callback(struct urb *urb)
no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); no_packages = urb->actual_length / (HCI_COMPLETE_FRAME);
if (urb->actual_length % HCI_COMPLETE_FRAME != 0) if (urb->actual_length % HCI_COMPLETE_FRAME != 0)
no_packages+=1; no_packages++;
for (i = 0; i < no_packages ;i++) { for (i = 0; i < no_packages; i++) {
if (remaining > (HCI_COMPLETE_FRAME)) if (remaining > (HCI_COMPLETE_FRAME))
package_length = HCI_COMPLETE_FRAME; package_length = HCI_COMPLETE_FRAME;
else else
...@@ -602,7 +604,7 @@ static struct usb_serial_driver aircable_device = { ...@@ -602,7 +604,7 @@ static struct usb_serial_driver aircable_device = {
.unthrottle = aircable_unthrottle, .unthrottle = aircable_unthrottle,
}; };
static int __init aircable_init (void) static int __init aircable_init(void)
{ {
int retval; int retval;
retval = usb_serial_register(&aircable_device); retval = usb_serial_register(&aircable_device);
...@@ -619,7 +621,7 @@ static int __init aircable_init (void) ...@@ -619,7 +621,7 @@ static int __init aircable_init (void)
return retval; return retval;
} }
static void __exit aircable_exit (void) static void __exit aircable_exit(void)
{ {
usb_deregister(&aircable_driver); usb_deregister(&aircable_driver);
usb_serial_deregister(&aircable_device); usb_serial_deregister(&aircable_device);
......
...@@ -69,7 +69,8 @@ static int airprime_send_setup(struct usb_serial_port *port) ...@@ -69,7 +69,8 @@ static int airprime_send_setup(struct usb_serial_port *port)
return usb_control_msg(serial->dev, return usb_control_msg(serial->dev,
usb_rcvctrlpipe(serial->dev, 0), usb_rcvctrlpipe(serial->dev, 0),
0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); 0x22, 0x21, val, 0, NULL, 0,
USB_CTRL_SET_TIMEOUT);
} }
return 0; return 0;
...@@ -90,17 +91,19 @@ static void airprime_read_bulk_callback(struct urb *urb) ...@@ -90,17 +91,19 @@ static void airprime_read_bulk_callback(struct urb *urb)
__func__, status); __func__, status);
return; 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->tty; tty = port->tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
tty_insert_flip_string (tty, data, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length);
tty_flip_buffer_push (tty); tty_flip_buffer_push(tty);
} }
result = usb_submit_urb (urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) 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); __func__, result);
return; return;
} }
...@@ -115,7 +118,7 @@ static void airprime_write_bulk_callback(struct urb *urb) ...@@ -115,7 +118,7 @@ static void airprime_write_bulk_callback(struct urb *urb)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
/* free up the transfer buffer, as usb_free_urb() does not do this */ /* free up the transfer buffer, as usb_free_urb() does not do this */
kfree (urb->transfer_buffer); kfree(urb->transfer_buffer);
if (status) if (status)
dbg("%s - nonzero write bulk status received: %d", dbg("%s - nonzero write bulk status received: %d",
...@@ -183,7 +186,8 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) ...@@ -183,7 +186,8 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
__func__, i, port->number, result); __func__, i, port->number, result);
goto errout; goto errout;
} }
/* remember this urb so we can kill it when the port is closed */ /* remember this urb so we can kill it when the
port is closed */
priv->read_urbp[i] = urb; priv->read_urbp[i] = urb;
} }
...@@ -192,22 +196,22 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) ...@@ -192,22 +196,22 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
goto out; goto out;
errout: errout:
/* some error happened, cancel any submitted urbs and clean up anything that /* some error happened, cancel any submitted urbs and clean up
got allocated successfully */ anything that got allocated successfully */
while (i-- != 0) { while (i-- != 0) {
urb = priv->read_urbp[i]; urb = priv->read_urbp[i];
buffer = urb->transfer_buffer; buffer = urb->transfer_buffer;
usb_kill_urb (urb); usb_kill_urb(urb);
usb_free_urb (urb); usb_free_urb(urb);
kfree (buffer); kfree(buffer);
} }
out: out:
return result; return result;
} }
static void airprime_close(struct usb_serial_port *port, struct file * filp) static void airprime_close(struct usb_serial_port *port, struct file *filp)
{ {
struct airprime_private *priv = usb_get_serial_port_data(port); struct airprime_private *priv = usb_get_serial_port_data(port);
int i; int i;
...@@ -223,13 +227,13 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) ...@@ -223,13 +227,13 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp)
mutex_unlock(&port->serial->disc_mutex); mutex_unlock(&port->serial->disc_mutex);
for (i = 0; i < NUM_READ_URBS; ++i) { for (i = 0; i < NUM_READ_URBS; ++i) {
usb_kill_urb (priv->read_urbp[i]); usb_kill_urb(priv->read_urbp[i]);
kfree (priv->read_urbp[i]->transfer_buffer); kfree(priv->read_urbp[i]->transfer_buffer);
usb_free_urb (priv->read_urbp[i]); usb_free_urb(priv->read_urbp[i]);
} }
/* free up private structure */ /* free up private structure */
kfree (priv); kfree(priv);
usb_set_serial_port_data(port, NULL); usb_set_serial_port_data(port, NULL);
} }
...@@ -259,10 +263,10 @@ static int airprime_write(struct usb_serial_port *port, ...@@ -259,10 +263,10 @@ static int airprime_write(struct usb_serial_port *port,
urb = usb_alloc_urb(0, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) { if (!urb) {
dev_err(&port->dev, "no more free urbs\n"); dev_err(&port->dev, "no more free urbs\n");
kfree (buffer); kfree(buffer);
return -ENOMEM; return -ENOMEM;
} }
memcpy (buffer, buf, count); memcpy(buffer, buf, count);
usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
...@@ -279,7 +283,7 @@ static int airprime_write(struct usb_serial_port *port, ...@@ -279,7 +283,7 @@ static int airprime_write(struct usb_serial_port *port,
"%s - usb_submit_urb(write bulk) failed with status = %d\n", "%s - usb_submit_urb(write bulk) failed with status = %d\n",
__func__, status); __func__, status);
count = status; count = status;
kfree (buffer); kfree(buffer);
} else { } else {
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
++priv->outstanding_urbs; ++priv->outstanding_urbs;
...@@ -287,7 +291,7 @@ static int airprime_write(struct usb_serial_port *port, ...@@ -287,7 +291,7 @@ static int airprime_write(struct usb_serial_port *port,
} }
/* we are done with this urb, so let the host driver /* we are done with this urb, so let the host driver
* really free it when it is finished with it */ * really free it when it is finished with it */
usb_free_urb (urb); usb_free_urb(urb);
return count; return count;
} }
...@@ -315,8 +319,10 @@ static int __init airprime_init(void) ...@@ -315,8 +319,10 @@ static int __init airprime_init(void)
{ {
int retval; int retval;
airprime_device.num_ports = airprime_device.num_ports = endpoints;
(endpoints > 0 && endpoints <= MAX_BULK_EPS) ? endpoints : NUM_BULK_EPS; if (endpoints < 0 || endpoints >= MAX_BULK_EPS)
airprime_device.num_ports = NUM_BULK_EPS;
retval = usb_serial_register(&airprime_device); retval = usb_serial_register(&airprime_device);
if (retval) if (retval)
return retval; return retval;
...@@ -341,6 +347,7 @@ MODULE_LICENSE("GPL"); ...@@ -341,6 +347,7 @@ MODULE_LICENSE("GPL");
module_param(debug, bool, S_IRUGO | S_IWUSR); module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled"); MODULE_PARM_DESC(debug, "Debug enabled");
module_param(buffer_size, int, 0); module_param(buffer_size, int, 0);
MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers in bytes (default 4096)"); MODULE_PARM_DESC(buffer_size,
"Size of the transfer buffers in bytes (default 4096)");
module_param(endpoints, int, 0); module_param(endpoints, int, 0);
MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
#include <linux/serial.h> #include <linux/serial.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
static int debug; static int debug;
...@@ -380,19 +380,19 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, ...@@ -380,19 +380,19 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
switch (cmd) { switch (cmd) {
case TIOCGSERIAL: case TIOCGSERIAL:
/* XXX: Some of these values are probably wrong. */ /* XXX: Some of these values are probably wrong. */
memset(&serstruct, 0, sizeof (serstruct)); memset(&serstruct, 0, sizeof(serstruct));
serstruct.type = PORT_16654; serstruct.type = PORT_16654;
serstruct.line = port->serial->minor; serstruct.line = port->serial->minor;
serstruct.port = port->number; serstruct.port = port->number;
serstruct.custom_divisor = 0; serstruct.custom_divisor = 0;
serstruct.baud_base = 460800; serstruct.baud_base = 460800;
if (copy_to_user(user_arg, &serstruct, sizeof (serstruct))) if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
return -EFAULT; return -EFAULT;
return 0; return 0;
case TIOCSSERIAL: case TIOCSSERIAL:
if (copy_from_user(&serstruct, user_arg, sizeof (serstruct))) if (copy_from_user(&serstruct, user_arg, sizeof(serstruct)))
return -EFAULT; return -EFAULT;
return 0; return 0;
default: default:
......
...@@ -130,7 +130,7 @@ static int ch341_get_status(struct usb_device *dev) ...@@ -130,7 +130,7 @@ static int ch341_get_status(struct usb_device *dev)
return -ENOMEM; return -ENOMEM;
r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size);
if ( r < 0) if (r < 0)
goto out; goto out;
/* Not having the datasheet for the CH341, we ignore the bytes returned /* Not having the datasheet for the CH341, we ignore the bytes returned
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment