diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2014-11-28 08:40:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-06 00:03:48 -0500 |
commit | c4b2b9a849eaf892fa53bf7fa90c67613ceb83c2 (patch) | |
tree | 5c52afee288b7857fd83806adf2e3d4fbe987a63 | |
parent | 244ebd9f8fa8beb7b37bdeebd6c5308b61f98aef (diff) |
stmmac: pci: allocate memory resources dynamically
Instead of using global variables we are going to use dynamically allocated
memory. It allows to append a support of more than one ethernet adapter which
might have different settings simultaniously.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 77a6d68f7189..054520d67de4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | |||
@@ -26,34 +26,26 @@ | |||
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include "stmmac.h" | 27 | #include "stmmac.h" |
28 | 28 | ||
29 | static struct plat_stmmacenet_data plat_dat; | 29 | static void stmmac_default_data(struct plat_stmmacenet_data *plat) |
30 | static struct stmmac_mdio_bus_data mdio_data; | ||
31 | static struct stmmac_dma_cfg dma_cfg; | ||
32 | |||
33 | static void stmmac_default_data(void) | ||
34 | { | 30 | { |
35 | memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data)); | 31 | plat->bus_id = 1; |
36 | 32 | plat->phy_addr = 0; | |
37 | plat_dat.bus_id = 1; | 33 | plat->interface = PHY_INTERFACE_MODE_GMII; |
38 | plat_dat.phy_addr = 0; | 34 | plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ |
39 | plat_dat.interface = PHY_INTERFACE_MODE_GMII; | 35 | plat->has_gmac = 1; |
40 | plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ | 36 | plat->force_sf_dma_mode = 1; |
41 | plat_dat.has_gmac = 1; | ||
42 | plat_dat.force_sf_dma_mode = 1; | ||
43 | 37 | ||
44 | mdio_data.phy_reset = NULL; | 38 | plat->mdio_bus_data->phy_reset = NULL; |
45 | mdio_data.phy_mask = 0; | 39 | plat->mdio_bus_data->phy_mask = 0; |
46 | plat_dat.mdio_bus_data = &mdio_data; | ||
47 | 40 | ||
48 | dma_cfg.pbl = 32; | 41 | plat->dma_cfg->pbl = 32; |
49 | dma_cfg.burst_len = DMA_AXI_BLEN_256; | 42 | plat->dma_cfg->burst_len = DMA_AXI_BLEN_256; |
50 | plat_dat.dma_cfg = &dma_cfg; | ||
51 | 43 | ||
52 | /* Set default value for multicast hash bins */ | 44 | /* Set default value for multicast hash bins */ |
53 | plat_dat.multicast_filter_bins = HASH_TABLE_SIZE; | 45 | plat->multicast_filter_bins = HASH_TABLE_SIZE; |
54 | 46 | ||
55 | /* Set default value for unicast filter entries */ | 47 | /* Set default value for unicast filter entries */ |
56 | plat_dat.unicast_filter_entries = 1; | 48 | plat->unicast_filter_entries = 1; |
57 | } | 49 | } |
58 | 50 | ||
59 | /** | 51 | /** |
@@ -71,10 +63,26 @@ static void stmmac_default_data(void) | |||
71 | static int stmmac_pci_probe(struct pci_dev *pdev, | 63 | static int stmmac_pci_probe(struct pci_dev *pdev, |
72 | const struct pci_device_id *id) | 64 | const struct pci_device_id *id) |
73 | { | 65 | { |
66 | struct plat_stmmacenet_data *plat; | ||
74 | struct stmmac_priv *priv; | 67 | struct stmmac_priv *priv; |
75 | int i; | 68 | int i; |
76 | int ret; | 69 | int ret; |
77 | 70 | ||
71 | plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); | ||
72 | if (!plat) | ||
73 | return -ENOMEM; | ||
74 | |||
75 | plat->mdio_bus_data = devm_kzalloc(&pdev->dev, | ||
76 | sizeof(*plat->mdio_bus_data), | ||
77 | GFP_KERNEL); | ||
78 | if (!plat->mdio_bus_data) | ||
79 | return -ENOMEM; | ||
80 | |||
81 | plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), | ||
82 | GFP_KERNEL); | ||
83 | if (!plat->dma_cfg) | ||
84 | return -ENOMEM; | ||
85 | |||
78 | /* Enable pci device */ | 86 | /* Enable pci device */ |
79 | ret = pcim_enable_device(pdev); | 87 | ret = pcim_enable_device(pdev); |
80 | if (ret) { | 88 | if (ret) { |
@@ -95,10 +103,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev, | |||
95 | 103 | ||
96 | pci_set_master(pdev); | 104 | pci_set_master(pdev); |
97 | 105 | ||
98 | stmmac_default_data(); | 106 | stmmac_default_data(plat); |
99 | 107 | ||
100 | priv = stmmac_dvr_probe(&pdev->dev, &plat_dat, | 108 | priv = stmmac_dvr_probe(&pdev->dev, plat, pcim_iomap_table(pdev)[i]); |
101 | pcim_iomap_table(pdev)[i]); | ||
102 | if (IS_ERR(priv)) { | 109 | if (IS_ERR(priv)) { |
103 | dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__); | 110 | dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__); |
104 | return PTR_ERR(priv); | 111 | return PTR_ERR(priv); |