Commit c4b2b9a8 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 244ebd9f
...@@ -26,34 +26,26 @@ ...@@ -26,34 +26,26 @@
#include <linux/pci.h> #include <linux/pci.h>
#include "stmmac.h" #include "stmmac.h"
static struct plat_stmmacenet_data plat_dat; static void stmmac_default_data(struct plat_stmmacenet_data *plat)
static struct stmmac_mdio_bus_data mdio_data;
static struct stmmac_dma_cfg dma_cfg;
static void stmmac_default_data(void)
{ {
memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data)); plat->bus_id = 1;
plat->phy_addr = 0;
plat_dat.bus_id = 1; plat->interface = PHY_INTERFACE_MODE_GMII;
plat_dat.phy_addr = 0; plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
plat_dat.interface = PHY_INTERFACE_MODE_GMII; plat->has_gmac = 1;
plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ plat->force_sf_dma_mode = 1;
plat_dat.has_gmac = 1;
plat_dat.force_sf_dma_mode = 1;
mdio_data.phy_reset = NULL; plat->mdio_bus_data->phy_reset = NULL;
mdio_data.phy_mask = 0; plat->mdio_bus_data->phy_mask = 0;
plat_dat.mdio_bus_data = &mdio_data;
dma_cfg.pbl = 32; plat->dma_cfg->pbl = 32;
dma_cfg.burst_len = DMA_AXI_BLEN_256; plat->dma_cfg->burst_len = DMA_AXI_BLEN_256;
plat_dat.dma_cfg = &dma_cfg;
/* Set default value for multicast hash bins */ /* Set default value for multicast hash bins */
plat_dat.multicast_filter_bins = HASH_TABLE_SIZE; plat->multicast_filter_bins = HASH_TABLE_SIZE;
/* Set default value for unicast filter entries */ /* Set default value for unicast filter entries */
plat_dat.unicast_filter_entries = 1; plat->unicast_filter_entries = 1;
} }
/** /**
...@@ -71,10 +63,26 @@ static void stmmac_default_data(void) ...@@ -71,10 +63,26 @@ static void stmmac_default_data(void)
static int stmmac_pci_probe(struct pci_dev *pdev, static int stmmac_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
struct plat_stmmacenet_data *plat;
struct stmmac_priv *priv; struct stmmac_priv *priv;
int i; int i;
int ret; int ret;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
return -ENOMEM;
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
sizeof(*plat->mdio_bus_data),
GFP_KERNEL);
if (!plat->mdio_bus_data)
return -ENOMEM;
plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
GFP_KERNEL);
if (!plat->dma_cfg)
return -ENOMEM;
/* Enable pci device */ /* Enable pci device */
ret = pcim_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) { if (ret) {
...@@ -95,10 +103,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev, ...@@ -95,10 +103,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
pci_set_master(pdev); pci_set_master(pdev);
stmmac_default_data(); stmmac_default_data(plat);
priv = stmmac_dvr_probe(&pdev->dev, &plat_dat, priv = stmmac_dvr_probe(&pdev->dev, plat, pcim_iomap_table(pdev)[i]);
pcim_iomap_table(pdev)[i]);
if (IS_ERR(priv)) { if (IS_ERR(priv)) {
dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__); dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__);
return PTR_ERR(priv); return PTR_ERR(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment