Skip to contentSkip to conversation

usb: core: config: fix all checkpatch.pl warnings

PATCH In review Robert Greener 4 participants 25 messages Oct 5, 2021 USB

lore
Share & tools
lore
#9 lore raw

PATCH 5/13 usb: core: config: Fix typo in dev_warn

In reply to Robert Greener

This fixes the following checkpatch.pl error:

core/config.c:66: WARNING:MISSING_SPACE: break quoted strings at a space character

This fix solvers inserts a space between companion and for, where there is not one currently.

---
 drivers/usb/core/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/config.c +1 -1
index f6c90214bba0..c7451081b08b 100644
@@ -62,7 +62,7 @@ static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
 	desc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;
 	if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||
 	    size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {
-		dev_warn(ddev, "Invalid SuperSpeedPlus isoc endpoint companion"
+		dev_warn(ddev, "Invalid SuperSpeedPlus isoc endpoint companion "
 			 "for config %d interface %d altsetting %d ep %d.\n",
 			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		return;
Signature · 1 line
2.32.0
#0 lore raw

cover usb: core: config: fix all checkpatch.pl warnings

This patchset fixes all checkpatch warnings in drivers/usb/core/config.c

(when combined with my earlier patch

Robert Greener (13):
usb: core: config: Use tabs rather than spaces for new lines of args
usb: core: config: fix block comment styles
usb: core: config: Change unsigned to unsigned int
usb: core: config: Avoid multiple line derefrence
usb: core: config: Fix typo in dev_warn
usb: core: config: unsplit strings which are split across lines
usb: core: config: remove unnecessary blank lines
usb: core: config: add blank lines after struct def
usb: core: config: fix inline spacign
usb: core: config: fix checkpatch.pl braces warning
usb: core: config: remove unnecessary parentheses
usb: core: config: remove multiple assignments
usb: core: config: fix parenthesis alignment

 drivers/usb/core/config.c | 393 ++++++++++++++++++++------------------
 1 file changed, 204 insertions(+), 189 deletions(-)
Signature · 1 line
2.32.0
#3 lore raw

PATCH 2/13 usb: core: config: fix block comment styles

Fix the following checkpatch warning at lines 45, 467, 547, 646, 696, 782, 897:

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line

---
 drivers/usb/core/config.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/usb/core/config.c +14 -7
index 52b0edee5b55..52aab1462787 100644
@@ -42,7 +42,8 @@ static int find_next_descriptor(unsigned char *buffer, int size,
 	}
 
 	/* Store the number of descriptors skipped and return the
-	 * number of bytes skipped */
+	 * number of bytes skipped
+	 */
 	if (num_skipped)
 		*num_skipped = n;
 	return buffer - buffer0;
@@ -464,7 +465,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 				inum, asnum, endpoint, buffer, size);
 
 	/* Skip over any Class Specific or Vendor Specific descriptors;
-	 * find the next endpoint or interface descriptor */
+	 * find the next endpoint or interface descriptor
+	 */
 	endpoint->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
 			USB_DT_INTERFACE, &n);
@@ -544,7 +546,8 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	memcpy(&alt->desc, d, USB_DT_INTERFACE_SIZE);
 
 	/* Skip over any Class Specific or Vendor Specific descriptors;
-	 * find the first endpoint or interface descriptor */
+	 * find the first endpoint or interface descriptor
+	 */
 	alt->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
 	    USB_DT_INTERFACE, &n);
@@ -643,7 +646,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	}
 
 	/* Go through the descriptors, checking their length and counting the
-	 * number of altsettings for each interface */
+	 * number of altsettings for each interface
+	 */
 	n = 0;
 	for ((buffer2 = buffer, size2 = size);
 	      size2 > 0;
@@ -693,7 +697,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 				    cfgno, inum, nintf_orig - 1);
 
 			/* Have we already encountered this interface?
-			 * Count its altsettings */
+			 * Count its altsettings
+			 */
 			for (i = 0; i < n; ++i) {
 				if (inums[i] == inum)
 					break;
@@ -779,7 +784,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	/* FIXME: parse the BOS descriptor */
 
 	/* Skip over any Class Specific or Vendor Specific descriptors;
-	 * find the first interface descriptor */
+	 * find the first interface descriptor
+	 */
 	config->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_INTERFACE,
 	    USB_DT_INTERFACE, &n);
