linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional()
@ 2017-11-13  8:07 Phil Reid
  2017-11-13  8:07 ` [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function Phil Reid
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Phil Reid @ 2017-11-13  8:07 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, preid, netdev, linux-kernel,
	bianpan2016, stable

Replaces Pan Bian <bianpan2016@163.com> patch 
"net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional"

Errors need to be prograted back from probe.

Note: I have only compile tested the code as I don't have the hardware.

Phil Reid (2):
  net: dsa: lan9303: make lan9303_handle_reset() a void function
  net: dsa: lan9303: check error value from devm_gpiod_get_optional()

 drivers/net/dsa/lan9303-core.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function
  2017-11-13  8:07 [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
@ 2017-11-13  8:07 ` Phil Reid
  2017-11-13  8:07 ` [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Phil Reid @ 2017-11-13  8:07 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, preid, netdev, linux-kernel,
	bianpan2016, stable

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 <preid@electromag.com.au>
---
 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 b471413..cc00308 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -550,18 +550,16 @@ static int lan9303_separate_ports(struct lan9303 *chip)
 				LAN9303_SWE_PORT_STATE_BLOCKING_PORT2);
 }
 
-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 */
@@ -855,9 +853,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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional()
  2017-11-13  8:07 [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
  2017-11-13  8:07 ` [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function Phil Reid
@ 2017-11-13  8:07 ` Phil Reid
  2017-11-13 11:32 ` [PATCH 0/2] " Egil Hjelmeland
  2018-01-06 16:54 ` Egil Hjelmeland
  3 siblings, 0 replies; 6+ messages in thread
From: Phil Reid @ 2017-11-13  8:07 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, preid, netdev, linux-kernel,
	bianpan2016, stable

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>
---
 drivers/net/dsa/lan9303-core.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index cc00308..b63173c 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -820,15 +820,18 @@ 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 (!chip->reset_gpio) {
 		dev_dbg(chip->dev, "No reset GPIO defined\n");
-		return;
+		return 0;
 	}
 
 	chip->reset_duration = 200;
@@ -843,6 +846,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)
@@ -851,7 +856,9 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np)
 
 	mutex_init(&chip->indirect_mutex);
 
-	lan9303_probe_reset_gpio(chip, np);
+	ret = lan9303_probe_reset_gpio(chip, np);
+	if (ret)
+		return ret;
 
 	lan9303_handle_reset(chip);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional()
  2017-11-13  8:07 [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
  2017-11-13  8:07 ` [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function Phil Reid
  2017-11-13  8:07 ` [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
@ 2017-11-13 11:32 ` Egil Hjelmeland
  2018-01-06 16:54 ` Egil Hjelmeland
  3 siblings, 0 replies; 6+ messages in thread
From: Egil Hjelmeland @ 2017-11-13 11:32 UTC (permalink / raw)
  To: Phil Reid, andrew, vivien.didelot, f.fainelli, netdev,
	linux-kernel, bianpan2016, stable

On 13. nov. 2017 09:07, Phil Reid wrote:
> Replaces Pan Bian <bianpan2016@163.com> patch
> "net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional"
> 
> Errors need to be prograted back from probe.
> 
> Note: I have only compile tested the code as I don't have the hardware.
> 
> Phil Reid (2):
>    net: dsa: lan9303: make lan9303_handle_reset() a void function
>    net: dsa: lan9303: check error value from devm_gpiod_get_optional()
> 
>   drivers/net/dsa/lan9303-core.c | 21 ++++++++++++---------
>   1 file changed, 12 insertions(+), 9 deletions(-)
> 

I tried this on our HW lan9303, it did not break anything.

Egil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional()
  2017-11-13  8:07 [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
                   ` (2 preceding siblings ...)
  2017-11-13 11:32 ` [PATCH 0/2] " Egil Hjelmeland
@ 2018-01-06 16:54 ` Egil Hjelmeland
  2018-01-09  8:38   ` Phil Reid
  3 siblings, 1 reply; 6+ messages in thread
From: Egil Hjelmeland @ 2018-01-06 16:54 UTC (permalink / raw)
  To: Phil Reid, andrew, vivien.didelot, f.fainelli, netdev,
	linux-kernel, bianpan2016, stable

Den 13. nov. 2017 09:07, skrev Phil Reid:
> Replaces Pan Bian <bianpan2016@163.com> patch
> "net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional"
> 
> Errors need to be prograted back from probe.
> 
> Note: I have only compile tested the code as I don't have the hardware.
> 
> Phil Reid (2):
>    net: dsa: lan9303: make lan9303_handle_reset() a void function
>    net: dsa: lan9303: check error value from devm_gpiod_get_optional()
> 
>   drivers/net/dsa/lan9303-core.c | 21 ++++++++++++---------
>   1 file changed, 12 insertions(+), 9 deletions(-)
> 

Evidently this one did not make it through. Do you care to rebase and 
try again?

Thanks
Egil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional()
  2018-01-06 16:54 ` Egil Hjelmeland
@ 2018-01-09  8:38   ` Phil Reid
  0 siblings, 0 replies; 6+ messages in thread
From: Phil Reid @ 2018-01-09  8:38 UTC (permalink / raw)
  To: Egil Hjelmeland, andrew, vivien.didelot, f.fainelli, netdev,
	linux-kernel, bianpan2016, stable

On 7/01/2018 00:54, Egil Hjelmeland wrote:
> Den 13. nov. 2017 09:07, skrev Phil Reid:
>> Replaces Pan Bian <bianpan2016@163.com> patch
>> "net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional"
>>
>> Errors need to be prograted back from probe.
>>
>> Note: I have only compile tested the code as I don't have the hardware.
>>
>> Phil Reid (2):
>>    net: dsa: lan9303: make lan9303_handle_reset() a void function
>>    net: dsa: lan9303: check error value from devm_gpiod_get_optional()
>>
>>   drivers/net/dsa/lan9303-core.c | 21 ++++++++++++---------
>>   1 file changed, 12 insertions(+), 9 deletions(-)
>>
> 
> Evidently this one did not make it through. Do you care to rebase and try again?
> 
> Thanks
> Egil
> 
> 
Sure I'll give it another go.

-- 
Regards
Phil Reid

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-09  8:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-13  8:07 [PATCH 0/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
2017-11-13  8:07 ` [PATCH 1/2] net: dsa: lan9303: make lan9303_handle_reset() a void function Phil Reid
2017-11-13  8:07 ` [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Phil Reid
2017-11-13 11:32 ` [PATCH 0/2] " Egil Hjelmeland
2018-01-06 16:54 ` Egil Hjelmeland
2018-01-09  8:38   ` Phil Reid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).