|
9 | 9 | #include <linux/usb/quirks.h>
|
10 | 10 | #include <linux/module.h>
|
11 | 11 | #include <linux/slab.h>
|
| 12 | +#include <linux/string_choices.h> |
12 | 13 | #include <linux/device.h>
|
13 | 14 | #include <asm/byteorder.h>
|
14 | 15 | #include "usb.h"
|
|
18 | 19 |
|
19 | 20 | #define USB_MAXCONFIG 8 /* Arbitrary limit */
|
20 | 21 |
|
21 |
| - |
22 |
| -static inline const char *plural(int n) |
23 |
| -{ |
24 |
| - return (n == 1 ? "" : "s"); |
25 |
| -} |
26 |
| - |
27 | 22 | static int find_next_descriptor(unsigned char *buffer, int size,
|
28 | 23 | int dt1, int dt2, int *num_skipped)
|
29 | 24 | {
|
@@ -484,7 +479,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
|
484 | 479 | retval = buffer - buffer0 + i;
|
485 | 480 | if (n > 0)
|
486 | 481 | dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
|
487 |
| - n, plural(n), "endpoint"); |
| 482 | + n, str_plural(n), "endpoint"); |
488 | 483 | return retval;
|
489 | 484 |
|
490 | 485 | skip_to_next_endpoint_or_interface_descriptor:
|
@@ -563,7 +558,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
|
563 | 558 | alt->extralen = i;
|
564 | 559 | if (n > 0)
|
565 | 560 | dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
|
566 |
| - n, plural(n), "interface"); |
| 561 | + n, str_plural(n), "interface"); |
567 | 562 | buffer += i;
|
568 | 563 | size -= i;
|
569 | 564 |
|
@@ -605,7 +600,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
|
605 | 600 | dev_notice(ddev, "config %d interface %d altsetting %d has %d "
|
606 | 601 | "endpoint descriptor%s, different from the interface "
|
607 | 602 | "descriptor's value: %d\n",
|
608 |
| - cfgno, inum, asnum, n, plural(n), num_ep_orig); |
| 603 | + cfgno, inum, asnum, n, str_plural(n), num_ep_orig); |
609 | 604 | return buffer - buffer0;
|
610 | 605 |
|
611 | 606 | skip_to_next_interface_descriptor:
|
@@ -664,7 +659,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
|
664 | 659 | if (size2 < sizeof(struct usb_descriptor_header)) {
|
665 | 660 | dev_notice(ddev, "config %d descriptor has %d excess "
|
666 | 661 | "byte%s, ignoring\n",
|
667 |
| - cfgno, size2, plural(size2)); |
| 662 | + cfgno, size2, str_plural(size2)); |
668 | 663 | break;
|
669 | 664 | }
|
670 | 665 |
|
@@ -754,7 +749,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
|
754 | 749 | if (n != nintf)
|
755 | 750 | dev_notice(ddev, "config %d has %d interface%s, different from "
|
756 | 751 | "the descriptor's value: %d\n",
|
757 |
| - cfgno, n, plural(n), nintf_orig); |
| 752 | + cfgno, n, str_plural(n), nintf_orig); |
758 | 753 | else if (n == 0)
|
759 | 754 | dev_notice(ddev, "config %d has no interfaces?\n", cfgno);
|
760 | 755 | config->desc.bNumInterfaces = nintf = n;
|
@@ -798,7 +793,7 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
|
798 | 793 | config->extralen = i;
|
799 | 794 | if (n > 0)
|
800 | 795 | dev_dbg(ddev, "skipped %d descriptor%s after %s\n",
|
801 |
| - n, plural(n), "configuration"); |
| 796 | + n, str_plural(n), "configuration"); |
802 | 797 | buffer += i;
|
803 | 798 | size -= i;
|
804 | 799 |
|
|
0 commit comments