2013-03-13 17:35:25

by Alexander Shiyan

[permalink] [raw]
Subject: [PATCH v7 1/2] mfd: syscon: Removed unneeded field "dev" from private driver structure


Signed-off-by: Alexander Shiyan <[email protected]>
---
drivers/mfd/syscon.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 61aea63..674af14 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -25,17 +25,15 @@
static struct platform_driver syscon_driver;

struct syscon {
- struct device *dev;
void __iomem *base;
struct regmap *regmap;
};

static int syscon_match(struct device *dev, void *data)
{
- struct syscon *syscon = dev_get_drvdata(dev);
struct device_node *dn = data;

- return (syscon->dev->of_node == dn) ? 1 : 0;
+ return (dev->of_node == dn) ? 1 : 0;
}

struct regmap *syscon_node_to_regmap(struct device_node *np)
@@ -130,7 +128,6 @@ static int syscon_probe(struct platform_device *pdev)
return PTR_ERR(syscon->regmap);
}

- syscon->dev = dev;
platform_set_drvdata(pdev, syscon);

dev_info(dev, "syscon regmap start 0x%x end 0x%x registered\n",
--
1.7.12.4


2013-03-13 17:35:15

by Alexander Shiyan

[permalink] [raw]
Subject: [PATCH v7 2/2] mfd: syscon: Add non-DT support

This patch allow using syscon driver from the platform data, i.e.
possibility using driver on systems without oftree support.
For search syscon device from the client drivers,
"syscon_regmap_lookup_by_pdevname" function was added.

Signed-off-by: Alexander Shiyan <[email protected]>
---
drivers/mfd/Kconfig | 1 -
drivers/mfd/syscon.c | 75 +++++++++++++++++++++++++++-------------------
include/linux/mfd/syscon.h | 1 +
3 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 671f5b1..8fdd87e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1070,7 +1070,6 @@ config MFD_STA2X11

config MFD_SYSCON
bool "System Controller Register R/W Based on Regmap"
- depends on OF
select REGMAP_MMIO
help
Select this option to enable accessing system control registers
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 674af14..d1e5eb9 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -29,7 +29,7 @@ struct syscon {
struct regmap *regmap;
};

-static int syscon_match(struct device *dev, void *data)
+static int syscon_match_node(struct device *dev, void *data)
{
struct device_node *dn = data;

@@ -42,7 +42,7 @@ struct regmap *syscon_node_to_regmap(struct device_node *np)
struct device *dev;

dev = driver_find_device(&syscon_driver.driver, NULL, np,
- syscon_match);
+ syscon_match_node);
if (!dev)
return ERR_PTR(-EPROBE_DEFER);

@@ -68,6 +68,34 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);

+static int syscon_match_pdevname(struct device *dev, void *data)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ const struct platform_device_id *id = platform_get_device_id(pdev);
+
+ if (id)
+ if (!strcmp(id->name, (const char *)data))
+ return 1;
+
+ return !strcmp(dev_name(dev), (const char *)data);
+}
+
+struct regmap *syscon_regmap_lookup_by_pdevname(const char *s)
+{
+ struct device *dev;
+ struct syscon *syscon;
+
+ dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
+ syscon_match_pdevname);
+ if (!dev)
+ return ERR_PTR(-EPROBE_DEFER);
+
+ syscon = dev_get_drvdata(dev);
+
+ return syscon->regmap;
+}
+EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_pdevname);
+
struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
const char *property)
{
@@ -99,28 +127,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;
- int ret;
-
- if (!np)
- return -ENOENT;
+ struct resource *res;

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

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

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

- syscon_regmap_config.max_register = res.end - res.start - 3;
+ syscon_regmap_config.max_register = res->end - res->start - 3;
syscon->regmap = devm_regmap_init_mmio(dev, syscon->base,
&syscon_regmap_config);
if (IS_ERR(syscon->regmap)) {
@@ -130,22 +152,15 @@ static int syscon_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, syscon);

- dev_info(dev, "syscon regmap start 0x%x end 0x%x registered\n",
- res.start, res.end);
+ dev_info(dev, "regmap 0x%x-0x%x registered\n", res->start, res->end);

return 0;
}

-static int syscon_remove(struct platform_device *pdev)
-{
- struct syscon *syscon;
-
- syscon = platform_get_drvdata(pdev);
- iounmap(syscon->base);
- platform_set_drvdata(pdev, NULL);
-
- return 0;
-}
+static const struct platform_device_id syscon_ids[] = {
+ { "syscon", },
+ { }
+};

static struct platform_driver syscon_driver = {
.driver = {
@@ -154,7 +169,7 @@ static struct platform_driver syscon_driver = {
.of_match_table = of_syscon_match,
},
.probe = syscon_probe,
- .remove = syscon_remove,
+ .id_table = syscon_ids,
};

static int __init syscon_init(void)
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 6aeb6b8..5c9ee6e 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -17,6 +17,7 @@

extern struct regmap *syscon_node_to_regmap(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(
struct device_node *np,
const char *property);
--
1.7.12.4

2013-03-13 18:33:07

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH v7 2/2] mfd: syscon: Add non-DT support

On 03/13/2013 11:34 AM, Alexander Shiyan wrote:
> This patch allow using syscon driver from the platform data, i.e.
> possibility using driver on systems without oftree support.
> For search syscon device from the client drivers,
> "syscon_regmap_lookup_by_pdevname" function was added.

This patch also removes the driver's remove() function, which isn't
mentioned in the commit description.

Otherwise I didn't see any issues at a quick glance.

2013-03-13 18:43:34

by Alexander Shiyan

[permalink] [raw]
Subject: Re[2]: [PATCH v7 2/2] mfd: syscon: Add non-DT support

> On 03/13/2013 11:34 AM, Alexander Shiyan wrote:
> > This patch allow using syscon driver from the platform data, i.e.
> > possibility using driver on systems without oftree support.
> > For search syscon device from the client drivers,
> > "syscon_regmap_lookup_by_pdevname" function was added.
>
> This patch also removes the driver's remove() function, which isn't
> mentioned in the commit description.

Driver is using resource managed functions, remove() is not necessary.

> Otherwise I didn't see any issues at a quick glance.


---
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-03-13 18:55:49

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH v7 2/2] mfd: syscon: Add non-DT support

On 03/13/2013 12:43 PM, Alexander Shiyan wrote:
>> On 03/13/2013 11:34 AM, Alexander Shiyan wrote:
>>> This patch allow using syscon driver from the platform data, i.e.
>>> possibility using driver on systems without oftree support.
>>> For search syscon device from the client drivers,
>>> "syscon_regmap_lookup_by_pdevname" function was added.
>>
>> This patch also removes the driver's remove() function, which isn't
>> mentioned in the commit description.
>
> Driver is using resource managed functions, remove() is not necessary.

Ah right, I see that conversion was made in this patch. It seems like it
should be mentioned in the commit description, but it's probably not a
big deal unless there is some other reason to repost this.

2013-03-14 02:51:19

by Dong Aisheng

[permalink] [raw]
Subject: Re: [PATCH v7 2/2] mfd: syscon: Add non-DT support

On 14 March 2013 01:34, Alexander Shiyan <[email protected]> wrote:
> This patch allow using syscon driver from the platform data, i.e.
> possibility using driver on systems without oftree support.
> For search syscon device from the client drivers,
> "syscon_regmap_lookup_by_pdevname" function was added.
>
> Signed-off-by: Alexander Shiyan <[email protected]>

Actually i've acked this series before, usually you can send out the
updated series
with my tag if no other big changes except the minor comments fix i pointed out.
Here again, for this series:
Acked-by: Dong Aisheng <[email protected]>

Regards
Dong Aisheng

