aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2012-09-02 05:29:27 -0400
committerLuciano Coelho <luca@coelho.fi>2012-09-27 05:13:54 -0400
commit3992eb2bf2b1f6d244cf527c922c0cbd810e69c5 (patch)
tree350ca46a30f15cfeec02daafa5a7ba86988900ed /drivers/net/wireless
parentd556023895c8968fd97ccb08300006b78975a23b (diff)
wlcore: Refactor probe
Move most of the device-specific probe functionality into setup(), a new op. By doing this, wlcore_probe will be the first to request a firmware from userspace, making it easier to load the NVS file asynchronously. Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Luciano Coelho <luca@coelho.fi>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c52
-rw-r--r--drivers/net/wireless/ti/wl18xx/main.c59
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c18
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore.h2
4 files changed, 83 insertions, 48 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index 630b4d4cea04..dadf1dbb002a 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -1589,7 +1589,10 @@ static int wl12xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
1589 return wlcore_set_key(wl, cmd, vif, sta, key_conf); 1589 return wlcore_set_key(wl, cmd, vif, sta, key_conf);
1590} 1590}
1591 1591
1592static int wl12xx_setup(struct wl1271 *wl);
1593
1592static struct wlcore_ops wl12xx_ops = { 1594static struct wlcore_ops wl12xx_ops = {
1595 .setup = wl12xx_setup,
1593 .identify_chip = wl12xx_identify_chip, 1596 .identify_chip = wl12xx_identify_chip,
1594 .identify_fw = wl12xx_identify_fw, 1597 .identify_fw = wl12xx_identify_fw,
1595 .boot = wl12xx_boot, 1598 .boot = wl12xx_boot,
@@ -1630,23 +1633,11 @@ static struct ieee80211_sta_ht_cap wl12xx_ht_cap = {
1630 }, 1633 },
1631}; 1634};
1632 1635
1633static int __devinit wl12xx_probe(struct platform_device *pdev) 1636static int wl12xx_setup(struct wl1271 *wl)
1634{ 1637{
1635 struct wl12xx_platform_data *pdata = pdev->dev.platform_data; 1638 struct wl12xx_priv *priv = wl->priv;
1636 struct wl1271 *wl; 1639 struct wl12xx_platform_data *pdata = wl->pdev->dev.platform_data;
1637 struct ieee80211_hw *hw;
1638 struct wl12xx_priv *priv;
1639
1640 hw = wlcore_alloc_hw(sizeof(*priv), WL12XX_AGGR_BUFFER_SIZE);
1641 if (IS_ERR(hw)) {
1642 wl1271_error("can't allocate hw");
1643 return PTR_ERR(hw);
1644 }
1645 1640
1646 wl = hw->priv;
1647 priv = wl->priv;
1648 wl->ops = &wl12xx_ops;
1649 wl->ptable = wl12xx_ptable;
1650 wl->rtable = wl12xx_rtable; 1641 wl->rtable = wl12xx_rtable;
1651 wl->num_tx_desc = WL12XX_NUM_TX_DESCRIPTORS; 1642 wl->num_tx_desc = WL12XX_NUM_TX_DESCRIPTORS;
1652 wl->num_rx_desc = WL12XX_NUM_RX_DESCRIPTORS; 1643 wl->num_rx_desc = WL12XX_NUM_RX_DESCRIPTORS;
@@ -1702,7 +1693,36 @@ static int __devinit wl12xx_probe(struct platform_device *pdev)
1702 wl1271_error("Invalid tcxo parameter %s", tcxo_param); 1693 wl1271_error("Invalid tcxo parameter %s", tcxo_param);
1703 } 1694 }
1704 1695
1705 return wlcore_probe(wl, pdev); 1696 return 0;
1697}
1698
1699static int __devinit wl12xx_probe(struct platform_device *pdev)
1700{
1701 struct wl1271 *wl;
1702 struct ieee80211_hw *hw;
1703 int ret;
1704
1705 hw = wlcore_alloc_hw(sizeof(struct wl12xx_priv),
1706 WL12XX_AGGR_BUFFER_SIZE);
1707 if (IS_ERR(hw)) {
1708 wl1271_error("can't allocate hw");
1709 ret = PTR_ERR(hw);
1710 goto out;
1711 }
1712
1713 wl = hw->priv;
1714 wl->ops = &wl12xx_ops;
1715 wl->ptable = wl12xx_ptable;
1716 ret = wlcore_probe(wl, pdev);
1717 if (ret)
1718 goto out_free;
1719
1720 return ret;
1721
1722out_free:
1723 wlcore_free_hw(wl);
1724out:
1725 return ret;
1706} 1726}
1707 1727
1708static const struct platform_device_id wl12xx_id_table[] __devinitconst = { 1728static const struct platform_device_id wl12xx_id_table[] __devinitconst = {
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index 44e5cadc8f32..9e3e10a13498 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -1304,7 +1304,10 @@ static u32 wl18xx_pre_pkt_send(struct wl1271 *wl,
1304 return buf_offset; 1304 return buf_offset;
1305} 1305}
1306 1306
1307static int wl18xx_setup(struct wl1271 *wl);
1308
1307static struct wlcore_ops wl18xx_ops = { 1309static struct wlcore_ops wl18xx_ops = {
1310 .setup = wl18xx_setup,
1308 .identify_chip = wl18xx_identify_chip, 1311 .identify_chip = wl18xx_identify_chip,
1309 .boot = wl18xx_boot, 1312 .boot = wl18xx_boot,
1310 .plt_init = wl18xx_plt_init, 1313 .plt_init = wl18xx_plt_init,
@@ -1385,24 +1388,11 @@ static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
1385 }, 1388 },
1386}; 1389};
1387 1390
1388static int __devinit wl18xx_probe(struct platform_device *pdev) 1391static int wl18xx_setup(struct wl1271 *wl)
1389{ 1392{
1390 struct wl1271 *wl; 1393 struct wl18xx_priv *priv = wl->priv;
1391 struct ieee80211_hw *hw;
1392 struct wl18xx_priv *priv;
1393 int ret; 1394 int ret;
1394 1395
1395 hw = wlcore_alloc_hw(sizeof(*priv), WL18XX_AGGR_BUFFER_SIZE);
1396 if (IS_ERR(hw)) {
1397 wl1271_error("can't allocate hw");
1398 ret = PTR_ERR(hw);
1399 goto out;
1400 }
1401
1402 wl = hw->priv;
1403 priv = wl->priv;
1404 wl->ops = &wl18xx_ops;
1405 wl->ptable = wl18xx_ptable;
1406 wl->rtable = wl18xx_rtable; 1396 wl->rtable = wl18xx_rtable;
1407 wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS; 1397 wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS;
1408 wl->num_rx_desc = WL18XX_NUM_TX_DESCRIPTORS; 1398 wl->num_rx_desc = WL18XX_NUM_TX_DESCRIPTORS;
@@ -1417,9 +1407,9 @@ static int __devinit wl18xx_probe(struct platform_device *pdev)
1417 if (num_rx_desc_param != -1) 1407 if (num_rx_desc_param != -1)
1418 wl->num_rx_desc = num_rx_desc_param; 1408 wl->num_rx_desc = num_rx_desc_param;
1419 1409
1420 ret = wl18xx_conf_init(wl, &pdev->dev); 1410 ret = wl18xx_conf_init(wl, wl->dev);
1421 if (ret < 0) 1411 if (ret < 0)
1422 goto out_free; 1412 return ret;
1423 1413
1424 /* If the module param is set, update it in conf */ 1414 /* If the module param is set, update it in conf */
1425 if (board_type_param) { 1415 if (board_type_param) {
@@ -1436,16 +1426,14 @@ static int __devinit wl18xx_probe(struct platform_device *pdev)
1436 } else { 1426 } else {
1437 wl1271_error("invalid board type '%s'", 1427 wl1271_error("invalid board type '%s'",
1438 board_type_param); 1428 board_type_param);
1439 ret = -EINVAL; 1429 return -EINVAL;
1440 goto out_free;
1441 } 1430 }
1442 } 1431 }
1443 1432
1444 if (priv->conf.phy.board_type >= NUM_BOARD_TYPES) { 1433 if (priv->conf.phy.board_type >= NUM_BOARD_TYPES) {
1445 wl1271_error("invalid board type '%d'", 1434 wl1271_error("invalid board type '%d'",
1446 priv->conf.phy.board_type); 1435 priv->conf.phy.board_type);
1447 ret = -EINVAL; 1436 return -EINVAL;
1448 goto out_free;
1449 } 1437 }
1450 1438
1451 if (low_band_component_param != -1) 1439 if (low_band_component_param != -1)
@@ -1477,8 +1465,7 @@ static int __devinit wl18xx_probe(struct platform_device *pdev)
1477 priv->conf.ht.mode = HT_MODE_SISO20; 1465 priv->conf.ht.mode = HT_MODE_SISO20;
1478 else { 1466 else {
1479 wl1271_error("invalid ht_mode '%s'", ht_mode_param); 1467 wl1271_error("invalid ht_mode '%s'", ht_mode_param);
1480 ret = -EINVAL; 1468 return -EINVAL;
1481 goto out_free;
1482 } 1469 }
1483 } 1470 }
1484 1471
@@ -1517,7 +1504,31 @@ static int __devinit wl18xx_probe(struct platform_device *pdev)
1517 /* Enable 11a Band only if we have 5G antennas */ 1504 /* Enable 11a Band only if we have 5G antennas */
1518 wl->enable_11a = (priv->conf.phy.number_of_assembled_ant5 != 0); 1505 wl->enable_11a = (priv->conf.phy.number_of_assembled_ant5 != 0);
1519 1506
1520 return wlcore_probe(wl, pdev); 1507 return 0;
1508}
1509
1510static int __devinit wl18xx_probe(struct platform_device *pdev)
1511{
1512 struct wl1271 *wl;
1513 struct ieee80211_hw *hw;
1514 int ret;
1515
1516 hw = wlcore_alloc_hw(sizeof(struct wl18xx_priv),
1517 WL18XX_AGGR_BUFFER_SIZE);
1518 if (IS_ERR(hw)) {
1519 wl1271_error("can't allocate hw");
1520 ret = PTR_ERR(hw);
1521 goto out;
1522 }
1523
1524 wl = hw->priv;
1525 wl->ops = &wl18xx_ops;
1526 wl->ptable = wl18xx_ptable;
1527 ret = wlcore_probe(wl, pdev);
1528 if (ret)
1529 goto out_free;
1530
1531 return ret;
1521 1532
1522out_free: 1533out_free:
1523 wlcore_free_hw(wl); 1534 wlcore_free_hw(wl);
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index 419c399a272e..7db6384a2457 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -5547,9 +5547,17 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
5547 5547
5548 if (!wl->ops || !wl->ptable) { 5548 if (!wl->ops || !wl->ptable) {
5549 ret = -EINVAL; 5549 ret = -EINVAL;
5550 goto out_free_hw; 5550 goto out;
5551 } 5551 }
5552 5552
5553 wl->dev = &pdev->dev;
5554 wl->pdev = pdev;
5555 platform_set_drvdata(pdev, wl);
5556
5557 ret = wl->ops->setup(wl);
5558 if (ret < 0)
5559 goto out;
5560
5553 BUG_ON(wl->num_tx_desc > WLCORE_MAX_TX_DESCRIPTORS); 5561 BUG_ON(wl->num_tx_desc > WLCORE_MAX_TX_DESCRIPTORS);
5554 5562
5555 /* adjust some runtime configuration parameters */ 5563 /* adjust some runtime configuration parameters */
@@ -5558,11 +5566,8 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
5558 wl->irq = platform_get_irq(pdev, 0); 5566 wl->irq = platform_get_irq(pdev, 0);
5559 wl->platform_quirks = pdata->platform_quirks; 5567 wl->platform_quirks = pdata->platform_quirks;
5560 wl->set_power = pdata->set_power; 5568 wl->set_power = pdata->set_power;
5561 wl->dev = &pdev->dev;
5562 wl->if_ops = pdata->ops; 5569 wl->if_ops = pdata->ops;
5563 5570
5564 platform_set_drvdata(pdev, wl);
5565
5566 if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) 5571 if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
5567 irqflags = IRQF_TRIGGER_RISING; 5572 irqflags = IRQF_TRIGGER_RISING;
5568 else 5573 else
@@ -5573,7 +5578,7 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
5573 pdev->name, wl); 5578 pdev->name, wl);
5574 if (ret < 0) { 5579 if (ret < 0) {
5575 wl1271_error("request_irq() failed: %d", ret); 5580 wl1271_error("request_irq() failed: %d", ret);
5576 goto out_free_hw; 5581 goto out;
5577 } 5582 }
5578 5583
5579#ifdef CONFIG_PM 5584#ifdef CONFIG_PM
@@ -5646,9 +5651,6 @@ out_unreg:
5646out_irq: 5651out_irq:
5647 free_irq(wl->irq, wl); 5652 free_irq(wl->irq, wl);
5648 5653
5649out_free_hw:
5650 wlcore_free_hw(wl);
5651
5652out: 5654out:
5653 return ret; 5655 return ret;
5654} 5656}
diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h
index 8ad5f37329d7..6a0455616289 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore.h
@@ -43,6 +43,7 @@ enum wl_rx_buf_align;
43struct wl1271_rx_descriptor; 43struct wl1271_rx_descriptor;
44 44
45struct wlcore_ops { 45struct wlcore_ops {
46 int (*setup)(struct wl1271 *wl);
46 int (*identify_chip)(struct wl1271 *wl); 47 int (*identify_chip)(struct wl1271 *wl);
47 int (*identify_fw)(struct wl1271 *wl); 48 int (*identify_fw)(struct wl1271 *wl);
48 int (*boot)(struct wl1271 *wl); 49 int (*boot)(struct wl1271 *wl);
@@ -149,6 +150,7 @@ struct wl1271 {
149 bool mac80211_registered; 150 bool mac80211_registered;
150 151
151 struct device *dev; 152 struct device *dev;
153 struct platform_device *pdev;
152 154
153 void *if_priv; 155 void *if_priv;
154 156