public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/3] swab: Add array operations
@ 2022-08-31 14:54 Andy Shevchenko
  2022-08-31 14:54 ` [PATCH v1 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
  2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: " Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:54 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

For now, some simple array operations to swab.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/swab.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/include/linux/swab.h b/include/linux/swab.h
index bcff5149861a..9b804dbb0d79 100644
--- a/include/linux/swab.h
+++ b/include/linux/swab.h
@@ -20,4 +20,29 @@
 # define swab64s __swab64s
 # define swahw32s __swahw32s
 # define swahb32s __swahb32s
+
+static inline void swab16_array(u16 *buf, unsigned int words)
+{
+	while (words--) {
+		swab16s(buf);
+		buf++;
+	}
+}
+
+static inline void swab32_array(u32 *buf, unsigned int words)
+{
+	while (words--) {
+		swab32s(buf);
+		buf++;
+	}
+}
+
+static inline void swab64_array(u64 *buf, unsigned int words)
+{
+	while (words--) {
+		swab64s(buf);
+		buf++;
+	}
+}
+
 #endif /* _LINUX_SWAB_H */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/3] regmap: mmio: Use swabXX_array() helpers
  2022-08-31 14:54 [PATCH v1 1/3] swab: Add array operations Andy Shevchenko
@ 2022-08-31 14:54 ` Andy Shevchenko
  2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: " Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:54 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

Since we have a few helpers to swab elements of a given size in an array
use them instead of open coded variants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap-mmio.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index e8d2675463ac..66f92caa2fa2 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/swab.h>
 
 #include "internal.h"
 