@@ -894,7 +900,8 @@ int usb_get_configuration(struct usb_device *dev)
 
 	for (cfgno = 0; cfgno < ncfg; cfgno++) {
 		/* We grab just the first descriptor so we know how long
-		 * the whole configuration is */
+		 * the whole configuration is
+		 */
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
 		    desc, USB_DT_CONFIG_SIZE);
 		if (result < 0) {
Signature · 1 line
2.32.0
#7 lore raw

PATCH 4/13 usb: core: config: Avoid multiple line derefrence

In reply to Robert Greener

Fix the following checkpatch warning:

core/config.c:816: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'intfc->altsetting[n].desc.bAlternateSetting'

---
 drivers/usb/core/config.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/core/config.c +1 -2
index 5de26d64a00b..f6c90214bba0 100644
@@ -812,8 +812,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 		intfc = config->intf_cache[i];
 		for (j = 0; j < intfc->num_altsetting; ++j) {
 			for (n = 0; n < intfc->num_altsetting; ++n) {
-				if (intfc->altsetting[n].desc.
-				    bAlternateSetting == j)
+				if (intfc->altsetting[n].desc.bAlternateSetting == j)
 					break;
 			}
 			if (n >= intfc->num_altsetting)
Signature · 1 line
2.32.0
#11 lore raw

PATCH 7/13 usb: core: config: remove unnecessary blank lines

In reply to Robert Greener

This patch fixes the following checkpatch.pl warning at multiple locations:

CHECK:LINE_SPACING: Please don't use multiple blank lines

---
 drivers/usb/core/config.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/usb/core/config.c +0 -3
index 51c590da7651..af88cfe52e92 100644
@@ -13,12 +13,10 @@
 #include <asm/byteorder.h>
 #include "usb.h"
 
-
 #define USB_MAXALTSETTING		128	/* Hard limit */
 
 #define USB_MAXCONFIG			8	/* Arbitrary limit */
 
-
 static inline const char *plural(int n)
 {
 	return (n == 1 ? "" : "s");
@@ -848,7 +846,6 @@ void usb_destroy_configuration(struct usb_device *dev)
 	dev->config = NULL;
 }
 
-
 /*
  * Get the USB config descriptors, cache and parse'em
  *
Signature · 1 line
2.32.0
#15 lore raw

PATCH 10/13 usb: core: config: fix checkpatch.pl braces warning

In reply to Robert Greener

This fixes the following checkpatch.pl warnings:

core/config.c:268: CHECK:BRACES: braces {} should be used on all arms of this statement core/config.c:272: CHECK:BRACES: Unbalanced braces around else statement core/config.c:649: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'

---
 drivers/usb/core/config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/core/config.c +4 -4
index 9717f89bcb6f..76038e8c84c5 100644
@@ -265,11 +265,12 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	buffer += d->bLength;
 	size -= d->bLength;
 
-	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE)
+	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) {
 		n = USB_DT_ENDPOINT_AUDIO_SIZE;
-	else if (d->bLength >= USB_DT_ENDPOINT_SIZE)
+	}
+	else if (d->bLength >= USB_DT_ENDPOINT_SIZE) {
 		n = USB_DT_ENDPOINT_SIZE;
-	else {
+	} else {
 		dev_warn(ddev,
 			 "config %d interface %d altsetting %d has an invalid endpoint descriptor of length %d, skipping\n",
 			 cfgno, inum, asnum, d->bLength);
@@ -646,7 +647,6 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	for ((buffer2 = buffer, size2 = size);
 	      size2 > 0;
 	     (buffer2 += header->bLength, size2 -= header->bLength)) {
-
 		if (size2 < sizeof(struct usb_descriptor_header)) {
 			dev_warn(ddev,
 				 "config %d descriptor has %d excess byte%s, ignoring\n",
Signature · 1 line
2.32.0
#12 lore raw

PATCH 8/13 usb: core: config: add blank lines after struct def

In reply to Robert Greener

This fixes the following checkpatch.pl warning at multiple locations:

CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations

---
 drivers/usb/core/config.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/core/config.c +3 -0
index af88cfe52e92..3bf04fdf850a 100644
@@ -176,12 +176,14 @@ static const unsigned short low_speed_maxpacket_maxes[4] = {
 	[USB_ENDPOINT_XFER_BULK] = 0,
 	[USB_ENDPOINT_XFER_INT] = 8,
 };
+
 static const unsigned short full_speed_maxpacket_maxes[4] = {
 	[USB_ENDPOINT_XFER_CONTROL] = 64,
 	[USB_ENDPOINT_XFER_ISOC] = 1023,
 	[USB_ENDPOINT_XFER_BULK] = 64,
 	[USB_ENDPOINT_XFER_INT] = 64,
 };
+
 static const unsigned short high_speed_maxpacket_maxes[4] = {
 	[USB_ENDPOINT_XFER_CONTROL] = 64,
 	[USB_ENDPOINT_XFER_ISOC] = 1024,
@@ -190,6 +192,7 @@ static const unsigned short high_speed_maxpacket_maxes[4] = {
 	[USB_ENDPOINT_XFER_BULK] = 1024,
 	[USB_ENDPOINT_XFER_INT] = 1024,
 };
+
 static const unsigned short super_speed_maxpacket_maxes[4] = {
 	[USB_ENDPOINT_XFER_CONTROL] = 512,
 	[USB_ENDPOINT_XFER_ISOC] = 1024,
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/13 usb: core: config: Use tabs rather than spaces for new lines of args

In reply to Robert Greener

This fixes the following checkpatch.pl warning at lines 28, 499, 500, 606:

WARNING:LEADING_SPACE: please, no spaces at the start of a line

---
 drivers/usb/core/config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/core/config.c +4 -4
index b199eb65f378..52b0edee5b55 100644
@@ -25,7 +25,7 @@ static inline const char *plural(int n)
 }
 
 static int find_next_descriptor(unsigned char *buffer, int size,
-    int dt1, int dt2, int *num_skipped)
+		int dt1, int dt2, int *num_skipped)
 {
 	struct usb_descriptor_header *h;
 	int n = 0;
@@ -496,8 +496,8 @@ void usb_release_interface_cache(struct kref *ref)
 }
 
 static int usb_parse_interface(struct device *ddev, int cfgno,
-    struct usb_host_config *config, unsigned char *buffer, int size,
-    u8 inums[], u8 nalts[])
+		struct usb_host_config *config, unsigned char *buffer, int size,
+		s[], u8 nalts[])
 {
 	unsigned char *buffer0 = buffer;
 	struct usb_interface_descriptor	*d;
@@ -603,7 +603,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 }
 
 static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
-    struct usb_host_config *config, unsigned char *buffer, int size)
+		struct usb_host_config *config, unsigned char *buffer, int size)
 {
 	struct device *ddev = &dev->dev;
 	unsigned char *buffer0 = buffer;
Signature · 1 line
2.32.0
#6 lore raw

PATCH 3/13 usb: core: config: Change `unsigned` to `unsigned int`

In reply to Robert Greener

Fix the following checkpatch warning:

core/config.c:622: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'

---
 drivers/usb/core/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/config.c +1 -1
index 52aab1462787..5de26d64a00b 100644
@@ -619,7 +619,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	struct usb_descriptor_header *header;
 	int retval;
 	u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES];
-	unsigned iad_num = 0;
+	unsigned int iad_num = 0;
 
 	memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
 	nintf = nintf_orig = config->desc.bNumInterfaces;
Signature · 1 line
2.32.0
#13 lore raw

PATCH 9/13 usb: core: config: fix inline spacign

In reply to Robert Greener

This fixes the following checkpatch.pl warnings:

(many locations) CHECK:SPACING: No space is necessary after a cast core/config.c:332: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV)

---
 drivers/usb/core/config.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/usb/core/config.c +10 -10
index 3bf04fdf850a..9717f89bcb6f 100644
@@ -31,7 +31,7 @@ static int find_next_descriptor(unsigned char *buffer, int size,
 
 	/* Find the next descriptor of type dt1 or dt2 */
 	while (size > 0) {
-		h = (struct usb_descriptor_header *) buffer;
+		h = (struct usb_descriptor_header *)buffer;
 		if (h->bDescriptorType == dt1 || h->bDescriptorType == dt2)
 			break;
 		buffer += h->bLength;
@@ -57,7 +57,7 @@ static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
 	 * The SuperSpeedPlus Isoc endpoint companion descriptor immediately
 	 * follows the SuperSpeed Endpoint Companion descriptor
 	 */
-	desc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;
+	desc = (struct usb_ssp_isoc_ep_comp_descriptor *)buffer;
 	if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||
 	    size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {
 		dev_warn(ddev,
@@ -78,7 +78,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	/* The SuperSpeed endpoint companion descriptor is supposed to
 	 * be the first thing immediately following the endpoint descriptor.
 	 */
-	desc = (struct usb_ss_ep_comp_descriptor *) buffer;
+	desc = (struct usb_ss_ep_comp_descriptor *)buffer;
 
 	if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
 			size < USB_DT_SS_EP_COMP_SIZE) {
@@ -261,7 +261,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	unsigned int maxp;
 	const unsigned short *maxpacket_maxes;
 
-	d = (struct usb_endpoint_descriptor *) buffer;
+	d = (struct usb_endpoint_descriptor *)buffer;
 	buffer += d->bLength;
 	size -= d->bLength;
 
@@ -329,7 +329,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 			 * descriptors. Try to fix those and fall back to an
 			 * 8-ms default value otherwise.
 			 */
-			n = fls(d->bInterval*8);
+			n = fls(d->bInterval * 8);
 			if (n == 0)
 				n = 7;	/* 8 ms = 2^(7-1) uframes */
 			j = 16;
@@ -505,7 +505,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	int len, retval;
 	int num_ep, num_ep_orig;
 
-	d = (struct usb_interface_descriptor *) buffer;
+	d = (struct usb_interface_descriptor *)buffer;
 	buffer += d->bLength;
 	size -= d->bLength;
 
@@ -574,7 +574,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	/* Parse all the endpoint descriptors */
 	n = 0;
 	while (size > 0) {
-		if (((struct usb_descriptor_header *) buffer)->bDescriptorType
+		if (((struct usb_descriptor_header *)buffer)->bDescriptorType
 		     == USB_DT_INTERFACE)
 			break;
 		retval = usb_parse_endpoint(ddev, cfgno, config, inum, asnum,
@@ -654,7 +654,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 			break;
 		}
 
-		header = (struct usb_descriptor_header *) buffer2;
+		header = (struct usb_descriptor_header *)buffer2;
 		if ((header->bLength > size2) || (header->bLength < 2)) {
 			dev_warn(ddev,
 				 "config %d has an invalid descriptor of length %d, skipping remainder of the config\n",
@@ -666,7 +666,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 			struct usb_interface_descriptor *d;
 			int inum;
 
-			d = (struct usb_interface_descriptor *) header;
+			d = (struct usb_interface_descriptor *)header;
 			if (d->bLength < USB_DT_INTERFACE_SIZE) {
 				dev_warn(ddev,
 					 "config %d has an invalid interface descriptor of length %d, skipping\n",
@@ -912,7 +912,7 @@ int usb_get_configuration(struct usb_device *dev)
 			result = -EINVAL;
 			goto err;
 		}
-		length = max((int) le16_to_cpu(desc->wTotalLength),
+		length = max((int)le16_to_cpu(desc->wTotalLength),
 		    USB_DT_CONFIG_SIZE);
 
 		/* Now that we know the length, get the whole thing */
Signature · 1 line
2.32.0
#19 lore raw

PATCH 12/13 usb: core: config: remove multiple assignments

In reply to Robert Greener

This fixes the following checkpatch.pl warning at multiple locations:

CHECK:MULTIPLE_ASSIGNMENTS: multiple assignments should be avoided

---
 drivers/usb/core/config.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/usb/core/config.c +14 -7
index ab3395ec4260..1fe995a66182 100644
@@ -342,7 +342,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 			 */
 			if (udev->quirks & USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) {
 				n = clamp(fls(d->bInterval) + 3, i, j);
-				i = j = n;
+				j = n;
+				i = j;
 			}
 			/*
 			 * This quirk fixes bIntervals reported in
@@ -350,7 +351,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 			 */
 			if (udev->quirks & USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) {
 				n = clamp(fls(d->bInterval), i, j);
-				i = j = n;
+				j = n;
+				i = j;
 			}
 			break;
 		default:		/* USB_SPEED_FULL or _LOW */
@@ -554,7 +556,8 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	size -= i;
 
 	/* Allocate space for the right(?) number of endpoints */
-	num_ep = num_ep_orig = alt->desc.bNumEndpoints;
+	num_ep_orig = alt->desc.bNumEndpoints;
+	num_ep = num_ep_orig;
 	alt->desc.bNumEndpoints = 0;		/* Use as a counter */
 	if (num_ep > USB_MAXENDPOINTS) {
 		dev_warn(ddev,
@@ -616,7 +619,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	unsigned int iad_num = 0;
 
 	memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
-	nintf = nintf_orig = config->desc.bNumInterfaces;
+	nintf_orig = config->desc.bNumInterfaces;
+	nintf = nintf_orig;
 	config->desc.bNumInterfaces = 0;	// Adjusted later
 
 	if (config->desc.bDescriptorType != USB_DT_CONFIG ||
@@ -741,7 +745,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 			 cfgno, n, plural(n), nintf_orig);
 	else if (n == 0)
 		dev_warn(ddev, "config %d has no interfaces?\n", cfgno);
-	config->desc.bNumInterfaces = nintf = n;
+	nintf = n;
+	config->desc.bNumInterfaces = nintf;
 
 	/* Check for missing interface numbers */
 	for (i = 0; i < nintf; ++i) {
@@ -762,7 +767,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 			dev_warn(ddev,
 				 "too many alternate settings for config %d interface %d: %d, using maximum allowed: %d\n",
 				 cfgno, inums[i], j, USB_MAXALTSETTING);
-			nalts[i] = j = USB_MAXALTSETTING;
+			j = USB_MAXALTSETTING;
+			nalts[i] = j;
 		}
 
 		intfc = kzalloc(struct_size(intfc, altsetting, j), GFP_KERNEL);
@@ -867,7 +873,8 @@ int usb_get_configuration(struct usb_device *dev)
 		dev_warn(ddev,
 			 "too many configurations: %d, using maximum allowed: %d\n",
 			 ncfg, USB_MAXCONFIG);
-		dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
+		ncfg = USB_MAXCONFIG;
+		dev->descriptor.bNumConfigurations = ncfg;
 	}
 
 	if (ncfg < 1) {
Signature · 1 line
2.32.0
#17 lore raw

PATCH 11/13 usb: core: config: remove unnecessary parentheses

In reply to Robert Greener

This fixes the following checkpatch.pl warnings:

core/config.c:657: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'header->bLength > size2' core/config.c:657: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'header->bLength < 2'

---
 drivers/usb/core/config.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/core/config.c +2 -3
index 76038e8c84c5..ab3395ec4260 100644
@@ -267,8 +267,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 
 	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) {
 		n = USB_DT_ENDPOINT_AUDIO_SIZE;
-	}
-	else if (d->bLength >= USB_DT_ENDPOINT_SIZE) {
+	} else if (d->bLength >= USB_DT_ENDPOINT_SIZE) {
 		n = USB_DT_ENDPOINT_SIZE;
 	} else {
 		dev_warn(ddev,
@@ -655,7 +654,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 		}
 
 		header = (struct usb_descriptor_header *)buffer2;
-		if ((header->bLength > size2) || (header->bLength < 2)) {
+		if (header->bLength > size2 || header->bLength < 2) {
 			dev_warn(ddev,
 				 "config %d has an invalid descriptor of length %d, skipping remainder of the config\n",
 				 cfgno, header->bLength);
Signature · 1 line
2.32.0
#10 lore raw

PATCH 6/13 usb: core: config: unsplit strings which are split across lines

In reply to Robert Greener

This patch fixes the following checkpatch.pl warning across many lines:

WARNING:SPLIT_STRING: quoted string split across lines

This fix will make it easier to grep these strings in the source code.

---
 drivers/usb/core/config.c | 224 +++++++++++++++++++-------------------
 1 file changed, 110 insertions(+), 114 deletions(-)
drivers/usb/core/config.c +110 -114
index c7451081b08b..51c590da7651 100644
@@ -62,8 +62,8 @@ static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
 	desc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;
 	if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||
 	    size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {
-		dev_warn(ddev, "Invalid SuperSpeedPlus isoc endpoint companion "
-			 "for config %d interface %d altsetting %d ep %d.\n",
+		dev_warn(ddev,
+			 "Invalid SuperSpeedPlus isoc endpoint companion for config %d interface %d altsetting %d ep %d.\n",
 			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		return;
 	}
@@ -84,10 +84,9 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 
 	if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
 			size < USB_DT_SS_EP_COMP_SIZE) {
-		dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "
-				" interface %d altsetting %d ep %d: "
-				"using minimum values\n",
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "No SuperSpeed endpoint companion for config %d interface %d altsetting %d ep %d: using minimum values\n",
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 
 		/* Fill in some default values.
 		 * Leave bmAttributes as zero, which will mean no streams for
@@ -110,44 +109,41 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 
 	/* Check the various values */
 	if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) {
-		dev_warn(ddev, "Control endpoint with bMaxBurst = %d in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to zero\n", desc->bMaxBurst,
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "Control endpoint with bMaxBurst = %d in config %d interface %d altsetting %d ep %d: setting to zero\n",
+			 desc->bMaxBurst, cfgno, inum, asnum,
+			 ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bMaxBurst = 0;
 	} else if (desc->bMaxBurst > 15) {
-		dev_warn(ddev, "Endpoint with bMaxBurst = %d in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to 15\n", desc->bMaxBurst,
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "Endpoint with bMaxBurst = %d in config %d interface %d altsetting %d ep %d: setting to 15\n",
+			 desc->bMaxBurst,
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bMaxBurst = 15;
 	}
 
 	if ((usb_endpoint_xfer_control(&ep->desc) ||
 			usb_endpoint_xfer_int(&ep->desc)) &&
 				desc->bmAttributes != 0) {
-		dev_warn(ddev, "%s endpoint with bmAttributes = %d in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to zero\n",
-				usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
-				desc->bmAttributes,
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "%s endpoint with bmAttributes = %d in config %d interface %d altsetting %d ep %d: setting to zero\n",
+			 usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
+			 desc->bmAttributes,
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bmAttributes = 0;
 	} else if (usb_endpoint_xfer_bulk(&ep->desc) &&
 			desc->bmAttributes > 16) {
-		dev_warn(ddev, "Bulk endpoint with more than 65536 streams in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to max\n",
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "Bulk endpoint with more than 65536 streams in config %d interface %d altsetting %d ep %d: setting to max\n",
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bmAttributes = 16;
 	} else if (usb_endpoint_xfer_isoc(&ep->desc) &&
 		   !USB_SS_SSP_ISOC_COMP(desc->bmAttributes) &&
 		   USB_SS_MULT(desc->bmAttributes) > 3) {
-		dev_warn(ddev, "Isoc endpoint has Mult of %d in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to 3\n",
-				USB_SS_MULT(desc->bmAttributes),
-				cfgno, inum, asnum, ep->desc.bEndpointAddress);
+		dev_warn(ddev,
+			 "Isoc endpoint has Mult of %d in config %d interface %d altsetting %d ep %d: setting to 3\n",
+			 USB_SS_MULT(desc->bmAttributes),
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
 		ep->ss_ep_comp.bmAttributes = 2;
 	}
 
@@ -161,13 +157,12 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	else
 		max_tx = 999999;
 	if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) {
-		dev_warn(ddev, "%s endpoint with wBytesPerInterval of %d in "
-				"config %d interface %d altsetting %d ep %d: "
-				"setting to %d\n",
-				usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",
-				le16_to_cpu(desc->wBytesPerInterval),
-				cfgno, inum, asnum, ep->desc.bEndpointAddress,
-				max_tx);
+		dev_warn(ddev,
+			 "%s endpoint with wBytesPerInterval of %d in config %d interface %d altsetting %d ep %d: setting to %d\n",
+			 usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",
+			 le16_to_cpu(desc->wBytesPerInterval),
+			 cfgno, inum, asnum, ep->desc.bEndpointAddress,
+			 max_tx);
 		ep->ss_ep_comp.wBytesPerInterval = cpu_to_le16(max_tx);
 	}
 	/* Parse a possible SuperSpeedPlus isoc ep companion descriptor */
@@ -274,17 +269,17 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	else if (d->bLength >= USB_DT_ENDPOINT_SIZE)
 		n = USB_DT_ENDPOINT_SIZE;
 	else {
-		dev_warn(ddev, "config %d interface %d altsetting %d has an "
-		    "invalid endpoint descriptor of length %d, skipping\n",
-		    cfgno, inum, asnum, d->bLength);
+		dev_warn(ddev,
+			 "config %d interface %d altsetting %d has an invalid endpoint descriptor of length %d, skipping\n",
+			 cfgno, inum, asnum, d->bLength);
 		goto skip_to_next_endpoint_or_interface_descriptor;
 	}
 
 	i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK;
 	if (i >= 16 || i == 0) {
-		dev_warn(ddev, "config %d interface %d altsetting %d has an "
-		    "invalid endpoint with address 0x%X, skipping\n",
-		    cfgno, inum, asnum, d->bEndpointAddress);
+		dev_warn(ddev,
+			 "config %d interface %d altsetting %d has an invalid endpoint with address 0x%X, skipping\n",
+			 cfgno, inum, asnum, d->bEndpointAddress);
 		goto skip_to_next_endpoint_or_interface_descriptor;
 	}
 
@@ -379,10 +374,9 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 		}
 	}
 	if (d->bInterval < i || d->bInterval > j) {
-		dev_warn(ddev, "config %d interface %d altsetting %d "
-		    "endpoint 0x%X has an invalid bInterval %d, "
-		    "changing to %d\n",
-		    cfgno, inum, asnum,
+		dev_warn(ddev,
+			 "config %d interface %d altsetting %d endpoint 0x%X has an invalid bInterval %d, changing to %d\n",
+			 cfgno, inum, asnum,
 		    d->bEndpointAddress, d->bInterval, n);
 		endpoint->desc.bInterval = n;
 	}
@@ -392,9 +386,9 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	 * them usable, we will try treating them as Interrupt endpoints.
 	 */
 	if (udev->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) {
-		dev_warn(ddev, "config %d interface %d altsetting %d "
-		    "endpoint 0x%X is Bulk; changing to Interrupt\n",
-		    cfgno, inum, asnum, d->bEndpointAddress);
+		dev_warn(ddev,
+			 "config %d interface %d altsetting %d endpoint 0x%X is Bulk; changing to Interrupt\n",
+			 cfgno, inum, asnum, d->bEndpointAddress);
 		endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT;
 		endpoint->desc.bInterval = 1;
 		if (usb_endpoint_maxp(&endpoint->desc) > 8)
@@ -453,10 +447,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	 */
 	if (udev->speed == USB_SPEED_HIGH && usb_endpoint_xfer_bulk(d)) {
 		if (maxp != 512)
-			dev_warn(ddev, "config %d interface %d altsetting %d "
-				"bulk endpoint 0x%X has invalid maxpacket %d\n",
-				cfgno, inum, asnum, d->bEndpointAddress,
-				maxp);
+			dev_warn(ddev,
+				 "config %d interface %d altsetting %d bulk endpoint 0x%X has invalid maxpacket %d\n",
+				 cfgno, inum, asnum, d->bEndpointAddress,
+				 maxp);
 	}
 
 	/* Parse a possible SuperSpeed endpoint companion descriptor */
@@ -535,9 +529,9 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	      i < intfc->num_altsetting;
 	     (++i, ++alt)) {
 		if (alt->desc.bAlternateSetting == asnum) {
-			dev_warn(ddev, "Duplicate descriptor for config %d "
-			    "interface %d altsetting %d, skipping\n",
-			    cfgno, inum, asnum);
+			dev_warn(ddev,
+				 "Duplicate descriptor for config %d interface %d altsetting %d, skipping\n",
+				 cfgno, inum, asnum);
 			goto skip_to_next_interface_descriptor;
 		}
 	}
@@ -562,9 +556,9 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	num_ep = num_ep_orig = alt->desc.bNumEndpoints;
 	alt->desc.bNumEndpoints = 0;		/* Use as a counter */
 	if (num_ep > USB_MAXENDPOINTS) {
-		dev_warn(ddev, "too many endpoints for config %d interface %d "
-		    "altsetting %d: %d, using maximum allowed: %d\n",
-		    cfgno, inum, asnum, num_ep, USB_MAXENDPOINTS);
+		dev_warn(ddev,
+			 "too many endpoints for config %d interface %d altsetting %d: %d, using maximum allowed: %d\n",
+			 cfgno, inum, asnum, num_ep, USB_MAXENDPOINTS);
 		num_ep = USB_MAXENDPOINTS;
 	}
 
@@ -593,10 +587,9 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	}
 
 	if (n != num_ep_orig)
-		dev_warn(ddev, "config %d interface %d altsetting %d has %d "
-		    "endpoint descriptor%s, different from the interface "
-		    "descriptor's value: %d\n",
-		    cfgno, inum, asnum, n, plural(n), num_ep_orig);
+		dev_warn(ddev,
+			 "config %d interface %d altsetting %d has %d endpoint descriptor%s, different from the interface descriptor's value: %d\n",
+			 cfgno, inum, asnum, n, plural(n), num_ep_orig);
 	return buffer - buffer0;
 
 skip_to_next_interface_descriptor:
@@ -628,9 +621,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	if (config->desc.bDescriptorType != USB_DT_CONFIG ||
 	    config->desc.bLength < USB_DT_CONFIG_SIZE ||
 	    config->desc.bLength > size) {
-		dev_err(ddev, "invalid descriptor for config index %d: "
-		    "type = 0x%X, length = %d\n", cfgidx,
-		    config->desc.bDescriptorType, config->desc.bLength);
+		dev_err(ddev, "invalid descriptor for config index %d: type = 0x%X, length = %d\n",
+			cfgidx, config->desc.bDescriptorType,
+			config->desc.bLength);
 		return -EINVAL;
 	}
 	cfgno = config->desc.bConfigurationValue;
@@ -639,9 +632,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	size -= config->desc.bLength;
 
 	if (nintf > USB_MAXINTERFACES) {
-		dev_warn(ddev, "config %d has too many interfaces: %d, "
-		    "using maximum allowed: %d\n",
-		    cfgno, nintf, USB_MAXINTERFACES);
+		dev_warn(ddev,
+			 "config %d has too many interfaces: %d, using maximum allowed: %d\n",
+			 cfgno, nintf, USB_MAXINTERFACES);
 		nintf = USB_MAXINTERFACES;
 	}
 
@@ -654,17 +647,17 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	     (buffer2 += header->bLength, size2 -= header->bLength)) {
 
 		if (size2 < sizeof(struct usb_descriptor_header)) {
-			dev_warn(ddev, "config %d descriptor has %d excess "
-			    "byte%s, ignoring\n",
-			    cfgno, size2, plural(size2));
+			dev_warn(ddev,
+				 "config %d descriptor has %d excess byte%s, ignoring\n",
+				 cfgno, size2, plural(size2));
 			break;
 		}
 
 		header = (struct usb_descriptor_header *) buffer2;
 		if ((header->bLength > size2) || (header->bLength < 2)) {
-			dev_warn(ddev, "config %d has an invalid descriptor "
-			    "of length %d, skipping remainder of the config\n",
-			    cfgno, header->bLength);
+			dev_warn(ddev,
+				 "config %d has an invalid descriptor of length %d, skipping remainder of the config\n",
+				 cfgno, header->bLength);
 			break;
 		}
 
@@ -674,9 +667,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 
 			d = (struct usb_interface_descriptor *) header;
 			if (d->bLength < USB_DT_INTERFACE_SIZE) {
-				dev_warn(ddev, "config %d has an invalid "
-				    "interface descriptor of length %d, "
-				    "skipping\n", cfgno, d->bLength);
+				dev_warn(ddev,
+					 "config %d has an invalid interface descriptor of length %d, skipping\n",
+					 cfgno, d->bLength);
 				continue;
 			}
 
@@ -684,17 +677,16 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 
 			if ((dev->quirks & USB_QUIRK_HONOR_BNUMINTERFACES) &&
 			    n >= nintf_orig) {
-				dev_warn(ddev, "config %d has more interface "
-				    "descriptors, than it declares in "
-				    "bNumInterfaces, ignoring interface "
-				    "number: %d\n", cfgno, inum);
+				dev_warn(ddev,
+					 "config %d has more interface descriptors, than it declares in bNumInterfaces, ignoring interface number: %d\n",
+					 cfgno, inum);
 				continue;
 			}
 
 			if (inum >= nintf_orig)
-				dev_warn(ddev, "config %d has an invalid "
-				    "interface number: %d but max is %d\n",
-				    cfgno, inum, nintf_orig - 1);
+				dev_warn(ddev,
+					 "config %d has an invalid interface number: %d but max is %d\n",
+					 cfgno, inum, nintf_orig - 1);
 
 			/* Have we already encountered this interface?
 			 * Count its altsettings
@@ -725,10 +717,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 			}
 
 			if (iad_num == USB_MAXIADS) {
-				dev_warn(ddev, "found more Interface "
-					       "Association Descriptors "
-					       "than allocated for in "
-					       "configuration %d\n", cfgno);
+				dev_warn(ddev,
+					 "found more Interface Association Descriptors than allocated for in configuration %d\n",
+					cfgno);
 			} else {
 				config->intf_assoc[iad_num] = d;
 				iad_num++;
@@ -736,18 +727,18 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 
 		} else if (header->bDescriptorType == USB_DT_DEVICE ||
 			    header->bDescriptorType == USB_DT_CONFIG)
-			dev_warn(ddev, "config %d contains an unexpected "
-			    "descriptor of type 0x%X, skipping\n",
-			    cfgno, header->bDescriptorType);
+			dev_warn(ddev,
+				 "config %d contains an unexpected descriptor of type 0x%X, skipping\n",
+				 cfgno, header->bDescriptorType);
 
 	}	/* for ((buffer2 = buffer, size2 = size); ...) */
 	size = buffer2 - buffer;
 	config->desc.wTotalLength = cpu_to_le16(buffer2 - buffer0);
 
 	if (n != nintf)
-		dev_warn(ddev, "config %d has %d interface%s, different from "
-		    "the descriptor's value: %d\n",
-		    cfgno, n, plural(n), nintf_orig);
+		dev_warn(ddev,
+			 "config %d has %d interface%s, different from the descriptor's value: %d\n",
+			 cfgno, n, plural(n), nintf_orig);
 	else if (n == 0)
 		dev_warn(ddev, "config %d has no interfaces?\n", cfgno);
 	config->desc.bNumInterfaces = nintf = n;
@@ -759,18 +750,18 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 				break;
 		}
 		if (j >= nintf)
-			dev_warn(ddev, "config %d has no interface number "
-			    "%d\n", cfgno, i);
+			dev_warn(ddev,
+				 "config %d has no interface number %d\n",
+				 cfgno, i);
 	}
 
 	/* Allocate the usb_interface_caches and altsetting arrays */
 	for (i = 0; i < nintf; ++i) {
 		j = nalts[i];
 		if (j > USB_MAXALTSETTING) {
-			dev_warn(ddev, "too many alternate settings for "
-			    "config %d interface %d: %d, "
-			    "using maximum allowed: %d\n",
-			    cfgno, inums[i], j, USB_MAXALTSETTING);
+			dev_warn(ddev,
+				 "too many alternate settings for config %d interface %d: %d, using maximum allowed: %d\n",
+				 cfgno, inums[i], j, USB_MAXALTSETTING);
 			nalts[i] = j = USB_MAXALTSETTING;
 		}
 
@@ -816,8 +807,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 					break;
 			}
 			if (n >= intfc->num_altsetting)
-				dev_warn(ddev, "config %d interface %d has no "
-				    "altsetting %d\n", cfgno, inums[i], j);
+				dev_warn(ddev,
+					 "config %d interface %d has no altsetting %d\n",
+					 cfgno, inums[i], j);
 		}
 	}
 
@@ -873,8 +865,9 @@ int usb_get_configuration(struct usb_device *dev)
 	int result;
 
 	if (ncfg > USB_MAXCONFIG) {
-		dev_warn(ddev, "too many configurations: %d, "
-		    "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
+		dev_warn(ddev,
+			 "too many configurations: %d, using maximum allowed: %d\n",
+			 ncfg, USB_MAXCONFIG);
 		dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
 	}
 
@@ -904,17 +897,18 @@ int usb_get_configuration(struct usb_device *dev)
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
 		    desc, USB_DT_CONFIG_SIZE);
 		if (result < 0) {
-			dev_err(ddev, "unable to read config index %d "
-			    "descriptor/%s: %d\n", cfgno, "start", result);
+			dev_err(ddev,
+				"unable to read config index %d descriptor/%s: %d\n",
+				cfgno, "start", result);
 			if (result != -EPIPE)
 				goto err;
 			dev_err(ddev, "chopping to %d config(s)\n", cfgno);
 			dev->descriptor.bNumConfigurations = cfgno;
 			break;
 		} else if (result < 4) {
-			dev_err(ddev, "config index %d descriptor too short "
-			    "(expected %i, got %i)\n", cfgno,
-			    USB_DT_CONFIG_SIZE, result);
+			dev_err(ddev,
+				"config index %d descriptor too short (expected %i, got %i)\n",
+				cfgno, USB_DT_CONFIG_SIZE, result);
 			result = -EINVAL;
 			goto err;
 		}
@@ -934,14 +928,16 @@ int usb_get_configuration(struct usb_device *dev)
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
 		    bigbuffer, length);
 		if (result < 0) {
-			dev_err(ddev, "unable to read config index %d "
-			    "descriptor/%s\n", cfgno, "all");
+			dev_err(ddev,
+				"unable to read config index %d descriptor/%s\n",
+				cfgno, "all");
 			kfree(bigbuffer);
 			goto err;
 		}
 		if (result < length) {
-			dev_warn(ddev, "config index %d descriptor too short "
-			    "(expected %i, got %i)\n", cfgno, length, result);
+			dev_warn(ddev,
+				 "config index %d descriptor too short (expected %i, got %i)\n",
+				 cfgno, length, result);
 			length = result;
 		}
 
Signature · 1 line
2.32.0
#21 lore raw

PATCH 13/13 usb: core: config: fix parenthesis alignment

In reply to Robert Greener

Fixes the following checkpatch.pl warnings at various locations:

CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

---
 drivers/usb/core/config.c | 87 +++++++++++++++++++++------------------
 1 file changed, 47 insertions(+), 40 deletions(-)
drivers/usb/core/config.c +47 -40
index 1fe995a66182..94de1476e9d0 100644
@@ -23,7 +23,7 @@ static inline const char *plural(int n)
 }
 
 static int find_next_descriptor(unsigned char *buffer, int size,
-		int dt1, int dt2, int *num_skipped)
+				int dt1, int dt2, int *num_skipped)
 {
 	struct usb_descriptor_header *h;
 	int n = 0;
@@ -48,8 +48,11 @@ static int find_next_descriptor(unsigned char *buffer, int size,
 }
 
 static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
-		int cfgno, int inum, int asnum, struct usb_host_endpoint *ep,
-		unsigned char *buffer, int size)
+						  int cfgno, int inum,
+						  int asnum,
+						  struct usb_host_endpoint *ep,
+						  unsigned char *buffer,
+						  int size)
 {
 	struct usb_ssp_isoc_ep_comp_descriptor *desc;
 
@@ -69,8 +72,9 @@ static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
 }
 
 static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
-		int inum, int asnum, struct usb_host_endpoint *ep,
-		unsigned char *buffer, int size)
+					    int inum, int asnum,
+					    struct usb_host_endpoint *ep,
+					    unsigned char *buffer, int size)
 {
 	struct usb_ss_ep_comp_descriptor *desc;
 	int max_tx;
@@ -81,7 +85,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	desc = (struct usb_ss_ep_comp_descriptor *)buffer;
 
 	if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
-			size < USB_DT_SS_EP_COMP_SIZE) {
+	    size < USB_DT_SS_EP_COMP_SIZE) {
 		dev_warn(ddev,
 			 "No SuperSpeed endpoint companion for config %d interface %d altsetting %d ep %d: using minimum values\n",
 			 cfgno, inum, asnum, ep->desc.bEndpointAddress);
@@ -96,7 +100,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 		ep->ss_ep_comp.bLength = USB_DT_SS_EP_COMP_SIZE;
 		ep->ss_ep_comp.bDescriptorType = USB_DT_SS_ENDPOINT_COMP;
 		if (usb_endpoint_xfer_isoc(&ep->desc) ||
-				usb_endpoint_xfer_int(&ep->desc))
+		    usb_endpoint_xfer_int(&ep->desc))
 			ep->ss_ep_comp.wBytesPerInterval =
 					ep->desc.wMaxPacketSize;
 		return;
@@ -121,8 +125,8 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	}
 
 	if ((usb_endpoint_xfer_control(&ep->desc) ||
-			usb_endpoint_xfer_int(&ep->desc)) &&
-				desc->bmAttributes != 0) {
+	     usb_endpoint_xfer_int(&ep->desc)) &&
+	    desc->bmAttributes != 0) {
 		dev_warn(ddev,
 			 "%s endpoint with bmAttributes = %d in config %d interface %d altsetting %d ep %d: setting to zero\n",
 			 usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
@@ -167,7 +171,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
 	if (usb_endpoint_xfer_isoc(&ep->desc) &&
 	    USB_SS_SSP_ISOC_COMP(desc->bmAttributes))
 		usb_parse_ssp_isoc_endpoint_companion(ddev, cfgno, inum, asnum,
-							ep, buffer, size);
+						      ep, buffer, size);
 }
 
 static const unsigned short low_speed_maxpacket_maxes[4] = {
@@ -201,7 +205,7 @@ static const unsigned short super_speed_maxpacket_maxes[4] = {
 };
 
 static bool endpoint_is_duplicate(struct usb_endpoint_descriptor *e1,
-		struct usb_endpoint_descriptor *e2)
+				  struct usb_endpoint_descriptor *e2)
 {
 	if (e1->bEndpointAddress == e2->bEndpointAddress)
 		return true;
@@ -219,7 +223,8 @@ static bool endpoint_is_duplicate(struct usb_endpoint_descriptor *e1,
  * altsetting currently being parsed.
  */
 static bool config_endpoint_is_duplicate(struct usb_host_config *config,
-		int inum, int asnum, struct usb_endpoint_descriptor *d)
+					 int inum, int asnum,
+					 struct usb_endpoint_descriptor *d)
 {
 	struct usb_endpoint_descriptor *epd;
 	struct usb_interface_cache *intfc;
@@ -233,7 +238,7 @@ static bool config_endpoint_is_duplicate(struct usb_host_config *config,
 			alt = &intfc->altsetting[j];
 
 			if (alt->desc.bInterfaceNumber == inum &&
-					alt->desc.bAlternateSetting != asnum)
+			    alt->desc.bAlternateSetting != asnum)
 				continue;
 
 			for (k = 0; k < alt->desc.bNumEndpoints; ++k) {
@@ -249,9 +254,9 @@ static bool config_endpoint_is_duplicate(struct usb_host_config *config,
 }
 
 static int usb_parse_endpoint(struct device *ddev, int cfgno,
-		struct usb_host_config *config, int inum, int asnum,
-		struct usb_host_interface *ifp, int num_ep,
-		unsigned char *buffer, int size)
+			      struct usb_host_config *config, int inum,
+			      int asnum, struct usb_host_interface *ifp,
+			      int num_ep, unsigned char *buffer, int size)
 {
 	struct usb_device *udev = to_usb_device(ddev);
 	unsigned char *buffer0 = buffer;
@@ -291,7 +296,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	/* Check for duplicate endpoint addresses */
 	if (config_endpoint_is_duplicate(config, inum, asnum, d)) {
 		dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
-				cfgno, inum, asnum, d->bEndpointAddress);
+			 cfgno, inum, asnum, d->bEndpointAddress);
 		goto skip_to_next_endpoint_or_interface_descriptor;
 	}
 
@@ -299,8 +304,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	if (udev->quirks & USB_QUIRK_ENDPOINT_IGNORE) {
 		if (usb_endpoint_is_ignored(udev, ifp, d)) {
 			dev_warn(ddev, "config %d interface %d altsetting %d has an ignored endpoint with address 0x%X, skipping\n",
-					cfgno, inum, asnum,
-					d->bEndpointAddress);
+				 cfgno, inum, asnum, d->bEndpointAddress);
 			goto skip_to_next_endpoint_or_interface_descriptor;
 		}
 	}
@@ -407,7 +411,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	maxp = usb_endpoint_maxp(&endpoint->desc);
 	if (maxp == 0 && !(usb_endpoint_xfer_isoc(d) && asnum == 0)) {
 		dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n",
-		    cfgno, inum, asnum, d->bEndpointAddress);
+			 cfgno, inum, asnum, d->bEndpointAddress);
 	}
 
 	/* Find the highest legal maxpacket size for this endpoint */
@@ -438,7 +442,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 
 	if (maxp > j) {
 		dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n",
-		    cfgno, inum, asnum, d->bEndpointAddress, maxp, j);
+			 cfgno, inum, asnum, d->bEndpointAddress, maxp, j);
 		maxp = j;
 		endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp);
 	}
@@ -459,24 +463,24 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	/* Parse a possible SuperSpeed endpoint companion descriptor */
 	if (udev->speed >= USB_SPEED_SUPER)
 		usb_parse_ss_endpoint_companion(ddev, cfgno,
-				inum, asnum, endpoint, buffer, size);
+						inum, asnum, endpoint, buffer, size);
 
 	/* Skip over any Class Specific or Vendor Specific descriptors;
 	 * find the next endpoint or interface descriptor
 	 */
 	endpoint->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
