[PATCH net-next v5 12/14] net: renesas: rswitch: add passing of rswitch_private into notifiers
flat view
STALE140d
From: Michael Dege <hidden>
Date: 2026-05-22 12:13:38
Also in:
linux-renesas-soc, lkml
Subsystem:
networking drivers, renesas ethernet switch driver, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
Revision v5 of 5 in this series.
Revisions (5)
Provide struct rswitch_private to notifiers. This will be needed to access the HW in the notification handlers. Signed-off-by: Michael Dege <redacted> --- drivers/net/ethernet/renesas/rswitch.h | 5 +++ drivers/net/ethernet/renesas/rswitch_l2.c | 45 ++++++++++------------- drivers/net/ethernet/renesas/rswitch_l2.h | 6 ++-- drivers/net/ethernet/renesas/rswitch_main.c | 56 +++++++++++++++-------------- 4 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h
index 736762912acf..9777966ebe0e 100644
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h@@ -1201,6 +1201,11 @@ struct rswitch_private { struct rswitch_etha etha[RSWITCH_NUM_PORTS]; struct rswitch_mfwd mfwd; + /* Notifiers */ + struct notifier_block rswitch_netdevice_nb; + struct notifier_block rswitch_switchdev_nb; + struct notifier_block rswitch_switchdev_blocking_nb; + struct list_head port_list; spinlock_t lock; /* lock interrupt registers' control */
diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
index c76fc8121ef0..d2deb7cb7634 100644
--- a/drivers/net/ethernet/renesas/rswitch_l2.c
+++ b/drivers/net/ethernet/renesas/rswitch_l2.c@@ -285,48 +285,39 @@ static int rswitch_switchdev_blocking_event(struct notifier_block *nb, return notifier_from_errno(ret); } -static struct notifier_block rswitch_netdevice_nb = { - .notifier_call = rswitch_netdevice_event, -}; - -static struct notifier_block rswitch_switchdev_nb = { - .notifier_call = rswitch_switchdev_event, -}; - -static struct notifier_block rswitch_switchdev_blocking_nb = { - .notifier_call = rswitch_switchdev_blocking_event, -}; - -int rswitch_register_notifiers(void) +int rswitch_register_notifiers(struct rswitch_private *priv) { - int ret; + int err; - ret = register_netdevice_notifier(&rswitch_netdevice_nb); - if (ret) + priv->rswitch_netdevice_nb.notifier_call = rswitch_netdevice_event; + err = register_netdevice_notifier(&priv->rswitch_netdevice_nb); + if (err) goto register_netdevice_notifier_failed; - ret = register_switchdev_notifier(&rswitch_switchdev_nb); - if (ret) + priv->rswitch_switchdev_nb.notifier_call = rswitch_switchdev_event; + err = register_switchdev_notifier(&priv->rswitch_switchdev_nb); + if (err) goto register_switchdev_notifier_failed; - ret = register_switchdev_blocking_notifier(&rswitch_switchdev_blocking_nb); - if (ret) + priv->rswitch_switchdev_blocking_nb.notifier_call = rswitch_switchdev_blocking_event; + err = register_switchdev_blocking_notifier(&priv->rswitch_switchdev_blocking_nb); + if (err) goto register_switchdev_blocking_notifier_failed; return 0; register_switchdev_blocking_notifier_failed: - unregister_switchdev_notifier(&rswitch_switchdev_nb); + unregister_switchdev_notifier(&priv->rswitch_switchdev_nb); register_switchdev_notifier_failed: - unregister_netdevice_notifier(&rswitch_netdevice_nb); + unregister_netdevice_notifier(&priv->rswitch_netdevice_nb); register_netdevice_notifier_failed: - return ret; + return err; } -void rswitch_unregister_notifiers(void) +void rswitch_unregister_notifiers(struct rswitch_private *priv) { - unregister_switchdev_blocking_notifier(&rswitch_switchdev_blocking_nb); - unregister_switchdev_notifier(&rswitch_switchdev_nb); - unregister_netdevice_notifier(&rswitch_netdevice_nb); + unregister_switchdev_blocking_notifier(&priv->rswitch_switchdev_blocking_nb); + unregister_switchdev_notifier(&priv->rswitch_switchdev_nb); + unregister_netdevice_notifier(&priv->rswitch_netdevice_nb); }
diff --git a/drivers/net/ethernet/renesas/rswitch_l2.h b/drivers/net/ethernet/renesas/rswitch_l2.h
index 57050ede8f31..af9780c63c9a 100644
--- a/drivers/net/ethernet/renesas/rswitch_l2.h
+++ b/drivers/net/ethernet/renesas/rswitch_l2.h@@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Renesas Ethernet Switch device driver * - * Copyright (C) 2025 Renesas Electronics Corporation + * Copyright (C) 2025 - 2026 Renesas Electronics Corporation */ #ifndef __RSWITCH_L2_H__
@@ -9,7 +9,7 @@ void rswitch_update_l2_offload(struct rswitch_private *priv); -int rswitch_register_notifiers(void); -void rswitch_unregister_notifiers(void); +int rswitch_register_notifiers(struct rswitch_private *priv); +void rswitch_unregister_notifiers(struct rswitch_private *priv); #endif /* #ifndef __RSWITCH_L2_H__ */
diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
index da400020a8f1..cfe7bfe6546b 100644
--- a/drivers/net/ethernet/renesas/rswitch_main.c
+++ b/drivers/net/ethernet/renesas/rswitch_main.c@@ -2241,6 +2241,30 @@ static int rswitch_init(struct rswitch_private *priv) return err; } +static void rswitch_deinit(struct rswitch_private *priv) +{ + unsigned int i; + + rswitch_gwca_hw_deinit(priv); + rcar_gen4_ptp_unregister(priv->ptp_priv); + + rswitch_for_each_enabled_port(priv, i) { + struct rswitch_device *rdev = priv->rdev[i]; + + unregister_netdev(rdev->ndev); + rswitch_ether_port_deinit_one(rdev); + phy_exit(priv->rdev[i]->serdes); + } + + for (i = 0; i < RSWITCH_NUM_PORTS; i++) + rswitch_device_free(priv, i); + + rswitch_gwca_ts_queue_free(priv); + rswitch_gwca_linkfix_free(priv); + + rswitch_clock_disable(priv); +} + static const struct soc_device_attribute rswitch_soc_no_speed_change[] = { { .soc_id = "r8a779f0", .revision = "ES1.0" }, { /* Sentinel */ }
@@ -2317,9 +2341,13 @@ static int renesas_eth_sw_probe(struct platform_device *pdev) if (list_empty(&priv->port_list)) dev_warn(&pdev->dev, "could not initialize any ports\n"); - ret = rswitch_register_notifiers(); + ret = rswitch_register_notifiers(priv); if (ret) { + rswitch_deinit(priv); + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); dev_err(&pdev->dev, "could not register notifiers\n"); + return ret; }
@@ -2328,35 +2356,11 @@ static int renesas_eth_sw_probe(struct platform_device *pdev) return ret; } -static void rswitch_deinit(struct rswitch_private *priv) -{ - unsigned int i; - - rswitch_gwca_hw_deinit(priv); - rcar_gen4_ptp_unregister(priv->ptp_priv); - - rswitch_for_each_enabled_port(priv, i) { - struct rswitch_device *rdev = priv->rdev[i]; - - unregister_netdev(rdev->ndev); - rswitch_ether_port_deinit_one(rdev); - phy_exit(priv->rdev[i]->serdes); - } - - for (i = 0; i < RSWITCH_NUM_PORTS; i++) - rswitch_device_free(priv, i); - - rswitch_gwca_ts_queue_free(priv); - rswitch_gwca_linkfix_free(priv); - - rswitch_clock_disable(priv); -} - static void renesas_eth_sw_remove(struct platform_device *pdev) { struct rswitch_private *priv = platform_get_drvdata(pdev); - rswitch_unregister_notifiers(); + rswitch_unregister_notifiers(priv); rswitch_deinit(priv); pm_runtime_put(&pdev->dev);
--
2.43.0