From a57d476d9707a470bbdcbd1ab00df73b55650bf7 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Wed, 10 Jan 2018 15:39:32 +0800 Subject: [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function lan9303_handle_reset never returns anything other than success. So there's not need for it to return an error code. Signed-off-by: Phil Reid Signed-off-by: David S. Miller --- drivers/net/dsa/lan9303-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 2dead7fa1f93..4ad7dbea2a6f 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -817,18 +817,16 @@ static void lan9303_bridge_ports(struct lan9303 *chip) lan9303_alr_add_port(chip, eth_stp_addr, 0, true); } -static int lan9303_handle_reset(struct lan9303 *chip) +static void lan9303_handle_reset(struct lan9303 *chip) { if (!chip->reset_gpio) - return 0; + return; if (chip->reset_duration != 0) msleep(chip->reset_duration); /* release (deassert) reset and activate the device */ gpiod_set_value_cansleep(chip->reset_gpio, 0); - - return 0; } /* stop processing packets for all ports */ @@ -1328,9 +1326,7 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np) lan9303_probe_reset_gpio(chip, np); - ret = lan9303_handle_reset(chip); - if (ret) - return ret; + lan9303_handle_reset(chip); ret = lan9303_check_device(chip); if (ret) From f16891326c1c6e6b0f17f60cb6921a145a13e017 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Wed, 10 Jan 2018 15:39:33 +0800 Subject: [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() 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 Signed-off-by: David S. Miller --- drivers/net/dsa/lan9303-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 4ad7dbea2a6f..6171c0853ff1 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -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; @@ -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) @@ -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);