Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097517ybl; Thu, 30 Jan 2020 11:18:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyR7gyEGjWXGIxTAE+Oi/Sv5jgtHb8LKxf/A7ldK1OEurqWjuGf3VqCPc7VjWh0il+ahRoJ X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr3781407oie.144.1580411916984; Thu, 30 Jan 2020 11:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411916; cv=none; d=google.com; s=arc-20160816; b=uD2R8UigutKjD4P/utGm2fFvLQbfDnGRq7dPhw93NSZEEKh9mxVD78TRXlmagZxcCn Xa927Bhmpd3ws4KyPCKHfgeXxvxnDmXFHa/8i0mylSg/EUhcTaprfaFgQr+wtrEJONSC Ac5qGpbQ7lb8og+IkexZOcu9f4Maq4I/jiFsfqSHfbtzLw2vA+6PjBgu/+3uQGcOnYSZ YIBlk/k45SZdcTDPLYi3xYdcrw20oBqeebHZToOCDO1gcmXg+2p2hOC4aYsWW3PDrRyu GF4ejaJAk1Wt5lu4UlVUUtjVr1ad6B/GQrk6iuLXzZcjsrOt/VFsJ9bMHfTkGMPe3+lU Rn7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ilr3dRWXXIsuY1IpMWzlRFY7HOSqT8+n4il3NkWE2EM=; b=sIJYI9gl++cqNwzzsDy9fZsHxDPpz7MmGqLYlcifM8EizGlyqsH/frVNaK5G6pzagM kAZHSwBavwKR13rAcTPXBiSdGDg+4Os7Iy4Yf//reh1tVMgJB3vXqKwfLXEgBMXgwpBf bzeuZsrAM+/pm85jTGDehvBHTphsoS9g4lZtpy87GvRARq6xE/IPNyTL9VvRrf+ATXIv CT0TZ3bA3KWOtWqeNYbyJB+YoeyGmYwT9wtNVFahNTZMkeU2NspfahvIgPDyV6zgl+Ru d7u3tluH30UeHhyYiv9bW7Yfbtky4RV67odSvNXynedICemkIwi07oXmyPNqnlj5DT7r FF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="e/9ed2iJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si3367194oti.249.2020.01.30.11.18.24; Thu, 30 Jan 2020 11:18:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="e/9ed2iJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730893AbgA3Sot (ORCPT + 99 others); Thu, 30 Jan 2020 13:44:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:54090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730880AbgA3Sos (ORCPT ); Thu, 30 Jan 2020 13:44:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1047E205F4; Thu, 30 Jan 2020 18:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409887; bh=vVe2J0NLPpOZp8vR8ECvcA8eLEA7SgBwdYsD8uicAmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/9ed2iJOMl0Wf9LWzZsTx1Z/kj7ThvNcH94gztW6qEIvMXOHBmnrDCMIHfcb74kL ytK8CoHxsjZGgaxnx3opC2KBmpHQwPyK2YhTe9HejVPi7wmTdyCe/kWFir2CfgMJx1 wb+gHKQtMBUZBA2iRZF8CGxTVCYgkVM3toDZJvso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiping Ma , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 072/110] stmmac: debugfs entry name is not be changed when udev rename device name. Date: Thu, 30 Jan 2020 19:38:48 +0100 Message-Id: <20200130183622.973401988@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiping Ma [ Upstream commit 481a7d154cbbd5ca355cc01cc8969876b240eded ] Add one notifier for udev changes net device name. Fixes: b6601323ef9e ("net: stmmac: debugfs entry name is not be changed when udev rename") Signed-off-by: Jiping Ma Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../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 1b3520d0e59ef..06dd65c419c49 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -105,6 +105,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 void stmmac_init_fs(struct net_device *dev); static void stmmac_exit_fs(struct net_device *dev); #endif @@ -4175,6 +4176,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 void stmmac_init_fs(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); @@ -4189,12 +4218,15 @@ static void stmmac_init_fs(struct net_device *dev) /* Entry to report the DMA HW features */ debugfs_create_file("dma_cap", 0444, priv->dbgfs_dir, dev, &stmmac_dma_cap_fops); + + register_netdevice_notifier(&stmmac_notifier); } 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.20.1