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 /drivers/net/wireless/wl12xx/wl1271_main.c | |
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>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_main.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_main.c | 42 |
1 files changed, 33 insertions, 9 deletions
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 | ||