Commit b6948e1b authored by Marek Vasut's avatar Marek Vasut Committed by David S. Miller

net: ks8851: Use devm_alloc_etherdev()

Use device managed version of alloc_etherdev() to simplify the code.
No functional change intended.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarMarek 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>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 848fc0ce
...@@ -1421,7 +1421,7 @@ static int ks8851_probe(struct spi_device *spi) ...@@ -1421,7 +1421,7 @@ static int ks8851_probe(struct spi_device *spi)
unsigned cider; unsigned cider;
int gpio; int gpio;
netdev = alloc_etherdev(sizeof(struct ks8851_net)); netdev = devm_alloc_etherdev(dev, sizeof(struct ks8851_net));
if (!netdev) if (!netdev)
return -ENOMEM; return -ENOMEM;
...@@ -1434,10 +1434,8 @@ static int ks8851_probe(struct spi_device *spi) ...@@ -1434,10 +1434,8 @@ static int ks8851_probe(struct spi_device *spi)
ks->tx_space = 6144; ks->tx_space = 6144;
gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL); gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL);
if (gpio == -EPROBE_DEFER) { if (gpio == -EPROBE_DEFER)
ret = gpio; return gpio;
goto err_gpio;
}
ks->gpio = gpio; ks->gpio = gpio;
if (gpio_is_valid(gpio)) { if (gpio_is_valid(gpio)) {
...@@ -1445,7 +1443,7 @@ static int ks8851_probe(struct spi_device *spi) ...@@ -1445,7 +1443,7 @@ static int ks8851_probe(struct spi_device *spi)
GPIOF_OUT_INIT_LOW, "ks8851_rst_n"); GPIOF_OUT_INIT_LOW, "ks8851_rst_n");
if (ret) { if (ret) {
dev_err(dev, "reset gpio request failed\n"); 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) ...@@ -1564,8 +1562,6 @@ static int ks8851_probe(struct spi_device *spi)
err_reg: err_reg:
regulator_disable(ks->vdd_io); regulator_disable(ks->vdd_io);
err_reg_io: err_reg_io:
err_gpio:
free_netdev(netdev);
return ret; return ret;
} }
...@@ -1582,7 +1578,6 @@ static int ks8851_remove(struct spi_device *spi) ...@@ -1582,7 +1578,6 @@ static int ks8851_remove(struct spi_device *spi)
gpio_set_value(priv->gpio, 0); gpio_set_value(priv->gpio, 0);
regulator_disable(priv->vdd_reg); regulator_disable(priv->vdd_reg);
regulator_disable(priv->vdd_io); regulator_disable(priv->vdd_io);
free_netdev(priv->netdev);
return 0; return 0;
} }
......
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