-			USB_DT_INTERFACE, &n);
+				 USB_DT_INTERFACE, &n);
 	endpoint->extralen = i;
 	retval = buffer - buffer0 + i;
 	if (n > 0)
 		dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
-		    n, plural(n), "endpoint");
+			n, plural(n), "endpoint");
 	return retval;
 
 skip_to_next_endpoint_or_interface_descriptor:
 	i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
-	    USB_DT_INTERFACE, NULL);
+				 USB_DT_INTERFACE, NULL);
 	return buffer - buffer0 + i;
 }
 
@@ -495,8 +499,9 @@ void usb_release_interface_cache(struct kref *ref)
 }
 
 static int usb_parse_interface(struct device *ddev, int cfgno,
-		struct usb_host_config *config, unsigned char *buffer, int size,
-		s[], u8 nalts[])
+			       struct usb_host_config *config,
+			       unsigned char *buffer, int size, s[],
+			       u8 nalts[])
 {
 	unsigned char *buffer0 = buffer;
 	struct usb_interface_descriptor	*d;
@@ -547,11 +552,11 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 	 */
 	alt->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_ENDPOINT,
-	    USB_DT_INTERFACE, &n);
+				 USB_DT_INTERFACE, &n);
 	alt->extralen = i;
 	if (n > 0)
 		dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
