* [PATCH net-next v4 0/3] net: dsa: realtek: support reset controller and update docs
@ 2024-02-19 23:44 Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 1/3] dt-bindings: net: dsa: realtek: reset-gpios is not required Luiz Angelo Daros de Luca
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Luiz Angelo Daros de Luca @ 2024-02-19 23:44 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Philipp Zabel
Cc: netdev, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
Arınç ÜNAL, Rob Herring
The driver previously supported reset pins using GPIO, but it lacked
support for reset controllers. Although a reset method is generally not
required, the driver fails to detect the switch if the reset was kept
asserted by a previous driver.
This series adds support to reset a Realtek switch using a reset
controller. It also updates the binding documentation to remove the
requirement of a reset method and to add the new reset controller
property.
It was tested on a TL-WR1043ND v1 router (rtl8366rb via SMI).
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
Changes in v4:
- do not test for priv->reset,priv->reset_ctl
- updated commit message
- Link to v3: https://lore.kernel.org/r/20240213-realtek-reset-v3-0-37837e574713@gmail.com
Changes in v3:
- Rebased on the Realtek DSA driver refactoring (08f627164126)
- Dropped the reset controller example in bindings
- Used %pe in error printing
- Linked to v2: https://lore.kernel.org/r/20231027190910.27044-1-luizluca@gmail.com/
Changes in v2:
- Introduced a dedicated commit for removing the reset-gpios requirement
- Placed binding patches before code changes
- Removed the 'reset-names' property
- Moved the example from the commit message to realtek.yaml
- Split the reset function into _assert/_deassert variants
- Modified reset functions to return a warning instead of a value
- Utilized devm_reset_control_get_optional to prevent failure when the
reset control is missing
- Used 'true' and 'false' for boolean values
- Removed the CONFIG_RESET_CONTROLLER check as stub methods are
sufficient when undefined
- Linked to v1: https://lore.kernel.org/r/20231024205805.19314-1-luizluca@gmail.com/
---
Luiz Angelo Daros de Luca (3):
dt-bindings: net: dsa: realtek: reset-gpios is not required
dt-bindings: net: dsa: realtek: add reset controller
net: dsa: realtek: support reset controller
.../devicetree/bindings/net/dsa/realtek.yaml | 4 +-
drivers/net/dsa/realtek/realtek.h | 2 +
drivers/net/dsa/realtek/rtl83xx.c | 46 +++++++++++++++++++---
drivers/net/dsa/realtek/rtl83xx.h | 2 +
4 files changed, 48 insertions(+), 6 deletions(-)
---
base-commit: d1d77120bc2867b3e449e07ee656a26b2fb03d1e
change-id: 20240212-realtek-reset-88a0bf25bb22
Best regards,
--
Luiz Angelo Daros de Luca <luizluca@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v4 1/3] dt-bindings: net: dsa: realtek: reset-gpios is not required
2024-02-19 23:44 [PATCH net-next v4 0/3] net: dsa: realtek: support reset controller and update docs Luiz Angelo Daros de Luca
@ 2024-02-19 23:44 ` Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 2/3] dt-bindings: net: dsa: realtek: add reset controller Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 3/3] net: dsa: realtek: support " Luiz Angelo Daros de Luca
2 siblings, 0 replies; 8+ messages in thread
From: Luiz Angelo Daros de Luca @ 2024-02-19 23:44 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Philipp Zabel
Cc: netdev, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
Arınç ÜNAL, Rob Herring
The 'reset-gpios' should not be mandatory. although they might be
required for some devices if the switch reset was left asserted by a
previous driver, such as the bootloader.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: devicetree@vger.kernel.org
Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
---
Documentation/devicetree/bindings/net/dsa/realtek.yaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/dsa/realtek.yaml b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
index cce692f57b08..46e113df77c8 100644
--- a/Documentation/devicetree/bindings/net/dsa/realtek.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
@@ -127,7 +127,6 @@ else:
- mdc-gpios
- mdio-gpios
- mdio
- - reset-gpios
required:
- compatible
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v4 2/3] dt-bindings: net: dsa: realtek: add reset controller
2024-02-19 23:44 [PATCH net-next v4 0/3] net: dsa: realtek: support reset controller and update docs Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 1/3] dt-bindings: net: dsa: realtek: reset-gpios is not required Luiz Angelo Daros de Luca
@ 2024-02-19 23:44 ` Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 3/3] net: dsa: realtek: support " Luiz Angelo Daros de Luca
2 siblings, 0 replies; 8+ messages in thread
From: Luiz Angelo Daros de Luca @ 2024-02-19 23:44 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Philipp Zabel
Cc: netdev, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
Arınç ÜNAL, Rob Herring
Realtek switches can use a reset controller instead of reset-gpios.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: devicetree@vger.kernel.org
Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Acked-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/net/dsa/realtek.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/dsa/realtek.yaml b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
index 46e113df77c8..70b6bda3cf98 100644
--- a/Documentation/devicetree/bindings/net/dsa/realtek.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
@@ -59,6 +59,9 @@ properties:
description: GPIO to be used to reset the whole device
maxItems: 1
+ resets:
+ maxItems: 1
+
realtek,disable-leds:
type: boolean
description: |
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v4 3/3] net: dsa: realtek: support reset controller
2024-02-19 23:44 [PATCH net-next v4 0/3] net: dsa: realtek: support reset controller and update docs Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 1/3] dt-bindings: net: dsa: realtek: reset-gpios is not required Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 2/3] dt-bindings: net: dsa: realtek: add reset controller Luiz Angelo Daros de Luca
@ 2024-02-19 23:44 ` Luiz Angelo Daros de Luca
2024-02-20 10:26 ` Alvin Šipraga
2 siblings, 1 reply; 8+ messages in thread
From: Luiz Angelo Daros de Luca @ 2024-02-19 23:44 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Philipp Zabel
Cc: netdev, devicetree, linux-kernel, Luiz Angelo Daros de Luca
Add support for resetting the device using a reset controller,
complementing the existing GPIO reset functionality (reset-gpios).
Although the reset is optional and the driver performs a soft reset
during setup, if the initial reset pin state was asserted, the driver
will not detect the device until the reset is deasserted.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/net/dsa/realtek/realtek.h | 2 ++
drivers/net/dsa/realtek/rtl83xx.c | 46 ++++++++++++++++++++++++++++++++++-----
drivers/net/dsa/realtek/rtl83xx.h | 2 ++
3 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h
index b80bfde1ad04..e0b1aa01337b 100644
--- a/drivers/net/dsa/realtek/realtek.h
+++ b/drivers/net/dsa/realtek/realtek.h
@@ -12,6 +12,7 @@
#include <linux/platform_device.h>
#include <linux/gpio/consumer.h>
#include <net/dsa.h>
+#include <linux/reset.h>
#define REALTEK_HW_STOP_DELAY 25 /* msecs */
#define REALTEK_HW_START_DELAY 100 /* msecs */
@@ -48,6 +49,7 @@ struct rtl8366_vlan_4k {
struct realtek_priv {
struct device *dev;
+ struct reset_control *reset_ctl;
struct gpio_desc *reset;
struct gpio_desc *mdc;
struct gpio_desc *mdio;
diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
index 801873754df2..8262ec5032a4 100644
--- a/drivers/net/dsa/realtek/rtl83xx.c
+++ b/drivers/net/dsa/realtek/rtl83xx.c
@@ -184,6 +184,13 @@ rtl83xx_probe(struct device *dev,
"realtek,disable-leds");
/* TODO: if power is software controlled, set up any regulators here */
+ priv->reset_ctl = devm_reset_control_get_optional(dev, NULL);
+ if (IS_ERR(priv->reset_ctl)) {
+ ret = PTR_ERR(priv->reset_ctl);
+ dev_err_probe(dev, ret, "failed to get reset control\n");
+ return ERR_CAST(priv->reset_ctl);
+ }
+
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(priv->reset)) {
dev_err(dev, "failed to get RESET GPIO\n");
@@ -192,11 +199,11 @@ rtl83xx_probe(struct device *dev,
dev_set_drvdata(dev, priv);
- if (priv->reset) {
- gpiod_set_value(priv->reset, 1);
+ if (priv->reset_ctl || priv->reset) {
+ rtl83xx_reset_assert(priv);
dev_dbg(dev, "asserted RESET\n");
msleep(REALTEK_HW_STOP_DELAY);
- gpiod_set_value(priv->reset, 0);
+ rtl83xx_reset_deassert(priv);
msleep(REALTEK_HW_START_DELAY);
dev_dbg(dev, "deasserted RESET\n");
}
@@ -292,11 +299,40 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_shutdown, REALTEK_DSA);
void rtl83xx_remove(struct realtek_priv *priv)
{
/* leave the device reset asserted */
- if (priv->reset)
- gpiod_set_value(priv->reset, 1);
+ rtl83xx_reset_assert(priv);
}
EXPORT_SYMBOL_NS_GPL(rtl83xx_remove, REALTEK_DSA);
+void rtl83xx_reset_assert(struct realtek_priv *priv)
+{
+ int ret;
+
+ ret = reset_control_assert(priv->reset_ctl);
+ if (!ret)
+ return;
+
+ dev_warn(priv->dev,
+ "Failed to assert the switch reset control: %pe\n",
+ ERR_PTR(ret));
+
+ gpiod_set_value(priv->reset, true);
+}
+
+void rtl83xx_reset_deassert(struct realtek_priv *priv)
+{
+ int ret;
+
+ ret = reset_control_deassert(priv->reset_ctl);
+ if (!ret)
+ return;
+
+ dev_warn(priv->dev,
+ "Failed to deassert the switch reset control: %pe\n",
+ ERR_PTR(ret));
+
+ gpiod_set_value(priv->reset, false);
+}
+
MODULE_AUTHOR("Luiz Angelo Daros de Luca <luizluca@gmail.com>");
MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
MODULE_DESCRIPTION("Realtek DSA switches common module");
diff --git a/drivers/net/dsa/realtek/rtl83xx.h b/drivers/net/dsa/realtek/rtl83xx.h
index 0ddff33df6b0..c8a0ff8fd75e 100644
--- a/drivers/net/dsa/realtek/rtl83xx.h
+++ b/drivers/net/dsa/realtek/rtl83xx.h
@@ -18,5 +18,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv);
void rtl83xx_unregister_switch(struct realtek_priv *priv);
void rtl83xx_shutdown(struct realtek_priv *priv);
void rtl83xx_remove(struct realtek_priv *priv);
+void rtl83xx_reset_assert(struct realtek_priv *priv);
+void rtl83xx_reset_deassert(struct realtek_priv *priv);
#endif /* _RTL83XX_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 3/3] net: dsa: realtek: support reset controller
2024-02-19 23:44 ` [PATCH net-next v4 3/3] net: dsa: realtek: support " Luiz Angelo Daros de Luca
@ 2024-02-20 10:26 ` Alvin Šipraga
2024-02-20 12:22 ` Luiz Angelo Daros de Luca
0 siblings, 1 reply; 8+ messages in thread
From: Alvin Šipraga @ 2024-02-20 10:26 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Linus Walleij, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
On Mon, Feb 19, 2024 at 08:44:42PM -0300, Luiz Angelo Daros de Luca wrote:
> +void rtl83xx_reset_assert(struct realtek_priv *priv)
> +{
> + int ret;
> +
> + ret = reset_control_assert(priv->reset_ctl);
> + if (!ret)
> + return;
If priv->reset_ctl is NULL - i.e. if no DT property is specified - then
this will always return early and the GPIO will not be asserted.
> +
> + dev_warn(priv->dev,
> + "Failed to assert the switch reset control: %pe\n",
> + ERR_PTR(ret));
You only log an error if the reset controller assert fails, but not if
the GPIO assert fails. Why the unequal treatment?
I suggest keeping it simple:
void rtl83xx_reset_assert(struct realtek_priv *priv)
{
int ret;
ret = reset_control_assert(priv->reset_ctl);
if (ret)
dev_warn(priv->dev, "failed to assert reset control: %d\n", ret);
ret = gpiod_set_value(priv->reset, false);
if (ret)
dev_warn(priv->dev, "failed to assert reset GPIO: %d\n", ret);
}
or even drop the warnings altogether.
> +
> + gpiod_set_value(priv->reset, true);
> +}
> +
> +void rtl83xx_reset_deassert(struct realtek_priv *priv)
> +{
> + int ret;
> +
> + ret = reset_control_deassert(priv->reset_ctl);
> + if (!ret)
> + return;
> +
> + dev_warn(priv->dev,
> + "Failed to deassert the switch reset control: %pe\n",
> + ERR_PTR(ret));
> +
> + gpiod_set_value(priv->reset, false);
> +}
Same comments apply to this function. Just deassert both.
> +
> MODULE_AUTHOR("Luiz Angelo Daros de Luca <luizluca@gmail.com>");
> MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
> MODULE_DESCRIPTION("Realtek DSA switches common module");
> diff --git a/drivers/net/dsa/realtek/rtl83xx.h b/drivers/net/dsa/realtek/rtl83xx.h
> index 0ddff33df6b0..c8a0ff8fd75e 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.h
> +++ b/drivers/net/dsa/realtek/rtl83xx.h
> @@ -18,5 +18,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv);
> void rtl83xx_unregister_switch(struct realtek_priv *priv);
> void rtl83xx_shutdown(struct realtek_priv *priv);
> void rtl83xx_remove(struct realtek_priv *priv);
> +void rtl83xx_reset_assert(struct realtek_priv *priv);
> +void rtl83xx_reset_deassert(struct realtek_priv *priv);
>
> #endif /* _RTL83XX_H */
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 3/3] net: dsa: realtek: support reset controller
2024-02-20 10:26 ` Alvin Šipraga
@ 2024-02-20 12:22 ` Luiz Angelo Daros de Luca
2024-02-20 13:30 ` Alvin Šipraga
0 siblings, 1 reply; 8+ messages in thread
From: Luiz Angelo Daros de Luca @ 2024-02-20 12:22 UTC (permalink / raw)
To: Alvin Šipraga
Cc: Linus Walleij, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Alvin,
> On Mon, Feb 19, 2024 at 08:44:42PM -0300, Luiz Angelo Daros de Luca wrote:
> > +void rtl83xx_reset_assert(struct realtek_priv *priv)
> > +{
> > + int ret;
> > +
> > + ret = reset_control_assert(priv->reset_ctl);
> > + if (!ret)
> > + return;
>
> If priv->reset_ctl is NULL - i.e. if no DT property is specified - then
> this will always return early and the GPIO will not be asserted.
I made a mistake. I should be
if (ret) {
dev_warn...
}
not returning on error (as you suggested below).
I was sure I was doing just that... I was surprised to see it as it
is. I'll recheck my branch with all the integrated changes. It passed
my tests as when reset is missed, it normally does not matter. Thanks
for the catch.
>
> > +
> > + dev_warn(priv->dev,
> > + "Failed to assert the switch reset control: %pe\n",
> > + ERR_PTR(ret));
>
> You only log an error if the reset controller assert fails, but not if
> the GPIO assert fails. Why the unequal treatment?
Because it does not return a value. There is no way to tell if it failed.
>
> I suggest keeping it simple:
>
> void rtl83xx_reset_assert(struct realtek_priv *priv)
> {
> int ret;
>
> ret = reset_control_assert(priv->reset_ctl);
> if (ret)
> dev_warn(priv->dev, "failed to assert reset control: %d\n", ret);
>
> ret = gpiod_set_value(priv->reset, false);
> if (ret)
> dev_warn(priv->dev, "failed to assert reset GPIO: %d\n", ret);
> }
>
> or even drop the warnings altogether.
>
> > +
> > + gpiod_set_value(priv->reset, true);
> > +}
> > +
> > +void rtl83xx_reset_deassert(struct realtek_priv *priv)
> > +{
> > + int ret;
> > +
> > + ret = reset_control_deassert(priv->reset_ctl);
> > + if (!ret)
> > + return;
> > +
> > + dev_warn(priv->dev,
> > + "Failed to deassert the switch reset control: %pe\n",
> > + ERR_PTR(ret));
> > +
> > + gpiod_set_value(priv->reset, false);
> > +}
>
> Same comments apply to this function. Just deassert both.
>
> > +
> > MODULE_AUTHOR("Luiz Angelo Daros de Luca <luizluca@gmail.com>");
> > MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
> > MODULE_DESCRIPTION("Realtek DSA switches common module");
> > diff --git a/drivers/net/dsa/realtek/rtl83xx.h b/drivers/net/dsa/realtek/rtl83xx.h
> > index 0ddff33df6b0..c8a0ff8fd75e 100644
> > --- a/drivers/net/dsa/realtek/rtl83xx.h
> > +++ b/drivers/net/dsa/realtek/rtl83xx.h
> > @@ -18,5 +18,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv);
> > void rtl83xx_unregister_switch(struct realtek_priv *priv);
> > void rtl83xx_shutdown(struct realtek_priv *priv);
> > void rtl83xx_remove(struct realtek_priv *priv);
> > +void rtl83xx_reset_assert(struct realtek_priv *priv);
> > +void rtl83xx_reset_deassert(struct realtek_priv *priv);
> >
> > #endif /* _RTL83XX_H */
> >
> > --
> > 2.43.0
> >
Regards,
Luiz
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 3/3] net: dsa: realtek: support reset controller
2024-02-20 12:22 ` Luiz Angelo Daros de Luca
@ 2024-02-20 13:30 ` Alvin Šipraga
2024-02-20 13:42 ` Alvin Šipraga
0 siblings, 1 reply; 8+ messages in thread
From: Alvin Šipraga @ 2024-02-20 13:30 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Linus Walleij, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
On Tue, Feb 20, 2024 at 09:22:44AM -0300, Luiz Angelo Daros de Luca wrote:
> Hi Alvin,
>
> > On Mon, Feb 19, 2024 at 08:44:42PM -0300, Luiz Angelo Daros de Luca wrote:
> > > +void rtl83xx_reset_assert(struct realtek_priv *priv)
> > > +{
> > > + int ret;
> > > +
> > > + ret = reset_control_assert(priv->reset_ctl);
> > > + if (!ret)
> > > + return;
> >
> > If priv->reset_ctl is NULL - i.e. if no DT property is specified - then
> > this will always return early and the GPIO will not be asserted.
>
> I made a mistake. I should be
>
> if (ret) {
> dev_warn...
> }
>
> not returning on error (as you suggested below).
>
> I was sure I was doing just that... I was surprised to see it as it
> is. I'll recheck my branch with all the integrated changes. It passed
> my tests as when reset is missed, it normally does not matter. Thanks
> for the catch.
>
> >
> > > +
> > > + dev_warn(priv->dev,
> > > + "Failed to assert the switch reset control: %pe\n",
> > > + ERR_PTR(ret));
> >
> > You only log an error if the reset controller assert fails, but not if
> > the GPIO assert fails. Why the unequal treatment?
>
> Because it does not return a value. There is no way to tell if it failed.
Ah ok, nevermind that part then.
BTW, please use gpiod_set_value_cansleep(). With that I think this is good.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v4 3/3] net: dsa: realtek: support reset controller
2024-02-20 13:30 ` Alvin Šipraga
@ 2024-02-20 13:42 ` Alvin Šipraga
0 siblings, 0 replies; 8+ messages in thread
From: Alvin Šipraga @ 2024-02-20 13:42 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Linus Walleij, Andrew Lunn, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
On Tue, Feb 20, 2024 at 01:30:33PM +0000, Alvin Šipraga wrote:
> On Tue, Feb 20, 2024 at 09:22:44AM -0300, Luiz Angelo Daros de Luca wrote:
> > Hi Alvin,
> >
> > > On Mon, Feb 19, 2024 at 08:44:42PM -0300, Luiz Angelo Daros de Luca wrote:
> > > > +void rtl83xx_reset_assert(struct realtek_priv *priv)
> > > > +{
> > > > + int ret;
> > > > +
> > > > + ret = reset_control_assert(priv->reset_ctl);
> > > > + if (!ret)
> > > > + return;
> > >
> > > If priv->reset_ctl is NULL - i.e. if no DT property is specified - then
> > > this will always return early and the GPIO will not be asserted.
> >
> > I made a mistake. I should be
> >
> > if (ret) {
> > dev_warn...
> > }
> >
> > not returning on error (as you suggested below).
> >
> > I was sure I was doing just that... I was surprised to see it as it
> > is. I'll recheck my branch with all the integrated changes. It passed
> > my tests as when reset is missed, it normally does not matter. Thanks
> > for the catch.
> >
> > >
> > > > +
> > > > + dev_warn(priv->dev,
> > > > + "Failed to assert the switch reset control: %pe\n",
> > > > + ERR_PTR(ret));
> > >
> > > You only log an error if the reset controller assert fails, but not if
> > > the GPIO assert fails. Why the unequal treatment?
> >
> > Because it does not return a value. There is no way to tell if it failed.
>
> Ah ok, nevermind that part then.
>
> BTW, please use gpiod_set_value_cansleep(). With that I think this is good.
OK, actually the original code wasn't doing that, so not crucial for this
change. It can be done in a follow-up.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-02-20 13:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-19 23:44 [PATCH net-next v4 0/3] net: dsa: realtek: support reset controller and update docs Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 1/3] dt-bindings: net: dsa: realtek: reset-gpios is not required Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 2/3] dt-bindings: net: dsa: realtek: add reset controller Luiz Angelo Daros de Luca
2024-02-19 23:44 ` [PATCH net-next v4 3/3] net: dsa: realtek: support " Luiz Angelo Daros de Luca
2024-02-20 10:26 ` Alvin Šipraga
2024-02-20 12:22 ` Luiz Angelo Daros de Luca
2024-02-20 13:30 ` Alvin Šipraga
2024-02-20 13:42 ` Alvin Šipraga
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).