Commit 2411a336 authored by Sven Van Asbroeck's avatar Sven Van Asbroeck Committed by Greg Kroah-Hartman

staging: fieldbus: arcx-anybus: change custom -> mmio regmap

The arcx-anybus's registers are accessed via a memory-mapped
IO region. A regmap associated with this region is created
using custom reg_read() / reg_write() callbacks.

However, an abstraction which creates a memory-mapped IO
region backed regmap already exists: devm_regmap_init_mmio().

Replace the custom regmap with the existing kernel abstraction.
As a pleasant side-effect, sparse warnings now disappear.
Signed-off-by: default avatarSven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67436a1e
...@@ -111,49 +111,31 @@ static void export_reset_1(struct device *dev, bool assert) ...@@ -111,49 +111,31 @@ static void export_reset_1(struct device *dev, bool assert)
* at a time for now. * at a time for now.
*/ */
static int read_reg_bus(void *context, unsigned int reg, static const struct regmap_config arcx_regmap_cfg = {
unsigned int *val) .reg_bits = 16,
{ .val_bits = 8,
void __iomem *base = context; .max_register = 0x7ff,
.use_single_read = true,
*val = readb(base + reg); .use_single_write = true,
return 0; /*
} * single-byte parallel bus accesses are atomic, so don't
* require any synchronization.
static int write_reg_bus(void *context, unsigned int reg, */
unsigned int val) .disable_locking = true,
{ };
void __iomem *base = context;
writeb(val, base + reg);
return 0;
}
static struct regmap *create_parallel_regmap(struct platform_device *pdev, static struct regmap *create_parallel_regmap(struct platform_device *pdev,
int idx) int idx)
{ {
struct regmap_config regmap_cfg = {
.reg_bits = 11,
.val_bits = 8,
/*
* single-byte parallel bus accesses are atomic, so don't
* require any synchronization.
*/
.disable_locking = true,
.reg_read = read_reg_bus,
.reg_write = write_reg_bus,
};
struct resource *res; struct resource *res;
void __iomem *base; void __iomem *base;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1); res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1);
if (resource_size(res) < (1 << regmap_cfg.reg_bits))
return ERR_PTR(-EINVAL);
base = devm_ioremap_resource(dev, res); base = devm_ioremap_resource(dev, res);
if (IS_ERR(base)) if (IS_ERR(base))
return ERR_CAST(base); return ERR_CAST(base);
return devm_regmap_init(dev, NULL, base, &regmap_cfg); return devm_regmap_init_mmio(dev, base, &arcx_regmap_cfg);
} }
static struct anybuss_host * static struct anybuss_host *
......
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