]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
PM / Domains: Make it possible to use domain names when adding devices
authorRafael J. Wysocki <rjw@sisk.pl>
Mon, 6 Aug 2012 23:06:11 +0000 (01:06 +0200)
committerRafael J. Wysocki <rjw@sisk.pl>
Mon, 3 Sep 2012 23:36:52 +0000 (01:36 +0200)
Add a new helper function __pm_genpd_name_add_device() allowing
a device to be added to a (registered) generic PM domain identified
by name.  Add a wrapper around it, pm_genpd_name_add_device(),
passing NULL as the last argument and reorganize pm_domains.h for the
new functions to be defined consistently with the existing ones.

These functions are useful for adding devices to PM domains whose
representations are stored in tables, when the caller doesn't know
the index of the domain to add the device to, but it knows the
domain's name.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
drivers/base/power/domain.c
include/linux/pm_domain.h

index 5f4606f13be6922f2c56987fd7089e2cd4b82d5f..ac06d0280b42d9061ef0ca121b6c5ceb40f85a2d 100644 (file)
@@ -1465,6 +1465,33 @@ int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
        return __pm_genpd_add_device(genpd, dev, td);
 }
 
+
+/**
+ * __pm_genpd_name_add_device - Find I/O PM domain and add a device to it.
+ * @domain_name: Name of the PM domain to add the device to.
+ * @dev: Device to be added.
+ * @td: Set of PM QoS timing parameters to attach to the device.
+ */
+int __pm_genpd_name_add_device(const char *domain_name, struct device *dev,
+                              struct gpd_timing_data *td)
+{
+       struct generic_pm_domain *genpd = NULL, *gpd;
+
+       if (IS_ERR_OR_NULL(domain_name) || IS_ERR_OR_NULL(dev))
+               return -EINVAL;
+
+       mutex_lock(&gpd_list_lock);
+       list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
+               if (!strcmp(gpd->name, domain_name)) {
+                       genpd = gpd;
+                       break;
+               }
+       }
+       mutex_unlock(&gpd_list_lock);
+
+       return __pm_genpd_add_device(genpd, dev, td);
+}
+
 /**
  * pm_genpd_remove_device - Remove a device from an I/O PM domain.
  * @genpd: PM domain to remove the device from.
index 08adf8e5a80e9c34ccb1ea9de19efe8bf992ea0d..1991a92b056732751f4eccd42dde93f8763cf960 100644 (file)
@@ -138,17 +138,9 @@ extern int __pm_genpd_of_add_device(struct device_node *genpd_node,
                                    struct device *dev,
                                    struct gpd_timing_data *td);
 
-static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
-                                     struct device *dev)
-{
-       return __pm_genpd_add_device(genpd, dev, NULL);
-}
-
-static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
-                                        struct device *dev)
-{
-       return __pm_genpd_of_add_device(genpd_node, dev, NULL);
-}
+extern int __pm_genpd_name_add_device(const char *domain_name,
+                                     struct device *dev,
+                                     struct gpd_timing_data *td);
 
 extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
                                  struct device *dev);
@@ -187,8 +179,15 @@ static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
 {
        return -ENOSYS;
 }
-static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
-                                     struct device *dev)
+static inline int __pm_genpd_of_add_device(struct device_node *genpd_node,
+                                          struct device *dev,
+                                          struct gpd_timing_data *td)
+{
+       return -ENOSYS;
+}
+static inline int __pm_genpd_name_add_device(const char *domain_name,
+                                            struct device *dev,
+                                            struct gpd_timing_data *td)
 {
        return -ENOSYS;
 }
@@ -242,6 +241,24 @@ static inline bool default_stop_ok(struct device *dev)
 #define pm_domain_always_on_gov NULL
 #endif
 
+static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
+                                     struct device *dev)
+{
+       return __pm_genpd_add_device(genpd, dev, NULL);
+}
+
+static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
+                                        struct device *dev)
+{
+       return __pm_genpd_of_add_device(genpd_node, dev, NULL);
+}
+
+static inline int pm_genpd_name_add_device(const char *domain_name,
+                                          struct device *dev)
+{
+       return __pm_genpd_name_add_device(domain_name, dev, NULL);
+}
+
 static inline int pm_genpd_remove_callbacks(struct device *dev)
 {
        return __pm_genpd_remove_callbacks(dev, true);