diff options
author | Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com> | 2010-03-18 06:26:46 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-03-23 16:50:25 -0400 |
commit | 3b56dd6a090e905eece023f690298013da4b6b67 (patch) | |
tree | 3cbb85dca62aa68ef14b134d813b77ec8919c4e4 | |
parent | 2ea9fb3d79aac371e5bb0c4b0f5be7195e8fcd33 (diff) |
wl1271: Changed platform_device to be dynamically allocated
Changed platform_device to be allocated dynamically from the
wl1271_alloc_hw function. Also cleaned up error handling in the
wl1271_alloc_hw function and module probe 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: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_io.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_main.c | 42 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_sdio.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_spi.c | 3 |
5 files changed, 39 insertions, 11 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h index a0262b7723c3..8f11506f8310 100644 --- a/drivers/net/wireless/wl12xx/wl1271.h +++ b/drivers/net/wireless/wl12xx/wl1271.h | |||
@@ -353,6 +353,7 @@ struct wl1271_if_operations { | |||
353 | }; | 353 | }; |
354 | 354 | ||
355 | struct wl1271 { | 355 | struct wl1271 { |
356 | struct platform_device *plat_dev; | ||
356 | struct ieee80211_hw *hw; | 357 | struct ieee80211_hw *hw; |
357 | bool mac80211_registered; | 358 | bool mac80211_registered; |
358 | 359 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.h b/drivers/net/wireless/wl12xx/wl1271_io.h index 3ff88d971308..d8837ef0bb40 100644 --- a/drivers/net/wireless/wl12xx/wl1271_io.h +++ b/drivers/net/wireless/wl12xx/wl1271_io.h | |||
@@ -161,6 +161,7 @@ int wl1271_set_partition(struct wl1271 *wl, | |||
161 | /* Functions from wl1271_main.c */ | 161 | /* Functions from wl1271_main.c */ |
162 | 162 | ||
163 | int wl1271_register_hw(struct wl1271 *wl); | 163 | int wl1271_register_hw(struct wl1271 *wl); |
164 | void wl1271_unregister_hw(struct wl1271 *wl); | ||
164 | int wl1271_init_ieee80211(struct wl1271 *wl); | 165 | int wl1271_init_ieee80211(struct wl1271 *wl); |
165 | struct ieee80211_hw *wl1271_alloc_hw(void); | 166 | struct ieee80211_hw *wl1271_alloc_hw(void); |
166 | int wl1271_free_hw(struct wl1271 *wl); | 167 | int wl1271_free_hw(struct wl1271 *wl); |
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c index 0bebc456ec0d..3daba6c0c77f 100644 --- a/drivers/net/wireless/wl12xx/wl1271_main.c +++ b/drivers/net/wireless/wl12xx/wl1271_main.c | |||
@@ -2008,6 +2008,14 @@ int wl1271_register_hw(struct wl1271 *wl) | |||
2008 | } | 2008 | } |
2009 | EXPORT_SYMBOL_GPL(wl1271_register_hw); | 2009 | EXPORT_SYMBOL_GPL(wl1271_register_hw); |
2010 | 2010 | ||
2011 | void wl1271_unregister_hw(struct wl1271 *wl) | ||
2012 | { | ||
2013 | ieee80211_unregister_hw(wl->hw); | ||
2014 | wl->mac80211_registered = false; | ||
2015 | |||
2016 | } | ||
2017 | EXPORT_SYMBOL_GPL(wl1271_unregister_hw); | ||
2018 | |||
2011 | int wl1271_init_ieee80211(struct wl1271 *wl) | 2019 | int wl1271_init_ieee80211(struct wl1271 *wl) |
2012 | { | 2020 | { |
2013 | /* The tx descriptor buffer and the TKIP space. */ | 2021 | /* The tx descriptor buffer and the TKIP space. */ |
@@ -2046,6 +2054,7 @@ EXPORT_SYMBOL_GPL(wl1271_init_ieee80211); | |||
2046 | struct ieee80211_hw *wl1271_alloc_hw(void) | 2054 | struct ieee80211_hw *wl1271_alloc_hw(void) |
2047 | { | 2055 | { |
2048 | struct ieee80211_hw *hw; | 2056 | struct ieee80211_hw *hw; |
2057 | struct platform_device *plat_dev = NULL; | ||
2049 | struct wl1271 *wl; | 2058 | struct wl1271 *wl; |
2050 | int i, ret; | 2059 | int i, ret; |
2051 | static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; | 2060 | static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; |
@@ -2054,15 +2063,25 @@ struct ieee80211_hw *wl1271_alloc_hw(void) | |||
2054 | if (!hw) { | 2063 | if (!hw) { |
2055 | wl1271_error("could not alloc ieee80211_hw"); | 2064 | wl1271_error("could not alloc ieee80211_hw"); |
2056 | ret = -ENOMEM; | 2065 | ret = -ENOMEM; |
2057 | goto err; | 2066 | goto err_hw_alloc; |
2067 | } | ||
2068 | |||
2069 | plat_dev = kmalloc(sizeof(wl1271_device), GFP_KERNEL); | ||
2070 | if (!plat_dev) { | ||
2071 | wl1271_error("could not allocate platform_device"); | ||
2072 | ret = -ENOMEM; | ||
2073 | goto err_plat_alloc; | ||
2058 | } | 2074 | } |
2059 | 2075 | ||
2076 | memcpy(plat_dev, &wl1271_device, sizeof(wl1271_device)); | ||
2077 | |||
2060 | wl = hw->priv; | 2078 | wl = hw->priv; |
2061 | memset(wl, 0, sizeof(*wl)); | 2079 | memset(wl, 0, sizeof(*wl)); |
2062 | 2080 | ||
2063 | INIT_LIST_HEAD(&wl->list); | 2081 | INIT_LIST_HEAD(&wl->list); |
2064 | 2082 | ||
2065 | wl->hw = hw; | 2083 | wl->hw = hw; |
2084 | wl->plat_dev = plat_dev; | ||
2066 | 2085 | ||
2067 | skb_queue_head_init(&wl->tx_queue); | 2086 | skb_queue_head_init(&wl->tx_queue); |
2068 | 2087 | ||
@@ -2103,15 +2122,15 @@ struct ieee80211_hw *wl1271_alloc_hw(void) | |||
2103 | wl1271_debugfs_init(wl); | 2122 | wl1271_debugfs_init(wl); |
2104 | 2123 | ||
2105 | /* Register platform device */ | 2124 | /* Register platform device */ |
2106 | ret = platform_device_register(&wl1271_device); | 2125 | ret = platform_device_register(wl->plat_dev); |
2107 | if (ret) { | 2126 | if (ret) { |
2108 | wl1271_error("couldn't register platform device"); | 2127 | wl1271_error("couldn't register platform device"); |
2109 | goto err_hw; | 2128 | goto err_hw; |
2110 | } | 2129 | } |
2111 | dev_set_drvdata(&wl1271_device.dev, wl); | 2130 | dev_set_drvdata(&wl->plat_dev->dev, wl); |
2112 | 2131 | ||
2113 | /* Create sysfs file to control bt coex state */ | 2132 | /* Create sysfs file to control bt coex state */ |
2114 | ret = device_create_file(&wl1271_device.dev, &dev_attr_bt_coex_state); | 2133 | ret = device_create_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); |
2115 | if (ret < 0) { | 2134 | if (ret < 0) { |
2116 | wl1271_error("failed to create sysfs file bt_coex_state"); | 2135 | wl1271_error("failed to create sysfs file bt_coex_state"); |
2117 | goto err_platform; | 2136 | goto err_platform; |
@@ -2120,20 +2139,25 @@ struct ieee80211_hw *wl1271_alloc_hw(void) | |||
2120 | return hw; | 2139 | return hw; |
2121 | 2140 | ||
2122 | err_platform: | 2141 | err_platform: |
2123 | platform_device_unregister(&wl1271_device); | 2142 | platform_device_unregister(wl->plat_dev); |
2124 | 2143 | ||
2125 | err_hw: | 2144 | err_hw: |
2126 | ieee80211_unregister_hw(wl->hw); | 2145 | wl1271_debugfs_exit(wl); |
2146 | kfree(plat_dev); | ||
2147 | |||
2148 | err_plat_alloc: | ||
2149 | ieee80211_free_hw(hw); | ||
2150 | |||
2151 | err_hw_alloc: | ||
2127 | 2152 | ||
2128 | err: | ||
2129 | return ERR_PTR(ret); | 2153 | return ERR_PTR(ret); |
2130 | } | 2154 | } |
2131 | EXPORT_SYMBOL_GPL(wl1271_alloc_hw); | 2155 | EXPORT_SYMBOL_GPL(wl1271_alloc_hw); |
2132 | 2156 | ||
2133 | int wl1271_free_hw(struct wl1271 *wl) | 2157 | int wl1271_free_hw(struct wl1271 *wl) |
2134 | { | 2158 | { |
2135 | platform_device_unregister(&wl1271_device); | 2159 | platform_device_unregister(wl->plat_dev); |
2136 | ieee80211_unregister_hw(wl->hw); | 2160 | kfree(wl->plat_dev); |
2137 | 2161 | ||
2138 | wl1271_debugfs_exit(wl); | 2162 | wl1271_debugfs_exit(wl); |
2139 | 2163 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_sdio.c b/drivers/net/wireless/wl12xx/wl1271_sdio.c index 99b5b3f7a92c..3c03de74dbfc 100644 --- a/drivers/net/wireless/wl12xx/wl1271_sdio.c +++ b/drivers/net/wireless/wl12xx/wl1271_sdio.c | |||
@@ -239,7 +239,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, | |||
239 | 239 | ||
240 | 240 | ||
241 | out_free: | 241 | out_free: |
242 | ieee80211_free_hw(hw); | 242 | wl1271_free_hw(wl); |
243 | 243 | ||
244 | return ret; | 244 | return ret; |
245 | } | 245 | } |
@@ -250,6 +250,7 @@ static void __devexit wl1271_remove(struct sdio_func *func) | |||
250 | 250 | ||
251 | free_irq(wl->irq, wl); | 251 | free_irq(wl->irq, wl); |
252 | 252 | ||
253 | wl1271_unregister_hw(wl); | ||
253 | wl1271_free_hw(wl); | 254 | wl1271_free_hw(wl); |
254 | } | 255 | } |
255 | 256 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c index 4c129c76c29d..f44b05a32b0d 100644 --- a/drivers/net/wireless/wl12xx/wl1271_spi.c +++ b/drivers/net/wireless/wl12xx/wl1271_spi.c | |||
@@ -422,7 +422,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) | |||
422 | free_irq(wl->irq, wl); | 422 | free_irq(wl->irq, wl); |
423 | 423 | ||
424 | out_free: | 424 | out_free: |
425 | ieee80211_free_hw(hw); | 425 | wl1271_free_hw(wl); |
426 | 426 | ||
427 | return ret; | 427 | return ret; |
428 | } | 428 | } |
@@ -433,6 +433,7 @@ static int __devexit wl1271_remove(struct spi_device *spi) | |||
433 | 433 | ||
434 | free_irq(wl->irq, wl); | 434 | free_irq(wl->irq, wl); |
435 | 435 | ||
436 | wl1271_unregister_hw(wl); | ||
436 | wl1271_free_hw(wl); | 437 | wl1271_free_hw(wl); |
437 | 438 | ||
438 | return 0; | 439 | return 0; |