diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-04-28 18:36:53 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-04-28 18:36:53 -0400 |
commit | 1d2b71f61b6a10216274e27b717becf9ae101fc7 (patch) | |
tree | 9a2c7c3411cfcf485f17fec985c646ee90390d02 /arch/arm/mach-shmobile | |
parent | 638080c37ae08fd0c44cec13d7948ca5385ae851 (diff) |
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: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch/arm/mach-shmobile')
-rw-r--r-- | arch/arm/mach-shmobile/pm_runtime.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/arch/arm/mach-shmobile/pm_runtime.c b/arch/arm/mach-shmobile/pm_runtime.c index 12bb504c7f49..30bbe9a99ae1 100644 --- a/arch/arm/mach-shmobile/pm_runtime.c +++ b/arch/arm/mach-shmobile/pm_runtime.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/sh_clk.h> | 19 | #include <linux/sh_clk.h> |
20 | #include <linux/bitmap.h> | 20 | #include <linux/bitmap.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #ifdef CONFIG_PM_RUNTIME | 23 | #ifdef CONFIG_PM_RUNTIME |
23 | #define BIT_ONCE 0 | 24 | #define BIT_ONCE 0 |
@@ -29,22 +30,9 @@ struct pm_runtime_data { | |||
29 | struct clk *clk; | 30 | struct clk *clk; |
30 | }; | 31 | }; |
31 | 32 | ||
32 | static void __devres_release(struct device *dev, void *res) | ||
33 | { | ||
34 | struct pm_runtime_data *prd = res; | ||
35 | |||
36 | dev_dbg(dev, "__devres_release()\n"); | ||
37 | |||
38 | if (test_bit(BIT_CLK_ENABLED, &prd->flags)) | ||
39 | clk_disable(prd->clk); | ||
40 | |||
41 | if (test_bit(BIT_ACTIVE, &prd->flags)) | ||
42 | clk_put(prd->clk); | ||
43 | } | ||
44 | |||
45 | static struct pm_runtime_data *__to_prd(struct device *dev) | 33 | static struct pm_runtime_data *__to_prd(struct device *dev) |
46 | { | 34 | { |
47 | return devres_find(dev, __devres_release, NULL, NULL); | 35 | return dev ? dev->power.subsys_data : NULL; |
48 | } | 36 | } |
49 | 37 | ||
50 | static void platform_pm_runtime_init(struct device *dev, | 38 | static void platform_pm_runtime_init(struct device *dev, |
@@ -121,14 +109,26 @@ static int platform_bus_notify(struct notifier_block *nb, | |||
121 | 109 | ||
122 | dev_dbg(dev, "platform_bus_notify() %ld !\n", action); | 110 | dev_dbg(dev, "platform_bus_notify() %ld !\n", action); |
123 | 111 | ||
124 | if (action == BUS_NOTIFY_BIND_DRIVER) { | 112 | switch (action) { |
125 | prd = devres_alloc(__devres_release, sizeof(*prd), GFP_KERNEL); | 113 | case BUS_NOTIFY_BIND_DRIVER: |
114 | prd = kzalloc(sizeof(*prd), GFP_KERNEL); | ||
126 | if (prd) { | 115 | if (prd) { |
127 | devres_add(dev, prd); | 116 | dev->power.subsys_data = prd; |
128 | dev->pwr_domain = &default_power_domain; | 117 | dev->pwr_domain = &default_power_domain; |
129 | } else { | 118 | } else { |
130 | dev_err(dev, "unable to alloc memory for runtime pm\n"); | 119 | dev_err(dev, "unable to alloc memory for runtime pm\n"); |
131 | } | 120 | } |
121 | break; | ||
122 | case BUS_NOTIFY_UNBOUND_DRIVER: | ||
123 | prd = __to_prd(dev); | ||
124 | if (prd) { | ||
125 | if (test_bit(BIT_CLK_ENABLED, &prd->flags)) | ||
126 | clk_disable(prd->clk); | ||
127 | |||
128 | if (test_bit(BIT_ACTIVE, &prd->flags)) | ||
129 | clk_put(prd->clk); | ||
130 | } | ||
131 | break; | ||
132 | } | 132 | } |
133 | 133 | ||
134 | return 0; | 134 | return 0; |