diff mbox series

[v2,7/8] usb: early: xhci-dbc: Make use of cpu_to_le16_array()

Message ID 20200817184659.58419-7-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/8] byteorder: Introduce cpu_to_le16_array() and le16_to_cpu_array() | expand

Commit Message

Andy Shevchenko Aug. 17, 2020, 6:46 p.m. UTC
Since we have a new helper, let's replace open coded variant by it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: updated commit message due to split (see patch 1)
 drivers/usb/early/xhci-dbc.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

kernel test robot Aug. 17, 2020, 9:23 p.m. UTC | #1
Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on jkirsher-next-queue/dev-queue linuxtv-media/master staging/staging-testing v5.9-rc1 next-20200817]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/byteorder-Introduce-cpu_to_le16_array-and-le16_to_cpu_array/20200818-024849
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-a003-20200817 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from drivers/usb/early/xhci-dbc.c:12:
>> include/linux/byteorder/generic.h:144:33: error: unknown type name '__le16'
     144 | static inline void le16_add_cpu(__le16 *var, u16 val)
         |                                 ^~~~~~
>> include/linux/byteorder/generic.h:144:46: error: unknown type name 'u16'
     144 | static inline void le16_add_cpu(__le16 *var, u16 val)
         |                                              ^~~
>> include/linux/byteorder/generic.h:149:33: error: unknown type name '__le32'
     149 | static inline void le32_add_cpu(__le32 *var, u32 val)
         |                                 ^~~~~~
>> include/linux/byteorder/generic.h:149:46: error: unknown type name 'u32'
     149 | static inline void le32_add_cpu(__le32 *var, u32 val)
         |                                              ^~~
>> include/linux/byteorder/generic.h:154:33: error: unknown type name '__le64'
     154 | static inline void le64_add_cpu(__le64 *var, u64 val)
         |                                 ^~~~~~
>> include/linux/byteorder/generic.h:154:46: error: unknown type name 'u64'
     154 | static inline void le64_add_cpu(__le64 *var, u64 val)
         |                                              ^~~
   include/linux/byteorder/generic.h:159:38: error: unknown type name '__le16'
     159 | static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len)
         |                                      ^~~~~~
   include/linux/byteorder/generic.h:159:57: error: unknown type name 'u16'
     159 | static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len)
         |                                                         ^~~
>> include/linux/byteorder/generic.h:159:67: error: unknown type name 'size_t'
     159 | static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len)
         |                                                                   ^~~~~~
   include/linux/byteorder/generic.h:1:1: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
     +++ |+#include <stddef.h>
       1 | /* SPDX-License-Identifier: GPL-2.0 */
   include/linux/byteorder/generic.h:167:38: error: unknown type name 'u16'
     167 | static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len)
         |                                      ^~~
   include/linux/byteorder/generic.h:167:54: error: unknown type name '__le16'
     167 | static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len)
         |                                                      ^~~~~~
   include/linux/byteorder/generic.h:167:67: error: unknown type name 'size_t'
     167 | static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len)
         |                                                                   ^~~~~~
   include/linux/byteorder/generic.h:167:67: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
   include/linux/byteorder/generic.h:176:38: error: unknown type name 'u32'
     176 | static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
         |                                      ^~~
   include/linux/byteorder/generic.h:184:38: error: unknown type name 'u32'
     184 | static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
         |                                      ^~~
>> include/linux/byteorder/generic.h:192:33: error: unknown type name '__be16'
     192 | static inline void be16_add_cpu(__be16 *var, u16 val)
         |                                 ^~~~~~
   include/linux/byteorder/generic.h:192:46: error: unknown type name 'u16'
     192 | static inline void be16_add_cpu(__be16 *var, u16 val)
         |                                              ^~~
>> include/linux/byteorder/generic.h:197:33: error: unknown type name '__be32'
     197 | static inline void be32_add_cpu(__be32 *var, u32 val)
         |                                 ^~~~~~
   include/linux/byteorder/generic.h:197:46: error: unknown type name 'u32'
     197 | static inline void be32_add_cpu(__be32 *var, u32 val)
         |                                              ^~~
>> include/linux/byteorder/generic.h:202:33: error: unknown type name '__be64'
     202 | static inline void be64_add_cpu(__be64 *var, u64 val)
         |                                 ^~~~~~
   include/linux/byteorder/generic.h:202:46: error: unknown type name 'u64'
     202 | static inline void be64_add_cpu(__be64 *var, u64 val)
         |                                              ^~~
   include/linux/byteorder/generic.h:207:38: error: unknown type name '__be32'
     207 | static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
         |                                      ^~~~~~
   include/linux/byteorder/generic.h:207:57: error: unknown type name 'u32'
     207 | static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
         |                                                         ^~~
   include/linux/byteorder/generic.h:207:67: error: unknown type name 'size_t'
     207 | static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
         |                                                                   ^~~~~~
   include/linux/byteorder/generic.h:207:67: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
   include/linux/byteorder/generic.h:215:38: error: unknown type name 'u32'
     215 | static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
         |                                      ^~~
   include/linux/byteorder/generic.h:215:54: error: unknown type name '__be32'
     215 | static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
         |                                                      ^~~~~~
   include/linux/byteorder/generic.h:215:67: error: unknown type name 'size_t'
     215 | static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
         |                                                                   ^~~~~~
   include/linux/byteorder/generic.h:215:67: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
   drivers/usb/early/xhci-dbc.c: In function 'xdbc_mem_init':
>> drivers/usb/early/xhci-dbc.c:259:2: error: implicit declaration of function 'cpu_to_le16_array'; did you mean 'cpu_to_le16'? [-Werror=implicit-function-declaration]
     259 |  cpu_to_le16_array(s_desc->wData, XDBC_STRING_SERIAL, strlen(XDBC_STRING_SERIAL));
         |  ^~~~~~~~~~~~~~~~~
         |  cpu_to_le16
   cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/05f0c7b5a2ca395d58f1ba7a8f84f4be3d504b56
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/byteorder-Introduce-cpu_to_le16_array-and-le16_to_cpu_array/20200818-024849
git checkout 05f0c7b5a2ca395d58f1ba7a8f84f4be3d504b56
vim +/__le16 +144 include/linux/byteorder/generic.h

