Staging: line6: fix checkpatch errors in driver.c

Lots of warnings also fixed up.

Cc: Markus Grabner <grabner@icg.tugraz.at>
Cc: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2009-02-27 22:42:18 -08:00
parent dfc70567d7
commit 36445bc118
1 changed files with 192 additions and 140 deletions

View File

@ -82,8 +82,7 @@ struct workqueue_struct *line6_workqueue;
/**
Class for asynchronous messages.
*/
struct message
{
struct message {
struct usb_line6 *line6;
const char *buffer;
int size;
@ -95,7 +94,8 @@ struct message
Forward declarations.
*/
static void line6_data_received(struct urb *urb);
static int line6_send_raw_message_async_part(struct message *msg, struct urb *urb);
static int line6_send_raw_message_async_part(struct message *msg,
struct urb *urb);
/*
@ -103,13 +103,10 @@ static int line6_send_raw_message_async_part(struct message *msg, struct urb *ur
*/
static int line6_start_listen(struct usb_line6 *line6)
{
usb_fill_int_urb(line6->urb_listen,
line6->usbdev,
usb_fill_int_urb(line6->urb_listen, line6->usbdev,
usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
line6_data_received,
line6,
line6->interval);
line6_data_received, line6, line6->interval);
line6->urb_listen->actual_length = 0;
return usb_submit_urb(line6->urb_listen, GFP_KERNEL);
}
@ -118,7 +115,8 @@ static int line6_start_listen(struct usb_line6 *line6)
/*
Write hexdump to syslog.
*/
void line6_write_hexdump(struct usb_line6 *line6, char dir, const unsigned char *buffer, int size)
void line6_write_hexdump(struct usb_line6 *line6, char dir,
const unsigned char *buffer, int size)
{
static const int BYTES_PER_LINE = 8;
char hexdump[100];
@ -138,8 +136,7 @@ void line6_write_hexdump(struct usb_line6 *line6, char dir, const unsigned char
unsigned char val = buffer[i + j];
bytes = snprintf(p, hexdumpsize, " %02X", val);
asc[j] = ((val >= 0x20) && (val < 0x7f)) ? val : '.';
}
else
} else
bytes = snprintf(p, hexdumpsize, " ");
if (bytes > hexdumpsize)
@ -165,14 +162,16 @@ static void line6_dump_urb(struct urb *urb)
if (urb->status < 0)
return;
line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer, urb->actual_length);
line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer,
urb->actual_length);
}
#endif
/*
Send raw message in pieces of wMaxPacketSize bytes.
*/
int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, int size)
int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
int size)
{
int i, done = 0;
@ -184,12 +183,17 @@ int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, int size
int partial;
const char *frag_buf = buffer + i;
int frag_size = min(line6->max_packet_size, size - i);
int retval = usb_interrupt_msg(line6->usbdev,
usb_sndintpipe(line6->usbdev, line6->ep_control_write),
(char *)frag_buf, frag_size, &partial, LINE6_TIMEOUT * HZ);
int retval;
retval = usb_interrupt_msg(line6->usbdev,
usb_sndintpipe(line6->usbdev,
line6->ep_control_write),
(char *)frag_buf, frag_size,
&partial, LINE6_TIMEOUT * HZ);
if (retval) {
dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", retval);
dev_err(line6->ifcdev,
"usb_interrupt_msg failed (%d)\n", retval);
break;
}
@ -209,23 +213,22 @@ static void line6_async_request_sent(struct urb *urb)
if (msg->done >= msg->size) {
usb_free_urb(urb);
kfree(msg);
}
else
} else
line6_send_raw_message_async_part(msg, urb);
}
/*
Asynchronously send part of a raw message.
*/
static int line6_send_raw_message_async_part(struct message *msg, struct urb *urb)
static int line6_send_raw_message_async_part(struct message *msg,
struct urb *urb)
{
int retval;
struct usb_line6 *line6 = msg->line6;
int done = msg->done;
int bytes = min(msg->size - done, line6->max_packet_size);
usb_fill_int_urb(urb,
line6->usbdev,
usb_fill_int_urb(urb, line6->usbdev,
usb_sndintpipe(line6->usbdev, line6->ep_control_write),
(char *)msg->buffer + done, bytes,
line6_async_request_sent, msg, line6->interval);
@ -238,7 +241,8 @@ static int line6_send_raw_message_async_part(struct message *msg, struct urb *ur
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval < 0) {
dev_err(line6->ifcdev, "line6_send_raw_message_async: usb_submit_urb failed (%d)\n", retval);
dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n",
__func__, retval);
usb_free_urb(urb);
kfree(msg);
return -EINVAL;
@ -250,7 +254,8 @@ static int line6_send_raw_message_async_part(struct message *msg, struct urb *ur
/*
Asynchronously send raw message.
*/
int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size)
int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
int size)
{
struct message *msg;
struct urb *urb;
@ -285,7 +290,8 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, in
/*
Send sysex message in pieces of wMaxPacketSize bytes.
*/
int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int size)
int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
int size)
{
return line6_send_raw_message(line6, buffer, size + SYSEX_EXTRA_SIZE) - SYSEX_EXTRA_SIZE;
}
@ -295,7 +301,8 @@ int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int si
@param code sysex message code
@param size number of bytes between code and sysex end
*/
char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, int size)
char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
int size)
{
char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_KERNEL);
@ -412,7 +419,8 @@ int line6_send_program(struct usb_line6 *line6, int value)
#endif
retval = usb_interrupt_msg(line6->usbdev,
usb_sndintpipe(line6->usbdev, line6->ep_control_write),
usb_sndintpipe(line6->usbdev,
line6->ep_control_write),
buffer, 2, &partial, LINE6_TIMEOUT * HZ);
if (retval)
@ -479,24 +487,32 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t dat
/* Wait for data length. We'll get a couple of 0xff until length arrives. */
do {
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x0012, 0x0000, &len, 1, LINE6_TIMEOUT * HZ);
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
USB_DIR_IN,
0x0012, 0x0000, &len, 1,
LINE6_TIMEOUT * HZ);
if (ret < 0) {
dev_err(line6->ifcdev, "receive length failed (error %d)\n", ret);
dev_err(line6->ifcdev,
"receive length failed (error %d)\n", ret);
return ret;
}
}
while(len == 0xff);
while (len == 0xff)
;
if(len != datalen) { /* should be equal or something went wrong */
dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", (int)datalen, (int)len);
if (len != datalen) {
/* should be equal or something went wrong */
dev_err(line6->ifcdev,
"length mismatch (expected %d, got %d)\n",
(int)datalen, (int)len);
return -EINVAL;
}
/* receive the result: */
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x0013, 0x0000, data, datalen, LINE6_TIMEOUT * HZ);
0x0013, 0x0000, data, datalen,
LINE6_TIMEOUT * HZ);
if (ret < 0) {
dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
@ -509,7 +525,8 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t dat
/*
Write data to device.
*/
int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen)
int line6_write_data(struct usb_line6 *line6, int address, void *data,
size_t datalen)
{
struct usb_device *usbdev = line6->usbdev;
int ret;
@ -517,24 +534,31 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t da
ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
0x0022, address, data, datalen, LINE6_TIMEOUT * HZ);
0x0022, address, data, datalen,
LINE6_TIMEOUT * HZ);
if (ret < 0) {
dev_err(line6->ifcdev, "write request failed (error %d)\n", ret);
dev_err(line6->ifcdev,
"write request failed (error %d)\n", ret);
return ret;
}
do {
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev,0), 0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x0012, 0x0000, &status, 1, LINE6_TIMEOUT * HZ);
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
USB_DIR_IN,
0x0012, 0x0000,
&status, 1, LINE6_TIMEOUT * HZ);
if (ret < 0) {
dev_err(line6->ifcdev, "receiving status failed (error %d)\n", ret);
dev_err(line6->ifcdev,
"receiving status failed (error %d)\n", ret);
return ret;
}
}
while(status == 0xff);
while (status == 0xff)
;
if (status != 0) {
dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
@ -591,16 +615,19 @@ ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
static void line6_destruct(struct usb_interface *interface)
{
struct usb_line6 *line6;
if(interface == NULL) return;
if (interface == NULL)
return;
line6 = usb_get_intfdata(interface);
if(line6 == NULL) return;
if (line6 == NULL)
return;
/* free buffer memory first: */
if(line6->buffer_message != NULL) kfree(line6->buffer_message);
if(line6->buffer_listen != NULL) kfree(line6->buffer_listen);
kfree(line6->buffer_message);
kfree(line6->buffer_listen);
/* then free URBs: */
if(line6->urb_listen != NULL) usb_free_urb(line6->urb_listen);
usb_free_urb(line6->urb_listen);
/* make sure the device isn't destructed twice: */
usb_set_intfdata(interface, NULL);
@ -640,9 +667,11 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
int ep_read = 0, ep_write = 0;
int ret;
if(interface == NULL) return -ENODEV;
if (interface == NULL)
return -ENODEV;
usbdev = interface_to_usbdev(interface);
if(usbdev == NULL) return -ENODEV;
if (usbdev == NULL)
return -ENODEV;
/* increment reference counters: */
usb_get_intf(interface);
@ -688,9 +717,14 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
case LINE6_DEVID_PODX3:
case LINE6_DEVID_PODX3LIVE:
switch (interface_number) {
case 0: alternate = 1; break;
case 1: alternate = 0; break;
default: MISSING_CASE;
case 0:
alternate = 1;
break;
case 1:
alternate = 0;
break;
default:
MISSING_CASE;
}
break;
@ -703,15 +737,21 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
case LINE6_DEVID_TONEPORT_GX:
case LINE6_DEVID_GUITARPORT:
alternate = 2; // 1..4 seem to be ok
alternate = 2; /* 1..4 seem to be ok */
break;
case LINE6_DEVID_TONEPORT_UX1:
case LINE6_DEVID_TONEPORT_UX2:
switch (interface_number) {
case 0: alternate = 2; break; /* defaults to 44.1kHz, 16-bit */
case 1: alternate = 0; break;
default: MISSING_CASE;
case 0:
/* defaults to 44.1kHz, 16-bit */
alternate = 2;
break;
case 1:
alternate = 0;
break;
default:
MISSING_CASE;
}
break;
@ -720,7 +760,8 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
return -ENODEV;
}
if((ret = usb_set_interface(usbdev, interface_number, alternate)) < 0) {
ret = usb_set_interface(usbdev, interface_number, alternate);
if (ret < 0) {
dev_err(&interface->dev, "set_interface failed\n");
return ret;
}
@ -814,8 +855,7 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
if (ep != NULL) {
line6->interval = ep->desc.bInterval;
line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
}
else {
} else {
line6->interval = LINE6_FALLBACK_INTERVAL;
line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE;
dev_err(line6->ifcdev, "endpoint not available, using fallback values");
@ -850,8 +890,10 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
return -ENOMEM;
}
if((ret = line6_start_listen(line6)) < 0) {
dev_err(&interface->dev, " line6_probe: usb_submit_urb failed\n");
ret = line6_start_listen(line6);
if (ret < 0) {
dev_err(&interface->dev, "%s: usb_submit_urb failed\n",
__func__);
line6_destruct(interface);
return ret;
}
@ -881,7 +923,9 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
break;
default:
dev_err(&interface->dev, "PODxt Live interface %d not supported\n", interface_number);
dev_err(&interface->dev,
"PODxt Live interface %d not supported\n",
interface_number);
ret = -ENODEV;
}
@ -908,12 +952,15 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
return ret;
}
if((ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj, "usb_device")) < 0) {
ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj,
"usb_device");
if (ret < 0) {
line6_destruct(interface);
return ret;
}
dev_info(&interface->dev, "Line6 %s now attached\n", line6->properties->name);
dev_info(&interface->dev, "Line6 %s now attached\n",
line6->properties->name);
line6_devices[devnum] = line6;
line6_list_devices();
return ret;
@ -928,9 +975,11 @@ static void line6_disconnect(struct usb_interface *interface)
struct usb_device *usbdev;
int interface_number, i;
if(interface == NULL) return;
if (interface == NULL)
return;
usbdev = interface_to_usbdev(interface);
if(usbdev == NULL) return;
if (usbdev == NULL)
return;
sysfs_remove_link(&interface->dev.kobj, "usb_device");
@ -938,10 +987,12 @@ static void line6_disconnect(struct usb_interface *interface)
line6 = usb_get_intfdata(interface);
if (line6 != NULL) {
if(line6->urb_listen != NULL) usb_kill_urb(line6->urb_listen);
if (line6->urb_listen != NULL)
usb_kill_urb(line6->urb_listen);
if (usbdev != line6->usbdev)
dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n");
dev_err(line6->ifcdev,
"driver bug: inconsistent usb device\n");
switch (line6->usbdev->descriptor.idProduct) {
case LINE6_DEVID_BASSPODXT:
@ -1013,7 +1064,8 @@ static int __init line6_init(void)
{
int i, retval;
printk("%s driver version %s%s\n", DRIVER_NAME, DRIVER_VERSION, DRIVER_REVISION);
printk(KERN_INFO "%s driver version %s%s\n",
DRIVER_NAME, DRIVER_VERSION, DRIVER_REVISION);
line6_workqueue = create_workqueue(DRIVER_NAME);
if (line6_workqueue == NULL) {