linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] First bunch of cleanups
@ 2020-09-14  0:09 Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 1/3] net: dec: tulip: de2104x: Replace alloc_etherdev by devm_alloc_etherdev Moritz Fischer
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Moritz Fischer @ 2020-09-14  0:09 UTC (permalink / raw)
  To: davem
  Cc: snelson, mst, hkallweit1, netdev, linux-parisc, linux-kernel,
	moritzf, Moritz Fischer

This series is the first bunch of minor cleanups for the de2104x driver
to make it look and behave more like a modern driver.

These changes replace some of the non-devres versions with devres
versions of functions to simplify the error paths.

Next up after this will be the ioremap part.

Moritz Fischer (3):
  net: dec: tulip: de2104x: Replace alloc_etherdev by
    devm_alloc_etherdev
  net: dec: tulip: de2104x: Replace pci_enable_device with devres
    version
  net: dec: tulip: de2104x: Replace kmemdup() with devm_kmempdup()

 drivers/net/ethernet/dec/tulip/de2104x.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

-- 
2.28.0


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

* [PATCH net-next 1/3] net: dec: tulip: de2104x: Replace alloc_etherdev by devm_alloc_etherdev
  2020-09-14  0:09 [PATCH net-next 0/3] First bunch of cleanups Moritz Fischer
