From 7e7ba58c94127efa97c249e38cc2d1c0ed78b58f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 8 Aug 2022 23:34:00 +0300 Subject: [PATCH] regmap: mmio: Fix MMIO accessors to avoid talking to IO port Currently regmap MMIO is inconsistent with IO accessors. I.e. the Big Endian counterparts are using ioreadXXbe() / iowriteXXbe() which are not clean implementations of readXXbe(). That said, reimplement current Big Endian MMIO accessors by replacing ioread()/iowrite() with respective read()/write() and swab() calls. Note, there are no current in-kernel users that may utilize the functionality of the IO ports on Big Endian hardware. All drivers that use regmap MMIO either Little Endian, or they don't map IO ports in a way that ioreadXX()/iowriteXX() may be utilized. Signed-off-by: Andy Shevchenko Acked-by: William Breathitt Gray Link: https://lore.kernel.org/r/20220808203401.35153-5-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-mmio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 37f79e912d01..eed488aad1b0 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -104,7 +104,7 @@ static void regmap_mmio_write16be(struct regmap_mmio_context *ctx, unsigned int reg, unsigned int val) { - iowrite16be(val, ctx->regs + reg); + writew(swab16(val), ctx->regs + reg); } static void regmap_mmio_iowrite16be(struct regmap_mmio_context *ctx, @@ -137,7 +137,7 @@ static void regmap_mmio_write32be(struct regmap_mmio_context *ctx, unsigned int reg, unsigned int val) { - iowrite32be(val, ctx->regs + reg); + writel(swab32(val), ctx->regs + reg); } static void regmap_mmio_iowrite32be(struct regmap_mmio_context *ctx, @@ -204,7 +204,7 @@ static unsigned int regmap_mmio_ioread16le(struct regmap_mmio_context *ctx, static unsigned int regmap_mmio_read16be(struct regmap_mmio_context *ctx, unsigned int reg) { - return ioread16be(ctx->regs + reg); + return swab16(readw(ctx->regs + reg)); } static unsigned int regmap_mmio_ioread16be(struct regmap_mmio_context *ctx, @@ -234,7 +234,7 @@ static unsigned int regmap_mmio_ioread32le(struct regmap_mmio_context *ctx, static unsigned int regmap_mmio_read32be(struct regmap_mmio_context *ctx, unsigned int reg) { - return ioread32be(ctx->regs + reg); + return swab32(readl(ctx->regs + reg)); } static unsigned int regmap_mmio_ioread32be(struct regmap_mmio_context *ctx,