* [PATCH v2 1/3] mfd: syscon: Removed support for unloading
@ 2013-02-11 18:42 Alexander Shiyan
2013-02-11 18:42 ` [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure Alexander Shiyan
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Alexander Shiyan @ 2013-02-11 18:42 UTC (permalink / raw)
To: linux-kernel
Cc: Dong Aisheng, Samuel Ortiz, Mark Brown, Arnd Bergmann,
Alexander Shiyan
The driver can be used in various subsystems and therefore should not
be unloaded when it is defined in the kernel configuration, so remove
support for unloading it.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
drivers/mfd/syscon.c | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3f10591..e1886fb 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -138,17 +138,6 @@ static int syscon_probe(struct platform_device *pdev)
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 struct platform_driver syscon_driver = {
.driver = {
.name = "syscon",
@@ -156,7 +145,6 @@ static struct platform_driver syscon_driver = {
.of_match_table = of_syscon_match,
},
.probe = syscon_probe,
- .remove = syscon_remove,
};
static int __init syscon_init(void)
@@ -165,12 +153,6 @@ static int __init syscon_init(void)
}
postcore_initcall(syscon_init);
-static void __exit syscon_exit(void)
-{
- platform_driver_unregister(&syscon_driver);
-}
-module_exit(syscon_exit);
-
MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
MODULE_DESCRIPTION("System Control driver");
MODULE_LICENSE("GPL v2");
--
1.7.12.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure
2013-02-11 18:42 [PATCH v2 1/3] mfd: syscon: Removed support for unloading Alexander Shiyan
@ 2013-02-11 18:42 ` Alexander Shiyan
2013-02-17 2:57 ` Dong Aisheng
2013-02-11 18:42 ` [PATCH v2 3/3] mfd: syscon: Add non-DT support Alexander Shiyan
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Alexander Shiyan @ 2013-02-11 18:42 UTC (permalink / raw)
To: linux-kernel
Cc: Dong Aisheng, Samuel Ortiz, Mark Brown, Arnd Bergmann,
Alexander Shiyan
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
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 e1886fb..4a7ed5a 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -24,17 +24,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)
@@ -129,7 +127,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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] mfd: syscon: Add non-DT support
2013-02-11 18:42 [PATCH v2 1/3] mfd: syscon: Removed support for unloading Alexander Shiyan
2013-02-11 18:42 ` [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure Alexander Shiyan
@ 2013-02-11 18:42 ` Alexander Shiyan
2013-02-11 20:05 ` [PATCH v2 1/3] mfd: syscon: Removed support for unloading Arnd Bergmann
2013-02-17 2:42 ` Dong Aisheng
3 siblings, 0 replies; 8+ messages in thread
From: Alexander Shiyan @ 2013-02-11 18:42 UTC (permalink / raw)
To: linux-kernel
Cc: Dong Aisheng, Samuel Ortiz, Mark Brown, Arnd Bergmann,
Alexander Shiyan
This patch allow using syscon driver from the platform data, i.e.
possibility works without oftree support.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
drivers/mfd/Kconfig | 1 -
drivers/mfd/syscon.c | 77 ++++++++++++++++++++++++++++++++++------------
include/linux/mfd/syscon.h | 4 +++
3 files changed, 62 insertions(+), 20 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 4a7ed5a..eac023e 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -21,6 +21,8 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+
static struct platform_driver syscon_driver;
struct syscon {
@@ -28,7 +30,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;
@@ -41,7 +43,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);
@@ -51,19 +53,40 @@ struct regmap *syscon_node_to_regmap(struct device_node *np)
}
EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
+static int syscon_match_pdata(struct device *dev, void *data)
+{
+ struct syscon_pdata *pdata = dev_get_platdata(dev);
+
+ if (pdata)
+ return !strcmp(pdata->compatible, (const char *)data);
+
+ return 0;
+}
+
struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
{
struct device_node *syscon_np;
struct regmap *regmap;
+ struct syscon *syscon;
+ struct device *dev;
syscon_np = of_find_compatible_node(NULL, NULL, s);
- if (!syscon_np)
+ if (syscon_np) {
+ regmap = syscon_node_to_regmap(syscon_np);
+ of_node_put(syscon_np);
+
+ return regmap;
+ }
+
+ /* Fallback to search by platform_data.compatible string */
+ dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
+ syscon_match_pdata);
+ if (!dev)
return ERR_PTR(-ENODEV);
- regmap = syscon_node_to_regmap(syscon_np);
- of_node_put(syscon_np);
+ syscon = dev_get_drvdata(dev);
- return regmap;
+ return syscon->regmap;
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
@@ -100,37 +123,53 @@ 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, res_of;
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)
- return -EADDRNOTAVAIL;
-
- ret = of_address_to_resource(np, 0, &res);
- if (ret)
- return ret;
+ if (IS_ENABLED(CONFIG_OF) && np) {
+ syscon->base = of_iomap(np, 0);
+ if (!syscon->base)
+ return -EADDRNOTAVAIL;
+
+ res = &res_of;
+ ret = of_address_to_resource(np, 0, res);
+ if (ret) {
+ iounmap(syscon->base);
+ return ret;
+ }
+ } else {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENOENT;
+
+ if (!devm_request_mem_region(dev, res->start,
+ resource_size(res),
+ dev_name(&pdev->dev)))
+ return -EBUSY;
+
+ syscon->base = ioremap(res->start, resource_size(res));
+ if (!syscon->base)
+ return -EADDRNOTAVAIL;
+ }
- 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)) {
dev_err(dev, "regmap init failed\n");
+ iounmap(syscon->base);
return PTR_ERR(syscon->regmap);
}
platform_set_drvdata(pdev, syscon);
dev_info(dev, "syscon regmap start 0x%x end 0x%x registered\n",
- res.start, res.end);
+ res->start, res->end);
return 0;
}
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index 6aeb6b8..96c2566 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -15,6 +15,10 @@
#ifndef __LINUX_MFD_SYSCON_H__
#define __LINUX_MFD_SYSCON_H__
+struct syscon_pdata {
+ const char *compatible;
+};
+
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_phandle(
--
1.7.12.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] mfd: syscon: Removed support for unloading
2013-02-11 18:42 [PATCH v2 1/3] mfd: syscon: Removed support for unloading Alexander Shiyan
2013-02-11 18:42 ` [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure Alexander Shiyan
2013-02-11 18:42 ` [PATCH v2 3/3] mfd: syscon: Add non-DT support Alexander Shiyan
@ 2013-02-11 20:05 ` Arnd Bergmann
2013-02-12 6:35 ` Re[2]: " Alexander Shiyan
2013-02-17 2:42 ` Dong Aisheng
3 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2013-02-11 20:05 UTC (permalink / raw)
To: Alexander Shiyan; +Cc: linux-kernel, Dong Aisheng, Samuel Ortiz, Mark Brown
On Monday 11 February 2013, Alexander Shiyan wrote:
> The driver can be used in various subsystems and therefore should not
> be unloaded when it is defined in the kernel configuration, so remove
> support for unloading it.
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Can you describe a scenario where that would happen? Normally the
module should stay pinned as long as any other module refers
to its exported symbols.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re[2]: [PATCH v2 1/3] mfd: syscon: Removed support for unloading
2013-02-11 20:05 ` [PATCH v2 1/3] mfd: syscon: Removed support for unloading Arnd Bergmann
@ 2013-02-12 6:35 ` Alexander Shiyan
2013-02-12 11:38 ` Arnd Bergmann
0 siblings, 1 reply; 8+ messages in thread
From: Alexander Shiyan @ 2013-02-12 6:35 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel, Dong Aisheng, Samuel Ortiz, Mark Brown
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 799 bytes --]
Hello.
> On Monday 11 February 2013, Alexander Shiyan wrote:
> > The driver can be used in various subsystems and therefore should not
> > be unloaded when it is defined in the kernel configuration, so remove
> > support for unloading it.
> >
> > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
>
> Can you describe a scenario where that would happen? Normally the
> module should stay pinned as long as any other module refers
> to its exported symbols.
Probably I wrote a bad description.
The driver registered by "postcore_initcall". Therefore, if we unregister the
driver, we have no way to register it back. Fixme please.
---
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re[2]: [PATCH v2 1/3] mfd: syscon: Removed support for unloading
2013-02-12 6:35 ` Re[2]: " Alexander Shiyan
@ 2013-02-12 11:38 ` Arnd Bergmann
0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2013-02-12 11:38 UTC (permalink / raw)
To: Alexander Shiyan; +Cc: linux-kernel, Dong Aisheng, Samuel Ortiz, Mark Brown
On Tuesday 12 February 2013, Alexander Shiyan wrote:
> > On Monday 11 February 2013, Alexander Shiyan wrote:
> > > The driver can be used in various subsystems and therefore should not
> > > be unloaded when it is defined in the kernel configuration, so remove
> > > support for unloading it.
> > >
> > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> >
> > Can you describe a scenario where that would happen? Normally the
> > module should stay pinned as long as any other module refers
> > to its exported symbols.
>
> Probably I wrote a bad description.
> The driver registered by "postcore_initcall". Therefore, if we unregister the
> driver, we have no way to register it back. Fixme please.
Ah, the driver is actually "bool" in Kconfig rather than "tristate", so
it is not possible to build it as a module. Makes sense then, and if
we ever want to turn this into a module, we can still revert your patch.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] mfd: syscon: Removed support for unloading
2013-02-11 18:42 [PATCH v2 1/3] mfd: syscon: Removed support for unloading Alexander Shiyan
` (2 preceding siblings ...)
2013-02-11 20:05 ` [PATCH v2 1/3] mfd: syscon: Removed support for unloading Arnd Bergmann
@ 2013-02-17 2:42 ` Dong Aisheng
3 siblings, 0 replies; 8+ messages in thread
From: Dong Aisheng @ 2013-02-17 2:42 UTC (permalink / raw)
To: Alexander Shiyan; +Cc: linux-kernel, Samuel Ortiz, Mark Brown, Arnd Bergmann
On 12 February 2013 02:42, Alexander Shiyan <shc_work@mail.ru> wrote:
> The driver can be used in various subsystems and therefore should not
> be unloaded when it is defined in the kernel configuration, so remove
> support for unloading it.
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Regards
Dong Aisheng
> ---
> drivers/mfd/syscon.c | 18 ------------------
> 1 file changed, 18 deletions(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 3f10591..e1886fb 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -138,17 +138,6 @@ static int syscon_probe(struct platform_device *pdev)
> 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 struct platform_driver syscon_driver = {
> .driver = {
> .name = "syscon",
> @@ -156,7 +145,6 @@ static struct platform_driver syscon_driver = {
> .of_match_table = of_syscon_match,
> },
> .probe = syscon_probe,
> - .remove = syscon_remove,
> };
>
> static int __init syscon_init(void)
> @@ -165,12 +153,6 @@ static int __init syscon_init(void)
> }
> postcore_initcall(syscon_init);
>
> -static void __exit syscon_exit(void)
> -{
> - platform_driver_unregister(&syscon_driver);
> -}
> -module_exit(syscon_exit);
> -
> MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
> MODULE_DESCRIPTION("System Control driver");
> MODULE_LICENSE("GPL v2");
> --
> 1.7.12.4
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure
2013-02-11 18:42 ` [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure Alexander Shiyan
@ 2013-02-17 2:57 ` Dong Aisheng
0 siblings, 0 replies; 8+ messages in thread
From: Dong Aisheng @ 2013-02-17 2:57 UTC (permalink / raw)
To: Alexander Shiyan; +Cc: linux-kernel, Samuel Ortiz, Mark Brown, Arnd Bergmann
On 12 February 2013 02:42, Alexander Shiyan <shc_work@mail.ru> wrote:
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Regards
Dong Aisheng
> ---
> 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 e1886fb..4a7ed5a 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -24,17 +24,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)
> @@ -129,7 +127,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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-02-17 2:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-11 18:42 [PATCH v2 1/3] mfd: syscon: Removed support for unloading Alexander Shiyan
2013-02-11 18:42 ` [PATCH v2 2/3] mfd: syscon: Removed unneeded field "dev" from private driver structure Alexander Shiyan
2013-02-17 2:57 ` Dong Aisheng
2013-02-11 18:42 ` [PATCH v2 3/3] mfd: syscon: Add non-DT support Alexander Shiyan
2013-02-11 20:05 ` [PATCH v2 1/3] mfd: syscon: Removed support for unloading Arnd Bergmann
2013-02-12 6:35 ` Re[2]: " Alexander Shiyan
2013-02-12 11:38 ` Arnd Bergmann
2013-02-17 2:42 ` Dong Aisheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox