Skip to content

Commit

Permalink
net: ks8851: Use devm_regulator_get_optional()
Browse files Browse the repository at this point in the history
This simplifies error paths and removes the need to
regulator_put().

Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephen Boyd authored and David S. Miller committed May 24, 2014
1 parent 481300c commit c78dbad
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/net/ethernet/micrel/ks8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ static int ks8851_probe(struct spi_device *spi)
ks->spidev = spi;
ks->tx_space = 6144;

ks->vdd_reg = regulator_get_optional(&spi->dev, "vdd");
ks->vdd_reg = devm_regulator_get_optional(&spi->dev, "vdd");
if (IS_ERR(ks->vdd_reg)) {
ret = PTR_ERR(ks->vdd_reg);
if (ret == -EPROBE_DEFER)
Expand All @@ -1427,7 +1427,7 @@ static int ks8851_probe(struct spi_device *spi)
if (ret) {
dev_err(&spi->dev, "regulator enable fail: %d\n",
ret);
goto err_reg_en;
goto err_reg;
}
}

Expand Down Expand Up @@ -1530,9 +1530,6 @@ static int ks8851_probe(struct spi_device *spi)
err_id:
if (!IS_ERR(ks->vdd_reg))
regulator_disable(ks->vdd_reg);
err_reg_en:
if (!IS_ERR(ks->vdd_reg))
regulator_put(ks->vdd_reg);
err_reg:
free_netdev(ndev);
return ret;
Expand All @@ -1547,10 +1544,8 @@ static int ks8851_remove(struct spi_device *spi)

unregister_netdev(priv->netdev);
free_irq(spi->irq, priv);
if (!IS_ERR(priv->vdd_reg)) {
if (!IS_ERR(priv->vdd_reg))
regulator_disable(priv->vdd_reg);
regulator_put(priv->vdd_reg);
}
free_netdev(priv->netdev);

return 0;
Expand Down

0 comments on commit c78dbad

Please sign in to comment.