mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jiping.ma2@windriver.com
Cc: peppe.cavallaro@st.com, alexandre.torgue@st.com,
	joabreu@synopsys.com, mcoquelin.stm32@gmail.com,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] stmmac: debugfs entry name is not be changed when udev rename device name.
Date: Sat, 04 Jan 2020 20:18:33 -0800 (PST)	[thread overview]
Message-ID: <20200104.201833.91020607861340266.davem@davemloft.net> (raw)
In-Reply-To: <20200102013544.19271-1-jiping.ma2@windriver.com>

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.

  reply	other threads:[~2020-01-05  4:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02  1:35 Jiping Ma
2020-01-05  4:18 ` David Miller [this message]
2020-01-06  1:30   ` Jiping Ma
  -- strict thread matches above, loose matches on Subject: below --
2020-01-06  2:33 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
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200104.201833.91020607861340266.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=alexandre.torgue@st.com \
    --cc=jiping.ma2@windriver.com \
    --cc=joabreu@synopsys.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®