netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: move notifier block to private data
@ 2020-02-25 11:16 aaro.koskinen
  2020-02-25 19:10 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: aaro.koskinen @ 2020-02-25 11:16 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller
  Cc: netdev, linux-kernel, Aaro Koskinen

From: Aaro Koskinen <aaro.koskinen@nokia.com>

Move notifier block to private data. Otherwise notifier code will complain
about double register with multiple stmmac instances.

Fixes: 481a7d154cbb ("stmmac: debugfs entry name is not be changed when udev rename device name.")
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 9c02fc754bf1..20621b964e6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -222,6 +222,7 @@ struct stmmac_priv {
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *dbgfs_dir;
+	struct notifier_block nb;
 #endif
 
 	unsigned long state;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5836b21edd7e..bf0ce8e4424b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4397,10 +4397,6 @@ static int stmmac_device_event(struct notifier_block *unused,
 	return NOTIFY_DONE;
 }
 
-static struct notifier_block stmmac_notifier = {
-	.notifier_call = stmmac_device_event,
-};
-
 static void stmmac_init_fs(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
@@ -4416,14 +4412,15 @@ static void stmmac_init_fs(struct net_device *dev)
 	debugfs_create_file("dma_cap", 0444, priv->dbgfs_dir, dev,
 			    &stmmac_dma_cap_fops);
 
-	register_netdevice_notifier(&stmmac_notifier);
+	priv->nb.notifier_call = stmmac_device_event;
+	register_netdevice_notifier(&priv->nb);
 }
 
 static void stmmac_exit_fs(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 
-	unregister_netdevice_notifier(&stmmac_notifier);
+	unregister_netdevice_notifier(&priv->nb);
 	debugfs_remove_recursive(priv->dbgfs_dir);
 }
 #endif /* CONFIG_DEBUG_FS */
-- 
2.11.0


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

* Re: [PATCH] net: stmmac: move notifier block to private data
  2020-02-25 11:16 [PATCH] net: stmmac: move notifier block to private data aaro.koskinen
@ 2020-02-25 19:10 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-02-25 19:10 UTC (permalink / raw)
  To: aaro.koskinen
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, netdev, linux-kernel

From: aaro.koskinen@nokia.com
Date: Tue, 25 Feb 2020 13:16:15 +0200

> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> 
> Move notifier block to private data. Otherwise notifier code will complain
> about double register with multiple stmmac instances.
> 
> Fixes: 481a7d154cbb ("stmmac: debugfs entry name is not be changed when udev rename device name.")
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>

This doesn't make any sense.

We need only one instance of the stmmac notifier registered, no matter how many
stmmac devices are probed.

Please change it such that we only call register_notifier() once (when the first
stmmac device is probed) and only unregister_notifier() when the last one is
removed.

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

end of thread, other threads:[~2020-02-25 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 11:16 [PATCH] net: stmmac: move notifier block to private data aaro.koskinen
2020-02-25 19:10 ` David Miller

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).