[PATCH v2] mfd: syscon: allow to register syscon with a device

From: Philipp Zabel
Date: Wed Feb 24 2016 - 06:19:20 EST


Commit bdb0066df96e ("mfd: syscon: Decouple syscon interface from platform
devices") added the possibility to register syscon devices without
associated platform device. This also removed regmap debugfs facilities,
which don't work without a device. Since there is no replacement, this
patch allows again to register syscon regions with an associated device
where that this device exists anyway.

Signed-off-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
---
Changes since v1:
- Rebased onto for-mfd-next
---
drivers/mfd/syscon.c | 10 ++++++++--
include/linux/mfd/syscon.h | 10 ++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 2f2225e..fe67fb0 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -42,7 +42,7 @@ static const struct regmap_config syscon_regmap_config = {
.reg_stride = 4,
};

-static struct syscon *of_syscon_register(struct device_node *np)
+struct syscon *syscon_register(struct device *dev, struct device_node *np)
{
struct syscon *syscon;
struct regmap *regmap;
@@ -89,7 +89,7 @@ static struct syscon *of_syscon_register(struct device_node *np)
syscon_config.val_bits = reg_io_width * 8;
syscon_config.max_register = resource_size(&res) - reg_io_width;

- regmap = regmap_init_mmio(NULL, base, &syscon_config);
+ regmap = regmap_init_mmio(dev, base, &syscon_config);
if (IS_ERR(regmap)) {
pr_err("regmap init failed\n");
ret = PTR_ERR(regmap);
@@ -111,6 +111,12 @@ err_map:
kfree(syscon);
return ERR_PTR(ret);
}
+EXPORT_SYMBOL_GPL(syscon_register);
+
+static struct syscon *of_syscon_register(struct device_node *np)
+{
+ return syscon_register(NULL, np);
+}

struct regmap *syscon_node_to_regmap(struct device_node *np)
{
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 1088149..e26037c 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -17,10 +17,14 @@

#include <linux/err.h>

+struct device;
struct device_node;
+struct syscon;

#ifdef CONFIG_MFD_SYSCON
extern struct regmap *syscon_node_to_regmap(struct device_node *np);
+extern struct syscon *syscon_register(struct device *dev,
+ struct device_node *np);
extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s);
extern struct regmap *syscon_regmap_lookup_by_phandle(
@@ -32,6 +36,12 @@ static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
return ERR_PTR(-ENOTSUPP);
}

+static struct syscon *syscon_register(struct device *dev,
+ struct device_node *np)
+{
+ return ERR_PTR(-ENOTSUPP);
+}
+
static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
{
return ERR_PTR(-ENOTSUPP);
--
2.7.0