wl1251: add power callback to wl1251_if_operations
authorGrazvydas Ignotas <notasas@gmail.com>
Wed, 3 Nov 2010 22:13:47 +0000 (00:13 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Nov 2010 18:27:00 +0000 (13:27 -0500)
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 <notasas@gmail.com>
Acked-by: Kalle Valo <kvalo@adurom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/wl1251/main.c
drivers/net/wireless/wl1251/sdio.c
drivers/net/wireless/wl1251/spi.c
drivers/net/wireless/wl1251/wl1251.h

index 7a8762553cdcb54470d5b430fa7019fabf6b471c..012e1a4016fed0a195a2790f5b23c8ab9b884062 100644 (file)
@@ -52,14 +52,14 @@ void wl1251_disable_interrupts(struct wl1251 *wl)
        wl->if_ops->disable_irq(wl);
 }
 
-static void wl1251_power_off(struct wl1251 *wl)
+static int wl1251_power_off(struct wl1251 *wl)
 {
-       wl->set_power(false);
+       return wl->if_ops->power(wl, false);
 }
 
-static void wl1251_power_on(struct wl1251 *wl)
+static int wl1251_power_on(struct wl1251 *wl)
 {
-       wl->set_power(true);
+       return wl->if_ops->power(wl, true);
 }
 
 static int wl1251_fetch_firmware(struct wl1251 *wl)
@@ -152,9 +152,12 @@ static void wl1251_fw_wakeup(struct wl1251 *wl)
 
 static int wl1251_chip_wakeup(struct wl1251 *wl)
 {
-       int ret = 0;
+       int ret;
+
+       ret = wl1251_power_on(wl);
+       if (ret < 0)
+               return ret;
 
-       wl1251_power_on(wl);
        msleep(WL1251_POWER_ON_SLEEP);
        wl->if_ops->reset(wl);
 
index 74ba9ced5393fd35901643a53a5607ec68bf4747..02851901677e354202af8144b9bc2af7f378d00e 100644 (file)
@@ -171,8 +171,12 @@ static void wl1251_disable_line_irq(struct wl1251 *wl)
        return disable_irq(wl->irq);
 }
 
-static void wl1251_sdio_set_power(bool enable)
+static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
 {
+       if (wl->set_power)
+               wl->set_power(enable);
+
+       return 0;
 }
 
 static struct wl1251_if_operations wl1251_sdio_ops = {
@@ -181,6 +185,7 @@ static struct wl1251_if_operations wl1251_sdio_ops = {
        .write_elp = wl1251_sdio_write_elp,
        .read_elp = wl1251_sdio_read_elp,
        .reset = wl1251_sdio_reset,
+       .power = wl1251_sdio_set_power,
 };
 
 static int wl1251_platform_probe(struct platform_device *pdev)
@@ -239,7 +244,6 @@ static int wl1251_sdio_probe(struct sdio_func *func,
        wl_sdio->func = func;
        wl->if_priv = wl_sdio;
        wl->if_ops = &wl1251_sdio_ops;
-       wl->set_power = wl1251_sdio_set_power;
 
        if (wl12xx_board_data != NULL) {
                wl->set_power = wl12xx_board_data->set_power;
index 88fa8e69d0d1d30b06c76a64cdc8d00f5592754a..ac872b38960f7a1d47089ba9f754b5c37aa7e2f5 100644 (file)
@@ -215,12 +215,21 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)
        return disable_irq(wl->irq);
 }
 
+static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
+{
+       if (wl->set_power)
+               wl->set_power(enable);
+
+       return 0;
+}
+
 static const struct wl1251_if_operations wl1251_spi_ops = {
        .read = wl1251_spi_read,
        .write = wl1251_spi_write,
        .reset = wl1251_spi_reset_wake,
        .enable_irq = wl1251_spi_enable_irq,
        .disable_irq = wl1251_spi_disable_irq,
+       .power = wl1251_spi_set_power,
 };
 
 static int __devinit wl1251_spi_probe(struct spi_device *spi)
index e113d4c1fb357924d20a342d4ec214b6fde33c85..13fbeeccf6091db47621abbefddea3e74718c356 100644 (file)
@@ -256,6 +256,7 @@ struct wl1251_if_operations {
        void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
        void (*read_elp)(struct wl1251 *wl, int addr, u32 *val);
        void (*write_elp)(struct wl1251 *wl, int addr, u32 val);
+       int  (*power)(struct wl1251 *wl, bool enable);
        void (*reset)(struct wl1251 *wl);
        void (*enable_irq)(struct wl1251 *wl);
        void (*disable_irq)(struct wl1251 *wl);