diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2010-10-08 09:16:16 -0400 |
---|---|---|
committer | Luciano Coelho <luciano.coelho@nokia.com> | 2010-10-08 09:16:16 -0400 |
commit | 00cbb3c5317d418c349c60876fe12fba7624f3e7 (patch) | |
tree | b25530e4570eae3cc585039bd08a0dc08d8d087d /drivers/net/wireless/wl12xx | |
parent | 15a6321d1c0f8db561932cd99e1b9897981da71f (diff) |
wl1271: sdio: enable runtime PM
Enable runtime PM for the wl1271 SDIO device.
We request power whenever the WLAN interface is brought up,
and release it after the WLAN interface is taken down.
As a result, power is released immediately after probe returns,
since at that point power has not been explicitly requested yet
(i.e. the WLAN interface is still down).
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Luciano Coelho <luciano.coelho@nokia.com>
Tested-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_sdio.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_sdio.c b/drivers/net/wireless/wl12xx/wl1271_sdio.c index 4c250d7dc3f..f7bef32f04c 100644 --- a/drivers/net/wireless/wl12xx/wl1271_sdio.c +++ b/drivers/net/wireless/wl12xx/wl1271_sdio.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/mmc/card.h> | 30 | #include <linux/mmc/card.h> |
31 | #include <linux/gpio.h> | 31 | #include <linux/gpio.h> |
32 | #include <linux/wl12xx.h> | 32 | #include <linux/wl12xx.h> |
33 | #include <linux/pm_runtime.h> | ||
33 | 34 | ||
34 | #include "wl1271.h" | 35 | #include "wl1271.h" |
35 | #include "wl12xx_80211.h" | 36 | #include "wl12xx_80211.h" |
@@ -160,12 +161,19 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, | |||
160 | static int wl1271_sdio_power_on(struct wl1271 *wl) | 161 | static int wl1271_sdio_power_on(struct wl1271 *wl) |
161 | { | 162 | { |
162 | struct sdio_func *func = wl_to_func(wl); | 163 | struct sdio_func *func = wl_to_func(wl); |
164 | int ret; | ||
165 | |||
166 | /* Power up the card */ | ||
167 | ret = pm_runtime_get_sync(&func->dev); | ||
168 | if (ret < 0) | ||
169 | goto out; | ||
163 | 170 | ||
164 | sdio_claim_host(func); | 171 | sdio_claim_host(func); |
165 | sdio_enable_func(func); | 172 | sdio_enable_func(func); |
166 | sdio_release_host(func); | 173 | sdio_release_host(func); |
167 | 174 | ||
168 | return 0; | 175 | out: |
176 | return ret; | ||
169 | } | 177 | } |
170 | 178 | ||
171 | static int wl1271_sdio_power_off(struct wl1271 *wl) | 179 | static int wl1271_sdio_power_off(struct wl1271 *wl) |
@@ -176,15 +184,12 @@ static int wl1271_sdio_power_off(struct wl1271 *wl) | |||
176 | sdio_disable_func(func); | 184 | sdio_disable_func(func); |
177 | sdio_release_host(func); | 185 | sdio_release_host(func); |
178 | 186 | ||
179 | return 0; | 187 | /* Power down the card */ |
188 | return pm_runtime_put_sync(&func->dev); | ||
180 | } | 189 | } |
181 | 190 | ||
182 | static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) | 191 | static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) |
183 | { | 192 | { |
184 | /* Let the SDIO stack handle wlan_enable control, so we | ||
185 | * keep host claimed while wlan is in use to keep wl1271 | ||
186 | * alive. | ||
187 | */ | ||
188 | if (enable) | 193 | if (enable) |
189 | return wl1271_sdio_power_on(wl); | 194 | return wl1271_sdio_power_on(wl); |
190 | else | 195 | else |
@@ -256,6 +261,9 @@ static int __devinit wl1271_probe(struct sdio_func *func, | |||
256 | 261 | ||
257 | sdio_set_drvdata(func, wl); | 262 | sdio_set_drvdata(func, wl); |
258 | 263 | ||
264 | /* Tell PM core that we don't need the card to be powered now */ | ||
265 | pm_runtime_put_noidle(&func->dev); | ||
266 | |||
259 | wl1271_notice("initialized"); | 267 | wl1271_notice("initialized"); |
260 | 268 | ||
261 | return 0; | 269 | return 0; |
@@ -274,6 +282,9 @@ static void __devexit wl1271_remove(struct sdio_func *func) | |||
274 | { | 282 | { |
275 | struct wl1271 *wl = sdio_get_drvdata(func); | 283 | struct wl1271 *wl = sdio_get_drvdata(func); |
276 | 284 | ||
285 | /* Undo decrement done above in wl1271_probe */ | ||
286 | pm_runtime_get_noresume(&func->dev); | ||
287 | |||
277 | wl1271_unregister_hw(wl); | 288 | wl1271_unregister_hw(wl); |
278 | free_irq(wl->irq, wl); | 289 | free_irq(wl->irq, wl); |
279 | wl1271_free_hw(wl); | 290 | wl1271_free_hw(wl); |