stmmac: debugfs entry name is not be changed when udev rename device name.
Subsystems (4)
PATCH 1/1 stmmac: debugfs entry name is not be changed when udev rename device name.
Add one notifier for udev changes net device name.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +28 -0
@@ -4038,6 +4038,31 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v) }DEFINE_SHOW_ATTRIBUTE (stmmac_dma_cap); +/* Use network device events to rename debugfs file entries. +*/ +static int stmmac_device_event (struct notifier_block *unused, +unsigned long event,void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct stmmac_priv *priv =netdev_priv (dev); + +switch (event) { +case NETDEV_CHANGENAME : +if (priv->dbgfs_dir) + priv->dbgfs_dir =debugfs_rename (stmmac_fs_dir, + priv->dbgfs_dir, + stmmac_fs_dir, + dev->name); +break ; + } +done: +return NOTIFY_DONE ; +} + +static struct notifier_block stmmac_notifier = { + .notifier_call = stmmac_device_event, +}; +static int stmmac_init_fs (struct net_device *dev) {struct stmmac_priv *priv =netdev_priv (dev);
@@ -4076,6 +4101,8 @@ static int stmmac_init_fs(struct net_device *dev)return -ENOMEM ; } +register_netdevice_notifier (&stmmac_notifier); +return 0 ; }
@@ -4083,6 +4110,7 @@ static void stmmac_exit_fs(struct net_device *dev) {struct stmmac_priv *priv =netdev_priv (dev); +unregister_netdevice_notifier (&stmmac_notifier);debugfs_remove_recursive (priv->dbgfs_dir); }#endif /* CONFIG_DEBUG_FS */
Signature · 1 line
2.23.0
David Miller
maintainerFrom: Jiping Ma <[email protected]>
Date: Thu, 2 Jan 2020 09:35:44 +0800
Quoted 15 lines
Add one notifier for udev changes net device name.
Signed-off-by Jiping Ma <[email protected]>--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -4038,6 +4038,31 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v) }DEFINE_SHOW_ATTRIBUTE (stmmac_dma_cap);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_dma_cap_show(struct seq_file *seq, void *v) · line 4050
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10
-0+/* Use network device events to rename debugfs file entries. +*/ +static int stmmac_device_event (struct notifier_block *unused, +unsigned long event,void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct stmmac_priv *priv =netdev_priv (dev); + +switch (event) { +case NETDEV_CHANGENAME :
This notifier gets called for every single netdevice in the entire system.
You cannot just assume that the device that gets passed in here is an stmmac device.
Look at how other drivers handle this to see how to do it correctly.
Thank you.
Quoted 31 lines · David Miller
From: Jiping Ma <[email protected]>
Date: Thu, 2 Jan 2020 09:35:44 +0800Quoted 15 lines
Add one notifier for udev changes net device name.
Signed-off-by Jiping Ma <[email protected]>--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -4038,6 +4038,31 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v) }DEFINE_SHOW_ATTRIBUTE (stmmac_dma_cap);drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_dma_cap_show(struct seq_file *seq, void *v) · line 4050
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10
-0+/* Use network device events to rename debugfs file entries. +*/ +static int stmmac_device_event (struct notifier_block *unused, +unsigned long event,void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct stmmac_priv *priv =netdev_priv (dev); + +switch (event) { +case NETDEV_CHANGENAME :This notifier gets called for every single netdevice in the entire system.
Quoted 6 lines
You cannot just assume that the device that gets passed in here is an stmmac device.
Look at how other drivers handle this to see how to do it correctly.
Thank you.
Thanks to remind. I will modify it and send it review again.