Skip to content

Commit

Permalink
net: dsa: lan9303: check error value from devm_gpiod_get_optional()
Browse files Browse the repository at this point in the history
devm_gpiod_get_optional() can return an error in addition to a NULL ptr.
Check for error and propagate that to the probe function. Check return
value in probe. This will now handle EPROBE_DEFER for the reset gpio.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Phil Reid authored and David S. Miller committed Jan 15, 2018
1 parent a57d476 commit f168913
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/net/dsa/lan9303-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,15 +1292,17 @@ static int lan9303_register_switch(struct lan9303 *chip)
return dsa_register_switch(chip->ds);
}

static void lan9303_probe_reset_gpio(struct lan9303 *chip,
static int lan9303_probe_reset_gpio(struct lan9303 *chip,
struct device_node *np)
{
chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(chip->reset_gpio))
return PTR_ERR(chip->reset_gpio);

if (IS_ERR(chip->reset_gpio)) {
if (!chip->reset_gpio) {
dev_dbg(chip->dev, "No reset GPIO defined\n");
return;
return 0;
}

chip->reset_duration = 200;
Expand All @@ -1315,6 +1317,8 @@ static void lan9303_probe_reset_gpio(struct lan9303 *chip,
/* A sane reset duration should not be longer than 1s */
if (chip->reset_duration > 1000)
chip->reset_duration = 1000;

return 0;
}

int lan9303_probe(struct lan9303 *chip, struct device_node *np)
Expand All @@ -1324,7 +1328,9 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np)
mutex_init(&chip->indirect_mutex);
mutex_init(&chip->alr_mutex);

lan9303_probe_reset_gpio(chip, np);
ret = lan9303_probe_reset_gpio(chip, np);
if (ret)
return ret;

lan9303_handle_reset(chip);

Expand Down

0 comments on commit f168913

Please sign in to comment.