]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
wl1271: Implemented abstraction of IO functions.
authorTeemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Mon, 22 Feb 2010 06:38:23 +0000 (08:38 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 9 Mar 2010 20:02:57 +0000 (15:02 -0500)
Changed the driver to use if_ops structure to abstract access to the IO
layer (SPI or SDIO).

Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/wl12xx/wl1271.h
drivers/net/wireless/wl12xx/wl1271_io.c
drivers/net/wireless/wl12xx/wl1271_io.h
drivers/net/wireless/wl12xx/wl1271_main.c
drivers/net/wireless/wl12xx/wl1271_spi.c

index 97ea5096bc8c96dfa974d2754e247051357edd00..10135c94e20e4241aed3519766467e3e23afd0a0 100644 (file)
@@ -334,11 +334,25 @@ struct wl1271_scan {
        u8 probe_requests;
 };
 
+struct wl1271_if_operations {
+       void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
+                    bool fixed);
+       void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
+                    bool fixed);
+       void (*reset)(struct wl1271 *wl);
+       void (*init)(struct wl1271 *wl);
+       struct device* (*dev)(struct wl1271 *wl);
+       void (*enable_irq)(struct wl1271 *wl);
+       void (*disable_irq)(struct wl1271 *wl);
+};
+
 struct wl1271 {
        struct ieee80211_hw *hw;
        bool mac80211_registered;
 
-       struct spi_device *spi;
+       void *if_priv;
+
+       struct wl1271_if_operations *if_ops;
 
        void (*set_power)(bool enable);
        int irq;
index b825cfa30ecfa2454a95c75a4495bfdb8b889b56..d00f7ed7f21c0d8096732b4b1b287c5d1c62d082 100644 (file)
 #include "wl1271_spi.h"
 #include "wl1271_io.h"
 
+struct device *wl1271_wl_to_dev(struct wl1271 *wl)
+{
+       return wl->if_ops->dev(wl);
+}
+
 void wl1271_disable_interrupts(struct wl1271 *wl)
 {
-       wl1271_spi_disable_interrupts(wl);
+       wl->if_ops->disable_irq(wl);
 }
 
 void wl1271_enable_interrupts(struct wl1271 *wl)
 {
-       wl1271_spi_enable_interrupts(wl);
+       wl->if_ops->enable_irq(wl);
 }
 
 static int wl1271_translate_addr(struct wl1271 *wl, int addr)
@@ -127,24 +132,24 @@ int wl1271_set_partition(struct wl1271 *wl,
 
 void wl1271_io_reset(struct wl1271 *wl)
 {
-       wl1271_spi_reset(wl);
+       wl->if_ops->reset(wl);
 }
 
 void wl1271_io_init(struct wl1271 *wl)
 {
-       wl1271_spi_init(wl);
+       wl->if_ops->init(wl);
 }
 
 void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
                      size_t len, bool fixed)
 {
-       wl1271_spi_raw_write(wl, addr, buf, len, fixed);
+       wl->if_ops->write(wl, addr, buf, len, fixed);
 }
 
 void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
                     size_t len, bool fixed)
 {
-       wl1271_spi_raw_read(wl, addr, buf, len, fixed);
+       wl->if_ops->read(wl, addr, buf, len, fixed);
 }
 
 void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len,
@@ -154,7 +159,7 @@ void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len,
 
        physical = wl1271_translate_addr(wl, addr);
 
-       wl1271_spi_raw_read(wl, physical, buf, len, fixed);
+       wl1271_raw_read(wl, physical, buf, len, fixed);
 }
 
 void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len,
@@ -164,7 +169,7 @@ void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len,
 
        physical = wl1271_translate_addr(wl, addr);
 
-       wl1271_spi_raw_write(wl, physical, buf, len, fixed);
+       wl1271_raw_write(wl, physical, buf, len, fixed);
 }
 
 u32 wl1271_read32(struct wl1271 *wl, int addr)
index c8b09718e18529fc6ad4ac57b3c5c618bb92b806..f2b6325ba2a7c3474de39a47da185300605a80ae 100644 (file)
@@ -33,6 +33,8 @@ void wl1271_enable_interrupts(struct wl1271 *wl);
 void wl1271_io_reset(struct wl1271 *wl);
 void wl1271_io_init(struct wl1271 *wl);
 
+struct device *wl1271_wl_to_dev(struct wl1271 *wl);
+
 /* Raw target IO, address is not translated */
 void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
                      size_t len, bool fixed);
index 18347c3a5e19d1b8724dcd2c36231b537e5fdf84..6b3fd0005ce030bcbeafa4d1179da191651a21eb 100644 (file)
@@ -480,7 +480,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl)
        const struct firmware *fw;
        int ret;
 
