aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/main.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-08-03 15:24:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-04 16:44:27 -0400
commit4f3acf81f2a47244f7403353784f528c92e98a6c (patch)
tree1db1b17c5779da0370b5e1e61723468eefe8721a /drivers/net/wireless/ath/ath9k/main.c
parent7819ac84b689b61340f29af6233fa1d15b76a6ef (diff)
ath9k: move memory allocation of ath_hw to ath_init()
This lets us simplify attach code and arguments passed. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/main.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index ada5fef924c8..c2b9974aa094 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1295,7 +1295,7 @@ static int ath9k_reg_notifier(struct wiphy *wiphy,
1295static int ath_init(u16 devid, struct ath_softc *sc) 1295static int ath_init(u16 devid, struct ath_softc *sc)
1296{ 1296{
1297 struct ath_hw *ah = NULL; 1297 struct ath_hw *ah = NULL;
1298 int error = 0, i; 1298 int r = 0, i;
1299 int csz = 0; 1299 int csz = 0;
1300 1300
1301 /* XXX: hardware will not be ready until ath_open() being called */ 1301 /* XXX: hardware will not be ready until ath_open() being called */
@@ -1322,11 +1322,21 @@ static int ath_init(u16 devid, struct ath_softc *sc)
1322 /* XXX assert csz is non-zero */ 1322 /* XXX assert csz is non-zero */
1323 sc->cachelsz = csz << 2; /* convert to bytes */ 1323 sc->cachelsz = csz << 2; /* convert to bytes */
1324 1324
1325 ah = ath9k_hw_attach(devid, sc, &error); 1325 ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL);
1326 if (ah == NULL) { 1326 if (!ah) {
1327 DPRINTF(sc, ATH_DBG_FATAL,
1328 "Cannot allocate memory for state block\n");
1329 r = -ENOMEM;
1330 goto bad_no_ah;
1331 }
1332
1333 ah->ah_sc = sc;
1334
1335 r = ath9k_hw_attach(ah, devid, sc);
1336 if (r) {
1327 DPRINTF(sc, ATH_DBG_FATAL, 1337 DPRINTF(sc, ATH_DBG_FATAL,
1328 "Unable to attach hardware; " 1338 "Unable to attach hardware; "
1329 "initialization status: %d\n", error); 1339 "initialization status: %d\n", r);
1330 goto bad; 1340 goto bad;
1331 } 1341 }
1332 sc->sc_ah = ah; 1342 sc->sc_ah = ah;
@@ -1347,7 +1357,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
1347 for (i = 0; i < sc->keymax; i++) 1357 for (i = 0; i < sc->keymax; i++)
1348 ath9k_hw_keyreset(ah, (u16) i); 1358 ath9k_hw_keyreset(ah, (u16) i);
1349 1359
1350 if (error) 1360 if (r)
1351 goto bad; 1361 goto bad;
1352 1362
1353 /* default to MONITOR mode */ 1363 /* default to MONITOR mode */
@@ -1369,14 +1379,14 @@ static int ath_init(u16 devid, struct ath_softc *sc)
1369 if (sc->beacon.beaconq == -1) { 1379 if (sc->beacon.beaconq == -1) {
1370 DPRINTF(sc, ATH_DBG_FATAL, 1380 DPRINTF(sc, ATH_DBG_FATAL,
1371 "Unable to setup a beacon xmit queue\n"); 1381 "Unable to setup a beacon xmit queue\n");
1372 error = -EIO; 1382 r = -EIO;
1373 goto bad2; 1383 goto bad2;
1374 } 1384 }
1375 sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0); 1385 sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0);
1376 if (sc->beacon.cabq == NULL) { 1386 if (sc->beacon.cabq == NULL) {
1377 DPRINTF(sc, ATH_DBG_FATAL, 1387 DPRINTF(sc, ATH_DBG_FATAL,
1378 "Unable to setup CAB xmit queue\n"); 1388 "Unable to setup CAB xmit queue\n");
1379 error = -EIO; 1389 r = -EIO;
1380 goto bad2; 1390 goto bad2;
1381 } 1391 }
1382 1392
@@ -1391,26 +1401,26 @@ static int ath_init(u16 devid, struct ath_softc *sc)
1391 if (!ath_tx_setup(sc, ATH9K_WME_AC_BK)) { 1401 if (!ath_tx_setup(sc, ATH9K_WME_AC_BK)) {
1392 DPRINTF(sc, ATH_DBG_FATAL, 1402 DPRINTF(sc, ATH_DBG_FATAL,
1393 "Unable to setup xmit queue for BK traffic\n"); 1403 "Unable to setup xmit queue for BK traffic\n");
1394 error = -EIO; 1404 r = -EIO;
1395 goto bad2; 1405 goto bad2;
1396 } 1406 }
1397 1407
1398 if (!ath_tx_setup(sc, ATH9K_WME_AC_BE)) { 1408 if (!ath_tx_setup(sc, ATH9K_WME_AC_BE)) {
1399 DPRINTF(sc, ATH_DBG_FATAL, 1409 DPRINTF(sc, ATH_DBG_FATAL,
1400 "Unable to setup xmit queue for BE traffic\n"); 1410 "Unable to setup xmit queue for BE traffic\n");
1401 error = -EIO; 1411 r = -EIO;
1402 goto bad2; 1412 goto bad2;
1403 } 1413 }
1404 if (!ath_tx_setup(sc, ATH9K_WME_AC_VI)) { 1414 if (!ath_tx_setup(sc, ATH9K_WME_AC_VI)) {
1405 DPRINTF(sc, ATH_DBG_FATAL, 1415 DPRINTF(sc, ATH_DBG_FATAL,
1406 "Unable to setup xmit queue for VI traffic\n"); 1416 "Unable to setup xmit queue for VI traffic\n");
1407 error = -EIO; 1417 r = -EIO;
1408 goto bad2; 1418 goto bad2;
1409 } 1419 }
1410 if (!ath_tx_setup(sc, ATH9K_WME_AC_VO)) { 1420 if (!ath_tx_setup(sc, ATH9K_WME_AC_VO)) {
1411 DPRINTF(sc, ATH_DBG_FATAL, 1421 DPRINTF(sc, ATH_DBG_FATAL,
1412 "Unable to setup xmit queue for VO traffic\n"); 1422 "Unable to setup xmit queue for VO traffic\n");
1413 error = -EIO; 1423 r = -EIO;
1414 goto bad2; 1424 goto bad2;
1415 } 1425 }
1416 1426
@@ -1506,9 +1516,10 @@ bad2:
1506bad: 1516bad:
1507 if (ah) 1517 if (ah)
1508 ath9k_hw_detach(ah); 1518 ath9k_hw_detach(ah);
1519bad_no_ah:
1509 ath9k_exit_debug(sc); 1520 ath9k_exit_debug(sc);
1510 1521
1511 return error; 1522 return r;
1512} 1523}
1513 1524
1514void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) 1525void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)