^1da177e4c3f41 Linus Torvalds  2005-04-16  143  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @144  static inline void le16_add_cpu(__le16 *var, u16 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  145  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  146  	*var = cpu_to_le16(le16_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  147  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  148  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @149  static inline void le32_add_cpu(__le32 *var, u32 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  150  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  151  	*var = cpu_to_le32(le32_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  152  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  153  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @154  static inline void le64_add_cpu(__le64 *var, u64 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  155  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  156  	*var = cpu_to_le64(le64_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  157  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  158  
47df9f29cc421e Andy Shevchenko 2020-08-17 @159  static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len)
47df9f29cc421e Andy Shevchenko 2020-08-17  160  {
47df9f29cc421e Andy Shevchenko 2020-08-17  161  	int i;
47df9f29cc421e Andy Shevchenko 2020-08-17  162  
47df9f29cc421e Andy Shevchenko 2020-08-17  163  	for (i = 0; i < len; i++)
47df9f29cc421e Andy Shevchenko 2020-08-17  164  		dst[i] = cpu_to_le16(src[i]);
47df9f29cc421e Andy Shevchenko 2020-08-17  165  }
47df9f29cc421e Andy Shevchenko 2020-08-17  166  
47df9f29cc421e Andy Shevchenko 2020-08-17  167  static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len)
47df9f29cc421e Andy Shevchenko 2020-08-17  168  {
47df9f29cc421e Andy Shevchenko 2020-08-17  169  	int i;
47df9f29cc421e Andy Shevchenko 2020-08-17  170  
47df9f29cc421e Andy Shevchenko 2020-08-17  171  	for (i = 0; i < len; i++)
47df9f29cc421e Andy Shevchenko 2020-08-17  172  		dst[i] = le16_to_cpu(src[i]);
47df9f29cc421e Andy Shevchenko 2020-08-17  173  }
47df9f29cc421e Andy Shevchenko 2020-08-17  174  
9def051018c08e Andy Shevchenko 2018-03-21  175  /* XXX: this stuff can be optimized */
9def051018c08e Andy Shevchenko 2018-03-21  176  static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
9def051018c08e Andy Shevchenko 2018-03-21  177  {
9def051018c08e Andy Shevchenko 2018-03-21  178  	while (words--) {
9def051018c08e Andy Shevchenko 2018-03-21  179  		__le32_to_cpus(buf);
9def051018c08e Andy Shevchenko 2018-03-21  180  		buf++;
9def051018c08e Andy Shevchenko 2018-03-21  181  	}
9def051018c08e Andy Shevchenko 2018-03-21  182  }
9def051018c08e Andy Shevchenko 2018-03-21  183  
9def051018c08e Andy Shevchenko 2018-03-21  184  static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
9def051018c08e Andy Shevchenko 2018-03-21  185  {
9def051018c08e Andy Shevchenko 2018-03-21  186  	while (words--) {
9def051018c08e Andy Shevchenko 2018-03-21  187  		__cpu_to_le32s(buf);
9def051018c08e Andy Shevchenko 2018-03-21  188  		buf++;
9def051018c08e Andy Shevchenko 2018-03-21  189  	}
9def051018c08e Andy Shevchenko 2018-03-21  190  }
9def051018c08e Andy Shevchenko 2018-03-21  191  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @192  static inline void be16_add_cpu(__be16 *var, u16 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  193  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  194  	*var = cpu_to_be16(be16_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  195  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  196  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @197  static inline void be32_add_cpu(__be32 *var, u32 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  198  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  199  	*var = cpu_to_be32(be32_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  200  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  201  
8b5f6883683c91 Marcin Slusarz  2008-02-08 @202  static inline void be64_add_cpu(__be64 *var, u64 val)
8b5f6883683c91 Marcin Slusarz  2008-02-08  203  {
8b5f6883683c91 Marcin Slusarz  2008-02-08  204  	*var = cpu_to_be64(be64_to_cpu(*var) + val);
8b5f6883683c91 Marcin Slusarz  2008-02-08  205  }
8b5f6883683c91 Marcin Slusarz  2008-02-08  206  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 77c2e8301971..c5761ea9394d 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -9,6 +9,7 @@ 
 
 #define pr_fmt(fmt)	KBUILD_MODNAME ":%s: " fmt, __func__
 
+#include <linux/byteorder/generic.h>
 #include <linux/console.h>
 #include <linux/pci_regs.h>
 #include <linux/pci_ids.h>
@@ -200,14 +201,6 @@  static void xdbc_reset_ring(struct xdbc_ring *ring)
 	}
 }
 
-static inline void xdbc_put_utf16(u16 *s, const char *c, size_t size)
-{
-	int i;
-
-	for (i = 0; i < size; i++)
-		s[i] = cpu_to_le16(c[i]);
-}
-
 static void xdbc_mem_init(void)
 {
 	struct xdbc_ep_context *ep_in, *ep_out;
@@ -263,7 +256,7 @@  static void xdbc_mem_init(void)
 	s_desc->bLength		= (strlen(XDBC_STRING_SERIAL) + 1) * 2;
 	s_desc->bDescriptorType	= USB_DT_STRING;
 
-	xdbc_put_utf16(s_desc->wData, XDBC_STRING_SERIAL, strlen(XDBC_STRING_SERIAL));
+	cpu_to_le16_array(s_desc->wData, XDBC_STRING_SERIAL, strlen(XDBC_STRING_SERIAL));
 	string_length = s_desc->bLength;
 	string_length <<= 8;
 
@@ -272,7 +265,7 @@  static void xdbc_mem_init(void)
 	s_desc->bLength		= (strlen(XDBC_STRING_PRODUCT) + 1) * 2;
 	s_desc->bDescriptorType	= USB_DT_STRING;
 
-	xdbc_put_utf16(s_desc->wData, XDBC_STRING_PRODUCT, strlen(XDBC_STRING_PRODUCT));
+	cpu_to_le16_array(s_desc->wData, XDBC_STRING_PRODUCT, strlen(XDBC_STRING_PRODUCT));
 	string_length += s_desc->bLength;
 	string_length <<= 8;
 
@@ -281,7 +274,7 @@  static void xdbc_mem_init(void)
 	s_desc->bLength		= (strlen(XDBC_STRING_MANUFACTURER) + 1) * 2;
 	s_desc->bDescriptorType	= USB_DT_STRING;
 
-	xdbc_put_utf16(s_desc->wData, XDBC_STRING_MANUFACTURER, strlen(XDBC_STRING_MANUFACTURER));
+	cpu_to_le16_array(s_desc->wData, XDBC_STRING_MANUFACTURER, strlen(XDBC_STRING_MANUFACTURER));
 	string_length += s_desc->bLength;
 	string_length <<= 8;