Commit 17007aa5 authored by David S. Miller's avatar David S. Miller

Merge branch 'stmmac-next'

Andy Shevchenko says:

====================
stmmac: pci: various cleanups and fixes

There are few cleanups and fixes regarding to stmmac PCI driver.
This has been tested on Intel Galileo board with recent net-next tree.

Since v2:
- drop patch 5/5 since it will be part of a big change across entire subsystem

Since v1:
- remove already applied patch
- append patch 1/5
- rework patch 3/5 to be functional compatible with original code
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 915af656 7627fc07
...@@ -71,64 +71,46 @@ static void stmmac_default_data(void) ...@@ -71,64 +71,46 @@ 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)
{ {
int ret = 0; struct stmmac_priv *priv;
void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL;
int i; int i;
int ret;
/* Enable pci device */ /* Enable pci device */
ret = pci_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) { if (ret) {
pr_err("%s : ERROR: failed to enable %s device\n", __func__, dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
pci_name(pdev)); __func__);
return ret; return ret;
} }
if (pci_request_regions(pdev, STMMAC_RESOURCE_NAME)) {
pr_err("%s: ERROR: failed to get PCI region\n", __func__);
ret = -ENODEV;
goto err_out_req_reg_failed;
}
/* Get the base address of device */ /* Get the base address of device */
for (i = 0; i <= 5; i++) { for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
if (pci_resource_len(pdev, i) == 0) if (pci_resource_len(pdev, i) == 0)
continue; continue;
addr = pci_iomap(pdev, i, 0); ret = pcim_iomap_regions(pdev, BIT(i), pci_name(pdev));
if (addr == NULL) { if (ret)
pr_err("%s: ERROR: cannot map register memory aborting", return ret;
__func__);
ret = -EIO;
goto err_out_map_failed;
}
break; break;
} }
pci_set_master(pdev); pci_set_master(pdev);
stmmac_default_data(); stmmac_default_data();
priv = stmmac_dvr_probe(&(pdev->dev), &plat_dat, addr); priv = stmmac_dvr_probe(&pdev->dev, &plat_dat,
pcim_iomap_table(pdev)[i]);
if (IS_ERR(priv)) { if (IS_ERR(priv)) {
pr_err("%s: main driver probe failed", __func__); dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__);
ret = PTR_ERR(priv); return PTR_ERR(priv);
goto err_out;
} }
priv->dev->irq = pdev->irq; priv->dev->irq = pdev->irq;
priv->wol_irq = pdev->irq; priv->wol_irq = pdev->irq;
pci_set_drvdata(pdev, priv->dev); pci_set_drvdata(pdev, priv->dev);
pr_debug("STMMAC platform driver registration completed"); dev_dbg(&pdev->dev, "STMMAC PCI driver registration completed\n");
return 0; return 0;
err_out:
pci_clear_master(pdev);
err_out_map_failed:
pci_release_regions(pdev);
err_out_req_reg_failed:
pci_disable_device(pdev);
return ret;
} }
/** /**
...@@ -141,39 +123,30 @@ static int stmmac_pci_probe(struct pci_dev *pdev, ...@@ -141,39 +123,30 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
static void stmmac_pci_remove(struct pci_dev *pdev) static void stmmac_pci_remove(struct pci_dev *pdev)
{ {
struct net_device *ndev = pci_get_drvdata(pdev); struct net_device *ndev = pci_get_drvdata(pdev);
struct stmmac_priv *priv = netdev_priv(ndev);
stmmac_dvr_remove(ndev); stmmac_dvr_remove(ndev);
pci_iounmap(pdev, priv->ioaddr);
pci_release_regions(pdev);
pci_disable_device(pdev);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP
static int stmmac_pci_suspend(struct pci_dev *pdev, pm_message_t state) static int stmmac_pci_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct net_device *ndev = pci_get_drvdata(pdev); struct net_device *ndev = pci_get_drvdata(pdev);
int ret;
ret = stmmac_suspend(ndev);
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return ret; return stmmac_suspend(ndev);
} }
static int stmmac_pci_resume(struct pci_dev *pdev) static int stmmac_pci_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct net_device *ndev = pci_get_drvdata(pdev); struct net_device *ndev = pci_get_drvdata(pdev);
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
return stmmac_resume(ndev); return stmmac_resume(ndev);
} }
#endif #endif
static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume);
#define STMMAC_VENDOR_ID 0x700 #define STMMAC_VENDOR_ID 0x700
#define STMMAC_DEVICE_ID 0x1108 #define STMMAC_DEVICE_ID 0x1108
...@@ -190,10 +163,9 @@ struct pci_driver stmmac_pci_driver = { ...@@ -190,10 +163,9 @@ struct pci_driver stmmac_pci_driver = {
.id_table = stmmac_id_table, .id_table = stmmac_id_table,
.probe = stmmac_pci_probe, .probe = stmmac_pci_probe,
.remove = stmmac_pci_remove, .remove = stmmac_pci_remove,
#ifdef CONFIG_PM .driver = {
.suspend = stmmac_pci_suspend, .pm = &stmmac_pm_ops,
.resume = stmmac_pci_resume, },
#endif
}; };
MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver"); MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver");
......
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