public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] swab: Add array operations
@ 2022-08-31 21:27 Andy Shevchenko
  2022-08-31 21:27 ` [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-08-31 21:27 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, 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>
---
v2: no changes
 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] 7+ messages in thread

* [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers
  2022-08-31 21:27 [PATCH v2 1/3] swab: Add array operations Andy Shevchenko
@ 2022-08-31 21:27 ` Andy Shevchenko
  2022-08-31 21:42   ` Linus Walleij
  2022-08-31 21:27 ` [PATCH v2 3/3] regmap: spi-avmm: " Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2022-08-31 21:27 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, 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>
---
v2: no changes
 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] 7+ messages in thread

* [PATCH v2 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 21:27 [PATCH v2 1/3] swab: Add array operations Andy Shevchenko
  2022-08-31 21:27 ` [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
@ 2022-08-31 21:27 ` Andy Shevchenko
  2022-08-31 21:43   ` Linus Walleij
  2022-08-31 21:41 ` [PATCH v2 1/3] swab: Add array operations Linus Walleij
  2022-09-07 13:26 ` Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2022-08-31 21:27 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, 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>
---
v2: fixed compilation error (LKP)
 drivers/base/regmap/regmap-spi-avmm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/base/regmap/regmap-spi-avmm.c b/drivers/base/regmap/regmap-spi-avmm.c
index ad1da83e849f..4c2b94b3e30b 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
@@ -162,19 +163,12 @@ struct spi_avmm_bridge {
 	/* bridge buffer used in translation between protocol layers */
 	char trans_buf[TRANS_BUF_SIZE];
 	char phy_buf[PHY_BUF_SIZE];
-	void (*swap_words)(char *buf, unsigned int len);
+	void (*swap_words)(void *buf, unsigned int len);
 };
 
-static void br_swap_words_32(char *buf, unsigned int len)
+static void br_swap_words_32(void *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] 7+ messages in thread

* Re: [PATCH v2 1/3] swab: Add array operations
  2022-08-31 21:27 [PATCH v2 1/3] swab: Add array operations Andy Shevchenko
  2022-08-31 21:27 ` [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
  2022-08-31 21:27 ` [PATCH v2 3/3] regmap: spi-avmm: " Andy Shevchenko
@ 2022-08-31 21:41 ` Linus Walleij
  2022-09-07 13:26 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-08-31 21:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki

On Wed, Aug 31, 2022 at 11:27 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> For now, some simple array operations to swab.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I like what you're doing here :)
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers
  2022-08-31 21:27 ` [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
@ 2022-08-31 21:42   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-08-31 21:42 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki

On Wed, Aug 31, 2022 at 11:27 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> 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>

Sweet!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2 3/3] regmap: spi-avmm: Use swabXX_array() helpers
  2022-08-31 21:27 ` [PATCH v2 3/3] regmap: spi-avmm: " Andy Shevchenko
@ 2022-08-31 21:43   ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-08-31 21:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki

On Wed, Aug 31, 2022 at 11:27 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> 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>

LGTM
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2 1/3] swab: Add array operations
  2022-08-31 21:27 [PATCH v2 1/3] swab: Add array operations Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-08-31 21:41 ` [PATCH v2 1/3] swab: Add array operations Linus Walleij
@ 2022-09-07 13:26 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2022-09-07 13:26 UTC (permalink / raw)
  To: linux-kernel, Andy Shevchenko
  Cc: Rafael J. Wysocki, Linus Walleij, Greg Kroah-Hartman

On Thu, 1 Sep 2022 00:27:42 +0300, Andy Shevchenko wrote:
> For now, some simple array operations to swab.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/3] swab: Add array operations
      commit: 2d4697375dea514be202abf563a9419e74489c25
[2/3] regmap: mmio: Use swabXX_array() helpers
      commit: 400dceb6f8b56472b36c5c2c8c3e0cbb7557d019
[3/3] regmap: spi-avmm: Use swabXX_array() helpers
      commit: 26cc2a788a1903da3ccff97061099f091255ecaf

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2022-09-07 13:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-31 21:27 [PATCH v2 1/3] swab: Add array operations Andy Shevchenko
2022-08-31 21:27 ` [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers Andy Shevchenko
2022-08-31 21:42   ` Linus Walleij
2022-08-31 21:27 ` [PATCH v2 3/3] regmap: spi-avmm: " Andy Shevchenko
2022-08-31 21:43   ` Linus Walleij
2022-08-31 21:41 ` [PATCH v2 1/3] swab: Add array operations Linus Walleij
2022-09-07 13:26 ` Mark Brown

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