-       ret = request_firmware(&fw, WL1271_FW_NAME, &wl->spi->dev);
+       ret = request_firmware(&fw, WL1271_FW_NAME, wl1271_wl_to_dev(wl));
 
        if (ret < 0) {
                wl1271_error("could not get firmware: %d", ret);
@@ -552,7 +552,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
        const struct firmware *fw;
        int ret;
 
-       ret = request_firmware(&fw, WL1271_NVS_NAME, &wl->spi->dev);
+       ret = request_firmware(&fw, WL1271_NVS_NAME, wl1271_wl_to_dev(wl));
 
        if (ret < 0) {
                wl1271_error("could not get nvs file: %d", ret);
@@ -1973,7 +1973,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl)
        if (wl1271_11a_enabled())
                wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wl1271_band_5ghz;
 
-       SET_IEEE80211_DEV(wl->hw, &wl->spi->dev);
+       SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl));
 
        return 0;
 }
index b422c9fdcd22691a72058b2bfcdc65114ab5626d..a0f416972be2bbc128842e20165ec9c2cbd6d413 100644 (file)
 #include "wl1271_spi.h"
 #include "wl1271_io.h"
 
+static struct spi_device *wl_to_spi(struct wl1271 *wl)
+{
+       return wl->if_priv;
+}
+
+static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
+{
+       return &(wl_to_spi(wl)->dev);
+}
 
 void wl1271_spi_disable_interrupts(struct wl1271 *wl)
 {
@@ -65,7 +74,7 @@ void wl1271_spi_reset(struct wl1271 *wl)
        t.len = WSPI_INIT_CMD_LEN;
        spi_message_add_tail(&t, &m);
 
-       spi_sync(wl->spi, &m);
+       spi_sync(wl_to_spi(wl), &m);
 
        wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
 }
@@ -119,7 +128,7 @@ void wl1271_spi_init(struct wl1271 *wl)
        t.len = WSPI_INIT_CMD_LEN;
        spi_message_add_tail(&t, &m);
 
-       spi_sync(wl->spi, &m);
+       spi_sync(wl_to_spi(wl), &m);
 
        wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
 }
@@ -151,7 +160,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
                        t[0].rx_buf = buf + (len - num_busy_bytes);
                        t[0].len = num_busy_bytes;
                        spi_message_add_tail(&t[0], &m);
-                       spi_sync(wl->spi, &m);
+                       spi_sync(wl_to_spi(wl), &m);
                        return;
                }
        }
@@ -171,7 +180,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
                t[0].rx_buf = busy_buf;
                t[0].len = sizeof(u32);
                spi_message_add_tail(&t[0], &m);
-               spi_sync(wl->spi, &m);
+               spi_sync(wl_to_spi(wl), &m);
 
                if (*busy_buf & 0x1) {
                        spi_message_init(&m);
@@ -179,7 +188,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
                        t[0].rx_buf = buf;
                        t[0].len = len;
                        spi_message_add_tail(&t[0], &m);
-                       spi_sync(wl->spi, &m);
+                       spi_sync(wl_to_spi(wl), &m);
                        return;
                }
        }
@@ -225,7 +234,7 @@ void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
        t[2].len = len;
        spi_message_add_tail(&t[2], &m);
 
-       spi_sync(wl->spi, &m);
+       spi_sync(wl_to_spi(wl), &m);
 
        /* FIXME: Check busy words, removed due to SPI bug */
        /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1))
@@ -263,7 +272,7 @@ void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
        t[1].len = len;
        spi_message_add_tail(&t[1], &m);
 
-       spi_sync(wl->spi, &m);
+       spi_sync(wl_to_spi(wl), &m);
 
        wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
        wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
@@ -306,6 +315,16 @@ static struct platform_device wl1271_device = {
        },
 };
 
+static struct wl1271_if_operations spi_ops = {
+       .read           = wl1271_spi_raw_read,
+       .write          = wl1271_spi_raw_write,
+       .reset          = wl1271_spi_reset,
+       .init           = wl1271_spi_init,
+       .dev            = wl1271_spi_wl_to_dev,
+       .enable_irq     = wl1271_spi_enable_interrupts,
+       .disable_irq    = wl1271_spi_disable_interrupts
+};
+
 static int __devinit wl1271_probe(struct spi_device *spi)
 {
        struct wl12xx_platform_data *pdata;
@@ -326,7 +345,9 @@ static int __devinit wl1271_probe(struct spi_device *spi)
        wl = hw->priv;
 
        dev_set_drvdata(&spi->dev, wl);
-       wl->spi = spi;
+       wl->if_priv = spi;
+
+       wl->if_ops = &spi_ops;
 
        /* This is the only SPI value that we need to set here, the rest
         * comes from the board-peripherals file */