aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTeemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>2010-02-18 06:25:57 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-02-19 15:52:48 -0500
commitc332a4b8eed69a6853dbdbdf16696a45b93e2bf8 (patch)
treec81228d210c20ed2d8252aa2d727d15a99384422 /drivers
parent9b28072220d56fda3249cb7e4e164038b456414d (diff)
wl1271: Added alloc and free hw functions
Moved allocation and freeing of context structure of the driver to separate functions from probe and remove functions. 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c80
1 files changed, 53 insertions, 27 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 66fb9a0a8efa..2a864b24291d 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -2025,23 +2025,17 @@ static struct platform_device wl1271_device = {
2025}; 2025};
2026 2026
2027#define WL1271_DEFAULT_CHANNEL 0 2027#define WL1271_DEFAULT_CHANNEL 0
2028static int __devinit wl1271_probe(struct spi_device *spi) 2028
2029static struct ieee80211_hw *wl1271_alloc_hw(void)
2029{ 2030{
2030 struct wl12xx_platform_data *pdata;
2031 struct ieee80211_hw *hw; 2031 struct ieee80211_hw *hw;
2032 struct wl1271 *wl; 2032 struct wl1271 *wl;
2033 int ret, i; 2033 int i;
2034
2035 pdata = spi->dev.platform_data;
2036 if (!pdata) {
2037 wl1271_error("no platform data");
2038 return -ENODEV;
2039 }
2040 2034
2041 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); 2035 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
2042 if (!hw) { 2036 if (!hw) {
2043 wl1271_error("could not alloc ieee80211_hw"); 2037 wl1271_error("could not alloc ieee80211_hw");
2044 return -ENOMEM; 2038 return ERR_PTR(-ENOMEM);
2045 } 2039 }
2046 2040
2047 wl = hw->priv; 2041 wl = hw->priv;
@@ -2050,8 +2044,6 @@ static int __devinit wl1271_probe(struct spi_device *spi)
2050 INIT_LIST_HEAD(&wl->list); 2044 INIT_LIST_HEAD(&wl->list);
2051 2045
2052 wl->hw = hw; 2046 wl->hw = hw;
2053 dev_set_drvdata(&spi->dev, wl);
2054 wl->spi = spi;
2055 2047
2056 skb_queue_head_init(&wl->tx_queue); 2048 skb_queue_head_init(&wl->tx_queue);
2057 2049
@@ -2078,6 +2070,54 @@ static int __devinit wl1271_probe(struct spi_device *spi)
2078 wl->state = WL1271_STATE_OFF; 2070 wl->state = WL1271_STATE_OFF;
2079 mutex_init(&wl->mutex); 2071 mutex_init(&wl->mutex);
2080 2072
2073 /* Apply default driver configuration. */
2074 wl1271_conf_init(wl);
2075
2076 return hw;
2077}
2078
2079int wl1271_free_hw(struct wl1271 *wl)
2080{
2081 ieee80211_unregister_hw(wl->hw);
2082
2083 wl1271_debugfs_exit(wl);
2084
2085 kfree(wl->target_mem_map);
2086 vfree(wl->fw);
2087 wl->fw = NULL;
2088 kfree(wl->nvs);
2089 wl->nvs = NULL;
2090
2091 kfree(wl->fw_status);
2092 kfree(wl->tx_res_if);
2093
2094 ieee80211_free_hw(wl->hw);
2095
2096 return 0;
2097}
2098
2099static int __devinit wl1271_probe(struct spi_device *spi)
2100{
2101 struct wl12xx_platform_data *pdata;
2102 struct ieee80211_hw *hw;
2103 struct wl1271 *wl;
2104 int ret;
2105
2106 pdata = spi->dev.platform_data;
2107 if (!pdata) {
2108 wl1271_error("no platform data");
2109 return -ENODEV;
2110 }
2111
2112 hw = wl1271_alloc_hw();
2113 if (IS_ERR(hw))
2114 return PTR_ERR(hw);
2115
2116 wl = hw->priv;
2117
2118 dev_set_drvdata(&spi->dev, wl);
2119 wl->spi = spi;
2120
2081 /* This is the only SPI value that we need to set here, the rest 2121 /* This is the only SPI value that we need to set here, the rest
2082 * comes from the board-peripherals file */ 2122 * comes from the board-peripherals file */
2083 spi->bits_per_word = 32; 2123 spi->bits_per_word = 32;
@@ -2119,9 +2159,6 @@ static int __devinit wl1271_probe(struct spi_device *spi)
2119 } 2159 }
2120 dev_set_drvdata(&wl1271_device.dev, wl); 2160 dev_set_drvdata(&wl1271_device.dev, wl);
2121 2161
2122 /* Apply default driver configuration. */
2123 wl1271_conf_init(wl);
2124
2125 ret = wl1271_init_ieee80211(wl); 2162 ret = wl1271_init_ieee80211(wl);
2126 if (ret) 2163 if (ret)
2127 goto out_platform; 2164 goto out_platform;
@@ -2152,21 +2189,10 @@ static int __devexit wl1271_remove(struct spi_device *spi)
2152{ 2189{
2153 struct wl1271 *wl = dev_get_drvdata(&spi->dev); 2190 struct wl1271 *wl = dev_get_drvdata(&spi->dev);
2154 2191
2155 ieee80211_unregister_hw(wl->hw);
2156
2157 wl1271_debugfs_exit(wl);
2158 platform_device_unregister(&wl1271_device); 2192 platform_device_unregister(&wl1271_device);
2159 free_irq(wl->irq, wl); 2193 free_irq(wl->irq, wl);
2160 kfree(wl->target_mem_map);
2161 vfree(wl->fw);
2162 wl->fw = NULL;
2163 kfree(wl->nvs);
2164 wl->nvs = NULL;
2165 2194
2166 kfree(wl->fw_status); 2195 wl1271_free_hw(wl);
2167 kfree(wl->tx_res_if);
2168
2169 ieee80211_free_hw(wl->hw);
2170 2196
2171 return 0; 2197 return 0;
2172} 2198}