Skip to content

Commit 9aff7c5

Browse files
AlanSterngregkh
authored andcommitted
USB: core: Change configuration warnings to notices
[ Upstream commit 7a09c12 ] It has been pointed out that the kernel log messages warning about problems in USB configuration and related descriptors are vexing for users. The warning log level has a fairly high priority, but the user can do nothing to fix the underlying errors in the device's firmware. To reduce the amount of useless information produced by tools that filter high-priority log messages, we can change these warnings to notices, i.e., change dev_warn() to dev_notice(). The same holds for a few messages that currently use dev_err(): Unless they indicate a failure that might make a device unusable (such as inability to transfer a config descriptor), change them to dev_notice() also. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216630 Suggested-by: Artem S. Tashkinov <[email protected]> Signed-off-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Stable-dep-of: 974bba5 ("usb: config: fix iteration issue in 'usb_get_bos_descriptor()'") Signed-off-by: Sasha Levin <[email protected]>
1 parent c89b34e commit 9aff7c5

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

drivers/usb/core/config.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void usb_parse_ssp_isoc_endpoint_companion(struct device *ddev,
6161
desc = (struct usb_ssp_isoc_ep_comp_descriptor *) buffer;
6262
if (desc->bDescriptorType != USB_DT_SSP_ISOC_ENDPOINT_COMP ||
6363
size < USB_DT_SSP_ISOC_EP_COMP_SIZE) {
64-
dev_warn(ddev, "Invalid SuperSpeedPlus isoc endpoint companion"
64+
dev_notice(ddev, "Invalid SuperSpeedPlus isoc endpoint companion"
6565
"for config %d interface %d altsetting %d ep %d.\n",
6666
cfgno, inum, asnum, ep->desc.bEndpointAddress);
6767
return;
@@ -83,7 +83,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
8383

8484
if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
8585
size < USB_DT_SS_EP_COMP_SIZE) {
86-
dev_warn(ddev, "No SuperSpeed endpoint companion for config %d "
86+
dev_notice(ddev, "No SuperSpeed endpoint companion for config %d "
8787
" interface %d altsetting %d ep %d: "
8888
"using minimum values\n",
8989
cfgno, inum, asnum, ep->desc.bEndpointAddress);
@@ -109,13 +109,13 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
109109

110110
/* Check the various values */
111111
if (usb_endpoint_xfer_control(&ep->desc) && desc->bMaxBurst != 0) {
112-
dev_warn(ddev, "Control endpoint with bMaxBurst = %d in "
112+
dev_notice(ddev, "Control endpoint with bMaxBurst = %d in "
113113
"config %d interface %d altsetting %d ep %d: "
114114
"setting to zero\n", desc->bMaxBurst,
115115
cfgno, inum, asnum, ep->desc.bEndpointAddress);
116116
ep->ss_ep_comp.bMaxBurst = 0;
117117
} else if (desc->bMaxBurst > 15) {
118-
dev_warn(ddev, "Endpoint with bMaxBurst = %d in "
118+
dev_notice(ddev, "Endpoint with bMaxBurst = %d in "
119119
"config %d interface %d altsetting %d ep %d: "
120120
"setting to 15\n", desc->bMaxBurst,
121121
cfgno, inum, asnum, ep->desc.bEndpointAddress);
@@ -125,7 +125,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
125125
if ((usb_endpoint_xfer_control(&ep->desc) ||
126126
usb_endpoint_xfer_int(&ep->desc)) &&
127127
desc->bmAttributes != 0) {
128-
dev_warn(ddev, "%s endpoint with bmAttributes = %d in "
128+
dev_notice(ddev, "%s endpoint with bmAttributes = %d in "
129129
"config %d interface %d altsetting %d ep %d: "
130130
"setting to zero\n",
131131
usb_endpoint_xfer_control(&ep->desc) ? "Control" : "Bulk",
@@ -134,15 +134,15 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
134134
ep->ss_ep_comp.bmAttributes = 0;
135135
} else if (usb_endpoint_xfer_bulk(&ep->desc) &&
136136
desc->bmAttributes > 16) {
137-
dev_warn(ddev, "Bulk endpoint with more than 65536 streams in "
137+
dev_notice(ddev, "Bulk endpoint with more than 65536 streams in "
138138
"config %d interface %d altsetting %d ep %d: "
139139
"setting to max\n",
140140
cfgno, inum, asnum, ep->desc.bEndpointAddress);
141141
ep->ss_ep_comp.bmAttributes = 16;
142142
} else if (usb_endpoint_xfer_isoc(&ep->desc) &&
143143
!USB_SS_SSP_ISOC_COMP(desc->bmAttributes) &&
144144
USB_SS_MULT(desc->bmAttributes) > 3) {
145-
dev_warn(ddev, "Isoc endpoint has Mult of %d in "
145+
dev_notice(ddev, "Isoc endpoint has Mult of %d in "
146146
"config %d interface %d altsetting %d ep %d: "
147147
"setting to 3\n",
148148
USB_SS_MULT(desc->bmAttributes),
@@ -160,7 +160,7 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
160160
else
161161
max_tx = 999999;
162162
if (le16_to_cpu(desc->wBytesPerInterval) > max_tx) {
163-
dev_warn(ddev, "%s endpoint with wBytesPerInterval of %d in "
163+
dev_notice(ddev, "%s endpoint with wBytesPerInterval of %d in "
164164
"config %d interface %d altsetting %d ep %d: "
165165
"setting to %d\n",
166166
usb_endpoint_xfer_isoc(&ep->desc) ? "Isoc" : "Int",
@@ -273,15 +273,15 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
273273
else if (d->bLength >= USB_DT_ENDPOINT_SIZE)
274274
n = USB_DT_ENDPOINT_SIZE;
275275
else {
276-
dev_warn(ddev, "config %d interface %d altsetting %d has an "
276+
dev_notice(ddev, "config %d interface %d altsetting %d has an "
277277
"invalid endpoint descriptor of length %d, skipping\n",
278278
cfgno, inum, asnum, d->bLength);
279279
goto skip_to_next_endpoint_or_interface_descriptor;
280280
}
281281

282282
i = d->bEndpointAddress & ~USB_ENDPOINT_DIR_MASK;
283283
if (i >= 16 || i == 0) {
284-
dev_warn(ddev, "config %d interface %d altsetting %d has an "
284+
dev_notice(ddev, "config %d interface %d altsetting %d has an "
285285
"invalid endpoint with address 0x%X, skipping\n",
286286
cfgno, inum, asnum, d->bEndpointAddress);
287287
goto skip_to_next_endpoint_or_interface_descriptor;
@@ -293,15 +293,15 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
293293

294294
/* Check for duplicate endpoint addresses */
295295
if (config_endpoint_is_duplicate(config, inum, asnum, d)) {
296-
dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
296+
dev_notice(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
297297
cfgno, inum, asnum, d->bEndpointAddress);
298298
goto skip_to_next_endpoint_or_interface_descriptor;
299299
}
300300

301301
/* Ignore some endpoints */
302302
if (udev->quirks & USB_QUIRK_ENDPOINT_IGNORE) {
303303
if (usb_endpoint_is_ignored(udev, ifp, d)) {
304-
dev_warn(ddev, "config %d interface %d altsetting %d has an ignored endpoint with address 0x%X, skipping\n",
304+
dev_notice(ddev, "config %d interface %d altsetting %d has an ignored endpoint with address 0x%X, skipping\n",
305305
cfgno, inum, asnum,
306306
d->bEndpointAddress);
307307
goto skip_to_next_endpoint_or_interface_descriptor;
@@ -378,7 +378,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
378378
}
379379
}
380380
if (d->bInterval < i || d->bInterval > j) {
381-
dev_warn(ddev, "config %d interface %d altsetting %d "
381+
dev_notice(ddev, "config %d interface %d altsetting %d "
382382
"endpoint 0x%X has an invalid bInterval %d, "
383383
"changing to %d\n",
384384
cfgno, inum, asnum,
@@ -391,7 +391,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
391391
* them usable, we will try treating them as Interrupt endpoints.
392392
*/
393393
if (udev->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) {
394-
dev_warn(ddev, "config %d interface %d altsetting %d "
394+
dev_notice(ddev, "config %d interface %d altsetting %d "
395395
"endpoint 0x%X is Bulk; changing to Interrupt\n",
396396
cfgno, inum, asnum, d->bEndpointAddress);
397397
endpoint->desc.bmAttributes = USB_ENDPOINT_XFER_INT;
@@ -408,7 +408,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
408408
*/
409409
maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize);
410410
if (maxp == 0 && !(usb_endpoint_xfer_isoc(d) && asnum == 0)) {
411-
dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n",
411+
dev_notice(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n",
412412
cfgno, inum, asnum, d->bEndpointAddress);
413413
}
414414

@@ -439,7 +439,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
439439
j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)];
440440

441441
if (maxp > j) {
442-
dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n",
442+
dev_notice(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n",
443443
cfgno, inum, asnum, d->bEndpointAddress, maxp, j);
444444
maxp = j;
445445
endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp);
@@ -452,7 +452,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
452452
*/
453453
if (udev->speed == USB_SPEED_HIGH && usb_endpoint_xfer_bulk(d)) {
454454
if (maxp != 512)
455-
dev_warn(ddev, "config %d interface %d altsetting %d "
455+
dev_notice(ddev, "config %d interface %d altsetting %d "
456456
"bulk endpoint 0x%X has invalid maxpacket %d\n",
457457
cfgno, inum, asnum, d->bEndpointAddress,
458458
maxp);
@@ -533,7 +533,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
533533
i < intfc->num_altsetting;
534534
(++i, ++alt)) {
535535
if (alt->desc.bAlternateSetting == asnum) {
536-
dev_warn(ddev, "Duplicate descriptor for config %d "
536+
dev_notice(ddev, "Duplicate descriptor for config %d "
537537
"interface %d altsetting %d, skipping\n",
538538
cfgno, inum, asnum);
539539
goto skip_to_next_interface_descriptor;
@@ -559,7 +559,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
559559
num_ep = num_ep_orig = alt->desc.bNumEndpoints;
560560
alt->desc.bNumEndpoints = 0; /* Use as a counter */
561561
if (num_ep > USB_MAXENDPOINTS) {
562-
dev_warn(ddev, "too many endpoints for config %d interface %d "
562+
dev_notice(ddev, "too many endpoints for config %d interface %d "
563563
"altsetting %d: %d, using maximum allowed: %d\n",
564564
cfgno, inum, asnum, num_ep, USB_MAXENDPOINTS);
565565
num_ep = USB_MAXENDPOINTS;
@@ -590,7 +590,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
590590
}
591591

592592
if (n != num_ep_orig)
593-
dev_warn(ddev, "config %d interface %d altsetting %d has %d "
593+
dev_notice(ddev, "config %d interface %d altsetting %d has %d "
594594
"endpoint descriptor%s, different from the interface "
595595
"descriptor's value: %d\n",
596596
cfgno, inum, asnum, n, plural(n), num_ep_orig);
@@ -625,7 +625,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
625625
if (config->desc.bDescriptorType != USB_DT_CONFIG ||
626626
config->desc.bLength < USB_DT_CONFIG_SIZE ||
627627
config->desc.bLength > size) {
628-
dev_err(ddev, "invalid descriptor for config index %d: "
628+
dev_notice(ddev, "invalid descriptor for config index %d: "
629629
"type = 0x%X, length = %d\n", cfgidx,
630630
config->desc.bDescriptorType, config->desc.bLength);
631631
return -EINVAL;
@@ -636,7 +636,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
636636
size -= config->desc.bLength;
637637

638638
if (nintf > USB_MAXINTERFACES) {
639-
dev_warn(ddev, "config %d has too many interfaces: %d, "
639+
dev_notice(ddev, "config %d has too many interfaces: %d, "
640640
"using maximum allowed: %d\n",
641641
cfgno, nintf, USB_MAXINTERFACES);
642642
nintf = USB_MAXINTERFACES;
@@ -650,15 +650,15 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
650650
(buffer2 += header->bLength, size2 -= header->bLength)) {
651651

652652
if (size2 < sizeof(struct usb_descriptor_header)) {
653-
dev_warn(ddev, "config %d descriptor has %d excess "
653+
dev_notice(ddev, "config %d descriptor has %d excess "
654654
"byte%s, ignoring\n",
655655
cfgno, size2, plural(size2));
656656
break;
657657
}
658658

659659
header = (struct usb_descriptor_header *) buffer2;
660660
if ((header->bLength > size2) || (header->bLength < 2)) {
661-
dev_warn(ddev, "config %d has an invalid descriptor "
661+
dev_notice(ddev, "config %d has an invalid descriptor "
662662
"of length %d, skipping remainder of the config\n",
663663
cfgno, header->bLength);
664664
break;
@@ -670,7 +670,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
670670

671671
d = (struct usb_interface_descriptor *) header;
672672
if (d->bLength < USB_DT_INTERFACE_SIZE) {
673-
dev_warn(ddev, "config %d has an invalid "
673+
dev_notice(ddev, "config %d has an invalid "
674674
"interface descriptor of length %d, "
675675
"skipping\n", cfgno, d->bLength);
676676
continue;
@@ -680,15 +680,15 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
680680

681681
if ((dev->quirks & USB_QUIRK_HONOR_BNUMINTERFACES) &&
682682
n >= nintf_orig) {
683-
dev_warn(ddev, "config %d has more interface "
683+
dev_notice(ddev, "config %d has more interface "
684684
"descriptors, than it declares in "
685685
"bNumInterfaces, ignoring interface "
686686
"number: %d\n", cfgno, inum);
687687
continue;
688688
}
689689

690690
if (inum >= nintf_orig)
691-
dev_warn(ddev, "config %d has an invalid "
691+
dev_notice(ddev, "config %d has an invalid "
692692
"interface number: %d but max is %d\n",
693693
cfgno, inum, nintf_orig - 1);
694694

@@ -713,14 +713,14 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
713713

714714
d = (struct usb_interface_assoc_descriptor *)header;
715715
if (d->bLength < USB_DT_INTERFACE_ASSOCIATION_SIZE) {
716-
dev_warn(ddev,
716+
dev_notice(ddev,
717717
"config %d has an invalid interface association descriptor of length %d, skipping\n",
718718
cfgno, d->bLength);
719719
continue;
720720
}
721721

722722
if (iad_num == USB_MAXIADS) {
723-
dev_warn(ddev, "found more Interface "
723+
dev_notice(ddev, "found more Interface "
724724
"Association Descriptors "
725725
"than allocated for in "
726726
"configuration %d\n", cfgno);
@@ -731,7 +731,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
731731

732732
} else if (header->bDescriptorType == USB_DT_DEVICE ||
733733
header->bDescriptorType == USB_DT_CONFIG)
734-
dev_warn(ddev, "config %d contains an unexpected "
734+
dev_notice(ddev, "config %d contains an unexpected "
735735
"descriptor of type 0x%X, skipping\n",
736736
cfgno, header->bDescriptorType);
737737

@@ -740,11 +740,11 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
740740
config->desc.wTotalLength = cpu_to_le16(buffer2 - buffer0);
741741

742742
if (n != nintf)
743-
dev_warn(ddev, "config %d has %d interface%s, different from "
743+
dev_notice(ddev, "config %d has %d interface%s, different from "
744744
"the descriptor's value: %d\n",
745745
cfgno, n, plural(n), nintf_orig);
746746
else if (n == 0)
747-
dev_warn(ddev, "config %d has no interfaces?\n", cfgno);
747+
dev_notice(ddev, "config %d has no interfaces?\n", cfgno);
748748
config->desc.bNumInterfaces = nintf = n;
749749

750750
/* Check for missing interface numbers */
@@ -754,15 +754,15 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
754754
break;
755755
}
756756
if (j >= nintf)
757-
dev_warn(ddev, "config %d has no interface number "
757+
dev_notice(ddev, "config %d has no interface number "
758758
"%d\n", cfgno, i);
759759
}
760760

761761
/* Allocate the usb_interface_caches and altsetting arrays */
762762
for (i = 0; i < nintf; ++i) {
763763
j = nalts[i];
764764
if (j > USB_MAXALTSETTING) {
765-
dev_warn(ddev, "too many alternate settings for "
765+
dev_notice(ddev, "too many alternate settings for "
766766
"config %d interface %d: %d, "
767767
"using maximum allowed: %d\n",
768768
cfgno, inums[i], j, USB_MAXALTSETTING);
@@ -811,7 +811,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
811811
break;
812812
}
813813
if (n >= intfc->num_altsetting)
814-
dev_warn(ddev, "config %d interface %d has no "
814+
dev_notice(ddev, "config %d interface %d has no "
815815
"altsetting %d\n", cfgno, inums[i], j);
816816
}
817817
}
@@ -868,7 +868,7 @@ int usb_get_configuration(struct usb_device *dev)
868868
int result;
869869

870870
if (ncfg > USB_MAXCONFIG) {
871-
dev_warn(ddev, "too many configurations: %d, "
871+
dev_notice(ddev, "too many configurations: %d, "
872872
"using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
873873
dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
874874
}
@@ -902,7 +902,7 @@ int usb_get_configuration(struct usb_device *dev)
902902
"descriptor/%s: %d\n", cfgno, "start", result);
903903
if (result != -EPIPE)
904904
goto err;
905-
dev_err(ddev, "chopping to %d config(s)\n", cfgno);
905+
dev_notice(ddev, "chopping to %d config(s)\n", cfgno);
906906
dev->descriptor.bNumConfigurations = cfgno;
907907
break;
908908
} else if (result < 4) {
@@ -934,7 +934,7 @@ int usb_get_configuration(struct usb_device *dev)
934934
goto err;
935935
}
936936
if (result < length) {
937-
dev_warn(ddev, "config index %d descriptor too short "
937+
dev_notice(ddev, "config index %d descriptor too short "
938938
"(expected %i, got %i)\n", cfgno, length, result);
939939
length = result;
940940
}
@@ -993,7 +993,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
993993
/* Get BOS descriptor */
994994
ret = usb_get_descriptor(dev, USB_DT_BOS, 0, bos, USB_DT_BOS_SIZE);
995995
if (ret < USB_DT_BOS_SIZE || bos->bLength < USB_DT_BOS_SIZE) {
996-
dev_err(ddev, "unable to get BOS descriptor or descriptor too short\n");
996+
dev_notice(ddev, "unable to get BOS descriptor or descriptor too short\n");
997997
if (ret >= 0)
998998
ret = -ENOMSG;
999999
kfree(bos);
@@ -1021,7 +1021,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
10211021

10221022
ret = usb_get_descriptor(dev, USB_DT_BOS, 0, buffer, total_len);
10231023
if (ret < total_len) {
1024-
dev_err(ddev, "unable to get BOS descriptor set\n");
1024+
dev_notice(ddev, "unable to get BOS descriptor set\n");
10251025
if (ret >= 0)
10261026
ret = -ENOMSG;
10271027
goto err;
@@ -1046,7 +1046,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
10461046
}
10471047

10481048
if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
1049-
dev_warn(ddev, "descriptor type invalid, skip\n");
1049+
dev_notice(ddev, "descriptor type invalid, skip\n");
10501050
continue;
10511051
}
10521052

0 commit comments

Comments
 (0)