Re: Re[10]: [PATCH v3] mfd: syscon: Add non-DT support

From: Arnd Bergmann
Date: Wed Feb 20 2013 - 10:00:29 EST


On Wednesday 20 February 2013, Alexander Shiyan wrote:
> OK. I can convert platform to DT, no so easy, but possible.
> But I will use syscon as way to using DT (and MULTIPLATFORM in the future),
> this mean that I should completely drop ATAG support from this platform
> (since I cannot use syscon device without DT support, but several platform devices
> need to use system-wide registers).
> Arnd, if its OK for you, I will use this way. (I talking about CLPS711X, you know it :) ).

Ah, I should have realized that this is about clps711x when the patch
is coming from you ;-)

This is an existing platform, and I would not require you to move it to
devicetree just for supporting syscon, although it may be a good idea
to make that move in the long run.

For clps711x, we know that there is only one syscon register set, so you
could do a very simple patch like below. Basically we don't need to
treat the absence of DT information as an error, and a call to
syscon_regmap_lookup_by_compatible or syscon_regmap_lookup_by_phandle
will always return the syscon device that was registered first, or
-EPROBE_DEFER for any error.

Arnd


diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3f10591..d3c06c6 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -59,9 +59,6 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
struct regmap *regmap;

syscon_np = of_find_compatible_node(NULL, NULL, s);
- if (!syscon_np)
- return ERR_PTR(-ENODEV);
-
regmap = syscon_node_to_regmap(syscon_np);
of_node_put(syscon_np);

@@ -76,9 +73,6 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
struct regmap *regmap;

syscon_np = of_parse_phandle(np, property, 0);
- if (!syscon_np)
- return ERR_PTR(-ENODEV);
-
regmap = syscon_node_to_regmap(syscon_np);
of_node_put(syscon_np);

@@ -100,26 +94,22 @@ static struct regmap_config syscon_regmap_config = {
static int syscon_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
struct syscon *syscon;
- struct resource res;
+ struct resource *res;
int ret;

- if (!np)
- return -ENOENT;
-
syscon = devm_kzalloc(dev, sizeof(struct syscon),
GFP_KERNEL);
if (!syscon)
return -ENOMEM;

- syscon->base = of_iomap(np, 0);
- if (!syscon->base)
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
return -EADDRNOTAVAIL;

- ret = of_address_to_resource(np, 0, &res);
- if (ret)
- return ret;
+ syscon->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!syscon->base)
+ return -ENOMEM;

syscon_regmap_config.max_register = res.end - res.start - 3;
syscon->regmap = devm_regmap_init_mmio(dev, syscon->base,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/