> ---
> drivers/mfd/Kconfig | 1 -
> drivers/mfd/syscon.c | 75 +++++++++++++++++++++++++++-------------------
> include/linux/mfd/syscon.h | 1 +
> 3 files changed, 46 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 671f5b1..8fdd87e 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1070,7 +1070,6 @@ config MFD_STA2X11
>
> config MFD_SYSCON
> bool "System Controller Register R/W Based on Regmap"
> - depends on OF
> select REGMAP_MMIO
> help
> Select this option to enable accessing system control registers
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 674af14..d1e5eb9 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -29,7 +29,7 @@ struct syscon {
> struct regmap *regmap;
> };
>
> -static int syscon_match(struct device *dev, void *data)
> +static int syscon_match_node(struct device *dev, void *data)
> {
> struct device_node *dn = data;
>
> @@ -42,7 +42,7 @@ struct regmap *syscon_node_to_regmap(struct device_node *np)
> struct device *dev;
>
> dev = driver_find_device(&syscon_driver.driver, NULL, np,
> - syscon_match);
> + syscon_match_node);
> if (!dev)
> return ERR_PTR(-EPROBE_DEFER);
>
> @@ -68,6 +68,34 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
> }
> EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
>
> +static int syscon_match_pdevname(struct device *dev, void *data)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + const struct platform_device_id *id = platform_get_device_id(pdev);
> +
> + if (id)
> + if (!strcmp(id->name, (const char *)data))
> + return 1;
> +
> + return !strcmp(dev_name(dev), (const char *)data);
> +}
> +
> +struct regmap *syscon_regmap_lookup_by_pdevname(const char *s)
> +{
> + struct device *dev;
> + struct syscon *syscon;
> +
> + dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
> + syscon_match_pdevname);
> + if (!dev)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + syscon = dev_get_drvdata(dev);
> +
> + return syscon->regmap;
> +}
> +EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_pdevname);
> +
> struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
> const char *property)
> {
> @@ -99,28 +127,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;
> - int ret;
> -
> - if (!np)
> - return -ENOENT;
> + struct resource *res;
>
> - syscon = devm_kzalloc(dev, sizeof(struct syscon),
> - GFP_KERNEL);
> + syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL);
> if (!syscon)
> return -ENOMEM;
>
> - syscon->base = of_iomap(np, 0);
> - if (!syscon->base)
> - return -EADDRNOTAVAIL;
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -ENOENT;
>
> - ret = of_address_to_resource(np, 0, &res);
> - if (ret)
> - return ret;
> + syscon->base = devm_ioremap(dev, res->start, resource_size(res));
> + if (!syscon->base)
> + return -ENOMEM;
>
> - syscon_regmap_config.max_register = res.end - res.start - 3;
> + syscon_regmap_config.max_register = res->end - res->start - 3;
> syscon->regmap = devm_regmap_init_mmio(dev, syscon->base,
> &syscon_regmap_config);
> if (IS_ERR(syscon->regmap)) {
> @@ -130,22 +152,15 @@ static int syscon_probe(struct platform_device *pdev)
>
> platform_set_drvdata(pdev, syscon);
>
> - dev_info(dev, "syscon regmap start 0x%x end 0x%x registered\n",
> - res.start, res.end);
> + dev_info(dev, "regmap 0x%x-0x%x registered\n", res->start, res->end);
>
> return 0;
> }
>
> -static int syscon_remove(struct platform_device *pdev)
> -{
> - struct syscon *syscon;
> -
> - syscon = platform_get_drvdata(pdev);
> - iounmap(syscon->base);
> - platform_set_drvdata(pdev, NULL);
> -
> - return 0;
> -}
> +static const struct platform_device_id syscon_ids[] = {
> + { "syscon", },
> + { }
> +};
>
> static struct platform_driver syscon_driver = {
> .driver = {
> @@ -154,7 +169,7 @@ static struct platform_driver syscon_driver = {
> .of_match_table = of_syscon_match,
> },
> .probe = syscon_probe,
> - .remove = syscon_remove,
> + .id_table = syscon_ids,
> };
>
> static int __init syscon_init(void)
> diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
> index 6aeb6b8..5c9ee6e 100644
> --- a/include/linux/mfd/syscon.h
> +++ b/include/linux/mfd/syscon.h
> @@ -17,6 +17,7 @@
>
> extern struct regmap *syscon_node_to_regmap(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(
> struct device_node *np,
> const char *property);
> --
> 1.7.12.4
>

2013-04-05 15:59:35

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH v7 1/2] mfd: syscon: Removed unneeded field "dev" from private driver structure

Hi Alexander,

On Wed, Mar 13, 2013 at 09:34:19PM +0400, Alexander Shiyan wrote:
>
> Signed-off-by: Alexander Shiyan <[email protected]>
> ---
> drivers/mfd/syscon.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
Both patches applied, thanks.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/