* [PATCH] mfd: syscon: add syscon_regmap_lookup_by_phandle()
@ 2019-06-28 15:37 Marcin Niestroj
2019-07-02 6:15 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Niestroj @ 2019-06-28 15:37 UTC (permalink / raw)
To: barebox; +Cc: Marcin Niestroj
This function is handy when syscon is passed as phandle to device_node
property.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
drivers/mfd/syscon.c | 19 +++++++++++++++++++
include/mfd/syscon.h | 9 +++++++++
2 files changed, 28 insertions(+)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index b1ff1b1ea..809941937 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -174,6 +174,25 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
return regmap;
}
+struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
+ const char *property)
+{
+ struct device_node *syscon_np;
+ struct regmap *regmap;
+
+ if (property)
+ syscon_np = of_parse_phandle(np, property, 0);
+ else
+ syscon_np = np;
+
+ if (!syscon_np)
+ return ERR_PTR(-ENODEV);
+
+ regmap = syscon_node_to_regmap(syscon_np);
+
+ return regmap;
+}
+
static int syscon_probe(struct device_d *dev)
{
struct syscon *syscon;
diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h
index 902f9fa2f..ac33f2d34 100644
--- a/include/mfd/syscon.h
+++ b/include/mfd/syscon.h
@@ -22,6 +22,9 @@ void __iomem *syscon_base_lookup_by_phandle
(struct device_node *np, const char *property);
struct regmap *syscon_node_to_regmap(struct device_node *np);
struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
+extern struct regmap *syscon_regmap_lookup_by_phandle(
+ struct device_node *np,
+ const char *property);
#else
static inline void __iomem *syscon_base_lookup_by_pdevname(const char *s)
{
@@ -42,6 +45,12 @@ static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
{
return ERR_PTR(-ENOSYS);
}
+static inline struct regmap *syscon_regmap_lookup_by_phandle(
+ struct device_node *np,
+ const char *property)
+{
+ return ERR_PTR(-ENOSYS);
+}
#endif
#endif
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mfd: syscon: add syscon_regmap_lookup_by_phandle()
2019-06-28 15:37 [PATCH] mfd: syscon: add syscon_regmap_lookup_by_phandle() Marcin Niestroj
@ 2019-07-02 6:15 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-07-02 6:15 UTC (permalink / raw)
To: Marcin Niestroj; +Cc: barebox
On Fri, Jun 28, 2019 at 05:37:27PM +0200, Marcin Niestroj wrote:
> This function is handy when syscon is passed as phandle to device_node
> property.
>
> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
> ---
> drivers/mfd/syscon.c | 19 +++++++++++++++++++
> include/mfd/syscon.h | 9 +++++++++
> 2 files changed, 28 insertions(+)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-02 6:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28 15:37 [PATCH] mfd: syscon: add syscon_regmap_lookup_by_phandle() Marcin Niestroj
2019-07-02 6:15 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox