[PATCH 1/7] PM / Domains: add generic function 'pm_genpd_of_add_device_by_name'

From: Simon Glass
Date: Tue Sep 18 2012 - 14:26:06 EST


From: Prathyush K <prathyush.k@xxxxxxxxxxx>

A new function pm_genpd_of_add_device_by_name is added to the pm_domain
file. This function takes three parameters - target device to be added to
genpd, a device node and the name of the property. This function reads
the "propname" property from the device node and finds the corresponding
genpd device node. The target device is then added to this genpd by
calling __pm_genpd_of_add_device.

of_property_read_u32(dev_node, propname, &val);
genpd_node = of_find_node_by_phandle(val);
__pm_genpd_of_add_device(genpd_node, dev, NULL);

Signed-off-by: Prathyush K <prathyush.k@xxxxxxxxxxx>
Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>
Tested-by: Prathyush Kalashwaram <prathyush@xxxxxxxxxxxx>
---
include/linux/pm_domain.h | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 30f794e..c733ece 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -137,6 +137,18 @@ static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
return __pm_genpd_add_device(genpd, dev, NULL);
}

+static inline int pm_genpd_of_add_device_by_name(
+ struct device_node *dev_node,
+ struct device *dev,
+ char *propname)
+{
+ u32 val;
+ struct device_node *genpd_node;
+ of_property_read_u32(dev_node, propname, &val);
+ genpd_node = of_find_node_by_phandle(val);
+ return __pm_genpd_of_add_device(genpd_node, dev, NULL);
+}
+
static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
struct device *dev)
{
@@ -184,6 +196,13 @@ static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
{
return -ENOSYS;
}
+static inline int pm_genpd_of_add_device_by_name(
+ struct device_node *dev_node,
+ struct device *dev,
+ char *propname)
+{
+ return -ENOSYS;
+}
static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
struct device *dev)
{
--
1.7.7.3

--
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/