Commit 1d2b71f6 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PM / Runtime: Add subsystem data field to struct dev_pm_info

Some subsystems need to attach PM-related data to struct device and
they need to use devres for this purpose.  For their convenience
and to make code more straightforward, add a new field called
subsys_data to struct dev_pm_info and let subsystems use it for
attaching PM-related information to devices.

Convert the ARM shmobile platform to using the new field.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 638080c3
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/sh_clk.h> #include <linux/sh_clk.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/slab.h>
#ifdef CONFIG_PM_RUNTIME #ifdef CONFIG_PM_RUNTIME
#define BIT_ONCE 0 #define BIT_ONCE 0
...@@ -29,22 +30,9 @@ struct pm_runtime_data { ...@@ -29,22 +30,9 @@ struct pm_runtime_data {
struct clk *clk; struct clk *clk;
}; };
static void __devres_release(struct device *dev, void *res)
{
struct pm_runtime_data *prd = res;
dev_dbg(dev, "__devres_release()\n");
if (test_bit(BIT_CLK_ENABLED, &prd->flags))
clk_disable(prd->clk);
if (test_bit(BIT_ACTIVE, &prd->flags))
clk_put(prd->clk);
}
static struct pm_runtime_data *__to_prd(struct device *dev) static struct pm_runtime_data *__to_prd(struct device *dev)
{ {
return devres_find(dev, __devres_release, NULL, NULL); return dev ? dev->power.subsys_data : NULL;
} }
static void platform_pm_runtime_init(struct device *dev, static void platform_pm_runtime_init(struct device *dev,
...@@ -121,14 +109,26 @@ static int platform_bus_notify(struct notifier_block *nb, ...@@ -121,14 +109,26 @@ static int platform_bus_notify(struct notifier_block *nb,
dev_dbg(dev, "platform_bus_notify() %ld !\n", action); dev_dbg(dev, "platform_bus_notify() %ld !\n", action);
if (action == BUS_NOTIFY_BIND_DRIVER) { switch (action) {
prd = devres_alloc(__devres_release, sizeof(*prd), GFP_KERNEL); case BUS_NOTIFY_BIND_DRIVER:
prd = kzalloc(sizeof(*prd), GFP_KERNEL);
if (prd) { if (prd) {
devres_add(dev, prd); dev->power.subsys_data = prd;
dev->pwr_domain = &default_power_domain; dev->pwr_domain = &default_power_domain;
} else { } else {
dev_err(dev, "unable to alloc memory for runtime pm\n"); dev_err(dev, "unable to alloc memory for runtime pm\n");
} }
break;
case BUS_NOTIFY_UNBOUND_DRIVER:
prd = __to_prd(dev);
if (prd) {
if (test_bit(BIT_CLK_ENABLED, &prd->flags))
clk_disable(prd->clk);
if (test_bit(BIT_ACTIVE, &prd->flags))
clk_put(prd->clk);
}
break;
} }
return 0; return 0;
......
...@@ -460,6 +460,7 @@ struct dev_pm_info { ...@@ -460,6 +460,7 @@ struct dev_pm_info {
unsigned long active_jiffies; unsigned long active_jiffies;
unsigned long suspended_jiffies; unsigned long suspended_jiffies;
unsigned long accounting_timestamp; unsigned long accounting_timestamp;
void *subsys_data; /* Owned by the subsystem. */
#endif #endif
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment