netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: netdev@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>, Andrew Lunn <andrew@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Lukas Wunner <lukas@wunner.de>, Petr Stetiar <ynezz@true.cz>,
	YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH V2 05/14] net: ks8851: Use devm_alloc_etherdev()
Date: Wed, 25 Mar 2020 16:05:34 +0100	[thread overview]
Message-ID: <20200325150543.78569-6-marex@denx.de> (raw)
In-Reply-To: <20200325150543.78569-1-marex@denx.de>

Use device managed version of alloc_etherdev() to simplify the code.
No functional change intended.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Petr Stetiar <ynezz@true.cz>
Cc: YueHaibing <yuehaibing@huawei.com>
---
V2: Add RB from Andrew
---
 drivers/net/ethernet/micrel/ks8851.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 942e694c750a..f0b70b79e7ed 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -1421,7 +1421,7 @@ static int ks8851_probe(struct spi_device *spi)
 	unsigned cider;
 	int gpio;
 
-	netdev = alloc_etherdev(sizeof(struct ks8851_net));
+	netdev = devm_alloc_etherdev(dev, sizeof(struct ks8851_net));
 	if (!netdev)
 		return -ENOMEM;
 
@@ -1434,10 +1434,8 @@ static int ks8851_probe(struct spi_device *spi)
 	ks->tx_space = 6144;
 
 	gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL);
-	if (gpio == -EPROBE_DEFER) {
-		ret = gpio;
-		goto err_gpio;
-	}
+	if (gpio == -EPROBE_DEFER)
+		return gpio;
 
 	ks->gpio = gpio;
 	if (gpio_is_valid(gpio)) {
@@ -1445,7 +1443,7 @@ static int ks8851_probe(struct spi_device *spi)
 					    GPIOF_OUT_INIT_LOW, "ks8851_rst_n");
 		if (ret) {
 			dev_err(dev, "reset gpio request failed\n");
-			goto err_gpio;
+			return ret;
 		}
 	}
 
@@ -1564,8 +1562,6 @@ static int ks8851_probe(struct spi_device *spi)
 err_reg:
 	regulator_disable(ks->vdd_io);
 err_reg_io:
-err_gpio:
-	free_netdev(netdev);
 	return ret;
 }
 
@@ -1582,7 +1578,6 @@ static int ks8851_remove(struct spi_device *spi)
 		gpio_set_value(priv->gpio, 0);
 	regulator_disable(priv->vdd_reg);
 	regulator_disable(priv->vdd_io);
-	free_netdev(priv->netdev);
 
 	return 0;
 }
-- 
2.25.1


  parent reply	other threads:[~2020-03-25 15:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 15:05 [PATCH V2 00/14] net: ks8851: Unify KS8851 SPI and MLL drivers Marek Vasut
2020-03-25 15:05 ` [PATCH V2 01/14] net: ks8851: Factor out spi->dev in probe()/remove() Marek Vasut
2020-03-25 15:05 ` [PATCH V2 02/14] net: ks8851: Rename ndev to netdev in probe Marek Vasut
2020-03-25 15:05 ` [PATCH V2 03/14] net: ks8851: Replace dev_err() with netdev_err() in IRQ handler Marek Vasut
2020-03-25 15:05 ` [PATCH V2 04/14] net: ks8851: Pass device node into ks8851_init_mac() Marek Vasut
2020-03-25 15:05 ` Marek Vasut [this message]
2020-03-25 15:05 ` [PATCH V2 06/14] net: ks8851: Use dev_{get,set}_drvdata() Marek Vasut
2020-03-25 15:05 ` [PATCH V2 07/14] net: ks8851: Remove ks8851_rdreg32() Marek Vasut
2020-03-25 15:05 ` [PATCH V2 08/14] net: ks8851: Use 16-bit writes to program MAC address Marek Vasut
2020-03-25 16:56   ` Michal Kubecek
2020-03-25 17:05     ` Marek Vasut
2020-03-25 17:30       ` Michal Kubecek
2020-03-27 18:16         ` Marek Vasut
2020-03-25 15:05 ` [PATCH V2 09/14] net: ks8851: Use 16-bit read of RXFC register Marek Vasut
2020-03-25 15:05 ` [PATCH V2 10/14] net: ks8851: Split out SPI specific entries in struct ks8851_net Marek Vasut
2020-03-25 15:05 ` [PATCH V2 11/14] net: ks8851: Split out SPI specific code from probe() and remove() Marek Vasut
2020-03-25 15:05 ` [PATCH V2 12/14] net: ks8851: Separate SPI operations into separate file Marek Vasut
2020-03-25 15:05 ` [PATCH V2 13/14] net: ks8851: Implement Parallel bus operations Marek Vasut
2020-03-25 15:05 ` [PATCH V2 14/14] net: ks8851: Remove ks8851_mll.c Marek Vasut
2020-03-26 19:02 ` [PATCH V2 00/14] net: ks8851: Unify KS8851 SPI and MLL drivers Lukas Wunner
2020-03-27 18:18   ` Marek Vasut
2020-03-27 19:25     ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325150543.78569-6-marex@denx.de \
    --to=marex@denx.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=ynezz@true.cz \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).