-		    n, plural(n), "interface");
+			n, plural(n), "interface");
 	buffer += i;
 	size -= i;
 
@@ -581,7 +586,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 		     == USB_DT_INTERFACE)
 			break;
 		retval = usb_parse_endpoint(ddev, cfgno, config, inum, asnum,
-				alt, num_ep, buffer, size);
+					    alt, num_ep, buffer, size);
 		if (retval < 0)
 			return retval;
 		++n;
@@ -598,12 +603,13 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
 
 skip_to_next_interface_descriptor:
 	i = find_next_descriptor(buffer, size, USB_DT_INTERFACE,
-	    USB_DT_INTERFACE, NULL);
+				 USB_DT_INTERFACE, NULL);
 	return buffer - buffer0 + i;
 }
 
 static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
-		struct usb_host_config *config, unsigned char *buffer, int size)
+				   struct usb_host_config *config,
+				   unsigned char *buffer, int size)
 {
 	struct device *ddev = &dev->dev;
 	unsigned char *buffer0 = buffer;
@@ -785,18 +791,18 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 	 */
 	config->extra = buffer;
 	i = find_next_descriptor(buffer, size, USB_DT_INTERFACE,
-	    USB_DT_INTERFACE, &n);
+				 USB_DT_INTERFACE, &n);
 	config->extralen = i;
 	if (n > 0)
 		dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
