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:
@@ -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,
|
static int usb_internal_control_msg(struct usb_device *usb_dev,
|
||||||
unsigned int pipe,
|
unsigned int pipe,
|
||||||
struct usb_ctrlrequest *cmd,
|
struct usb_ctrlrequest *cmd,
|
||||||
@@ -108,28 +108,32 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
|
|||||||
* @index: USB message index value
|
* @index: USB message index value
|
||||||
* @data: pointer to the data to send
|
* @data: pointer to the data to send
|
||||||
* @size: length in bytes of 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
|
* @timeout: time in msecs to wait for the message to complete before timing
|
||||||
* timing out (if 0 the wait is forever)
|
* out (if 0 the wait is forever)
|
||||||
|
*
|
||||||
* Context: !in_interrupt ()
|
* Context: !in_interrupt ()
|
||||||
*
|
*
|
||||||
* This function sends a simple control message to a specified endpoint
|
* This function sends a simple control message to a specified endpoint and
|
||||||
* and waits for the message to complete, or timeout.
|
* 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
|
* Don't use this function from within an interrupt context, like a bottom half
|
||||||
* bottom half handler. If you need an asynchronous message, or need to send
|
* handler. If you need an asynchronous message, or need to send a message
|
||||||
* a message from within interrupt context, use usb_submit_urb()
|
* from within interrupt context, use usb_submit_urb().
|
||||||
* If a thread in your driver uses this call, make sure your disconnect()
|
* 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
|
* method can wait for it to complete. Since you don't have a handle on the
|
||||||
* the URB used, you can't cancel the request.
|
* URB used, you can't cancel the request.
|
||||||
*/
|
*/
|
||||||
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype,
|
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
|
||||||
__u16 value, __u16 index, void *data, __u16 size, int timeout)
|
__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;
|
int ret;
|
||||||
|
|
||||||
|
dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
|
||||||
if (!dr)
|
if (!dr)
|
||||||
return -ENOMEM;
|
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->wIndex = cpu_to_le16p(&index);
|
||||||
dr->wLength = cpu_to_le16p(&size);
|
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);
|
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
|
* @pipe: endpoint "pipe" to send the message to
|
||||||
* @data: pointer to the data to send
|
* @data: pointer to the data to send
|
||||||
* @len: length in bytes of 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
|
* @timeout: time in msecs to wait for the message to complete before
|
||||||
* timing out (if 0 the wait is forever)
|
* timing out (if 0 the wait is forever)
|
||||||
|
*
|
||||||
* Context: !in_interrupt ()
|
* Context: !in_interrupt ()
|
||||||
*
|
*
|
||||||
* This function sends a simple interrupt message to a specified endpoint and
|
* 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
|
* @pipe: endpoint "pipe" to send the message to
|
||||||
* @data: pointer to the data to send
|
* @data: pointer to the data to send
|
||||||
* @len: length in bytes of 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
|
* @timeout: time in msecs to wait for the message to complete before
|
||||||
* timing out (if 0 the wait is forever)
|
* timing out (if 0 the wait is forever)
|
||||||
|
*
|
||||||
* Context: !in_interrupt ()
|
* Context: !in_interrupt ()
|
||||||
*
|
*
|
||||||
* This function sends a simple bulk message to a specified endpoint
|
* This function sends a simple bulk message to a specified endpoint
|
||||||
* and waits for the message to complete, or timeout.
|
* and waits for the message to complete, or timeout.
|
||||||
*
|
*
|
||||||
* If successful, it returns 0, otherwise a negative error number.
|
* If successful, it returns 0, otherwise a negative error number. The number
|
||||||
* The number of actual bytes transferred will be stored in the
|
* of actual bytes transferred will be stored in the actual_length paramater.
|
||||||
* actual_length paramater.
|
|
||||||
*
|
*
|
||||||
* Don't use this function from within an interrupt context, like a
|
* Don't use this function from within an interrupt context, like a bottom half
|
||||||
* bottom half handler. If you need an asynchronous message, or need to
|
* handler. If you need an asynchronous message, or need to send a message
|
||||||
* send a message from within interrupt context, use usb_submit_urb()
|
* from within interrupt context, use usb_submit_urb() If a thread in your
|
||||||
* If a thread in your driver uses this call, make sure your disconnect()
|
* driver uses this call, make sure your disconnect() method can wait for it to
|
||||||
* method can wait for it to complete. Since you don't have a handle on
|
* complete. Since you don't have a handle on the URB used, you can't cancel
|
||||||
* the URB used, you can't cancel the request.
|
* the request.
|
||||||
*
|
*
|
||||||
* Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT
|
* Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl,
|
||||||
* ioctl, users are forced to abuse this routine by using it to submit
|
* users are forced to abuse this routine by using it to submit URBs for
|
||||||
* URBs for interrupt endpoints. We will take the liberty of creating
|
* interrupt endpoints. We will take the liberty of creating an interrupt URB
|
||||||
* an interrupt URB (with the default interval) if the target is an
|
* (with the default interval) if the target is an interrupt endpoint.
|
||||||
* interrupt endpoint.
|
|
||||||
*/
|
*/
|
||||||
int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
|
int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
|
||||||
void *data, int len, int *actual_length, int timeout)
|
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_endpoint_num(&urb->ep->desc),
|
||||||
usb_urb_dir_in(urb) ? "in" : "out",
|
usb_urb_dir_in(urb) ? "in" : "out",
|
||||||
status, io->status);
|
status, io->status);
|
||||||
// BUG ();
|
/* BUG (); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (io->status == 0 && status && status != -ECONNRESET) {
|
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
|
* The request may be canceled with usb_sg_cancel(), either before or after
|
||||||
* usb_sg_wait() is called.
|
* usb_sg_wait() is called.
|
||||||
*/
|
*/
|
||||||
int usb_sg_init (
|
int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
|
||||||
struct usb_sg_request *io,
|
unsigned pipe, unsigned period, struct scatterlist *sg,
|
||||||
struct usb_device *dev,
|
int nents, size_t length, gfp_t mem_flags)
|
||||||
unsigned pipe,
|
|
||||||
unsigned period,
|
|
||||||
struct scatterlist *sg,
|
|
||||||
int nents,
|
|
||||||
size_t length,
|
|
||||||
gfp_t mem_flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int urb_flags;
|
int urb_flags;
|
||||||
@@ -509,7 +508,8 @@ EXPORT_SYMBOL_GPL(usb_sg_init);
|
|||||||
*/
|
*/
|
||||||
void usb_sg_wait(struct usb_sg_request *io)
|
void usb_sg_wait(struct usb_sg_request *io)
|
||||||
{
|
{
|
||||||
int i, entries = io->entries;
|
int i;
|
||||||
|
int entries = io->entries;
|
||||||
|
|
||||||
/* queue the urbs. */
|
/* queue the urbs. */
|
||||||
spin_lock_irq(&io->lock);
|
spin_lock_irq(&io->lock);
|
||||||
@@ -526,7 +526,7 @@ void usb_sg_wait (struct usb_sg_request *io)
|
|||||||
spin_unlock_irq(&io->lock);
|
spin_unlock_irq(&io->lock);
|
||||||
switch (retval) {
|
switch (retval) {
|
||||||
/* maybe we retrying will recover */
|
/* maybe we retrying will recover */
|
||||||
case -ENXIO: // hc didn't queue this one
|
case -ENXIO: /* hc didn't queue this one */
|
||||||
case -EAGAIN:
|
case -EAGAIN:
|
||||||
case -ENOMEM:
|
case -ENOMEM:
|
||||||
io->urbs[i]->dev = NULL;
|
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
|
* Returns the number of bytes received on success, or else the status code
|
||||||
* returned by the underlying usb_control_msg() call.
|
* 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 i;
|
||||||
int result;
|
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) {
|
for (i = 0; i < 3; ++i) {
|
||||||
/* retry on length 0 or error; some devices are flakey */
|
/* 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;
|
err = idx;
|
||||||
|
|
||||||
if (tbuf[1] != USB_DT_STRING)
|
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:
|
errout:
|
||||||
kfree(tbuf);
|
kfree(tbuf);
|
||||||
@@ -847,9 +850,15 @@ char *usb_cache_string(struct usb_device *udev, int index)
|
|||||||
char *smallbuf = NULL;
|
char *smallbuf = NULL;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) {
|
if (index <= 0)
|
||||||
if ((len = usb_string(udev, index, buf, 256)) > 0) {
|
return NULL;
|
||||||
if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == 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;
|
return buf;
|
||||||
memcpy(smallbuf, buf, len);
|
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
|
* usb_disable_device - Disable all the endpoints for a USB device
|
||||||
* @dev: the device whose endpoints are being disabled
|
* @dev: the device whose endpoints are being disabled
|
||||||
* @skip_ep0: 0 to disable endpoint 0, 1 to skip it.
|
* @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
|
* usb_enable_endpoint - Enable an endpoint for USB communications
|
||||||
* @dev: the device whose interface is being enabled
|
* @dev: the device whose interface is being enabled
|
||||||
* @ep: the endpoint
|
* @ep: the endpoint
|
||||||
@@ -1123,7 +1131,7 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep)
|
|||||||
ep->enabled = 1;
|
ep->enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* usb_enable_interface - Enable all the endpoints for an interface
|
* usb_enable_interface - Enable all the endpoints for an interface
|
||||||
* @dev: the device whose interface is being enabled
|
* @dev: the device whose interface is being enabled
|
||||||
* @intf: pointer to the interface descriptor
|
* @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;
|
struct usb_host_interface *alt;
|
||||||
int ret;
|
int ret;
|
||||||
int manual = 0;
|
int manual = 0;
|
||||||
|
unsigned int epaddr;
|
||||||
|
unsigned int pipe;
|
||||||
|
|
||||||
if (dev->state == USB_STATE_SUSPENDED)
|
if (dev->state == USB_STATE_SUSPENDED)
|
||||||
return -EHOSTUNREACH;
|
return -EHOSTUNREACH;
|
||||||
@@ -1233,11 +1243,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < alt->desc.bNumEndpoints; i++) {
|
for (i = 0; i < alt->desc.bNumEndpoints; i++) {
|
||||||
unsigned int epaddr =
|
epaddr = alt->endpoint[i].desc.bEndpointAddress;
|
||||||
alt->endpoint[i].desc.bEndpointAddress;
|
pipe = __create_pipe(dev,
|
||||||
unsigned int pipe =
|
USB_ENDPOINT_NUMBER_MASK & epaddr) |
|
||||||
__create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr)
|
(usb_endpoint_out(epaddr) ?
|
||||||
| (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN);
|
USB_DIR_OUT : USB_DIR_IN);
|
||||||
|
|
||||||
usb_clear_halt(dev, pipe);
|
usb_clear_halt(dev, pipe);
|
||||||
}
|
}
|
||||||
@@ -1366,7 +1376,8 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (add_uevent_var(env,
|
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.idVendor),
|
||||||
le16_to_cpu(usb_dev->descriptor.idProduct),
|
le16_to_cpu(usb_dev->descriptor.idProduct),
|
||||||
le16_to_cpu(usb_dev->descriptor.bcdDevice),
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* usb_set_configuration - Makes a particular device setting be current
|
* usb_set_configuration - Makes a particular device setting be current
|
||||||
* @dev: the device whose configuration is being updated
|
* @dev: the device whose configuration is being updated
|
||||||
@@ -1542,12 +1552,12 @@ free_interfaces:
|
|||||||
* getting rid of old interfaces means unbinding their drivers.
|
* getting rid of old interfaces means unbinding their drivers.
|
||||||
*/
|
*/
|
||||||
if (dev->state != USB_STATE_ADDRESS)
|
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,
|
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?
|
/* All the old state is gone, so what else can we do?
|
||||||
* The device is probably useless now anyway.
|
* The device is probably useless now anyway.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user