swab: Add array operations
Subsystems (2)
PATCH v2 1/3 swab: Add array operations
For now, some simple array operations to swab.
---
v2: no changes
include/linux/swab.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
include/linux/swab.h +25 -0
@@ -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 */
Signature · 1 line
2.35.1
PATCH v2 2/3 regmap: mmio: Use swabXX_array() helpers
Since we have a few helpers to swab elements of a given size in an array use them instead of open coded variants.
---
v2: no changes
drivers/base/regmap/regmap-mmio.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/base/regmap/regmap-mmio.c +4 -16
@@ -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 ;
Signature · 1 line
2.35.1
Re: [PATCH v2 2/3] regmap: mmio: Use swabXX_array() helpers
Quoted 4 lines · Andy Shevchenko
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 <[email protected]>
Sweet!
Yours,
Linus Walleij
PATCH v2 3/3 regmap: spi-avmm: Use swabXX_array() helpers
In reply to Andy ShevchenkoSince we have a few helpers to swab elements of a given size in an array use them instead of open coded variants.
---
v2: fixed compilation error (LKP)
drivers/base/regmap/regmap-spi-avmm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/base/regmap/regmap-spi-avmm.c +4 -10
@@ -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 ); }/*
Signature · 1 line
2.35.1
Re: [PATCH v2 3/3] regmap: spi-avmm: Use swabXX_array() helpers
Quoted 4 lines · Andy Shevchenko
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 <[email protected]>
LGTM
Yours,
Linus Walleij
Quoted 3 lines · Andy Shevchenko
For now, some simple array operations to swab.
Signed-off-by Andy Shevchenko <[email protected]>
I like what you're doing here :)
Yours,
Linus Walleij
Mark Brown
maintainerQuoted 3 lines · Andy Shevchenko
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: 26cc2a788a1903da3ccff97061099f091255ecafAll 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