-		    n, plural(n), "configuration");
+			n, plural(n), "configuration");
 	buffer += i;
 	size -= i;
 
 	/* Parse all the interface/altsetting descriptors */
 	while (size > 0) {
 		retval = usb_parse_interface(ddev, cfgno, config,
-		    buffer, size, inums, nalts);
+					     buffer, size, inums, nalts);
 		if (retval < 0)
 			return retval;
 
@@ -847,7 +853,7 @@ void usb_destroy_configuration(struct usb_device *dev)
 		for (i = 0; i < cf->desc.bNumInterfaces; i++) {
 			if (cf->intf_cache[i])
 				kref_put(&cf->intf_cache[i]->ref,
-					  usb_release_interface_cache);
+					 usb_release_interface_cache);
 		}
 	}
 	kfree(dev->config);
@@ -901,7 +907,7 @@ int usb_get_configuration(struct usb_device *dev)
 		 * the whole configuration is
 		 */
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
-		    desc, USB_DT_CONFIG_SIZE);
+					    desc, USB_DT_CONFIG_SIZE);
 		if (result < 0) {
 			dev_err(ddev,
 				"unable to read config index %d descriptor/%s: %d\n",
@@ -919,7 +925,7 @@ int usb_get_configuration(struct usb_device *dev)
 			goto err;
 		}
 		length = max((int)le16_to_cpu(desc->wTotalLength),
-		    USB_DT_CONFIG_SIZE);
+			     USB_DT_CONFIG_SIZE);
 
 		/* Now that we know the length, get the whole thing */
 		bigbuffer = kmalloc(length, GFP_KERNEL);
@@ -932,7 +938,7 @@ int usb_get_configuration(struct usb_device *dev)
 			msleep(200);
 
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
-		    bigbuffer, length);
+					    bigbuffer, length);
 		if (result < 0) {
 			dev_err(ddev,
 				"unable to read config index %d descriptor/%s\n",
@@ -950,7 +956,8 @@ int usb_get_configuration(struct usb_device *dev)
 		dev->rawdescriptors[cfgno] = bigbuffer;
 
 		result = usb_parse_configuration(dev, cfgno,
-		    &dev->config[cfgno], bigbuffer, length);
+						 &dev->config[cfgno],
+						 bigbuffer, length);
 		if (result < 0) {
 			++cfgno;
 			goto err;
Signature · 1 line
2.32.0
#4 lore raw

Re: [PATCH 02/13] usb: core: config: fix block comment styles

In reply to Robert Greener

Robert:

Replying to this message would be easier if you had included an actual recipient list in the mail header.

Quoted 15 lines · Robert Greener

Fix the following checkpatch warning at lines 45, 467, 547, 646, 696, 782, 897:

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line

---
 drivers/usb/core/config.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/usb/core/config.c +0 -0
index 52b0edee5b55..52aab1462787 100644

drivers/usb/core/config.c static int find_next_descriptor(unsigned char *buffer, int size, · line 46

Quoted 6 lines
drivers/usb/core/config.c +2 -1
@@ -42,7 +42,8 @@ static int find_next_descriptor(unsigned char *buffer, int size,
 	}
 
 	/* Store the number of descriptors skipped and return the
-	 * number of bytes skipped */
+	 * number of bytes skipped
+	 */

In fact, the style we use in the USB subsystem is like this:

	/*
	 * Store the number of descriptors skipped and return the
	 * number of bytes skipped
	 */

with both the opening "/*" and closing "*/" on separate lines. As long as you're changing the comments, you might as well update them to the style we use everywhere else.

Alan Stern

#14 lore raw

Re: [PATCH 09/13] usb: core: config: fix inline spacign

In reply to Robert Greener

You might want to fix the spelling error in the patch title (the email's Subject: line).

Quoted 4 lines · Robert Greener

This fixes the following checkpatch.pl warnings:

(many locations) CHECK:SPACING: No space is necessary after a cast core/config.c:332: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV)

This is one of the recommendations in checkpatch.pl that I heartily disagree with. K&R put spaces after casts; I don't see why we shouldn't do the same.

Alan Stern

maintainer
#23 lore raw
In reply to Robert Greener

First off, your cc: list was corrupted and stripped everything off :(

Quoted 1 line · Robert Greener

This patchset fixes all checkpatch warnings in drivers/usb/core/config.c

Why?

Please do not do this for subsystems that do not explicitly ask for it. If you wish to work on checkpatch issues, please start with drivers/staging/* and go from there.

For now, USB should be pretty "clean" with some minor issues. The churn here is not yet worth it as you have found.

sorry,

greg k-h

#16 lore raw

Re: [PATCH 10/13] usb: core: config: fix checkpatch.pl braces warning

In reply to Robert Greener
Quoted 5 lines · Robert Greener

This fixes the following checkpatch.pl warnings:

core/config.c:268: CHECK:BRACES: braces {} should be used on all arms of this statement core/config.c:272: CHECK:BRACES: Unbalanced braces around else statement core/config.c:649: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'

This is one aspect of checkpatch I don't understand at all.

Quoted 10 lines
---
 drivers/usb/core/config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/core/config.c +0 -0
index 9717f89bcb6f..76038e8c84c5 100644

drivers/usb/core/config.c static int usb_parse_endpoint(struct device *ddev, int cfgno, · line 270

Quoted 8 lines
drivers/usb/core/config.c +2 -2
@@ -265,11 +265,12 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 	buffer += d->bLength;
 	size -= d->bLength;
 
-	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE)
+	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) {
 		n = USB_DT_ENDPOINT_AUDIO_SIZE;
-	else if (d->bLength >= USB_DT_ENDPOINT_SIZE)
+	}

Why is it necessary to add braces to the "if" clause? The "else" clause doesn't use braces; it consists of a single "if" statement. Things would different if the code had been:

	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE)
		n = USB_DT_ENDPOINT_AUDIO_SIZE;
	else {
		if (d->bLength >= USB_DT_ENDPOINT_SIZE)
			...
	}

Then I would agree that braces were needed. But it isn't. After all, coding-style.rst says "Do not unnecessarily use braces where a single statement will do."

This seems like a bug in checkpatch.pl.

Alan Stern

#18 lore raw

Re: [PATCH 11/13] usb: core: config: remove unnecessary parentheses

In reply to Robert Greener
Quoted 15 lines · Robert Greener

This fixes the following checkpatch.pl warnings:

core/config.c:657: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'header->bLength > size2' core/config.c:657: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'header->bLength < 2'

---
 drivers/usb/core/config.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/core/config.c +0 -0
index 76038e8c84c5..ab3395ec4260 100644

drivers/usb/core/config.c static int usb_parse_endpoint(struct device *ddev, int cfgno, · line 273

Quoted 9 lines
drivers/usb/core/config.c +1 -2
@@ -267,8 +267,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 
 	if (d->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE) {
 		n = USB_DT_ENDPOINT_AUDIO_SIZE;
-	}
-	else if (d->bLength >= USB_DT_ENDPOINT_SIZE) {
+	} else if (d->bLength >= USB_DT_ENDPOINT_SIZE) {
 		n = USB_DT_ENDPOINT_SIZE;
 	} else {
 		dev_warn(ddev,

This has no connection with the patch's purpose. It looks like a remnant from an earlier patch.

Alan Stern

Quoted 12 lines
drivers/usb/core/config.c +1 -1
@@ -655,7 +654,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
 		}
 
 		header = (struct usb_descriptor_header *)buffer2;
-		if ((header->bLength > size2) || (header->bLength < 2)) {
+		if (header->bLength > size2 || header->bLength < 2) {
 			dev_warn(ddev,
 				 "config %d has an invalid descriptor of length %d, skipping remainder of the config\n",
 				 cfgno, header->bLength);
Signature · 1 line
2.32.0
#20 lore raw

Re: [PATCH 12/13] usb: core: config: remove multiple assignments

In reply to Robert Greener
Quoted 14 lines · Robert Greener

This fixes the following checkpatch.pl warning at multiple locations:

CHECK:MULTIPLE_ASSIGNMENTS: multiple assignments should be avoided

---
 drivers/usb/core/config.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/usb/core/config.c +0 -0
index ab3395ec4260..1fe995a66182 100644

drivers/usb/core/config.c static int usb_parse_endpoint(struct device *ddev, int cfgno, · line 346

Quoted 6 lines
drivers/usb/core/config.c +2 -1
@@ -342,7 +342,8 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 			 */
 			if (udev->quirks & USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) {
 				n = clamp(fls(d->bInterval) + 3, i, j);
-				i = j = n;
+				j = n;
+				i = j;

This is another case where I disagree with checkpatch.pl. There are times when multiple assignments are appropriate; this is one of them. So are the other ones in this patch.

Alan Stern

#22 lore raw

Re: [PATCH 13/13] usb: core: config: fix parenthesis alignment

In reply to Robert Greener
Quoted 3 lines · Robert Greener

Fixes the following checkpatch.pl warnings at various locations:

CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis

This is yet another case where I disagree with checkpatch.pl. C isn't Lisp; we shouldn't have to use the same conventions about aligning parentheses.

My preference is to indent continuation lines by two tab stops. In config.c I modified this practice because the continuation lines were very long and were indented very far; instead I sometimes indented them by four spaces. But in no case does it seem reasonable to align continuation lines with opening parens.

Alan Stern

#24 lore raw
In reply to Greg KH
Quoted 1 line · Greg KH

First off, your cc: list was corrupted and stripped everything off :(

Sorry, will make double check this in future...

Quoted 4 lines · Robert Greener
Quoted 1 line

This patchset fixes all checkpatch warnings in drivers/usb/core/config.c

Please do not do this for subsystems that do not explicitly ask for it.

Sure.

Thanks,
Robert

#2 lore raw

Re: [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args

In reply to Robert Greener
Quoted 1 line · Robert Greener

This fixes the following checkpatch.pl warning at lines 28, 499, 500, 606:

Please do not bcc an entire patch set.

drivers/usb/core/config.c

Quoted 1 line
drivers/usb/core/config.c +0 -0

[]

drivers/usb/core/config.c void usb_release_interface_cache(struct kref *ref) · line 500

Quoted 8 lines
drivers/usb/core/config.c +0 -0
@@ -496,8 +496,8 @@ void usb_release_interface_cache(struct kref *ref)
  }


 static int usb_parse_interface(struct device *ddev, int cfgno,

drivers/usb/core/config.c +2 -2
-    struct usb_host_config *config, unsigned char *buffer, int size,
-    u8 inums[], u8 nalts[])
+		struct usb_host_config *config, unsigned char *buffer, int size,
+		s[], u8 nalts[])

And don't send patches that likely don't compile.

A patch described as a whitespace only patch should not change anything other that whitespace.

#5 lore raw

Re: [PATCH 02/13] usb: core: config: fix block comment styles

In reply to Alan Stern

Hi Alan,

Quoted 2 lines · Alan Stern

Replying to this message would be easier if you had included an actual recipient list in the mail header.

Yes, sorry about this...

Thank you for your comments on my patchset. As it isn't going to be taken forward as its not worth the churn, I won't respond to each comment. However, they are useful for considering the output of checkpatch.pl in the future.

Robert