linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
@ 2020-01-06  2:33 Jiping Ma
  2020-01-06 21:45 ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: Jiping Ma @ 2020-01-06  2:33 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel, jiping.ma2

Add one notifier for udev changes net device name.

Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b14f46a57154..8d927e455123 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -104,6 +104,7 @@ MODULE_PARM_DESC(chain_mode, "To use chain instead of ring mode");
 static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
 
 #ifdef CONFIG_DEBUG_FS
+static const struct net_device_ops stmmac_netdev_ops;
 static int stmmac_init_fs(struct net_device *dev);
 static void stmmac_exit_fs(struct net_device *dev);
 #endif
@@ -4038,6 +4039,34 @@ 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);
+
+	if (dev->netdev_ops != &stmmac_netdev_ops)
+		goto done;
+
+	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 +4105,8 @@ static int stmmac_init_fs(struct net_device *dev)
 		return -ENOMEM;
 	}
 
+	register_netdevice_notifier(&stmmac_notifier);
+
 	return 0;
 }
 
@@ -4083,6 +4114,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 */
-- 
2.23.0


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-06  2:33 [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name Jiping Ma
@ 2020-01-06 21:45 ` David Miller
  2020-01-07  1:00   ` Jiping Ma
  0 siblings, 1 reply; 18+ messages in thread
From: David Miller @ 2020-01-06 21:45 UTC (permalink / raw)
  To: jiping.ma2
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel

From: Jiping Ma <jiping.ma2@windriver.com>
Date: Mon, 6 Jan 2020 10:33:41 +0800

> Add one notifier for udev changes net device name.
> 
> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>

This doesn't apply to 'net' and since this is a bug fix that is where
you should target this change.

Thank you.


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-06 21:45 ` David Miller
@ 2020-01-07  1:00   ` Jiping Ma
  2020-01-07  2:22     ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: Jiping Ma @ 2020-01-07  1:00 UTC (permalink / raw)
  To: David Miller
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel



On 01/07/2020 05:45 AM, David Miller wrote:
> From: Jiping Ma <jiping.ma2@windriver.com>
> Date: Mon, 6 Jan 2020 10:33:41 +0800
>
>> Add one notifier for udev changes net device name.
>>
>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
> This doesn't apply to 'net' and since this is a bug fix that is where
> you should target this change.
What's the next step that I can do?
> Thank you.
>
>


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-07  1:00   ` Jiping Ma
@ 2020-01-07  2:22     ` David Miller
  2020-01-07  2:59       ` Jiping Ma
  0 siblings, 1 reply; 18+ messages in thread
From: David Miller @ 2020-01-07  2:22 UTC (permalink / raw)
  To: Jiping.Ma2
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel

From: Jiping Ma <Jiping.Ma2@windriver.com>
Date: Tue, 7 Jan 2020 09:00:53 +0800

> 
> 
> On 01/07/2020 05:45 AM, David Miller wrote:
>> From: Jiping Ma <jiping.ma2@windriver.com>
>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>
>>> Add one notifier for udev changes net device name.
>>>
>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>> This doesn't apply to 'net' and since this is a bug fix that is where
>> you should target this change.
> What's the next step that I can do?

Respin your patch against the net GIT tree so that it applies clean.y

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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-07  2:22     ` David Miller
@ 2020-01-07  2:59       ` Jiping Ma
  2020-01-07  4:44         ` Florian Fainelli
  2020-01-07 21:01         ` David Miller
  0 siblings, 2 replies; 18+ messages in thread
From: Jiping Ma @ 2020-01-07  2:59 UTC (permalink / raw)
  To: David Miller
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel



On 01/07/2020 10:22 AM, David Miller wrote:
> From: Jiping Ma <Jiping.Ma2@windriver.com>
> Date: Tue, 7 Jan 2020 09:00:53 +0800
>
>>
>> On 01/07/2020 05:45 AM, David Miller wrote:
>>> From: Jiping Ma <jiping.ma2@windriver.com>
>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>
>>>> Add one notifier for udev changes net device name.
>>>>
>>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>> you should target this change.
>> What's the next step that I can do?
> Respin your patch against the net GIT tree so that it applies clean.y
OK, I will generate the new patch based on the latest linux kernel code.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Thanks,


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-07  2:59       ` Jiping Ma
@ 2020-01-07  4:44         ` Florian Fainelli
  2020-01-07 21:01         ` David Miller
  1 sibling, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-01-07  4:44 UTC (permalink / raw)
  To: Jiping Ma, David Miller
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel



On 1/6/2020 6:59 PM, Jiping Ma wrote:
> 
> 
> On 01/07/2020 10:22 AM, David Miller wrote:
>> From: Jiping Ma <Jiping.Ma2@windriver.com>
>> Date: Tue, 7 Jan 2020 09:00:53 +0800
>>
>>>
>>> On 01/07/2020 05:45 AM, David Miller wrote:
>>>> From: Jiping Ma <jiping.ma2@windriver.com>
>>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>>
>>>>> Add one notifier for udev changes net device name.
>>>>>
>>>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>>> you should target this change.
>>> What's the next step that I can do?
>> Respin your patch against the net GIT tree so that it applies clean.y
> OK, I will generate the new patch based on the latest linux kernel code.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

That is not quite the tree you should be using, you should be using the
"net" tree, which is here:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/

and here are some useful pieces of information in the netdev FAQ:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/tree/Documentation/networking/netdev-FAQ.rst#n28

Also, since this is not the version version of your patch, please make
sure your subject indicates this is not the first version, I have lost
count of the exact number of times you submitted this already (4?) so
this could be [PATCH net v5] in the subject or something like that.

Given you fix a bug please also provide an appropriate Fixes tag, which
should be:

Fixes: 466c5ac8bdf2 ("net: stmmac: create one debugfs dir per net-device")
-- 
Florian

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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-07  2:59       ` Jiping Ma
  2020-01-07  4:44         ` Florian Fainelli
@ 2020-01-07 21:01         ` David Miller
  1 sibling, 0 replies; 18+ messages in thread
From: David Miller @ 2020-01-07 21:01 UTC (permalink / raw)
  To: Jiping.Ma2
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel

From: Jiping Ma <Jiping.Ma2@windriver.com>
Date: Tue, 7 Jan 2020 10:59:22 +0800

> 
> 
> On 01/07/2020 10:22 AM, David Miller wrote:
>> From: Jiping Ma <Jiping.Ma2@windriver.com>
>> Date: Tue, 7 Jan 2020 09:00:53 +0800
>>
>>>
>>> On 01/07/2020 05:45 AM, David Miller wrote:
>>>> From: Jiping Ma <jiping.ma2@windriver.com>
>>>> Date: Mon, 6 Jan 2020 10:33:41 +0800
>>>>
>>>>> Add one notifier for udev changes net device name.
>>>>>
>>>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>>>> This doesn't apply to 'net' and since this is a bug fix that is where
>>>> you should target this change.
>>> What's the next step that I can do?
>> Respin your patch against the net GIT tree so that it applies clean.y
> OK, I will generate the new patch based on the latest linux kernel
> code.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

That's not the networking GIT tree.

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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-05  4:18 ` David Miller
@ 2020-01-06  1:30   ` Jiping Ma
  0 siblings, 0 replies; 18+ messages in thread
From: Jiping Ma @ 2020-01-06  1:30 UTC (permalink / raw)
  To: David Miller
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel, ytao



On 01/05/2020 12:18 PM, David Miller wrote:
> From: Jiping Ma <jiping.ma2@windriver.com>
> Date: Thu, 2 Jan 2020 09:35:44 +0800
>
>> Add one notifier for udev changes net device name.
>>
>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>> ---
>>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index b14f46a57154..3b05cb80eed7 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -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:
> 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.
Thanks to remind.  I will modify it and send it review again.
>


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2020-01-02  1:35 Jiping Ma
@ 2020-01-05  4:18 ` David Miller
  2020-01-06  1:30   ` Jiping Ma
  0 siblings, 1 reply; 18+ messages in thread
From: David Miller @ 2020-01-05  4:18 UTC (permalink / raw)
  To: jiping.ma2
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-arm-kernel, linux-stm32, linux-kernel

From: Jiping Ma <jiping.ma2@windriver.com>
Date: Thu, 2 Jan 2020 09:35:44 +0800

> Add one notifier for udev changes net device name.
> 
> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b14f46a57154..3b05cb80eed7 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -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:

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.

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

* [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
@ 2020-01-02  1:35 Jiping Ma
  2020-01-05  4:18 ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: Jiping Ma @ 2020-01-02  1:35 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel, jiping.ma2

Add one notifier for udev changes net device name.

Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b14f46a57154..3b05cb80eed7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -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 */
-- 
2.23.0


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31 10:12 ` Sergei Shtylyov
@ 2020-01-02  0:38   ` Jiping Ma
  0 siblings, 0 replies; 18+ messages in thread
From: Jiping Ma @ 2020-01-02  0:38 UTC (permalink / raw)
  To: Sergei Shtylyov, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel



On 12/31/2019 06:12 PM, Sergei Shtylyov wrote:
> Hello!
>
> On 31.12.2019 5:03, Jiping Ma wrote:
>
>> Add one notifier for udev changes net device name.
>>
>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>> ---
>>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>>   1 file changed, 37 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index b14f46a57154..c1c877bb4421 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file 
>> *seq, void *v)
>>   }
>>   DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>>   +/**
>> + * Use network device events to create/remove/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;
>> +
>> +    case NETDEV_GOING_DOWN:
>> +        break;
>> +
>> +    case NETDEV_UP:
>> +        break;
>
>    Why not merge the above 2 cases? Or just remove them('event' is not 
> *enum*)?
I will remove them.

Thanks,
>
>> +    }
>> +
>> +done:
>> +    return NOTIFY_DONE;
>> +}
> [...]
>
> MBR, Sergei
>


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31  2:03 Jiping Ma
  2019-12-31  2:11 ` Randy Dunlap
@ 2019-12-31 10:12 ` Sergei Shtylyov
  2020-01-02  0:38   ` Jiping Ma
  1 sibling, 1 reply; 18+ messages in thread
From: Sergei Shtylyov @ 2019-12-31 10:12 UTC (permalink / raw)
  To: Jiping Ma, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel

Hello!

On 31.12.2019 5:03, Jiping Ma wrote:

> Add one notifier for udev changes net device name.
> 
> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
> ---
>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>   1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b14f46a57154..c1c877bb4421 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
>   }
>   DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>   
> +/**
> + * Use network device events to create/remove/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;
> +
> +	case NETDEV_GOING_DOWN:
> +		break;
> +
> +	case NETDEV_UP:
> +		break;

    Why not merge the above 2 cases? Or just remove them('event' is not *enum*)?

> +	}
> +
> +done:
> +	return NOTIFY_DONE;
> +}
[...]

MBR, Sergei

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

* [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
@ 2019-12-31  3:02 Jiping Ma
  0 siblings, 0 replies; 18+ messages in thread
From: Jiping Ma @ 2019-12-31  3:02 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel, jiping.ma2

Add one notifier for udev changes net device name.

Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b14f46a57154..e7604d77f449 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4038,6 +4038,39 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
 
+/* Use network device events to create/remove/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;
+
+	case NETDEV_GOING_DOWN:
+		break;
+
+	case NETDEV_UP:
+		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 +4109,8 @@ static int stmmac_init_fs(struct net_device *dev)
 		return -ENOMEM;
 	}
 
+	register_netdevice_notifier(&stmmac_notifier);
+
 	return 0;
 }
 
@@ -4083,6 +4118,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 */
-- 
2.23.0


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31  2:22     ` Randy Dunlap
@ 2019-12-31  2:28       ` Jiping Ma
  0 siblings, 0 replies; 18+ messages in thread
