From patchwork Sat May 23 13:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11566805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C29E21391 for ; Sat, 23 May 2020 13:27:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C7C620727 for ; Sat, 23 May 2020 13:27:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GZMU5vOX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Jb+5ZKal" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C7C620727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mm05YctDaTKfxhzeAi5RFa5kwKELVnbSMnJaDiTpAWY=; b=GZMU5vOXjkL3hj mWI7TSbXbP3z7KBdnYz2ngGu330JO4B8CxIn0b5kiG73ZPPMaXcIQA5t4nlWNjAT1vmk3BlRJV/jI 0MIjDQt8WcmHtFYz/FbIA0GGSrYWtNQvGhxwh9k9gEP34mLGfyPwPZPjkEiMCqPCTBr1WZPcAN8Nu o0/vCcBY73kRpU/RoKcUxjqhViYgJbNEAUlHQDaBtBVvEESnjcTpCH4vN+zdnztkI7FeJXSCY27qg be7OXAye0AE83Fbs/z6xvQuVpm1N5c6XjOMIdbxJyoGkj43uYUudZwMSgnD7OZLE67VtyZDtdR33l BO8RGCff7YMSlLQ0+bXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBg-0003CI-GR; Sat, 23 May 2020 13:27:40 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBN-0002wW-VX for linux-mediatek@lists.infradead.org; Sat, 23 May 2020 13:27:23 +0000 Received: by mail-wr1-x443.google.com with SMTP id c3so8726031wru.12 for ; Sat, 23 May 2020 06:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v4BoYkqJ2NsZ2nSSjChgUqJJCyqhbfFRrbuVJ3n7szg=; b=Jb+5ZKalM86utufO41gum/2tS7OCDO9S01QHf7MGzAdq8QJbiQutr25oxxnlWFKFjx SZR18qW8XesCnotOkM8H9quVQqYTgPCdLi6Hhg42qTzojhe4TfWrzycKi3iHikDyNJsf Ky8/1dwIBaNGn+BmOnu4CzyVMTy5XGhLj6c2FWrDQ7sNwWtbGGg15vH/P5a5y6+hovy8 0rlqQeKnqGk4cNbfwQjDY2T8Oh4k/d1T2eWIevxv44tfqW6CCjW1/zyJBqc/LB1fD7fQ e6hxAoYbB+3ek0K4qJKeZW6zAPnzXJfiIuSvoj5gtKzV/sqVyURCSsJZ7bY796SijLfg e/sw== 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:mime-version:content-transfer-encoding; bh=v4BoYkqJ2NsZ2nSSjChgUqJJCyqhbfFRrbuVJ3n7szg=; b=Emk32Svugt9dFN8Zt54KllHOLnImXfVHznfWcGeXUIAd59QhOysqch0Z1/FtL3ekdd fJF3NSZU9DfNwiv/U6elupVtrkRm/mlkTr91ATNgnLZ4nd3yh4T0zi0BcdvASBVM9Ruo IRMjojevEoy6T643pKbW9JOjGy+BgEfA3Oq+aEORF5LpAwsaoe7Hj7aEeHnD3erte1Qb glXMHbSWXAA9TyuoSkaHFLT85r87EJokB8+ksmCPinaIrNMf0eZXaZugELfO/PBNbYeG NHa9bwIYybKAqQe1SN7laS5dvRYSsW3eGNph1iEtV0zVh7XIVcVlqGR1BOhL+2ViR/3Q CIug== X-Gm-Message-State: AOAM531cYTxettv5p0FTEE8/cKr5kR0iRUxQNyJQFVOrVFcJdYqy53rE 3LHIuT2FdQl3U/ZcLd3zr7WQrw== X-Google-Smtp-Source: ABdhPJwRfYPqDnrdo+HMqNm8KeR9hux7USj8U+isJ4xnjN1tAmXFnQplrYileiKI5uqJotyI3sPrWw== X-Received: by 2002:adf:f907:: with SMTP id b7mr7636363wrr.203.1590240440783; Sat, 23 May 2020 06:27:20 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id g69sm8098703wmg.15.2020.05.23.06.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 06:27:20 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer Subject: [PATCH v2 1/5] Documentation: devres: add a missing section for networking helpers Date: Sat, 23 May 2020 15:27:07 +0200 Message-Id: <20200523132711.30617-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200523132711.30617-1-brgl@bgdev.pl> References: <20200523132711.30617-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200523_062722_011677_E118A028 X-CRM114-Status: UNSURE ( 7.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephane Le Provost , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Bartosz Golaszewski Add a new section for networking devres helpers to devres.rst and list the two existing devm functions. Signed-off-by: Bartosz Golaszewski --- Documentation/driver-api/driver-model/devres.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index 46c13780994c..50df28d20fa7 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -372,6 +372,10 @@ MUX devm_mux_chip_register() devm_mux_control_get() +NET + devm_alloc_etherdev() + devm_alloc_etherdev_mqs() + PER-CPU MEM devm_alloc_percpu() devm_free_percpu() From patchwork Sat May 23 13:27:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11566811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0242190 for ; Sat, 23 May 2020 13:28:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD86820727 for ; Sat, 23 May 2020 13:28:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AM41dOj2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="rp37gfzA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD86820727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=osO2TCvHBkrbO6lMt3k/WsYCbtBaGadsq7UvqjOYOck=; b=AM41dOj2hNSrin LOEovMCi2BjjLZ8MNjf97I1dl3XBnnlIoH72A3LC9LItJfxY41EWZmRZKOPvLkgT42zE5xiHLyF0X 0izHMmfPolnQumeU3NH70Ndp02OzKLQpprFjxVEgxjEMfzHl/n/w33AVTJrpOTbqCu+MEyMK75to2 z5vk4fliEzahPYU5cqSOYm7vsThctbfww7LrPOLCRO+b54RCN3ZCjty/nR30UzFqPQ0dZl1g+bQN0 ctz0QWuZAVepBtM7fjiWcEfzfKdjtWUestHG/0ArPsQGhxQ0SQmdGbvfU1iN2zZ5uBI+RCZ+4zle1 lCQ+lfRObXYG1IAMkTGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUCL-0003jB-OX; Sat, 23 May 2020 13:28:21 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBR-0002xM-SR for linux-mediatek@lists.infradead.org; Sat, 23 May 2020 13:27:27 +0000 Received: by mail-wr1-x444.google.com with SMTP id c11so3482028wrn.6 for ; Sat, 23 May 2020 06:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s+yFWYJIlSICmhm10tVUfzLOMvlRQ6VDJMbx/0w2dnM=; b=rp37gfzAHCsfIapPIDnPi7bhKo6b+4zS1qkIx4xs7tAznZqzIdivacCFjDJKCqT6hG 1OX9zD5yiWYH4CqkM6qHcEAAGbm1wVPBTh2lWvqqDpdi98elF69xmUr8VREH3Bf2OLjK 6yV3qoI0RCu8I5DOcq5Nb+MnauOEWgc1E1hQGs3NdKmTOl4Y/Jlz9OVZARBw8pvX/22+ 7Cm1u4L8WZQo7PMHtZpGsGWh9TvXKsGW7Dc9Rh/GcaTJTp5l/mRjnaFxrE6C8hONjgIc dTVbBVazQyYYBzO8OZNy/C8jOnDmZrw3gBLCOA1jSBsnsqlLmZjZ8bkqn8UaNgYNkcVk r0Zg== 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:mime-version:content-transfer-encoding; bh=s+yFWYJIlSICmhm10tVUfzLOMvlRQ6VDJMbx/0w2dnM=; b=MQi1EZh/x5Q0pNX/vgJSwfwxh06WDSUagYyaTJwmQeaSmjxdcsAXxFUIf7I12F0QPq hbrRUvLg3a22TojrmAgldmfZI7WLAZlDCcz6ldqQL2ILJlLhfTF7dZ8EBOCL3HvQREsk L2YNEOr6JKoyGRoeZG6NUrx9PCqCB+PY9BgcXvO+PTBYCNaMRTqxqRZAunvkk18XECRX MoVAl0zKb0O4wEVDKbuSZJdGn/cZcO3OLZ/QZ/hF+A9J3PFlWQlRiisHi3PWd+0EYgIk 09Dpc7vQ8MUqDXx+gOrTtFEF6TfTUPs+5jziSnB06YPydyw8kRCS03QK0W9Ufv+Db90R YWaQ== X-Gm-Message-State: AOAM531H2sQhSNzvl80QlBP3GOpdxoCT7jXpujORio+07NDH8O1qXzbh k1MZKYDp6v5dhwOmHSyu0tHq1g== X-Google-Smtp-Source: ABdhPJxCZ/C5LkU5FvQk1ZK/F68K0jYwlV3rlUq0UEXtfIpESu0BTugHOfJzFdukxZNlBknHIuZEVQ== X-Received: by 2002:adf:eccf:: with SMTP id s15mr7285736wro.70.1590240442325; Sat, 23 May 2020 06:27:22 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id g69sm8098703wmg.15.2020.05.23.06.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 06:27:21 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer Subject: [PATCH v2 2/5] net: move devres helpers into a separate source file Date: Sat, 23 May 2020 15:27:08 +0200 Message-Id: <20200523132711.30617-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200523132711.30617-1-brgl@bgdev.pl> References: <20200523132711.30617-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200523_062726_027937_03C99FF0 X-CRM114-Status: GOOD ( 14.81 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephane Le Provost , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Bartosz Golaszewski There's currently only a single devres helper in net/ - devm variant of alloc_etherdev. Let's move it to net/devres.c with the intention of assing a second one: devm_register_netdev(). This new routine will need to know the address of the release function of devm_alloc_etherdev() so that it can verify (using devres_find()) that the struct net_device that's being passed to it is also resource managed. Signed-off-by: Bartosz Golaszewski --- net/Makefile | 2 +- net/devres.c | 36 ++++++++++++++++++++++++++++++++++++ net/ethernet/eth.c | 28 ---------------------------- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 net/devres.c diff --git a/net/Makefile b/net/Makefile index 07ea48160874..5744bf1997fd 100644 --- a/net/Makefile +++ b/net/Makefile @@ -6,7 +6,7 @@ # Rewritten to use lists instead of if-statements. # -obj-$(CONFIG_NET) := socket.o core/ +obj-$(CONFIG_NET) := devres.o socket.o core/ tmp-$(CONFIG_COMPAT) := compat.o obj-$(CONFIG_NET) += $(tmp-y) diff --git a/net/devres.c b/net/devres.c new file mode 100644 index 000000000000..c1465d9f9019 --- /dev/null +++ b/net/devres.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * This file contains all networking devres helpers. + */ + +#include +#include +#include + +static void devm_free_netdev(struct device *dev, void *res) +{ + free_netdev(*(struct net_device **)res); +} + +struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv, + unsigned int txqs, unsigned int rxqs) +{ + struct net_device **dr; + struct net_device *netdev; + + dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL); + if (!dr) + return NULL; + + netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs); + if (!netdev) { + devres_free(dr); + return NULL; + } + + *dr = netdev; + devres_add(dev, dr); + + return netdev; +} +EXPORT_SYMBOL(devm_alloc_etherdev_mqs); diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index c8b903302ff2..dac65180c4ef 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -400,34 +400,6 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs, } EXPORT_SYMBOL(alloc_etherdev_mqs); -static void devm_free_netdev(struct device *dev, void *res) -{ - free_netdev(*(struct net_device **)res); -} - -struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv, - unsigned int txqs, unsigned int rxqs) -{ - struct net_device **dr; - struct net_device *netdev; - - dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL); - if (!dr) - return NULL; - - netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs); - if (!netdev) { - devres_free(dr); - return NULL; - } - - *dr = netdev; - devres_add(dev, dr); - - return netdev; -} -EXPORT_SYMBOL(devm_alloc_etherdev_mqs); - ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) { return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr); From patchwork Sat May 23 13:27:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11566815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D9D590 for ; Sat, 23 May 2020 13:28:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D48DD20727 for ; Sat, 23 May 2020 13:28:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QF2G8aGW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="mp9fRUIz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D48DD20727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xeKardh/GTb6NTkIcPcEUFgnUQPVfYITjVFtAN/Rhf8=; b=QF2G8aGWAPzQOv Xcj8FAvdXZcgFrgGPyU3T3i7Cn25E2IThClO+ThUx96P/bTGkXNJxD/bVe/r8ktLeVNjDLBLfCUt1 iRs0osMHdhKQqm7YMFAG9NuIRplkHPmiEIARxifp38ykr0aEfqAJwZm/YQtWorJU4PxA9KJmjt2B3 9St2eVkZ54n5/y32pBQMKXlkfU5JKHfqDWnvv5znGCet92Y/MBxSwJlqOWKMnhLkWCB5RdwVjIIpY qTm9ujdV1hKMEJ48HGT/0RGc3DQ0cOylZNLyu64u8jg2QN2U0mSccYTBT/BmExYs42jaskONdYks+ XLFD/cVY5tirx3O5a9kw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUCj-00044B-Ef; Sat, 23 May 2020 13:28:45 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBS-0002xv-35 for linux-mediatek@lists.infradead.org; Sat, 23 May 2020 13:27:28 +0000 Received: by mail-wm1-x344.google.com with SMTP id g14so6159276wme.1 for ; Sat, 23 May 2020 06:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=85LArQ1FkfasqQwvTGBUsmFOdZ74xT3FAzPREvSXT3E=; b=mp9fRUIz3f7zzigyw8CU4tWQdJuD/cNnqmRAvK/VRG+g0juXIdGy1ACtv8QzDSAVvX zZTtdlmptVqzrDUoGctCNcVv+sp+kvHHQLKobjmUSABO5WlVbnS7ZjDu5eL8ghHSECVm K66u1sz1Vvr9cojS1puCVm7MHqwqSP+KeNpcs0Ikin3L/OSp6a6ja1mHMqLhXZ7QSF33 cmQ40C5Sb89UJ4E1ZZShWVrrBxftRA6RfclHz/BjVeWTuoRi2J+VvqnLv5AlUcR7mc7l F0zaODP7z0PlC5yJ+Y5QhZw5HjxWCqux45s0hgaopOwzgqaGcyNlp2dO1XJ/1y0vfKmZ FmJw== 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:mime-version:content-transfer-encoding; bh=85LArQ1FkfasqQwvTGBUsmFOdZ74xT3FAzPREvSXT3E=; b=o4IEKyHTlrD0WF7OOceS3wGi2W3ZRcu3Ihwk06u594KlRQ2F1ZgAnHpwJkrFN4TFiA jmZ5/QjL6zWD2gosBzPLmKwL9N6oshfVkKbRn5JrBEA4sXGZZ/w9VUKerFwpWUV17IFm 6XwFKtBurm8o4DRsNwx/TniDByk3ArvkRdps53OwDxaQrVM4dt4CTrx2D/tgqbPUvtgM UUoL2FZtwlgta0gCnlcuDLEBpZbk9LoCGTCKidg9gLLMj/dCdATv5dL/ETPiYtbKJATV DpI8NDwwj3WxaSoOJzamX4LDfyJIJgP8e47yp9BlyB2xu1Tt3+aWpyINCZMjWSIvBtAu WHEw== X-Gm-Message-State: AOAM533yWyYOGgfCYVL6j12/su2cWFQsO7hqzZK3FR2TvNsMBsQ6Y0kv llIuDVdzX2qPjGVxppVT9C6jsg== X-Google-Smtp-Source: ABdhPJw0PA+P0HcUXiWXYQRZQG2lReeBtiQJfZFPYkFAcWtI7Dg+DCbBae2YfDUJLHDk1mI3Rm2NpA== X-Received: by 2002:a1c:acc8:: with SMTP id v191mr18521019wme.154.1590240443748; Sat, 23 May 2020 06:27:23 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id g69sm8098703wmg.15.2020.05.23.06.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 06:27:23 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer Subject: [PATCH v2 3/5] net: devres: define a separate devres structure for devm_alloc_etherdev() Date: Sat, 23 May 2020 15:27:09 +0200 Message-Id: <20200523132711.30617-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200523132711.30617-1-brgl@bgdev.pl> References: <20200523132711.30617-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200523_062726_140550_88CCCE40 X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephane Le Provost , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Bartosz Golaszewski Not using a proxy structure to store struct net_device doesn't save anything in terms of compiled code size or memory usage but significantly decreases the readability of the code with all the pointer casting. Define struct net_device_devres and use it in devm_alloc_etherdev_mqs(). Signed-off-by: Bartosz Golaszewski --- net/devres.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/net/devres.c b/net/devres.c index c1465d9f9019..b97b0c5a8216 100644 --- a/net/devres.c +++ b/net/devres.c @@ -7,30 +7,34 @@ #include #include -static void devm_free_netdev(struct device *dev, void *res) +struct net_device_devres { + struct net_device *ndev; +}; + +static void devm_free_netdev(struct device *dev, void *this) { - free_netdev(*(struct net_device **)res); + struct net_device_devres *res = this; + + free_netdev(res->ndev); } struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv, unsigned int txqs, unsigned int rxqs) { - struct net_device **dr; - struct net_device *netdev; + struct net_device_devres *dr; dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL); if (!dr) return NULL; - netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs); - if (!netdev) { + dr->ndev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs); + if (!dr->ndev) { devres_free(dr); return NULL; } - *dr = netdev; devres_add(dev, dr); - return netdev; + return dr->ndev; } EXPORT_SYMBOL(devm_alloc_etherdev_mqs); From patchwork Sat May 23 13:27:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11566817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95C621391 for ; Sat, 23 May 2020 13:28:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AC6320727 for ; Sat, 23 May 2020 13:28:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MGy+ioXU"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="zXGySE29" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AC6320727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OeTVJF+gg8cHAuULX0DRaYXHeOVolFy+8IqTVm7MGZM=; b=MGy+ioXUQ/+rad 5AjFOZYcOJsyv+UnJ9+3oQ3XSlbnqO0WIVkTdn+weEA8RD4lVgnxDudzjZ3aZs+dQDznWd1mulyfn toSNLl3QDOnLLKSQAjK0oYZZuKo3MATUPIta+noO70T+uQGX2GAz6ZjoVhG9ZM+KygibrqoKkJcjl xcwbiT36T50YhR6A5Rt3rIlC4s/GTO3ukLdw0B627d3vjfL6is8VFJoMmlFa0cWg/uacIActf0rtB YsmV9iow9UTdtkHLfNYo3MjY0vrpFs84O+zEBXZSztPls5OkdblflScpaXvOXjAPrrHAnLO42hO04 I8aBQmqVFIyZLMdjhuuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUCn-00047b-1v; Sat, 23 May 2020 13:28:49 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBS-0002zx-Rc for linux-mediatek@lists.infradead.org; Sat, 23 May 2020 13:27:28 +0000 Received: by mail-wm1-x344.google.com with SMTP id u12so7875877wmd.3 for ; Sat, 23 May 2020 06:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ONT3vRSeVRfEE12bPXzs+yYjP//BMjbMroWZWOBsM7g=; b=zXGySE29onLTxz3KlDEKLrBZoY6D4JfFiFwNCAQEsaN0Ue1lCSE0cFDtjB5glen5hf GpBUnIenKwWi8UyeKz9QEs+24f7Ew6x1qeX/2zG8bze2muYu/Z/ExTsKrBWsykAXN+VA sr3LHySTm7WGu7mIc7Qtyp4SgPSTIk4yBfKpE7Hbn121fk66KsH3Br0OhrzjMWsGOVpH MjT2tOUaB/PC3Kvg9BiAVE+sb1fQeHj/KA47f4HERf78tYLh/PfIAmhULEzLHMzjs3KI EBgrzPb21BrFyh7XwJ/KdeCcdgruYTjLs7YfHGNDlxjOwY/waUeoZFx7rXmiSkjv267s rwmg== 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:mime-version:content-transfer-encoding; bh=ONT3vRSeVRfEE12bPXzs+yYjP//BMjbMroWZWOBsM7g=; b=dYuv470wHdSxZkli8aS6B0whRKZsdtQ5MIquTUU0fK4U4CeGvu1Y9uKgcgdaLDjSIE oaFPYvK4AyeyYIIpig4KtrRx3LuHud3Z2zBrkGelk9yHrhfGtxLLUCi8q2AMy3PcdYHz U0nSd6x82QE3WA7wW1HgH/G4XreYJqlNO6IH7fnMGS1OMJWm4/dq7UEnpS7FSPlveSxA sZ01LxyKCaiPpI5G5Lt3oeyVqjgWLFxuCn3pCODxu21x6BkybvLliXv2oXCPHtziGAuL p+kS5I9IrBVVGL3shWv5x0Hxm5kLKzIX6YFF2YnRtgnzu5V0zE4hrfttuVIiZzYiF/V9 dBWA== X-Gm-Message-State: AOAM532iefknyNdKSIPdjR79lYFhj9FykMUsPV+bYzTQGThd7/WT3QCu W2vr20IZfGZ4yaluc5upmalqvQ== X-Google-Smtp-Source: ABdhPJyCQeCyp/Z7zfBD8KySrZNmyBzGf1kVuRCo1R5Ao5q3l4Ezr4kGNvE/pPs4RmWXLElvmDBbfw== X-Received: by 2002:a1c:4e0c:: with SMTP id g12mr964734wmh.25.1590240445253; Sat, 23 May 2020 06:27:25 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id g69sm8098703wmg.15.2020.05.23.06.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 06:27:24 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer Subject: [PATCH v2 4/5] net: devres: provide devm_register_netdev() Date: Sat, 23 May 2020 15:27:10 +0200 Message-Id: <20200523132711.30617-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200523132711.30617-1-brgl@bgdev.pl> References: <20200523132711.30617-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200523_062726_921473_FC99AA4D X-CRM114-Status: GOOD ( 13.30 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephane Le Provost , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Bartosz Golaszewski Provide devm_register_netdev() - a device resource managed variant of register_netdev(). This new helper will only work for net_device structs that are also already managed by devres. Signed-off-by: Bartosz Golaszewski --- .../driver-api/driver-model/devres.rst | 1 + include/linux/netdevice.h | 2 + net/devres.c | 55 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index 50df28d20fa7..fc242ed4bde5 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -375,6 +375,7 @@ MUX NET devm_alloc_etherdev() devm_alloc_etherdev_mqs() + devm_register_netdev() PER-CPU MEM devm_alloc_percpu() diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a18f8fdf4260..1a96e9c4ec36 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4280,6 +4280,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, int register_netdev(struct net_device *dev); void unregister_netdev(struct net_device *dev); +int devm_register_netdev(struct device *dev, struct net_device *ndev); + /* General hardware address lists handling functions */ int __hw_addr_sync(struct netdev_hw_addr_list *to_list, struct netdev_hw_addr_list *from_list, int addr_len); diff --git a/net/devres.c b/net/devres.c index b97b0c5a8216..57a6a88d11f6 100644 --- a/net/devres.c +++ b/net/devres.c @@ -38,3 +38,58 @@ struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv, return dr->ndev; } EXPORT_SYMBOL(devm_alloc_etherdev_mqs); + +static void devm_netdev_release(struct device *dev, void *this) +{ + struct net_device_devres *res = this; + + unregister_netdev(res->ndev); +} + +static int netdev_devres_match(struct device *dev, void *this, void *match_data) +{ + struct net_device_devres *res = this; + struct net_device *ndev = match_data; + + return ndev == res->ndev; +} + +/** + * devm_register_netdev - resource managed variant of register_netdev() + * @dev: managing device for this netdev - usually the parent device + * @ndev: device to register + * + * This is a devres variant of register_netdev() for which the unregister + * function will be call automatically when the managing device is + * detached. Note: the net_device used must also be resource managed by + * the same struct device. + */ +int devm_register_netdev(struct device *dev, struct net_device *ndev) +{ + struct net_device_devres *dr; + int ret; + + /* struct net_device must itself be managed. For now a managed netdev + * can only be allocated by devm_alloc_etherdev_mqs() so the check is + * straightforward. + */ + if (WARN_ON(!devres_find(dev, devm_free_netdev, + netdev_devres_match, ndev))) + return -EINVAL; + + dr = devres_alloc(devm_netdev_release, sizeof(*dr), GFP_KERNEL); + if (!dr) + return -ENOMEM; + + ret = register_netdev(ndev); + if (ret) { + devres_free(dr); + return ret; + } + + dr->ndev = ndev; + devres_add(ndev->dev.parent, dr); + + return 0; +} +EXPORT_SYMBOL(devm_register_netdev); From patchwork Sat May 23 13:27:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11566823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B04BD90 for ; Sat, 23 May 2020 13:29:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E10C20727 for ; Sat, 23 May 2020 13:29:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Zd8N8kAW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="WCoxlxcA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E10C20727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EENaklHDdjYmZtp2inA9lMkwFYY2AJggLuADeOPbxOI=; b=Zd8N8kAWiODF/8 PkuO18xjjOYnGip/Rbmv2bmEFDMh9hLmPOJdTls6rHT4tkIvzUxwuoSQoVFNZL1w+GKvNfrcJqFXg /3O0eGzI4tKh4sfcIfvKMAZ6aBdP2c5RINp1jijGgwndhNx9z77h3x0EgrrC5cdBrYsO4aRmUXx4X GS5D/7yxXYCFoFIUr74vaCqOoo6HCNqnDk476uiz8xXa5Ioagyf7XDMHfV0pEs4TaqdYwf9pWgt66 72MX1Un99QjobUpFq4EiSXZb3WzMmLqwZX9fCLpty3nxZ+2hLW3zitLE2qk8zDNChgC9xE7z0fVox F6jDt2UNt6/W5/3CW/AQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUDN-0004e2-0u; Sat, 23 May 2020 13:29:25 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBU-00031U-D0 for linux-mediatek@lists.infradead.org; Sat, 23 May 2020 13:27:29 +0000 Received: by mail-wr1-x441.google.com with SMTP id e1so12974070wrt.5 for ; Sat, 23 May 2020 06:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=64kvwBG1/A4ZIpIpQ81Lq/ynCrPXhKaGjAzI5WzwgPE=; b=WCoxlxcAreaFf6FWNGwNvYKxgyg/0gU+HbaYFg23bXDv4PSZYQHZlcxTOz7FCYoubj 5e5E0jUoENWF/3lKC2kOeluwhMEcroHJYd4LLhnNzHEnkUXIYnNGkbayPKVmcdBOa4Ct Zd7GHa3AvzA8wj3qLAFTjfju/dvJxGVk6M8DDJ+ik4ZotMuSwK1r56f3O59Uk50PFPVn R0DaSsNzfIUyeO9IWOXdsNRiOpScHj5lcBRivA9lt7wATE958fMmZQ8bNr/E3zw9Lp+a lRCGiGC2Qe4t821qu5XEVbdXbkQ+sQS32lFBOC3K6B9MwNUMYCIjE+kQk5GoDFnQ/755 JQPw== 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:mime-version:content-transfer-encoding; bh=64kvwBG1/A4ZIpIpQ81Lq/ynCrPXhKaGjAzI5WzwgPE=; b=AKk7fdkyRiNqyjIl8ZvYVQ/5xbUmXIO81slDX+hTa0UO4H7G2w+Hq8yTDE/q/ZM/pM CG4oUqlpoy5qQDyO5if2n5ZaI0VYwx4/HhHBt9XFIBFV6AnoaS4J0fOB80rla4kUIwmF DvFs3/XE9v/4BrxidTX6guhXXnxhyRZ2DYRk7sI90vJ9gHjh7wmwHjfEDT/nU9U42s0J AEN8q+AKgxDP7zuoYv9P1IxvNoP9k3U8iQSpuTpLF0jJigq5UiBXxH0A6kj/qIoK51ue oD/Asrk8p20NxgUtdLyyAGAznJvk/2Ga2yX+SF4BQcduu/xtuyx4sQzgDi8jFaKN0V5o JP8w== X-Gm-Message-State: AOAM5333d6Rpv2LfvDBzmIid1du7RscqvawxgAO0cJu+BAkHTNnt3CdZ iC0jc9d+2puAzMAYWz/Az/IJqQ== X-Google-Smtp-Source: ABdhPJzIGyb5J01y0YxEKH5gekjElLjvEzQP6NEzA1GtaboJVo5CQutHS2WF+ceWndsriO45lbSBPQ== X-Received: by 2002:adf:e3c1:: with SMTP id k1mr3797110wrm.33.1590240446683; Sat, 23 May 2020 06:27:26 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id g69sm8098703wmg.15.2020.05.23.06.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 06:27:26 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Jakub Kicinski , Arnd Bergmann , Fabien Parent , Heiner Kallweit , Edwin Peer Subject: [PATCH v2 5/5] net: ethernet: mtk_star_emac: use devm_register_netdev() Date: Sat, 23 May 2020 15:27:11 +0200 Message-Id: <20200523132711.30617-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200523132711.30617-1-brgl@bgdev.pl> References: <20200523132711.30617-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200523_062728_459041_D3E52EB5 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephane Le Provost , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Bartosz Golaszewski Use the new devres variant of register_netdev() in the mtk-star-emac driver and shrink the code by a couple lines. Signed-off-by: Bartosz Golaszewski --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index 789c77af501f..b74349cede28 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -1519,13 +1519,6 @@ static void mtk_star_mdiobus_unregister(void *data) mdiobus_unregister(priv->mii); } -static void mtk_star_unregister_netdev(void *data) -{ - struct net_device *ndev = data; - - unregister_netdev(ndev); -} - static int mtk_star_probe(struct platform_device *pdev) { struct device_node *of_node; @@ -1641,15 +1634,7 @@ static int mtk_star_probe(struct platform_device *pdev) netif_napi_add(ndev, &priv->napi, mtk_star_poll, MTK_STAR_NAPI_WEIGHT); - ret = register_netdev(ndev); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, mtk_star_unregister_netdev, ndev); - if (ret) - return ret; - - return 0; + return devm_register_netdev(dev, ndev); } static const struct of_device_id mtk_star_of_match[] = {