Skip to content

Commit cb7bbc7

Browse files
notazlinvjw
authored andcommitted
wl1251: add power callback to wl1251_if_operations
Call interface specific power callback before calling board specific one. Also allow that callback to fail. This is how it's done for wl1271 and will be used for runtime_pm support. Signed-off-by: Grazvydas Ignotas <[email protected]> Acked-by: Kalle Valo <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent f81c1f4 commit cb7bbc7

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

drivers/net/wireless/wl1251/main.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ void wl1251_disable_interrupts(struct wl1251 *wl)
5252
wl->if_ops->disable_irq(wl);
5353
}
5454

55-
static void wl1251_power_off(struct wl1251 *wl)
55+
static int wl1251_power_off(struct wl1251 *wl)
5656
{
57-
wl->set_power(false);
57+
return wl->if_ops->power(wl, false);
5858
}
5959

60-
static void wl1251_power_on(struct wl1251 *wl)
60+
static int wl1251_power_on(struct wl1251 *wl)
6161
{
62-
wl->set_power(true);
62+
return wl->if_ops->power(wl, true);
6363
}
6464

6565
static int wl1251_fetch_firmware(struct wl1251 *wl)
@@ -152,9 +152,12 @@ static void wl1251_fw_wakeup(struct wl1251 *wl)
152152

153153
static int wl1251_chip_wakeup(struct wl1251 *wl)
154154
{
155-
int ret = 0;
155+
int ret;
156+
157+
ret = wl1251_power_on(wl);
158+
if (ret < 0)
159+
return ret;
156160

157-
wl1251_power_on(wl);
158161
msleep(WL1251_POWER_ON_SLEEP);
159162
wl->if_ops->reset(wl);
160163

drivers/net/wireless/wl1251/sdio.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,12 @@ static void wl1251_disable_line_irq(struct wl1251 *wl)
171171
return disable_irq(wl->irq);
172172
}
173173

174-
static void wl1251_sdio_set_power(bool enable)
174+
static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
175175
{
176+
if (wl->set_power)
177+
wl->set_power(enable);
178+
179+
return 0;
176180
}
177181

178182
static struct wl1251_if_operations wl1251_sdio_ops = {
@@ -181,6 +185,7 @@ static struct wl1251_if_operations wl1251_sdio_ops = {
181185
.write_elp = wl1251_sdio_write_elp,
182186
.read_elp = wl1251_sdio_read_elp,
183187
.reset = wl1251_sdio_reset,
188+
.power = wl1251_sdio_set_power,
184189
};
185190

186191
static int wl1251_platform_probe(struct platform_device *pdev)
@@ -239,7 +244,6 @@ static int wl1251_sdio_probe(struct sdio_func *func,
239244
wl_sdio->func = func;
240245
wl->if_priv = wl_sdio;
241246
wl->if_ops = &wl1251_sdio_ops;
242-
wl->set_power = wl1251_sdio_set_power;
243247

244248
if (wl12xx_board_data != NULL) {
245249
wl->set_power = wl12xx_board_data->set_power;

drivers/net/wireless/wl1251/spi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,21 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)
215215
return disable_irq(wl->irq);
216216
}
217217

218+
static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
219+
{
220+
if (wl->set_power)
221+
wl->set_power(enable);
222+
223+
return 0;
224+
}
225+
218226
static const struct wl1251_if_operations wl1251_spi_ops = {
219227
.read = wl1251_spi_read,
220228
.write = wl1251_spi_write,
221229
.reset = wl1251_spi_reset_wake,
222230
.enable_irq = wl1251_spi_enable_irq,
223231
.disable_irq = wl1251_spi_disable_irq,
232+
.power = wl1251_spi_set_power,
224233
};
225234

226235
static int __devinit wl1251_spi_probe(struct spi_device *spi)

drivers/net/wireless/wl1251/wl1251.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ struct wl1251_if_operations {
256256
void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
257257
void (*read_elp)(struct wl1251 *wl, int addr, u32 *val);
258258
void (*write_elp)(struct wl1251 *wl, int addr, u32 val);
259+
int (*power)(struct wl1251 *wl, bool enable);
259260
void (*reset)(struct wl1251 *wl);
260261
void (*enable_irq)(struct wl1251 *wl);
261262
void (*disable_irq)(struct wl1251 *wl);

0 commit comments

Comments
 (0)