* [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
@ 2021-10-05 12:22 ` Robert Greener
2021-10-05 14:59 ` Joe Perches
2021-10-05 12:31 ` [PATCH 02/13] usb: core: config: fix block comment styles Robert Greener
` (11 subsequent siblings)
12 siblings, 1 reply; 15+ messages in thread
From: Robert Greener @ 2021-10-05 12:22 UTC (permalink / raw)
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
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index b199eb65f378..52b0edee5b55 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/13] usb: core: config: fix block comment styles
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
2021-10-05 12:22 ` [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args Robert Greener
@ 2021-10-05 12:31 ` Robert Greener
2021-10-05 12:35 ` [PATCH 03/13] usb: core: config: Change `unsigned` to `unsigned int` Robert Greener
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 12:31 UTC (permalink / raw)
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
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 52b0edee5b55..52aab1462787 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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) {
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/13] usb: core: config: Change `unsigned` to `unsigned int`
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
2021-10-05 12:22 ` [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args Robert Greener
2021-10-05 12:31 ` [PATCH 02/13] usb: core: config: fix block comment styles Robert Greener
@ 2021-10-05 12:35 ` Robert Greener
2021-10-05 12:37 ` [PATCH 04/13] usb: core: config: Avoid multiple line derefrence Robert Greener
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 12:35 UTC (permalink / raw)
Fix the following checkpatch warning:
core/config.c:622: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 52aab1462787..5de26d64a00b 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/13] usb: core: config: Avoid multiple line derefrence
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (2 preceding siblings ...)
2021-10-05 12:35 ` [PATCH 03/13] usb: core: config: Change `unsigned` to `unsigned int` Robert Greener
@ 2021-10-05 12:37 ` Robert Greener
2021-10-05 12:41 ` [PATCH 05/13] usb: core: config: Fix typo in dev_warn Robert Greener
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 12:37 UTC (permalink / raw)
Fix the following checkpatch warning:
core/config.c:816: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'intfc->altsetting[n].desc.bAlternateSetting'
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 5de26d64a00b..f6c90214bba0 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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)
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/13] usb: core: config: Fix typo in dev_warn
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (3 preceding siblings ...)
2021-10-05 12:37 ` [PATCH 04/13] usb: core: config: Avoid multiple line derefrence Robert Greener
@ 2021-10-05 12:41 ` Robert Greener
2021-10-05 13:22 ` [PATCH 06/13] usb: core: config: unsplit strings which are split across lines Robert Greener
` (7 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 12:41 UTC (permalink / raw)
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.
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index f6c90214bba0..c7451081b08b 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/13] usb: core: config: unsplit strings which are split across lines
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (4 preceding siblings ...)
2021-10-05 12:41 ` [PATCH 05/13] usb: core: config: Fix typo in dev_warn Robert Greener
@ 2021-10-05 13:22 ` Robert Greener
2021-10-05 13:25 ` [PATCH 07/13] usb: core: config: remove unnecessary blank lines Robert Greener
` (6 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:22 UTC (permalink / raw)
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.
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 224 +++++++++++++++++++-------------------
1 file changed, 110 insertions(+), 114 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index c7451081b08b..51c590da7651 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/13] usb: core: config: remove unnecessary blank lines
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (5 preceding siblings ...)
2021-10-05 13:22 ` [PATCH 06/13] usb: core: config: unsplit strings which are split across lines Robert Greener
@ 2021-10-05 13:25 ` Robert Greener
2021-10-05 13:26 ` [PATCH 08/13] usb: core: config: add blank lines after struct def Robert Greener
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:25 UTC (permalink / raw)
This patch fixes the following checkpatch.pl warning at multiple
locations:
CHECK:LINE_SPACING: Please don't use multiple blank lines
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 51c590da7651..af88cfe52e92 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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
*
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/13] usb: core: config: add blank lines after struct def
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (6 preceding siblings ...)
2021-10-05 13:25 ` [PATCH 07/13] usb: core: config: remove unnecessary blank lines Robert Greener
@ 2021-10-05 13:26 ` Robert Greener
2021-10-05 13:30 ` [PATCH 09/13] usb: core: config: fix inline spacign Robert Greener
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:26 UTC (permalink / raw)
This fixes the following checkpatch.pl warning at multiple locations:
CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index af88cfe52e92..3bf04fdf850a 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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,
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/13] usb: core: config: fix inline spacign
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (7 preceding siblings ...)
2021-10-05 13:26 ` [PATCH 08/13] usb: core: config: add blank lines after struct def Robert Greener
@ 2021-10-05 13:30 ` Robert Greener
2021-10-05 13:34 ` [PATCH 10/13] usb: core: config: fix checkpatch.pl braces warning Robert Greener
` (3 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:30 UTC (permalink / raw)
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)
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 3bf04fdf850a..9717f89bcb6f 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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 */
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/13] usb: core: config: fix checkpatch.pl braces warning
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (8 preceding siblings ...)
2021-10-05 13:30 ` [PATCH 09/13] usb: core: config: fix inline spacign Robert Greener
@ 2021-10-05 13:34 ` Robert Greener
2021-10-05 13:37 ` [PATCH 11/13] usb: core: config: remove unnecessary parentheses Robert Greener
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:34 UTC (permalink / raw)
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 '{'
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 9717f89bcb6f..76038e8c84c5 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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",
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/13] usb: core: config: remove unnecessary parentheses
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (9 preceding siblings ...)
2021-10-05 13:34 ` [PATCH 10/13] usb: core: config: fix checkpatch.pl braces warning Robert Greener
@ 2021-10-05 13:37 ` Robert Greener
2021-10-05 13:43 ` [PATCH 12/13] usb: core: config: remove multiple assignments Robert Greener
2021-10-05 13:52 ` [PATCH 13/13] usb: core: config: fix parenthesis alignment Robert Greener
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:37 UTC (permalink / raw)
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'
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 76038e8c84c5..ab3395ec4260 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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);
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/13] usb: core: config: remove multiple assignments
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (10 preceding siblings ...)
2021-10-05 13:37 ` [PATCH 11/13] usb: core: config: remove unnecessary parentheses Robert Greener
@ 2021-10-05 13:43 ` Robert Greener
2021-10-05 13:52 ` [PATCH 13/13] usb: core: config: fix parenthesis alignment Robert Greener
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:43 UTC (permalink / raw)
This fixes the following checkpatch.pl warning at multiple locations:
CHECK:MULTIPLE_ASSIGNMENTS: multiple assignments should be avoided
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index ab3395ec4260..1fe995a66182 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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) {
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 13/13] usb: core: config: fix parenthesis alignment
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
` (11 preceding siblings ...)
2021-10-05 13:43 ` [PATCH 12/13] usb: core: config: remove multiple assignments Robert Greener
@ 2021-10-05 13:52 ` Robert Greener
12 siblings, 0 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:52 UTC (permalink / raw)
Fixes the following checkpatch.pl warnings at various locations:
CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
Signed-off-by: Robert Greener <rob@robgreener.com>
---
drivers/usb/core/config.c | 87 +++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 40 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 1fe995a66182..94de1476e9d0 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -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;
--
2.32.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings
@ 2021-10-05 13:55 Robert Greener
2021-10-05 12:22 ` [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args Robert Greener
` (12 more replies)
0 siblings, 13 replies; 15+ messages in thread
From: Robert Greener @ 2021-10-05 13:55 UTC (permalink / raw)
This patchset fixes all checkpatch warnings in drivers/usb/core/config.c
(when combined with my earlier patch
Link: https://lore.kernel.org/r/20211001151350.ijiexr3ebwvypmdd@shortbread)
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(-)
--
2.32.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args
2021-10-05 12:22 ` [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args Robert Greener
@ 2021-10-05 14:59 ` Joe Perches
0 siblings, 0 replies; 15+ messages in thread
From: Joe Perches @ 2021-10-05 14:59 UTC (permalink / raw)
To: Robert Greener; +Cc: LKML
On Tue, 2021-10-05 at 13:22 +0100, Robert Greener wrote:
> This fixes the following checkpatch.pl warning at lines 28, 499, 500, 606:
Please do not bcc an entire patch set.
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
[]
> @@ -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[])
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-10-05 14:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 13:55 [PATCH 00/13] usb: core: config: fix all checkpatch.pl warnings Robert Greener
2021-10-05 12:22 ` [PATCH 01/13] usb: core: config: Use tabs rather than spaces for new lines of args Robert Greener
2021-10-05 14:59 ` Joe Perches
2021-10-05 12:31 ` [PATCH 02/13] usb: core: config: fix block comment styles Robert Greener
2021-10-05 12:35 ` [PATCH 03/13] usb: core: config: Change `unsigned` to `unsigned int` Robert Greener
2021-10-05 12:37 ` [PATCH 04/13] usb: core: config: Avoid multiple line derefrence Robert Greener
2021-10-05 12:41 ` [PATCH 05/13] usb: core: config: Fix typo in dev_warn Robert Greener
2021-10-05 13:22 ` [PATCH 06/13] usb: core: config: unsplit strings which are split across lines Robert Greener
2021-10-05 13:25 ` [PATCH 07/13] usb: core: config: remove unnecessary blank lines Robert Greener
2021-10-05 13:26 ` [PATCH 08/13] usb: core: config: add blank lines after struct def Robert Greener
2021-10-05 13:30 ` [PATCH 09/13] usb: core: config: fix inline spacign Robert Greener
2021-10-05 13:34 ` [PATCH 10/13] usb: core: config: fix checkpatch.pl braces warning Robert Greener
2021-10-05 13:37 ` [PATCH 11/13] usb: core: config: remove unnecessary parentheses Robert Greener
2021-10-05 13:43 ` [PATCH 12/13] usb: core: config: remove multiple assignments Robert Greener
2021-10-05 13:52 ` [PATCH 13/13] usb: core: config: fix parenthesis alignment Robert Greener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).