@@ -345,7 +346,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
 {
 	struct regmap_mmio_context *ctx = context;
 	int ret = 0;
-	int i;
 
 	if (!IS_ERR(ctx->clk)) {
 		ret = clk_enable(ctx->clk);
@@ -382,27 +382,15 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
 	if (ctx->big_endian && (ctx->val_bytes > 1)) {
 		switch (ctx->val_bytes) {
 		case 2:
-		{
-			u16 *valp = (u16 *)val;
-			for (i = 0; i < val_count; i++)
-				valp[i] = swab16(valp[i]);
+			swab16_array(val, val_count);
 			break;
-		}
 		case 4:
-		{
-			u32 *valp = (u32 *)val;
-			for (i = 0; i < val_count; i++)
-				valp[i] = swab32(valp[i]);
+			swab32_array(val, val_count);
 			break;
-		}
 #ifdef CONFIG_64BIT
 		case 8:
-		{
-			u64 *valp = (u64 *)val;
-			for (i = 0; i < val_count; i++)
-				valp[i] = swab64(valp[i]);
+			swab64_array(val, val_count);
 			break;
-		}
 #endif
 		default:
 			ret = -EINVAL;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 14:54 [PATCH v1 1/3] swab: Add array operations Andy Shevchenko
  2022-08-31 14:54 ` [PATCH v1 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
@ 2022-08-31 14:54 ` Andy Shevchenko
  2022-08-31 20:12   ` kernel test robot
  2022-08-31 21:22   ` kernel test robot
  1 sibling, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:54 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

Since we have a few helpers to swab elements of a given size in an array
use them instead of open coded variants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap-spi-avmm.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap-spi-avmm.c b/drivers/base/regmap/regmap-spi-avmm.c
index ad1da83e849f..1cf133c49bd4 100644
--- a/drivers/base/regmap/regmap-spi-avmm.c
+++ b/drivers/base/regmap/regmap-spi-avmm.c
@@ -7,6 +7,7 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
+#include <linux/swab.h>
 
 /*
  * This driver implements the regmap operations for a generic SPI
@@ -167,14 +168,7 @@ struct spi_avmm_bridge {
 
 static void br_swap_words_32(char *buf, unsigned int len)
 {
-	u32 *p = (u32 *)buf;
-	unsigned int count;
-
-	count = len / 4;
-	while (count--) {
-		*p = swab32p(p);
-		p++;
-	}
+	swab32_array(buf, len / 4);
 }
 
 /*
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: " Andy Shevchenko
@ 2022-08-31 20:12   ` kernel test robot
  2022-08-31 21:19     ` Andy Shevchenko
  2022-08-31 21:22   ` kernel test robot
  1 sibling, 1 reply; 6+ messages in thread
From: kernel test robot @ 2022-08-31 20:12 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-kernel
  Cc: llvm, kbuild-all, Greg Kroah-Hartman, Rafael J. Wysocki,
	Linus Walleij

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on broonie-regmap/for-next]
[also build test ERROR on next-20220831]
[cannot apply to linus/master v6.0-rc3]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/swab-Add-array-operations/20220831-225514
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
config: hexagon-randconfig-r045-20220831 (https://download.01.org/0day-ci/archive/20220901/202209010444.n3YAkNP1-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 1c66bacd6cde1f37d6ac96c45b389666a1334ec0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/783618682b27b5d06605086a386d64d355914b38
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/swab-Add-array-operations/20220831-225514
        git checkout 783618682b27b5d06605086a386d64d355914b38
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/base/

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

All errors (new ones prefixed by >>):

   In file included from drivers/base/regmap/regmap-spi-avmm.c:8:
   In file included from include/linux/regmap.h:20:
   In file included from include/linux/iopoll.h:14:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/base/regmap/regmap-spi-avmm.c:8:
   In file included from include/linux/regmap.h:20:
   In file included from include/linux/iopoll.h:14:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/base/regmap/regmap-spi-avmm.c:8:
   In file included from include/linux/regmap.h:20:
   In file included from include/linux/iopoll.h:14:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/base/regmap/regmap-spi-avmm.c:171:15: error: incompatible pointer types passing 'char *' to parameter of type 'u32 *' (aka 'unsigned int *') [-Werror,-Wincompatible-pointer-types]
           swab32_array(buf, len / 4);
                        ^~~
   include/linux/swab.h:32:38: note: passing argument to parameter 'buf' here
   static inline void swab32_array(u32 *buf, unsigned int words)
                                        ^
   6 warnings and 1 error generated.


vim +171 drivers/base/regmap/regmap-spi-avmm.c

   168	
   169	static void br_swap_words_32(char *buf, unsigned int len)
   170	{
 > 171		swab32_array(buf, len / 4);
   172	}
   173	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 20:12   ` kernel test robot
@ 2022-08-31 21:19     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-31 21:19 UTC (permalink / raw)
  To: kernel test robot
  Cc: Mark Brown, linux-kernel, llvm, kbuild-all, Greg Kroah-Hartman,
	Rafael J. Wysocki, Linus Walleij

On Thu, Sep 01, 2022 at 04:12:01AM +0800, kernel test robot wrote:

...

>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/base/
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):

Indeed, I compiled only first two patches on x86.

> >> drivers/base/regmap/regmap-spi-avmm.c:171:15: error: incompatible pointer types passing 'char *' to parameter of type 'u32 *' (aka 'unsigned int *') [-Werror,-Wincompatible-pointer-types]
>            swab32_array(buf, len / 4);
>                         ^~~
>    include/linux/swab.h:32:38: note: passing argument to parameter 'buf' here
>    static inline void swab32_array(u32 *buf, unsigned int words)
>                                         ^
>    6 warnings and 1 error generated.

While error message is valid, I believe the warnings are not related to the
patch in question and were before it.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: " Andy Shevchenko
  2022-08-31 20:12   ` kernel test robot
@ 2022-08-31 21:22   ` kernel test robot
  1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-08-31 21:22 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-kernel
  Cc: kbuild-all, Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on broonie-regmap/for-next]
[also build test ERROR on next-20220831]
[cannot apply to linus/master v6.0-rc3]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/swab-Add-array-operations/20220831-225514
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
config: x86_64-randconfig-a013 (https://download.01.org/0day-ci/archive/20220901/202209010548.ZC5MnsXX-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/783618682b27b5d06605086a386d64d355914b38
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/swab-Add-array-operations/20220831-225514
        git checkout 783618682b27b5d06605086a386d64d355914b38
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

   drivers/base/regmap/regmap-spi-avmm.c: In function 'br_swap_words_32':
>> drivers/base/regmap/regmap-spi-avmm.c:171:22: error: passing argument 1 of 'swab32_array' from incompatible pointer type [-Werror=incompatible-pointer-types]
     171 |         swab32_array(buf, len / 4);
         |                      ^~~
         |                      |
         |                      char *
   In file included from include/uapi/linux/byteorder/little_endian.h:14,
                    from include/linux/byteorder/little_endian.h:5,
                    from arch/x86/include/uapi/asm/byteorder.h:5,
                    from arch/x86/include/asm/orc_types.h:43,
                    from arch/x86/include/asm/unwind_hints.h:6,
                    from arch/x86/include/asm/nospec-branch.h:13,
                    from arch/x86/include/asm/paravirt_types.h:40,
                    from arch/x86/include/asm/ptrace.h:97,
                    from arch/x86/include/asm/math_emu.h:5,
                    from arch/x86/include/asm/processor.h:13,
                    from arch/x86/include/asm/timex.h:5,
                    from include/linux/timex.h:67,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from drivers/base/regmap/regmap-spi-avmm.c:7:
   include/linux/swab.h:32:38: note: expected 'u32 *' {aka 'unsigned int *'} but argument is of type 'char *'
      32 | static inline void swab32_array(u32 *buf, unsigned int words)
         |                                 ~~~~~^~~
   cc1: some warnings being treated as errors


vim +/swab32_array +171 drivers/base/regmap/regmap-spi-avmm.c

   168	
   169	static void br_swap_words_32(char *buf, unsigned int len)
   170	{
 > 171		swab32_array(buf, len / 4);
   172	}
   173	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-31 21:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-31 14:54 [PATCH v1 1/3] swab: Add array operations Andy Shevchenko
2022-08-31 14:54 ` [PATCH v1 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: " Andy Shevchenko
2022-08-31 20:12   ` kernel test robot
2022-08-31 21:19     ` Andy Shevchenko
2022-08-31 21:22   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox