Commit 400dceb6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

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.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220831212744.56435-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2d469737
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/swab.h>
#include "internal.h" #include "internal.h"
...@@ -345,7 +346,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg, ...@@ -345,7 +346,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
{ {
struct regmap_mmio_context *ctx = context; struct regmap_mmio_context *ctx = context;
int ret = 0; int ret = 0;
int i;
if (!IS_ERR(ctx->clk)) { if (!IS_ERR(ctx->clk)) {
ret = clk_enable(ctx->clk); ret = clk_enable(ctx->clk);
...@@ -382,27 +382,15 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg, ...@@ -382,27 +382,15 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
if (ctx->big_endian && (ctx->val_bytes > 1)) { if (ctx->big_endian && (ctx->val_bytes > 1)) {
switch (ctx->val_bytes) { switch (ctx->val_bytes) {
case 2: case 2:
{ swab16_array(val, val_count);
u16 *valp = (u16 *)val;
for (i = 0; i < val_count; i++)
valp[i] = swab16(valp[i]);
break; break;
}
case 4: case 4:
{ swab32_array(val, val_count);
u32 *valp = (u32 *)val;
for (i = 0; i < val_count; i++)
valp[i] = swab32(valp[i]);
break; break;
}
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
case 8: case 8:
{ swab64_array(val, val_count);
u64 *valp = (u64 *)val;
for (i = 0; i < val_count; i++)
valp[i] = swab64(valp[i]);
break; break;
}
#endif #endif
default: default:
ret = -EINVAL; ret = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment