Skip to content

Commit 400dceb

Browse files
andy-shevbroonie
authored andcommitted
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220831212744.56435-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2d46973 commit 400dceb

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

drivers/base/regmap/regmap-mmio.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/module.h>
1111
#include <linux/regmap.h>
1212
#include <linux/slab.h>
13+
#include <linux/swab.h>
1314

1415
#include "internal.h"
1516

@@ -345,7 +346,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
345346
{
346347
struct regmap_mmio_context *ctx = context;
347348
int ret = 0;
348-
int i;
349349

350350
if (!IS_ERR(ctx->clk)) {
351351
ret = clk_enable(ctx->clk);
@@ -382,27 +382,15 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
382382
if (ctx->big_endian && (ctx->val_bytes > 1)) {
383383
switch (ctx->val_bytes) {
384384
case 2:
385-
{
386-
u16 *valp = (u16 *)val;
387-
for (i = 0; i < val_count; i++)
388-
valp[i] = swab16(valp[i]);
385+
swab16_array(val, val_count);
389386
break;
390-
}
391387
case 4:
392-
{
393-
u32 *valp = (u32 *)val;
394-
for (i = 0; i < val_count; i++)
395-
valp[i] = swab32(valp[i]);
388+
swab32_array(val, val_count);
396389
break;
397-
}
398390
#ifdef CONFIG_64BIT
399391
case 8:
400-
{
401-
u64 *valp = (u64 *)val;
402-
for (i = 0; i < val_count; i++)
403-
valp[i] = swab64(valp[i]);
392+
swab64_array(val, val_count);
404393
break;
405-
}
406394
#endif
407395
default:
408396
ret = -EINVAL;

0 commit comments

Comments
 (0)