* [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe()
@ 2025-08-30 17:13 Christophe JAILLET
2025-08-30 19:24 ` Andrew Lunn
2025-09-01 19:46 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-08-30 17:13 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Russell King, Helmut Buchsbaum
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev
If an error occurs after calling gpiod_set_value_cansleep(..., 0), it must
be undone by a corresponding gpiod_set_value_cansleep(..., 1) call as
already done in the remove function.
In order to easily do the needed clean-up in the probe, add a new
devm_add_action_or_reset() call and simplify the remove function
accordingly.
Fixes: cd6f288cbaab ("net: phy: spi_ks8995: add support for resetting switch using GPIO")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
drivers/net/dsa/ks8995.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/ks8995.c b/drivers/net/dsa/ks8995.c
index 5c4c83e00477..debb2cd7ab61 100644
--- a/drivers/net/dsa/ks8995.c
+++ b/drivers/net/dsa/ks8995.c
@@ -742,6 +742,14 @@ static const struct dsa_switch_ops ks8995_ds_ops = {
.phylink_get_caps = ks8995_phylink_get_caps,
};
+static void devm_reset_assert(void *data)
+{
+ struct ks8995_switch *ks = data;
+
+ /* assert reset */
+ gpiod_set_value_cansleep(ks->reset_gpio, 1);
+}
+
/* ------------------------------------------------------------------------ */
static int ks8995_probe(struct spi_device *spi)
{
@@ -784,6 +792,11 @@ static int ks8995_probe(struct spi_device *spi)
*/
gpiod_set_value_cansleep(ks->reset_gpio, 0);
udelay(100);
+
+ err = devm_add_action_or_reset(&spi->dev,
+ devm_reset_assert, ks);
+ if (err)
+ return err;
}
spi_set_drvdata(spi, ks);
@@ -834,8 +847,6 @@ static void ks8995_remove(struct spi_device *spi)
struct ks8995_switch *ks = spi_get_drvdata(spi);
dsa_unregister_switch(ks->ds);
- /* assert reset */
- gpiod_set_value_cansleep(ks->reset_gpio, 1);
}
/* ------------------------------------------------------------------------ */
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe()
2025-08-30 17:13 [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe() Christophe JAILLET
@ 2025-08-30 19:24 ` Andrew Lunn
2025-09-01 19:46 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2025-08-30 19:24 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Russell King, Helmut Buchsbaum, linux-kernel,
kernel-janitors, netdev
On Sat, Aug 30, 2025 at 07:13:59PM +0200, Christophe JAILLET wrote:
> If an error occurs after calling gpiod_set_value_cansleep(..., 0), it must
> be undone by a corresponding gpiod_set_value_cansleep(..., 1) call as
> already done in the remove function.
>
> In order to easily do the needed clean-up in the probe, add a new
> devm_add_action_or_reset() call and simplify the remove function
> accordingly.
>
> Fixes: cd6f288cbaab ("net: phy: spi_ks8995: add support for resetting switch using GPIO")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe()
2025-08-30 17:13 [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe() Christophe JAILLET
2025-08-30 19:24 ` Andrew Lunn
@ 2025-09-01 19:46 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-09-01 19:46 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Paolo Abeni, Russell King, Helmut Buchsbaum, linux-kernel,
kernel-janitors, netdev
On Sat, 30 Aug 2025 19:13:59 +0200 Christophe JAILLET wrote:
> drivers/net/dsa/ks8995.c
This file got renamed from drivers/net/phy/spi_ks8995.c in net-next,
this needs to be regenerated against the real net tree.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-01 19:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30 17:13 [PATCH net] net: dsa: ks8995: Fix some error handling path in ks8995_probe() Christophe JAILLET
2025-08-30 19:24 ` Andrew Lunn
2025-09-01 19:46 ` Jakub Kicinski
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).