From patchwork Thu Jan 12 03:41:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9512009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 48AB960710 for ; Thu, 12 Jan 2017 03:43:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39DF92864B for ; Thu, 12 Jan 2017 03:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EC142865F; Thu, 12 Jan 2017 03:43:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2EF12864B for ; Thu, 12 Jan 2017 03:43:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRWIB-00005f-T5; Thu, 12 Jan 2017 03:43:11 +0000 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRWHM-000742-Ci for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2017 03:42:23 +0000 Received: by mail-oi0-x244.google.com with SMTP id j15so1161448oih.0 for ; Wed, 11 Jan 2017 19:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oKigQS8++pg+WXpM4J9IVTJisANxpFsLLpQOHs6uvoc=; b=lDQcHxUP5YMoC8ww0ComztPSGq8VbrNctTrV6iRRJJwxAYtEUGTou3proWXTy/n8AW So64t5POeB9wayHv3eMYJVxefeE8PbeFYulHKgWaRXFEZ33hinfTEUq6xfuhUD5jYfC8 cvbOCnzQZhEUfF1M4C3EkXOwxPHPrFgrvd1tcA1M2guhJT+GN3mkTOIRtmlFvtUiK0s6 VY2qOjEavLWesC4M1ek4seMVwhR4xiABP+24Bjmae7vZnE5VPyPwpiPG9OQBksn3hahi yt0nShAUBgOYLqtiEEy/UIhriJIMy+gFzhQxjB0S/n3cBhrTNqkrctlnuzaTeLg1lxMT Zqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oKigQS8++pg+WXpM4J9IVTJisANxpFsLLpQOHs6uvoc=; b=LyNPdVUywj6O0Tuv98T0RRTUxQ3Q0+gU9niecdUu4fRzXuYIUO/tmbqWuKMxgJkPub t8jtANBCuSBeRdJH6HVvNp5SH0SU8rZlErFe9nCvOHINpApJQGy/qxTToWFaA91Mz9HL CHvurdhIAG5/8f6BgisPf+n24dBsVlrnhz7a7qI6f5rRqdhLXexQ3V9w0ndoMCmAlX+h XwYzIYN+24TWjGxQlAju88NzM+gs/IH0FYh3l7hUYkfEngUgdsWVDY3PeKdfE2xe7PUZ J/mqB1dr7d6Sxn9q0zMwAzSuKOB2Ue6xktGmF5Ey37IkZLTWzpO6VoaAVZSdeTDmDVcf gJsQ== X-Gm-Message-State: AIkVDXIb8GyMpuzLoXmU0fwsDGJFeJ9zg6n2Y+ia0LaMf7DiRrrPXGMLSKW633M3mgC84Q== X-Received: by 10.157.40.72 with SMTP id h8mr6185870otd.79.1484192519420; Wed, 11 Jan 2017 19:41:59 -0800 (PST) Received: from fainelli-laptop.lan ([2001:470:d:73f:b16f:f382:be58:4136]) by smtp.gmail.com with ESMTPSA id f7sm3585543otb.34.2017.01.11.19.41.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 19:41:58 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Subject: [PATCH net-next v2 07/10] net: Relocate dev_to_net_device() into core Date: Wed, 11 Jan 2017 19:41:18 -0800 Message-Id: <20170112034121.27697-8-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170112034121.27697-1-f.fainelli@gmail.com> References: <20170112034121.27697-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170111_194220_772266_75556A3F X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Florian Fainelli , Jason Cooper , Vivien Didelot , gregkh@linuxfoundation.org, Russell King , open list , Gregory Clement , "David S. Miller" , "moderated list:ARM SUB-ARCHITECTURES" , Sebastian Hesselbarth MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP dev_to_net_device() is moved from net/dsa/dsa.c to net/core/dev.c since it going to be used by net/dsa/dsa2.c and the namespace of the function justifies making it available to other users potentially. Signed-off-by: Florian Fainelli --- include/linux/netdevice.h | 2 ++ net/core/dev.c | 19 +++++++++++++++++++ net/dsa/dsa.c | 18 ------------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ebd9e2c12f44..d532c070163f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4378,4 +4378,6 @@ do { \ #define PTYPE_HASH_SIZE (16) #define PTYPE_HASH_MASK (PTYPE_HASH_SIZE - 1) +struct net_device *dev_to_net_device(struct device *dev); + #endif /* _LINUX_NETDEVICE_H */ diff --git a/net/core/dev.c b/net/core/dev.c index e98cc06d2577..643e4a4491c6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8150,6 +8150,25 @@ const char *netdev_drivername(const struct net_device *dev) return empty; } +struct net_device *dev_to_net_device(struct device *dev) +{ + struct device *d; + + d = device_find_class(dev, "net"); + if (d) { + struct net_device *nd; + + nd = to_net_dev(d); + dev_hold(nd); + put_device(d); + + return nd; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(dev_to_net_device); + static void __netdev_printk(const char *level, const struct net_device *dev, struct va_format *vaf) { diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 77fa4c4f5828..6c264f92fec5 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -473,24 +473,6 @@ struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev) } EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus); -static struct net_device *dev_to_net_device(struct device *dev) -{ - struct device *d; - - d = device_find_class(dev, "net"); - if (d != NULL) { - struct net_device *nd; - - nd = to_net_dev(d); - dev_hold(nd); - put_device(d); - - return nd; - } - - return NULL; -} - #ifdef CONFIG_OF static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, struct dsa_chip_data *cd,