diff options
author | David Kilroy <kilroyd@googlemail.com> | 2009-06-18 18:21:19 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-10 15:01:43 -0400 |
commit | e9e3d0100eae5f254024bd59229ef1be2b719b84 (patch) | |
tree | 61baee2156fa2756b39e1c3de1fbdf8b608e9d46 /drivers/net/wireless/orinoco | |
parent | a2d1a42a4b44c97fb83c5bf53af8cd6ab4c6c110 (diff) |
orinoco: Move card reading code into hw.c
This is part of refactorring the initialisation code so that we can
load the firmware before registerring with netdev.
Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco')
-rw-r--r-- | drivers/net/wireless/orinoco/hw.c | 112 | ||||
-rw-r--r-- | drivers/net/wireless/orinoco/hw.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/orinoco/main.c | 102 |
3 files changed, 115 insertions, 100 deletions
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c index 209c6bef0cd9..40dc25c7d0eb 100644 --- a/drivers/net/wireless/orinoco/hw.c +++ b/drivers/net/wireless/orinoco/hw.c | |||
@@ -252,6 +252,118 @@ int determine_fw_capabilities(struct orinoco_private *priv) | |||
252 | return 0; | 252 | return 0; |
253 | } | 253 | } |
254 | 254 | ||
255 | /* Read settings from EEPROM into our private structure. | ||
256 | * MAC address gets dropped into callers buffer */ | ||
257 | int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) | ||
258 | { | ||
259 | struct net_device *dev = priv->ndev; | ||
260 | struct hermes_idstring nickbuf; | ||
261 | hermes_t *hw = &priv->hw; | ||
262 | int len; | ||
263 | int err; | ||
264 | u16 reclen; | ||
265 | |||
266 | /* Get the MAC address */ | ||
267 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | ||
268 | ETH_ALEN, NULL, dev_addr); | ||
269 | if (err) { | ||
270 | printk(KERN_WARNING "%s: failed to read MAC address!\n", | ||
271 | dev->name); | ||
272 | goto out; | ||
273 | } | ||
274 | |||
275 | printk(KERN_DEBUG "%s: MAC address %pM\n", | ||
276 | dev->name, dev_addr); | ||
277 | |||
278 | /* Get the station name */ | ||
279 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
280 | sizeof(nickbuf), &reclen, &nickbuf); | ||
281 | if (err) { | ||
282 | printk(KERN_ERR "%s: failed to read station name\n", | ||
283 | dev->name); | ||
284 | goto out; | ||
285 | } | ||
286 | if (nickbuf.len) | ||
287 | len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len)); | ||
288 | else | ||
289 | len = min(IW_ESSID_MAX_SIZE, 2 * reclen); | ||
290 | memcpy(priv->nick, &nickbuf.val, len); | ||
291 | priv->nick[len] = '\0'; | ||
292 | |||
293 | printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); | ||
294 | |||
295 | /* Get allowed channels */ | ||
296 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, | ||
297 | &priv->channel_mask); | ||
298 | if (err) { | ||
299 | printk(KERN_ERR "%s: failed to read channel list!\n", | ||
300 | dev->name); | ||
301 | goto out; | ||
302 | } | ||
303 | |||
304 | /* Get initial AP density */ | ||
305 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, | ||
306 | &priv->ap_density); | ||
307 | if (err || priv->ap_density < 1 || priv->ap_density > 3) | ||
308 | priv->has_sensitivity = 0; | ||
309 | |||
310 | /* Get initial RTS threshold */ | ||
311 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
312 | &priv->rts_thresh); | ||
313 | if (err) { | ||
314 | printk(KERN_ERR "%s: failed to read RTS threshold!\n", | ||
315 | dev->name); | ||
316 | goto out; | ||
317 | } | ||
318 | |||
319 | /* Get initial fragmentation settings */ | ||
320 | if (priv->has_mwo) | ||
321 | err = hermes_read_wordrec(hw, USER_BAP, | ||
322 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
323 | &priv->mwo_robust); | ||
324 | else | ||
325 | err = hermes_read_wordrec(hw, USER_BAP, | ||
326 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
327 | &priv->frag_thresh); | ||
328 | if (err) { | ||
329 | printk(KERN_ERR "%s: failed to read fragmentation settings!\n", | ||
330 | dev->name); | ||
331 | goto out; | ||
332 | } | ||
333 | |||
334 | /* Power management setup */ | ||
335 | if (priv->has_pm) { | ||
336 | priv->pm_on = 0; | ||
337 | priv->pm_mcast = 1; | ||
338 | err = hermes_read_wordrec(hw, USER_BAP, | ||
339 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
340 | &priv->pm_period); | ||
341 | if (err) { | ||
342 | printk(KERN_ERR "%s: failed to read power management " | ||
343 | "period!\n", dev->name); | ||
344 | goto out; | ||
345 | } | ||
346 | err = hermes_read_wordrec(hw, USER_BAP, | ||
347 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
348 | &priv->pm_timeout); | ||
349 | if (err) { | ||
350 | printk(KERN_ERR "%s: failed to read power management " | ||
351 | "timeout!\n", dev->name); | ||
352 | goto out; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | /* Preamble setup */ | ||
357 | if (priv->has_preamble) { | ||
358 | err = hermes_read_wordrec(hw, USER_BAP, | ||
359 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
360 | &priv->preamble); | ||
361 | } | ||
362 | |||
363 | out: | ||
364 | return err; | ||
365 | } | ||
366 | |||
255 | int orinoco_get_bitratemode(int bitrate, int automatic) | 367 | int orinoco_get_bitratemode(int bitrate, int automatic) |
256 | { | 368 | { |
257 | int ratemode = -1; | 369 | int ratemode = -1; |
diff --git a/drivers/net/wireless/orinoco/hw.h b/drivers/net/wireless/orinoco/hw.h index f7845b855f76..6186e44f54e9 100644 --- a/drivers/net/wireless/orinoco/hw.h +++ b/drivers/net/wireless/orinoco/hw.h | |||
@@ -24,6 +24,7 @@ struct orinoco_private; | |||
24 | struct dev_addr_list; | 24 | struct dev_addr_list; |
25 | 25 | ||
26 | int determine_fw_capabilities(struct orinoco_private *priv); | 26 | int determine_fw_capabilities(struct orinoco_private *priv); |
27 | int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr); | ||
27 | int orinoco_get_bitratemode(int bitrate, int automatic); | 28 | int orinoco_get_bitratemode(int bitrate, int automatic); |
28 | void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic); | 29 | void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic); |
29 | 30 | ||
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c index 33326d6ef815..0fe9420c4905 100644 --- a/drivers/net/wireless/orinoco/main.c +++ b/drivers/net/wireless/orinoco/main.c | |||
@@ -2100,9 +2100,6 @@ static int orinoco_init(struct net_device *dev) | |||
2100 | struct orinoco_private *priv = netdev_priv(dev); | 2100 | struct orinoco_private *priv = netdev_priv(dev); |
2101 | hermes_t *hw = &priv->hw; | 2101 | hermes_t *hw = &priv->hw; |
2102 | int err = 0; | 2102 | int err = 0; |
2103 | struct hermes_idstring nickbuf; | ||
2104 | u16 reclen; | ||
2105 | int len; | ||
2106 | 2103 | ||
2107 | /* No need to lock, the hw_unavailable flag is already set in | 2104 | /* No need to lock, the hw_unavailable flag is already set in |
2108 | * alloc_orinocodev() */ | 2105 | * alloc_orinocodev() */ |
@@ -2166,34 +2163,9 @@ static int orinoco_init(struct net_device *dev) | |||
2166 | goto out; | 2163 | goto out; |
2167 | orinoco_bss_data_init(priv); | 2164 | orinoco_bss_data_init(priv); |
2168 | 2165 | ||
2169 | /* Get the MAC address */ | 2166 | err = orinoco_hw_read_card_settings(priv, dev->dev_addr); |
2170 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | 2167 | if (err) |
2171 | ETH_ALEN, NULL, dev->dev_addr); | ||
2172 | if (err) { | ||
2173 | printk(KERN_WARNING "%s: failed to read MAC address!\n", | ||
2174 | dev->name); | ||
2175 | goto out; | ||
2176 | } | ||
2177 | |||
2178 | printk(KERN_DEBUG "%s: MAC address %pM\n", | ||
2179 | dev->name, dev->dev_addr); | ||
2180 | |||
2181 | /* Get the station name */ | ||
2182 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
2183 | sizeof(nickbuf), &reclen, &nickbuf); | ||
2184 | if (err) { | ||
2185 | printk(KERN_ERR "%s: failed to read station name\n", | ||
2186 | dev->name); | ||
2187 | goto out; | 2168 | goto out; |
2188 | } | ||
2189 | if (nickbuf.len) | ||
2190 | len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len)); | ||
2191 | else | ||
2192 | len = min(IW_ESSID_MAX_SIZE, 2 * reclen); | ||
2193 | memcpy(priv->nick, &nickbuf.val, len); | ||
2194 | priv->nick[len] = '\0'; | ||
2195 | |||
2196 | printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); | ||
2197 | 2169 | ||
2198 | err = orinoco_allocate_fid(dev); | 2170 | err = orinoco_allocate_fid(dev); |
2199 | if (err) { | 2171 | if (err) { |
@@ -2202,76 +2174,6 @@ static int orinoco_init(struct net_device *dev) | |||
2202 | goto out; | 2174 | goto out; |
2203 | } | 2175 | } |
2204 | 2176 | ||
2205 | /* Get allowed channels */ | ||
2206 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, | ||
2207 | &priv->channel_mask); | ||
2208 | if (err) { | ||
2209 | printk(KERN_ERR "%s: failed to read channel list!\n", | ||
2210 | dev->name); | ||
2211 | goto out; | ||
2212 | } | ||
2213 | |||
2214 | /* Get initial AP density */ | ||
2215 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, | ||
2216 | &priv->ap_density); | ||
2217 | if (err || priv->ap_density < 1 || priv->ap_density > 3) | ||
2218 | priv->has_sensitivity = 0; | ||
2219 | |||
2220 | /* Get initial RTS threshold */ | ||
2221 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
2222 | &priv->rts_thresh); | ||
2223 | if (err) { | ||
2224 | printk(KERN_ERR "%s: failed to read RTS threshold!\n", | ||
2225 | dev->name); | ||
2226 | goto out; | ||
2227 | } | ||
2228 | |||
2229 | /* Get initial fragmentation settings */ | ||
2230 | if (priv->has_mwo) | ||
2231 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2232 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
2233 | &priv->mwo_robust); | ||
2234 | else | ||
2235 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2236 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
2237 | &priv->frag_thresh); | ||
2238 | if (err) { | ||
2239 | printk(KERN_ERR "%s: failed to read fragmentation settings!\n", | ||
2240 | dev->name); | ||
2241 | goto out; | ||
2242 | } | ||
2243 | |||
2244 | /* Power management setup */ | ||
2245 | if (priv->has_pm) { | ||
2246 | priv->pm_on = 0; | ||
2247 | priv->pm_mcast = 1; | ||
2248 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2249 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
2250 | &priv->pm_period); | ||
2251 | if (err) { | ||
2252 | printk(KERN_ERR "%s: failed to read power management period!\n", | ||
2253 | dev->name); | ||
2254 | goto out; | ||
2255 | } | ||
2256 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2257 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
2258 | &priv->pm_timeout); | ||
2259 | if (err) { | ||
2260 | printk(KERN_ERR "%s: failed to read power management timeout!\n", | ||
2261 | dev->name); | ||
2262 | goto out; | ||
2263 | } | ||
2264 | } | ||
2265 | |||
2266 | /* Preamble setup */ | ||
2267 | if (priv->has_preamble) { | ||
2268 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2269 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
2270 | &priv->preamble); | ||
2271 | if (err) | ||
2272 | goto out; | ||
2273 | } | ||
2274 | |||
2275 | /* Set up the default configuration */ | 2177 | /* Set up the default configuration */ |
2276 | priv->iw_mode = IW_MODE_INFRA; | 2178 | priv->iw_mode = IW_MODE_INFRA; |
2277 | /* By default use IEEE/IBSS ad-hoc mode if we have it */ | 2179 | /* By default use IEEE/IBSS ad-hoc mode if we have it */ |