Skip to content

Commit 687908c

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
net: phy: at803x: simplify using devm_gpiod_get_optional and its 4th argument
Since 39b2bbe (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Moreover use devm_gpiod_get_optional instead of ignoring all errors returned by devm_gpiod_get and simplify accordingly. The result is more strict error handling which is good. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 906a798 commit 687908c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/net/phy/at803x.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,17 @@ static int at803x_probe(struct phy_device *phydev)
192192
{
193193
struct device *dev = &phydev->dev;
194194
struct at803x_priv *priv;
195+
struct gpio_desc *gpiod_reset;
195196

196197
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
197198
if (!priv)
198199
return -ENOMEM;
199200

200-
priv->gpiod_reset = devm_gpiod_get(dev, "reset");
201-
if (IS_ERR(priv->gpiod_reset))
202-
priv->gpiod_reset = NULL;
203-
else
204-
gpiod_direction_output(priv->gpiod_reset, 1);
201+
gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
202+
if (IS_ERR(gpiod_reset))
203+
return PTR_ERR(gpiod_reset);
204+
205+
priv->gpiod_reset = gpiod_reset;
205206

206207
phydev->priv = priv;
207208

0 commit comments

Comments
 (0)