@ 2020-09-14  0:10 ` Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 3/3] net: dec: tulip: de2104x: Replace kmemdup() with devm_kmempdup() Moritz Fischer
  2 siblings, 0 replies; 5+ messages in thread
From: Moritz Fischer @ 2020-09-14  0:10 UTC (permalink / raw)
  To: davem
  Cc: snelson, mst, hkallweit1, netdev, linux-parisc, linux-kernel,
	moritzf, Moritz Fischer

Replace devm_alloc_etherdev() with its devres version.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de2104x.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index 42b798a3fad4..9bcfc82b71d1 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -1986,7 +1986,7 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 #endif
 
 	/* allocate a new ethernet device structure, and fill in defaults */
-	dev = alloc_etherdev(sizeof(struct de_private));
+	dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct de_private));
 	if (!dev)
 		return -ENOMEM;
 
@@ -2011,7 +2011,7 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	/* wake up device, assign resources */
 	rc = pci_enable_device(pdev);
 	if (rc)
-		goto err_out_free;
+		return rc;
 
 	/* reserve PCI resources to ensure driver atomicity */
 	rc = pci_request_regions(pdev, DRV_NAME);
@@ -2098,8 +2098,6 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_release_regions(pdev);
 err_out_disable:
 	pci_disable_device(pdev);
-err_out_free:
-	free_netdev(dev);
 	return rc;
 }
 
@@ -2114,7 +2112,6 @@ static void de_remove_one(struct pci_dev *pdev)
 	iounmap(de->regs);
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
-	free_netdev(dev);
 }
 
 #ifdef CONFIG_PM
-- 
2.28.0


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

* [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version
  2020-09-14  0:09 [PATCH net-next 0/3] First bunch of cleanups Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 1/3] net: dec: tulip: de2104x: Replace alloc_etherdev by devm_alloc_etherdev Moritz Fischer
@ 2020-09-14  0:10 ` Moritz Fischer
  2020-09-14  3:04   ` Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 3/3] net: dec: tulip: de2104x: Replace kmemdup() with devm_kmempdup() Moritz Fischer
  2 siblings, 1 reply; 5+ messages in thread
From: Moritz Fischer @ 2020-09-14  0:10 UTC (permalink / raw)
  To: davem
  Cc: snelson, mst, hkallweit1, netdev, linux-parisc, linux-kernel,
	moritzf, Moritz Fischer

Replace pci_enable_device() with its devres counterpart
pcim_enable_device().

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de2104x.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index 9bcfc82b71d1..e4189c45c2ba 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -2009,14 +2009,14 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	netif_carrier_off(dev);
 
 	/* wake up device, assign resources */
-	rc = pci_enable_device(pdev);
+	rc = pcim_enable_device(pdev);
 	if (rc)
 		return rc;
 
 	/* reserve PCI resources to ensure driver atomicity */
 	rc = pci_request_regions(pdev, DRV_NAME);
 	if (rc)
-		goto err_out_disable;
+		return rc;
 
 	/* check for invalid IRQ value */
 	if (pdev->irq < 2) {
@@ -2096,8 +2096,6 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	iounmap(regs);
 err_out_res:
 	pci_release_regions(pdev);
-err_out_disable:
-	pci_disable_device(pdev);
 	return rc;
 }
 
@@ -2111,7 +2109,6 @@ static void de_remove_one(struct pci_dev *pdev)
 	kfree(de->ee_data);
 	iounmap(de->regs);
 	pci_release_regions(pdev);
-	pci_disable_device(pdev);
 }
 
 #ifdef CONFIG_PM
-- 
2.28.0


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

* [PATCH net-next 3/3] net: dec: tulip: de2104x: Replace kmemdup() with devm_kmempdup()
  2020-09-14  0:09 [PATCH net-next 0/3] First bunch of cleanups Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 1/3] net: dec: tulip: de2104x: Replace alloc_etherdev by devm_alloc_etherdev Moritz Fischer
  2020-09-14  0:10 ` [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version Moritz Fischer
@ 2020-09-14  0:10 ` Moritz Fischer
  2 siblings, 0 replies; 5+ messages in thread
From: Moritz Fischer @ 2020-09-14  0:10 UTC (permalink / raw)
  To: davem
  Cc: snelson, mst, hkallweit1, netdev, linux-parisc, linux-kernel,
	moritzf, Moritz Fischer

Replace an instance of kmemdup() with the devres counted version
instead.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/net/ethernet/dec/tulip/de2104x.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index e4189c45c2ba..4933799c6a15 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -1940,7 +1940,8 @@ static void de21041_get_srom_info(struct de_private *de)
 			de->media[i].csr15 = t21041_csr15[i];
 	}
 
-	de->ee_data = kmemdup(&ee_data[0], DE_EEPROM_SIZE, GFP_KERNEL);
+	de->ee_data = devm_kmemdup(&de->pdev->dev, &ee_data[0], DE_EEPROM_SIZE,
+				   GFP_KERNEL);
 
 	return;
 
@@ -2092,7 +2093,6 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	return 0;
 
 err_out_iomap:
-	kfree(de->ee_data);
 	iounmap(regs);
 err_out_res:
 	pci_release_regions(pdev);
@@ -2106,7 +2106,6 @@ static void de_remove_one(struct pci_dev *pdev)
 
 	BUG_ON(!dev);
 	unregister_netdev(dev);
-	kfree(de->ee_data);
 	iounmap(de->regs);
 	pci_release_regions(pdev);
 }
-- 
2.28.0


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

* Re: [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version
  2020-09-14  0:10 ` [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version Moritz Fischer
@ 2020-09-14  3:04   ` Moritz Fischer
  0 siblings, 0 replies; 5+ messages in thread
From: Moritz Fischer @ 2020-09-14  3:04 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: davem, snelson, mst, hkallweit1, netdev, linux-parisc,
	linux-kernel, moritzf

On Sun, Sep 13, 2020 at 05:10:01PM -0700, Moritz Fischer wrote:
> Replace pci_enable_device() with its devres counterpart
> pcim_enable_device().
> 
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/net/ethernet/dec/tulip/de2104x.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
> index 9bcfc82b71d1..e4189c45c2ba 100644
> --- a/drivers/net/ethernet/dec/tulip/de2104x.c
> +++ b/drivers/net/ethernet/dec/tulip/de2104x.c
> @@ -2009,14 +2009,14 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	netif_carrier_off(dev);
>  
>  	/* wake up device, assign resources */
> -	rc = pci_enable_device(pdev);
> +	rc = pcim_enable_device(pdev);
>  	if (rc)
>  		return rc;
>  
>  	/* reserve PCI resources to ensure driver atomicity */
>  	rc = pci_request_regions(pdev, DRV_NAME);
>  	if (rc)
> -		goto err_out_disable;
> +		return rc;
>  
>  	/* check for invalid IRQ value */
>  	if (pdev->irq < 2) {
> @@ -2096,8 +2096,6 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	iounmap(regs);
>  err_out_res:
>  	pci_release_regions(pdev);
> -err_out_disable:
> -	pci_disable_device(pdev);
>  	return rc;
>  }
>  
> @@ -2111,7 +2109,6 @@ static void de_remove_one(struct pci_dev *pdev)
>  	kfree(de->ee_data);
>  	iounmap(de->regs);
>  	pci_release_regions(pdev);
> -	pci_disable_device(pdev);
>  }
>  
>  #ifdef CONFIG_PM
> -- 
> 2.28.0
> 

Ugh, sorry for the noise, I missed the instances in the suspend/resume.
Let me resend a v2 of this ...

Thanks,
Moritz

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

end of thread, other threads:[~2020-09-14  3:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14  0:09 [PATCH net-next 0/3] First bunch of cleanups Moritz Fischer
2020-09-14  0:10 ` [PATCH net-next 1/3] net: dec: tulip: de2104x: Replace alloc_etherdev by devm_alloc_etherdev Moritz Fischer
2020-09-14  0:10 ` [PATCH net-next 2/3] net: dec: tulip: de2104x: Replace pci_enable_device with devres version Moritz Fischer
2020-09-14  3:04   ` Moritz Fischer
2020-09-14  0:10 ` [PATCH net-next 3/3] net: dec: tulip: de2104x: Replace kmemdup() with devm_kmempdup() Moritz Fischer

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).