From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH v1 2/3] regmap: mmio: Use swabXX_array() helpers
Date: Wed, 31 Aug 2022 17:54:06 +0300 [thread overview]
Message-ID: <20220831145407.78166-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20220831145407.78166-1-andriy.shevchenko@linux.intel.com>
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
next prev parent reply other threads:[~2022-08-31 14:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 14:54 [PATCH v1 1/3] swab: Add array operations Andy Shevchenko
2022-08-31 14:54 ` Andy Shevchenko [this message]
2022-08-31 14:54 ` [PATCH v1 3/3] regmap: spi-avmm: Use swabXX_array() helpers 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220831145407.78166-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.