From: Jiping Ma @ 2019-12-31  2:28 UTC (permalink / raw)
  To: Randy Dunlap, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel



On 12/31/2019 10:22 AM, Randy Dunlap wrote:
> On 12/30/19 6:16 PM, Jiping Ma wrote:
>>
>> On 12/31/2019 10:11 AM, Randy Dunlap wrote:
>>> Hi,
>>>
>>> On 12/30/19 6:03 PM, Jiping Ma wrote:
>>>> Add one notifier for udev changes net device name.
>>>>
>>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>>>> ---
>>>>    .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>>>>    1 file changed, 37 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> index b14f46a57154..c1c877bb4421 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>>> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
>>>>    }
>>>>    DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>>>>    +/**
>>> Just use /* here since this is not a kernel-doc comment.
>>> /** is reserved for kernel-doc comments/notation.
>> I use checkpatch.pl to check my patch, it show one warning, then I change * to **.   I will change it back to *.
> It should be more like:
>
> /* Use network device events to create/remove/rename
>   * debugfs file entries.
>   */
>
Got it.  Thanks.
>> WARNING: networking block comments don't use an empty /* line, use /* Comment...
>> #23: FILE: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4042:
>> +/*
>> + * Use network device events to create/remove/rename
>>>> + * Use network device events to create/remove/rename
>>>> + * debugfs file entries
>>>> + */
>>>> +static int stmmac_device_event(struct notifier_block *unused,
>>>> +                   unsigned long event, void *ptr)
>>>> +{
>


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31  2:16   ` Jiping Ma
@ 2019-12-31  2:22     ` Randy Dunlap
  2019-12-31  2:28       ` Jiping Ma
  0 siblings, 1 reply; 18+ messages in thread
From: Randy Dunlap @ 2019-12-31  2:22 UTC (permalink / raw)
  To: Jiping Ma, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel

On 12/30/19 6:16 PM, Jiping Ma wrote:
> 
> 
> On 12/31/2019 10:11 AM, Randy Dunlap wrote:
>> Hi,
>>
>> On 12/30/19 6:03 PM, Jiping Ma wrote:
>>> Add one notifier for udev changes net device name.
>>>
>>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>>> ---
>>>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>>>   1 file changed, 37 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> index b14f46a57154..c1c877bb4421 100644
>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
>>>   }
>>>   DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>>>   +/**
>> Just use /* here since this is not a kernel-doc comment.
>> /** is reserved for kernel-doc comments/notation.
> I use checkpatch.pl to check my patch, it show one warning, then I change * to **.   I will change it back to *.

It should be more like:

/* Use network device events to create/remove/rename
 * debugfs file entries.
 */

> WARNING: networking block comments don't use an empty /* line, use /* Comment...
> #23: FILE: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4042:
> +/*
> + * Use network device events to create/remove/rename
>>
>>> + * Use network device events to create/remove/rename
>>> + * debugfs file entries
>>> + */
>>> +static int stmmac_device_event(struct notifier_block *unused,
>>> +                   unsigned long event, void *ptr)
>>> +{
>>


-- 
~Randy
Reported-by: Randy Dunlap <rdunlap@infradead.org>

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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31  2:11 ` Randy Dunlap
@ 2019-12-31  2:16   ` Jiping Ma
  2019-12-31  2:22     ` Randy Dunlap
  0 siblings, 1 reply; 18+ messages in thread
From: Jiping Ma @ 2019-12-31  2:16 UTC (permalink / raw)
  To: Randy Dunlap, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel



On 12/31/2019 10:11 AM, Randy Dunlap wrote:
> Hi,
>
> On 12/30/19 6:03 PM, Jiping Ma wrote:
>> Add one notifier for udev changes net device name.
>>
>> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
>> ---
>>   .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>>   1 file changed, 37 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index b14f46a57154..c1c877bb4421 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
>>   }
>>   DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>>   
>> +/**
> Just use /* here since this is not a kernel-doc comment.
> /** is reserved for kernel-doc comments/notation.
I use checkpatch.pl to check my patch, it show one warning, then I 
change * to **.   I will change it back to *.
WARNING: networking block comments don't use an empty /* line, use /* 
Comment...
#23: FILE: drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4042:
+/*
+ * Use network device events to create/remove/rename
>
>> + * Use network device events to create/remove/rename
>> + * debugfs file entries
>> + */
>> +static int stmmac_device_event(struct notifier_block *unused,
>> +			       unsigned long event, void *ptr)
>> +{
>
>> @@ -4050,7 +4084,6 @@ static int stmmac_init_fs(struct net_device *dev)
>>   
>>   		return -ENOMEM;
>>   	}
>> -
>>   	/* Entry to report DMA RX/TX rings */
>>   	priv->dbgfs_rings_status =
>>   		debugfs_create_file("descriptors_status", 0444,
> I don't see a problem with the blank line.  Why remove it?
I will change it back.
>
>
> thanks.


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

* Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
  2019-12-31  2:03 Jiping Ma
@ 2019-12-31  2:11 ` Randy Dunlap
  2019-12-31  2:16   ` Jiping Ma
  2019-12-31 10:12 ` Sergei Shtylyov
  1 sibling, 1 reply; 18+ messages in thread
From: Randy Dunlap @ 2019-12-31  2:11 UTC (permalink / raw)
  To: Jiping Ma, peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel

Hi,

On 12/30/19 6:03 PM, Jiping Ma wrote:
> Add one notifier for udev changes net device name.
> 
> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b14f46a57154..c1c877bb4421 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
>  }
>  DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
>  
> +/**

Just use /* here since this is not a kernel-doc comment.
/** is reserved for kernel-doc comments/notation.

> + * Use network device events to create/remove/rename
> + * debugfs file entries
> + */
> +static int stmmac_device_event(struct notifier_block *unused,
> +			       unsigned long event, void *ptr)
> +{


> @@ -4050,7 +4084,6 @@ static int stmmac_init_fs(struct net_device *dev)
>  
>  		return -ENOMEM;
>  	}
> -
>  	/* Entry to report DMA RX/TX rings */
>  	priv->dbgfs_rings_status =
>  		debugfs_create_file("descriptors_status", 0444,

I don't see a problem with the blank line.  Why remove it?


thanks.
-- 
~Randy


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

* [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
@ 2019-12-31  2:03 Jiping Ma
  2019-12-31  2:11 ` Randy Dunlap
  2019-12-31 10:12 ` Sergei Shtylyov
  0 siblings, 2 replies; 18+ messages in thread
From: Jiping Ma @ 2019-12-31  2:03 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: joabreu, mcoquelin.stm32, netdev, linux-arm-kernel, linux-stm32,
	linux-kernel, jiping.ma2

Add one notifier for udev changes net device name.

Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 38 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b14f46a57154..c1c877bb4421 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4038,6 +4038,40 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(stmmac_dma_cap);
 
+/**
+ * Use network device events to create/remove/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;
+
+	case NETDEV_GOING_DOWN:
+		break;
+
+	case NETDEV_UP:
+		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);
@@ -4050,7 +4084,6 @@ static int stmmac_init_fs(struct net_device *dev)
 
 		return -ENOMEM;
 	}
-
 	/* Entry to report DMA RX/TX rings */
 	priv->dbgfs_rings_status =
 		debugfs_create_file("descriptors_status", 0444,
@@ -4076,6 +4109,8 @@ static int stmmac_init_fs(struct net_device *dev)
 		return -ENOMEM;
 	}
 
+	register_netdevice_notifier(&stmmac_notifier);
+
 	return 0;
 }
 
@@ -4083,6 +4118,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 */
-- 
2.23.0


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

end of thread, other threads:[~2020-01-07 21:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06  2:33 [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name Jiping Ma
2020-01-06 21:45 ` David Miller
2020-01-07  1:00   ` Jiping Ma
2020-01-07  2:22     ` David Miller
2020-01-07  2:59       ` Jiping Ma
2020-01-07  4:44         ` Florian Fainelli
2020-01-07 21:01         ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2020-01-02  1:35 Jiping Ma
2020-01-05  4:18 ` David Miller
2020-01-06  1:30   ` Jiping Ma
2019-12-31  3:02 Jiping Ma
2019-12-31  2:03 Jiping Ma
2019-12-31  2:11 ` Randy Dunlap
2019-12-31  2:16   ` Jiping Ma
2019-12-31  2:22     ` Randy Dunlap
2019-12-31  2:28       ` Jiping Ma
2019-12-31 10:12 ` Sergei Shtylyov
2020-01-02  0:38   ` Jiping Ma

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