USB: fix codingstyle issues in drivers/usb/core/message.c
Fixes a number of coding style issues in the message.c file. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
34bbe4c16c
commit
3e35bf39e0
1 changed files with 199 additions and 189 deletions
|
@ -74,7 +74,7 @@ out:
|
|||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
// returns status (negative) or length (positive)
|
||||
/* returns status (negative) or length (positive) */
|
||||
static int usb_internal_control_msg(struct usb_device *usb_dev,
|
||||
unsigned int pipe,
|
||||
struct usb_ctrlrequest *cmd,
|
||||
|
@ -108,28 +108,32 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
|
|||
* @index: USB message index value
|
||||
* @data: pointer to the data to send
|
||||
* @size: length in bytes of the data to send
|
||||
* @timeout: time in msecs to wait for the message to complete before
|
||||
* timing out (if 0 the wait is forever)
|
||||
* @timeout: time in msecs to wait for the message to complete before timing
|
||||
* out (if 0 the wait is forever)
|
||||
*
|
||||
* Context: !in_interrupt ()
|
||||
*
|
||||
* This function sends a simple control message to a specified endpoint
|
||||
* and waits for the message to complete, or timeout.
|
||||
* This function sends a simple control message to a specified endpoint and
|
||||
* waits for the message to complete, or timeout.
|
||||
*
|
||||
* If successful, it returns the number of bytes transferred, otherwise a negative error number.
|
||||
* If successful, it returns the number of bytes transferred, otherwise a
|
||||
* negative error number.
|
||||
*
|
||||
* Don't use this function from within an interrupt context, like a
|
||||
* bottom half handler. If you need an asynchronous message, or need to send
|
||||
* a message from within interrupt context, use usb_submit_urb()
|
||||
* Don't use this function from within an interrupt context, like a bottom half
|
||||
* handler. If you need an asynchronous message, or need to send a message
|
||||
* from within interrupt context, use usb_submit_urb().
|
||||
* If a thread in your driver uses this call, make sure your disconnect()
|
||||
* method can wait for it to complete. Since you don't have a handle on
|
||||
* the URB used, you can't cancel the request.
|
||||
* method can wait for it to complete. Since you don't have a handle on the
|
||||
* URB used, you can't cancel the request.
|
||||
*/
|
||||
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype,
|
||||
__u16 value, __u16 index, void *data, __u16 size, int timeout)
|
||||
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
|
||||
__u8 requesttype, __u16 value, __u16 index, void *data,
|
||||
__u16 size, int timeout)
|
||||
{
|
||||
struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
|
||||
struct usb_ctrlrequest *dr;
|
||||
int ret;
|
||||
|
||||
dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
|
||||
if (!dr)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -139,7 +143,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u
|
|||
dr->wIndex = cpu_to_le16p(&index);
|
||||
dr->wLength = cpu_to_le16p(&size);
|
||||
|
||||
//dbg("usb_control_msg");
|
||||
/* dbg("usb_control_msg"); */
|
||||
|
||||
ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout);
|
||||
|
||||
|
@ -155,9 +159,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
|
|||
* @pipe: endpoint "pipe" to send the message to
|
||||
* @data: pointer to the data to send
|
||||
* @len: length in bytes of the data to send
|
||||
* @actual_length: pointer to a location to put the actual length transferred in bytes
|
||||
* @actual_length: pointer to a location to put the actual length transferred
|
||||
* in bytes
|
||||
* @timeout: time in msecs to wait for the message to complete before
|
||||
* timing out (if 0 the wait is forever)
|
||||
*
|
||||
* Context: !in_interrupt ()
|
||||
*
|
||||
* This function sends a simple interrupt message to a specified endpoint and
|
||||
|
@ -186,30 +192,30 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
|
|||
* @pipe: endpoint "pipe" to send the message to
|
||||
* @data: pointer to the data to send
|
||||
* @len: length in bytes of the data to send
|
||||
* @actual_length: pointer to a location to put the actual length transferred in bytes
|
||||
* @actual_length: pointer to a location to put the actual length transferred
|
||||
* in bytes
|
||||
* @timeout: time in msecs to wait for the message to complete before
|
||||
* timing out (if 0 the wait is forever)
|
||||
*
|
||||
* Context: !in_interrupt ()
|
||||
*
|
||||
* This function sends a simple bulk message to a specified endpoint
|
||||
* and waits for the message to complete, or timeout.
|
||||
*
|
||||
* If successful, it returns 0, otherwise a negative error number.
|
||||
* The number of actual bytes transferred will be stored in the
|
||||
* actual_length paramater.
|
||||
* If successful, it returns 0, otherwise a negative error number. The number
|
||||
* of actual bytes transferred will be stored in the actual_length paramater.
|
||||
*
|
||||
* Don't use this function from within an interrupt context, like a
|
||||
* bottom half handler. If you need an asynchronous message, or need to
|
||||
* send a message from within interrupt context, use usb_submit_urb()
|
||||
* If a thread in your driver uses this call, make sure your disconnect()
|
||||
* method can wait for it to complete. Since you don't have a handle on
|
||||
* the URB used, you can't cancel the request.
|
||||
* Don't use this function from within an interrupt context, like a bottom half
|
||||
* handler. If you need an asynchronous message, or need to send a message
|
||||
* from within interrupt context, use usb_submit_urb() If a thread in your
|
||||
* driver uses this call, make sure your disconnect() method can wait for it to
|
||||
* complete. Since you don't have a handle on the URB used, you can't cancel
|
||||
* the request.
|
||||
*
|
||||
* Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT
|
||||
* ioctl, users are forced to abuse this routine by using it to submit
|
||||
* URBs for interrupt endpoints. We will take the liberty of creating
|
||||
* an interrupt URB (with the default interval) if the target is an
|
||||
* interrupt endpoint.
|
||||
* Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl,
|
||||
* users are forced to abuse this routine by using it to submit URBs for
|
||||
* interrupt endpoints. We will take the liberty of creating an interrupt URB
|
||||
* (with the default interval) if the target is an interrupt endpoint.
|
||||
*/
|
||||
int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
|
||||
void *data, int len, int *actual_length, int timeout)
|
||||
|
@ -283,7 +289,7 @@ static void sg_complete (struct urb *urb)
|
|||
usb_endpoint_num(&urb->ep->desc),
|
||||
usb_urb_dir_in(urb) ? "in" : "out",
|
||||
status, io->status);
|
||||
// BUG ();
|
||||
/* BUG (); */
|
||||
}
|
||||
|
||||
if (io->status == 0 && status && status != -ECONNRESET) {
|
||||
|
@ -349,16 +355,9 @@ static void sg_complete (struct urb *urb)
|
|||
* The request may be canceled with usb_sg_cancel(), either before or after
|
||||
* usb_sg_wait() is called.
|
||||
*/
|
||||
int usb_sg_init (
|
||||
struct usb_sg_request *io,
|
||||
struct usb_device *dev,
|
||||
unsigned pipe,
|
||||
unsigned period,
|
||||
struct scatterlist *sg,
|
||||
int nents,
|
||||
size_t length,
|
||||
gfp_t mem_flags
|
||||
)
|
||||
int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
|
||||
unsigned pipe, unsigned period, struct scatterlist *sg,
|
||||
int nents, size_t length, gfp_t mem_flags)
|
||||
{
|
||||
int i;
|
||||
int urb_flags;
|
||||
|
@ -509,7 +508,8 @@ EXPORT_SYMBOL_GPL(usb_sg_init);
|
|||
*/
|
||||
void usb_sg_wait(struct usb_sg_request *io)
|
||||
{
|
||||
int i, entries = io->entries;
|
||||
int i;
|
||||
int entries = io->entries;
|
||||
|
||||
/* queue the urbs. */
|
||||
spin_lock_irq(&io->lock);
|
||||
|
@ -526,7 +526,7 @@ void usb_sg_wait (struct usb_sg_request *io)
|
|||
spin_unlock_irq(&io->lock);
|
||||
switch (retval) {
|
||||
/* maybe we retrying will recover */
|
||||
case -ENXIO: // hc didn't queue this one
|
||||
case -ENXIO: /* hc didn't queue this one */
|
||||
case -EAGAIN:
|
||||
case -ENOMEM:
|
||||
io->urbs[i]->dev = NULL;
|
||||
|
@ -632,12 +632,13 @@ EXPORT_SYMBOL_GPL(usb_sg_cancel);
|
|||
* Returns the number of bytes received on success, or else the status code
|
||||
* returned by the underlying usb_control_msg() call.
|
||||
*/
|
||||
int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
|
||||
int usb_get_descriptor(struct usb_device *dev, unsigned char type,
|
||||
unsigned char index, void *buf, int size)
|
||||
{
|
||||
int i;
|
||||
int result;
|
||||
|
||||
memset(buf,0,size); // Make sure we parse really received data
|
||||
memset(buf, 0, size); /* Make sure we parse really received data */
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
/* retry on length 0 or error; some devices are flakey */
|
||||
|
@ -825,7 +826,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
|
|||
err = idx;
|
||||
|
||||
if (tbuf[1] != USB_DT_STRING)
|
||||
dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf);
|
||||
dev_dbg(&dev->dev,
|
||||
"wrong descriptor type %02x for string %d (\"%s\")\n",
|
||||
tbuf[1], index, buf);
|
||||
|
||||
errout:
|
||||
kfree(tbuf);
|
||||
|
@ -847,9 +850,15 @@ char *usb_cache_string(struct usb_device *udev, int index)
|
|||
char *smallbuf = NULL;
|
||||
int len;
|
||||
|
||||
if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) {
|
||||
if ((len = usb_string(udev, index, buf, 256)) > 0) {
|
||||
if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL)
|
||||
if (index <= 0)
|
||||
return NULL;
|
||||
|
||||
buf = kmalloc(256, GFP_KERNEL);
|
||||
if (buf) {
|
||||
len = usb_string(udev, index, buf, 256);
|
||||
if (len > 0) {
|
||||
smallbuf = kmalloc(++len, GFP_KERNEL);
|
||||
if (!smallbuf)
|
||||
return buf;
|
||||
memcpy(smallbuf, buf, len);
|
||||
}
|
||||
|
@ -1045,7 +1054,7 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* usb_disable_device - Disable all the endpoints for a USB device
|
||||
* @dev: the device whose endpoints are being disabled
|
||||
* @skip_ep0: 0 to disable endpoint 0, 1 to skip it.
|
||||
|
@ -1097,8 +1106,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* usb_enable_endpoint - Enable an endpoint for USB communications
|
||||
* @dev: the device whose interface is being enabled
|
||||
* @ep: the endpoint
|
||||
|
@ -1123,7 +1131,7 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep)
|
|||
ep->enabled = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* usb_enable_interface - Enable all the endpoints for an interface
|
||||
* @dev: the device whose interface is being enabled
|
||||
* @intf: pointer to the interface descriptor
|
||||
|
@ -1179,6 +1187,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||
struct usb_host_interface *alt;
|
||||
int ret;
|
||||
int manual = 0;
|
||||
unsigned int epaddr;
|
||||
unsigned int pipe;
|
||||
|
||||
if (dev->state == USB_STATE_SUSPENDED)
|
||||
return -EHOSTUNREACH;
|
||||
|
@ -1233,11 +1243,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < alt->desc.bNumEndpoints; i++) {
|
||||
unsigned int epaddr =
|
||||
alt->endpoint[i].desc.bEndpointAddress;
|
||||
unsigned int pipe =
|
||||
__create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr)
|
||||
| (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN);
|
||||
epaddr = alt->endpoint[i].desc.bEndpointAddress;
|
||||
pipe = __create_pipe(dev,
|
||||
USB_ENDPOINT_NUMBER_MASK & epaddr) |
|
||||
(usb_endpoint_out(epaddr) ?
|
||||
USB_DIR_OUT : USB_DIR_IN);
|
||||
|
||||
usb_clear_halt(dev, pipe);
|
||||
}
|
||||
|
@ -1366,7 +1376,8 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|||
return -ENOMEM;
|
||||
|
||||
if (add_uevent_var(env,
|
||||
"MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
|
||||
"MODALIAS=usb:"
|
||||
"v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
|
||||
le16_to_cpu(usb_dev->descriptor.idVendor),
|
||||
le16_to_cpu(usb_dev->descriptor.idProduct),
|
||||
le16_to_cpu(usb_dev->descriptor.bcdDevice),
|
||||
|
@ -1424,7 +1435,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev,
|
|||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* usb_set_configuration - Makes a particular device setting be current
|
||||
* @dev: the device whose configuration is being updated
|
||||
|
@ -1542,12 +1552,12 @@ free_interfaces:
|
|||
* getting rid of old interfaces means unbinding their drivers.
|
||||
*/
|
||||
if (dev->state != USB_STATE_ADDRESS)
|
||||
usb_disable_device (dev, 1); // Skip ep0
|
||||
usb_disable_device(dev, 1); /* Skip ep0 */
|
||||
|
||||
if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||
USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
|
||||
NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) {
|
||||
|
||||
NULL, 0, USB_CTRL_SET_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
/* All the old state is gone, so what else can we do?
|
||||
* The device is probably useless now anyway.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue