Skip to content

Commit 2c044a4

Browse files
committed
USB: fix codingstyle issues in drivers/usb/core/*.c
Fixes a number of coding style issues in the remaining .c files in drivers/usb/core/ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 3e35bf3 commit 2c044a4

6 files changed

Lines changed: 74 additions & 74 deletions

File tree

‎drivers/usb/core/buffer.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ int hcd_buffer_create(struct usb_hcd *hcd)
5757
!(hcd->driver->flags & HCD_LOCAL_MEM))
5858
return 0;
5959

60-
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
61-
if (!(size = pool_max [i]))
60+
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
61+
size = pool_max[i];
62+
if (!size)
6263
continue;
6364
snprintf(name, sizeof name, "buffer-%d", size);
6465
hcd->pool[i] = dma_pool_create(name, hcd->self.controller,
@@ -81,10 +82,10 @@ int hcd_buffer_create(struct usb_hcd *hcd)
8182
*/
8283
void hcd_buffer_destroy(struct usb_hcd *hcd)
8384
{
84-
int i;
85+
int i;
8586

86-
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
87-
struct dma_pool *pool = hcd->pool[i];
87+
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
88+
struct dma_pool *pool = hcd->pool[i];
8889
if (pool) {
8990
dma_pool_destroy(pool);
9091
hcd->pool[i] = NULL;

‎drivers/usb/core/config.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,16 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
238238

239239
/* Allocate space for the right(?) number of endpoints */
240240
num_ep = num_ep_orig = alt->desc.bNumEndpoints;
241-
alt->desc.bNumEndpoints = 0; // Use as a counter
241+
alt->desc.bNumEndpoints = 0; /* Use as a counter */
242242
if (num_ep > USB_MAXENDPOINTS) {
243243
dev_warn(ddev, "too many endpoints for config %d interface %d "
244244
"altsetting %d: %d, using maximum allowed: %d\n",
245245
cfgno, inum, asnum, num_ep, USB_MAXENDPOINTS);
246246
num_ep = USB_MAXENDPOINTS;
247247
}
248248

249-
if (num_ep > 0) { /* Can't allocate 0 bytes */
249+
if (num_ep > 0) {
250+
/* Can't allocate 0 bytes */
250251
len = sizeof(struct usb_host_endpoint) * num_ep;
251252
alt->endpoint = kzalloc(len, GFP_KERNEL);
252253
if (!alt->endpoint)
@@ -475,8 +476,9 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx,
475476
return 0;
476477
}
477478

478-
// hub-only!! ... and only exported for reset/reinit path.
479-
// otherwise used internally on disconnect/destroy path
479+
/* hub-only!! ... and only exported for reset/reinit path.
480+
* otherwise used internally on disconnect/destroy path
481+
*/
480482
void usb_destroy_configuration(struct usb_device *dev)
481483
{
482484
int c, i;
@@ -498,7 +500,7 @@ void usb_destroy_configuration(struct usb_device *dev)
498500
kfree(cf->string);
499501
for (i = 0; i < cf->desc.bNumInterfaces; i++) {
500502
if (cf->intf_cache[i])
501-
kref_put(&cf->intf_cache[i]->ref,
503+
kref_put(&cf->intf_cache[i]->ref,
502504
usb_release_interface_cache);
503505
}
504506
}
@@ -525,7 +527,7 @@ int usb_get_configuration(struct usb_device *dev)
525527
unsigned int cfgno, length;
526528
unsigned char *buffer;
527529
unsigned char *bigbuffer;
528-
struct usb_config_descriptor *desc;
530+
struct usb_config_descriptor *desc;
529531

530532
cfgno = 0;
531533
if (dev->authorized == 0) /* Not really an error */

‎drivers/usb/core/driver.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ static int usb_probe_interface(struct device *dev)
202202
intf = to_usb_interface(dev);
203203
udev = interface_to_usbdev(intf);
204204

205-
if (udev->authorized == 0) {
206-
dev_err(&intf->dev, "Device is not authorized for usage\n");
207-
return -ENODEV;
208-
}
205+
if (udev->authorized == 0) {
206+
dev_err(&intf->dev, "Device is not authorized for usage\n");
207+
return -ENODEV;
208+
}
209209

210210
id = usb_match_id(intf, driver->id_table);
211211
if (!id)
@@ -299,7 +299,7 @@ static int usb_unbind_interface(struct device *dev)
299299
* lock.
300300
*/
301301
int usb_driver_claim_interface(struct usb_driver *driver,
302-
struct usb_interface *iface, void* priv)
302+
struct usb_interface *iface, void *priv)
303303
{
304304
struct device *dev = &iface->dev;
305305
struct usb_device *udev = interface_to_usbdev(iface);
@@ -398,7 +398,7 @@ int usb_match_device(struct usb_device *dev, const struct usb_device_id *id)
398398
return 0;
399399

400400
if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
401-
(id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))
401+
(id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
402402
return 0;
403403

404404
if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
@@ -586,7 +586,7 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
586586
struct usb_device *usb_dev;
587587

588588
/* driver is often null here; dev_dbg() would oops */
589-
pr_debug ("usb %s: uevent\n", dev->bus_id);
589+
pr_debug("usb %s: uevent\n", dev->bus_id);
590590

591591
if (is_usb_device(dev))
592592
usb_dev = to_usb_device(dev);
@@ -596,11 +596,11 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
596596
}
597597

598598
if (usb_dev->devnum < 0) {
599-
pr_debug ("usb %s: already deleted?\n", dev->bus_id);
599+
pr_debug("usb %s: already deleted?\n", dev->bus_id);
600600
return -ENODEV;
601601
}
602602
if (!usb_dev->bus) {
603-
pr_debug ("usb %s: bus removed?\n", dev->bus_id);
603+
pr_debug("usb %s: bus removed?\n", dev->bus_id);
604604
return -ENODEV;
605605
}
606606

@@ -854,8 +854,10 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg)
854854
dev_err(&intf->dev, "%s error %d\n",
855855
"suspend", status);
856856
} else {
857-
// FIXME else if there's no suspend method, disconnect...
858-
// Not possible if auto_pm is set...
857+
/*
858+
* FIXME else if there's no suspend method, disconnect...
859+
* Not possible if auto_pm is set...
860+
*/
859861
dev_warn(&intf->dev, "no suspend for driver %s?\n",
860862
driver->name);
861863
mark_quiesced(intf);
@@ -894,7 +896,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume)
894896
dev_err(&intf->dev, "%s error %d\n",
895897
"reset_resume", status);
896898
} else {
897-
// status = -EOPNOTSUPP;
899+
/* status = -EOPNOTSUPP; */
898900
dev_warn(&intf->dev, "no %s for driver %s?\n",
899901
"reset_resume", driver->name);
900902
}
@@ -905,7 +907,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume)
905907
dev_err(&intf->dev, "%s error %d\n",
906908
"resume", status);
907909
} else {
908-
// status = -EOPNOTSUPP;
910+
/* status = -EOPNOTSUPP; */
909911
dev_warn(&intf->dev, "no %s for driver %s?\n",
910912
"resume", driver->name);
911913
}
@@ -1175,7 +1177,7 @@ static int usb_resume_both(struct usb_device *udev)
11751177
* so if a root hub's controller is suspended
11761178
* then we're stuck. */
11771179
status = usb_resume_device(udev);
1178-
}
1180+
}
11791181
} else {
11801182

11811183
/* Needed for setting udev->dev.power.power_state.event,

‎drivers/usb/core/sysfs.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ set_bConfigurationValue(struct device *dev, struct device_attribute *attr,
7272
return (value < 0) ? value : count;
7373
}
7474

75-
static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR,
75+
static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR,
7676
show_bConfigurationValue, set_bConfigurationValue);
7777

7878
/* String fields */
@@ -650,21 +650,21 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
650650
/* Interface Accociation Descriptor fields */
651651
#define usb_intf_assoc_attr(field, format_string) \
652652
static ssize_t \
653-
show_iad_##field (struct device *dev, struct device_attribute *attr, \
653+
show_iad_##field(struct device *dev, struct device_attribute *attr, \
654654
char *buf) \
655655
{ \
656-
struct usb_interface *intf = to_usb_interface (dev); \
656+
struct usb_interface *intf = to_usb_interface(dev); \
657657
\
658-
return sprintf (buf, format_string, \
659-
intf->intf_assoc->field); \
658+
return sprintf(buf, format_string, \
659+
intf->intf_assoc->field); \
660660
} \
661661
static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL);
662662

663-
usb_intf_assoc_attr (bFirstInterface, "%02x\n")
664-
usb_intf_assoc_attr (bInterfaceCount, "%02d\n")
665-
usb_intf_assoc_attr (bFunctionClass, "%02x\n")
666-
usb_intf_assoc_attr (bFunctionSubClass, "%02x\n")
667-
usb_intf_assoc_attr (bFunctionProtocol, "%02x\n")
663+
usb_intf_assoc_attr(bFirstInterface, "%02x\n")
664+
usb_intf_assoc_attr(bInterfaceCount, "%02d\n")
665+
usb_intf_assoc_attr(bFunctionClass, "%02x\n")
666+
usb_intf_assoc_attr(bFunctionSubClass, "%02x\n")
667+
usb_intf_assoc_attr(bFunctionProtocol, "%02x\n")
668668

669669
/* Interface fields */
670670
#define usb_intf_attr(field, format_string) \

‎drivers/usb/core/urb.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ EXPORT_SYMBOL_GPL(usb_free_urb);
103103
*
104104
* A pointer to the urb with the incremented reference counter is returned.
105105
*/
106-
struct urb * usb_get_urb(struct urb *urb)
106+
struct urb *usb_get_urb(struct urb *urb)
107107
{
108108
if (urb)
109109
kref_get(&urb->kref);
@@ -176,7 +176,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
176176
* describing that request to the USB subsystem. Request completion will
177177
* be indicated later, asynchronously, by calling the completion handler.
178178
* The three types of completion are success, error, and unlink
179-
* (a software-induced fault, also called "request cancellation").
179+
* (a software-induced fault, also called "request cancellation").
180180
*
181181
* URBs may be submitted in interrupt context.
182182
*
@@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
259259
* semaphores), or
260260
* (c) current->state != TASK_RUNNING, this is the case only after
261261
* you've changed it.
262-
*
262+
*
263263
* GFP_NOIO is used in the block io path and error handling of storage
264264
* devices.
265265
*
@@ -288,7 +288,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
288288

289289
if (!urb || urb->hcpriv || !urb->complete)
290290
return -EINVAL;
291-
if (!(dev = urb->dev) || dev->state < USB_STATE_DEFAULT)
291+
dev = urb->dev;
292+
if ((!dev) || (dev->state < USB_STATE_DEFAULT))
292293
return -ENODEV;
293294

294295
/* For now, get the endpoint from the pipe. Eventually drivers
@@ -351,11 +352,11 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
351352
max *= mult;
352353
}
353354

354-
if (urb->number_of_packets <= 0)
355+
if (urb->number_of_packets <= 0)
355356
return -EINVAL;
356357
for (n = 0; n < urb->number_of_packets; n++) {
357358
len = urb->iso_frame_desc[n].length;
358-
if (len < 0 || len > max)
359+
if (len < 0 || len > max)
359360
return -EMSGSIZE;
360361
urb->iso_frame_desc[n].status = -EXDEV;
361362
urb->iso_frame_desc[n].actual_length = 0;
@@ -420,7 +421,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
420421
/* too big? */
421422
switch (dev->speed) {
422423
case USB_SPEED_HIGH: /* units are microframes */
423-
// NOTE usb handles 2^15
424+
/* NOTE usb handles 2^15 */
424425
if (urb->interval > (1024 * 8))
425426
urb->interval = 1024 * 8;
426427
max = 1024 * 8;
@@ -430,12 +431,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
430431
if (xfertype == USB_ENDPOINT_XFER_INT) {
431432
if (urb->interval > 255)
432433
return -EINVAL;
433-
// NOTE ohci only handles up to 32
434+
/* NOTE ohci only handles up to 32 */
434435
max = 128;
435436
} else {
436437
if (urb->interval > 1024)
437438
urb->interval = 1024;
438-
// NOTE usb and ohci handle up to 2^15
439+
/* NOTE usb and ohci handle up to 2^15 */
439440
max = 1024;
440441
}
441442
break;
@@ -574,7 +575,8 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor)
574575

575576
spin_lock_irq(&anchor->lock);
576577
while (!list_empty(&anchor->urb_list)) {
577-
victim = list_entry(anchor->urb_list.prev, struct urb, anchor_list);
578+
victim = list_entry(anchor->urb_list.prev, struct urb,
579+
anchor_list);
578580
/* we must make sure the URB isn't freed before we kill it*/
579581
usb_get_urb(victim);
580582
spin_unlock_irq(&anchor->lock);

0 commit comments

Comments
 (0)