]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
PM / Domains: Add generic data pointer to struct genpd_power_state
authorUlf Hansson <ulf.hansson@linaro.org>
Wed, 27 Mar 2019 14:35:45 +0000 (15:35 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 9 Apr 2019 22:32:34 +0000 (00:32 +0200)
Add a data pointer to the genpd_power_state struct, to allow a genpd
backend driver to store per-state specific data. To introduce the
pointer, change the way genpd deals with freeing of the corresponding
allocated data.

More precisely, clarify the responsibility of whom that shall free the
data, by adding a ->free_states() callback to the generic_pm_domain
structure. The one allocating the data will be expected to set the
callback, to allow genpd to invoke it from genpd_remove().

Co-developed-by: Lina Iyer <lina.iyer@linaro.org>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[ rjw: Subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c
include/linux/pm_domain.h

index 96a6dc9d305c88b842258f4ed91cc7b7b569d506..ff6f992f7a1d152ad19bc2b4e7c61b859f86a2cf 100644 (file)
@@ -1686,6 +1686,12 @@ out:
 }
 EXPORT_SYMBOL_GPL(pm_genpd_remove_subdomain);
 
+static void genpd_free_default_power_state(struct genpd_power_state *states,
+                                          unsigned int state_count)
+{
+       kfree(states);
+}
+
 static int genpd_set_default_power_state(struct generic_pm_domain *genpd)
 {
        struct genpd_power_state *state;
@@ -1696,7 +1702,7 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd)
 
        genpd->states = state;
        genpd->state_count = 1;
-       genpd->free = state;
+       genpd->free_states = genpd_free_default_power_state;
 
        return 0;
 }
@@ -1812,7 +1818,9 @@ static int genpd_remove(struct generic_pm_domain *genpd)
        list_del(&genpd->gpd_list_node);
        genpd_unlock(genpd);
        cancel_work_sync(&genpd->power_off_work);
-       kfree(genpd->free);
+       if (genpd->free_states)
+               genpd->free_states(genpd->states, genpd->state_count);
+
        pr_debug("%s: removed %s\n", __func__, genpd->name);
 
        return 0;
index 1ed5874bcee09afef28c505574bbd2d213abd785..8e1399231753c35cbe3497810b648abf7c1337f7 100644 (file)
@@ -69,6 +69,7 @@ struct genpd_power_state {
        s64 residency_ns;
        struct fwnode_handle *fwnode;
        ktime_t idle_time;
+       void *data;
 };
 
 struct genpd_lock_ops;
@@ -110,9 +111,10 @@ struct generic_pm_domain {
                           struct device *dev);
        unsigned int flags;             /* Bit field of configs for genpd */
        struct genpd_power_state *states;
+       void (*free_states)(struct genpd_power_state *states,
+                           unsigned int state_count);
        unsigned int state_count; /* number of states */
        unsigned int state_idx; /* state that genpd will go to when off */
-       void *free; /* Free the state that was allocated for default */
        ktime_t on_time;
        ktime_t accounting_time;
        const struct genpd_lock_ops *lock_ops;