netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5]  stmmac: pci: various cleanups and fixes
@ 2014-11-03 13:02 Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 1/5] stmmac: pci: use defined constant instead of magic number Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

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 v1:
- remove already applied patch
- append patch 1/5
- rework patch 3/5 to be functional compatible with original code

Andy Shevchenko (5):
  stmmac: pci: use defined constant instead of magic number
  stmmac: pci: convert to use dev_pm_ops
  stmmac: pci: use managed resources
  stmmac: pci: convert to use dev_* macros
  stmmac: pci: remove FSF address

 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 84 ++++++++----------------
 1 file changed, 26 insertions(+), 58 deletions(-)

-- 
2.1.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/5] stmmac: pci: use defined constant instead of magic number
  2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
@ 2014-11-03 13:02 ` Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 2/5] stmmac: pci: convert to use dev_pm_ops Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

The last standard PCI resource is defined as PCI_STD_RESOURCE_END. Thus, we
could use it instead of plain integer.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index e17a970..e45794d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -90,7 +90,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	}
 
 	/* 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)
 			continue;
 		addr = pci_iomap(pdev, i, 0);
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/5] stmmac: pci: convert to use dev_pm_ops
  2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 1/5] stmmac: pci: use defined constant instead of magic number Andy Shevchenko
@ 2014-11-03 13:02 ` Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 3/5] stmmac: pci: use managed resources Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

Convert system PM callbacks to use dev_pm_ops. In addition remove the PCI calls
related to a power state since the bus code cares about this already.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 27 ++++++++++--------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index e45794d..f19ac8e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -150,30 +150,26 @@ static void stmmac_pci_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
-#ifdef CONFIG_PM
-static int stmmac_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int stmmac_pci_suspend(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	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);
 
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-
 	return stmmac_resume(ndev);
 }
 #endif
 
+static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume);
+
 #define STMMAC_VENDOR_ID 0x700
 #define STMMAC_DEVICE_ID 0x1108
 
@@ -190,10 +186,9 @@ struct pci_driver stmmac_pci_driver = {
 	.id_table = stmmac_id_table,
 	.probe = stmmac_pci_probe,
 	.remove = stmmac_pci_remove,
-#ifdef CONFIG_PM
-	.suspend = stmmac_pci_suspend,
-	.resume = stmmac_pci_resume,
-#endif
+	.driver         = {
+		.pm     = &stmmac_pm_ops,
+	},
 };
 
 MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PCI driver");
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/5] stmmac: pci: use managed resources
  2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 1/5] stmmac: pci: use defined constant instead of magic number Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 2/5] stmmac: pci: convert to use dev_pm_ops Andy Shevchenko
@ 2014-11-03 13:02 ` Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 4/5] stmmac: pci: convert to use dev_* macros Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 5/5] stmmac: pci: remove FSF address Andy Shevchenko
  4 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

Migrate pci driver to managed resources to reduce boilerplate error handling
code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 43 ++++++------------------
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index f19ac8e..5357a3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -71,46 +71,37 @@ static void stmmac_default_data(void)
 static int stmmac_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id)
 {
-	int ret = 0;
-	void __iomem *addr = NULL;
-	struct stmmac_priv *priv = NULL;
+	struct stmmac_priv *priv;
 	int i;
+	int ret;
 
 	/* Enable pci device */
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (ret) {
 		pr_err("%s : ERROR: failed to enable %s device\n", __func__,
 		       pci_name(pdev));
 		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 */
 	for (i = 0; i <= PCI_STD_RESOURCE_END; i++) {
 		if (pci_resource_len(pdev, i) == 0)
 			continue;
-		addr = pci_iomap(pdev, i, 0);
-		if (addr == NULL) {
-			pr_err("%s: ERROR: cannot map register memory aborting",
-			       __func__);
-			ret = -EIO;
-			goto err_out_map_failed;
-		}
+		ret = pcim_iomap_regions(pdev, BIT(i), pci_name(pdev));
+		if (ret)
+			return ret;
 		break;
 	}
+
 	pci_set_master(pdev);
 
 	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)) {
 		pr_err("%s: main driver probe failed", __func__);
-		ret = PTR_ERR(priv);
-		goto err_out;
+		return PTR_ERR(priv);
 	}
 	priv->dev->irq = pdev->irq;
 	priv->wol_irq = pdev->irq;
@@ -120,15 +111,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	pr_debug("STMMAC platform driver registration completed");
 
 	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,13 +123,8 @@ err_out_req_reg_failed:
 static void stmmac_pci_remove(struct pci_dev *pdev)
 {
 	struct net_device *ndev = pci_get_drvdata(pdev);
-	struct stmmac_priv *priv = netdev_priv(ndev);
 
 	stmmac_dvr_remove(ndev);
-
-	pci_iounmap(pdev, priv->ioaddr);
-	pci_release_regions(pdev);
-	pci_disable_device(pdev);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/5] stmmac: pci: convert to use dev_* macros
  2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
                   ` (2 preceding siblings ...)
  2014-11-03 13:02 ` [PATCH v2 3/5] stmmac: pci: use managed resources Andy Shevchenko
@ 2014-11-03 13:02 ` Andy Shevchenko
  2014-11-03 13:02 ` [PATCH v2 5/5] stmmac: pci: remove FSF address Andy Shevchenko
  4 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

Instead of pr_* macros let's use dev_* macros which provide device name.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 5357a3f..5084699 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -78,8 +78,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	/* Enable pci device */
 	ret = pcim_enable_device(pdev);
 	if (ret) {
-		pr_err("%s : ERROR: failed to enable %s device\n", __func__,
-		       pci_name(pdev));
+		dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
+			__func__);
 		return ret;
 	}
 
@@ -100,7 +100,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	priv = stmmac_dvr_probe(&pdev->dev, &plat_dat,
 				pcim_iomap_table(pdev)[i]);
 	if (IS_ERR(priv)) {
-		pr_err("%s: main driver probe failed", __func__);
+		dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__);
 		return PTR_ERR(priv);
 	}
 	priv->dev->irq = pdev->irq;
@@ -108,7 +108,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
 	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;
 }
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 5/5] stmmac: pci: remove FSF address
  2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
                   ` (3 preceding siblings ...)
  2014-11-03 13:02 ` [PATCH v2 4/5] stmmac: pci: convert to use dev_* macros Andy Shevchenko
@ 2014-11-03 13:02 ` Andy Shevchenko
  2014-11-03 20:57   ` David Miller
  4 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-03 13:02 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, Kweh Hock Leong, David S . Miller,
	Vince Bridgers, Rayagond K
  Cc: Andy Shevchenko

The FSF address is subject to change, thus remove it from the file.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 5084699..068ef8e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -12,10 +12,6 @@
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.
 
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
   The full GNU General Public License is included in this distribution in
   the file called "COPYING".
 
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 5/5] stmmac: pci: remove FSF address
  2014-11-03 13:02 ` [PATCH v2 5/5] stmmac: pci: remove FSF address Andy Shevchenko
@ 2014-11-03 20:57   ` David Miller
  2014-11-04  9:06     ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2014-11-03 20:57 UTC (permalink / raw)
  To: andriy.shevchenko
  Cc: peppe.cavallaro, netdev, hock.leong.kweh, vbridgers2013, rayagond

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Mon,  3 Nov 2014 15:02:17 +0200

> The FSF address is subject to change, thus remove it from the file.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I cound 90t instances of this under drivers/net, therefore if this change is
appropriate I'd rather someone script this and kill it across entire
subdirectories.

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 5/5] stmmac: pci: remove FSF address
  2014-11-03 20:57   ` David Miller
@ 2014-11-04  9:06     ` Andy Shevchenko
  2014-11-04 16:25       ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2014-11-04  9:06 UTC (permalink / raw)
  To: David Miller
  Cc: peppe.cavallaro, netdev, hock.leong.kweh, vbridgers2013, rayagond

On Mon, 2014-11-03 at 15:57 -0500, David Miller wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Date: Mon,  3 Nov 2014 15:02:17 +0200
> 
> > The FSF address is subject to change, thus remove it from the file.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> I cound 90t instances of this under drivers/net, therefore if this change is
> appropriate 

Can't find fast the discussion, but there is the commit
4783f894d0f3bfb107cf3b1d9aed1f1a0672ee1d "checkpatch.pl: check for the
FSF mailing address".


> I'd rather someone script this and kill it across entire
> subdirectories.

I'm okay if you don't apply this patch now.


-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 5/5] stmmac: pci: remove FSF address
  2014-11-04  9:06     ` Andy Shevchenko
@ 2014-11-04 16:25       ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2014-11-04 16:25 UTC (permalink / raw)
  To: andriy.shevchenko
  Cc: peppe.cavallaro, netdev, hock.leong.kweh, vbridgers2013, rayagond

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Tue, 04 Nov 2014 11:06:24 +0200

> On Mon, 2014-11-03 at 15:57 -0500, David Miller wrote:
>> I'd rather someone script this and kill it across entire
>> subdirectories.
> 
> I'm okay if you don't apply this patch now.

Then please resubmit this series with it ommitted, you'll have
to update your cover letter as well if the patch is mentioned
there.

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-04 16:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03 13:02 [PATCH v2 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
2014-11-03 13:02 ` [PATCH v2 1/5] stmmac: pci: use defined constant instead of magic number Andy Shevchenko
2014-11-03 13:02 ` [PATCH v2 2/5] stmmac: pci: convert to use dev_pm_ops Andy Shevchenko
2014-11-03 13:02 ` [PATCH v2 3/5] stmmac: pci: use managed resources Andy Shevchenko
2014-11-03 13:02 ` [PATCH v2 4/5] stmmac: pci: convert to use dev_* macros Andy Shevchenko
2014-11-03 13:02 ` [PATCH v2 5/5] stmmac: pci: remove FSF address Andy Shevchenko
2014-11-03 20:57   ` David Miller
2014-11-04  9:06     ` Andy Shevchenko
2014-11-04 16:25       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).