The DSA framework requires that dsa_switch_shutdown() be called when the driver is shut down. Make sure to also implement the mutual exclusion required by checking the platform data pointer to be NULL in .remove() and .shutdown(). Fixes: a7fe8b266f65 ("net: dsa: ks8995: Add basic switch set-up") Reported-by: Vladimir Oltean Signed-off-by: Linus Walleij --- drivers/net/dsa/ks8995.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/dsa/ks8995.c b/drivers/net/dsa/ks8995.c index 77d8b842693c..2522c9057382 100644 --- a/drivers/net/dsa/ks8995.c +++ b/drivers/net/dsa/ks8995.c @@ -833,11 +833,26 @@ static void ks8995_remove(struct spi_device *spi) { struct ks8995_switch *ks = spi_get_drvdata(spi); + if (!ks) + return; + dsa_unregister_switch(ks->ds); /* assert reset */ gpiod_set_value_cansleep(ks->reset_gpio, 1); } +static void ks8995_shutdown(struct spi_device *spi) +{ + struct ks8995_switch *ks = spi_get_drvdata(spi); + + if (!ks) + return; + + dsa_switch_shutdown(ks->ds); + + spi_set_drvdata(spi, NULL); +} + /* ------------------------------------------------------------------------ */ static struct spi_driver ks8995_driver = { .driver = { @@ -846,6 +861,7 @@ static struct spi_driver ks8995_driver = { }, .probe = ks8995_probe, .remove = ks8995_remove, + .shutdown = ks8995_shutdown, .id_table = ks8995_id, }; -- 2.53.0