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: 11566807 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 B60161391 for ; Sat, 23 May 2020 13:27: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 8884520727 for ; Sat, 23 May 2020 13:27:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rnERHkp2"; 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 8884520727 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-arm-kernel-bounces+patchwork-linux-arm=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=xrm4rtMwu+lG/0PBVFPWT/QeKhVVapSlHO7pUIyq6do=; b=rnERHkp2HXWIZJ VGBMIgy+TsuXDEUAEc7aDE3VZbgANTuGzM7IH2K7p5n5uhG68DcQ572tYda9LUG8cLbSwxbmQ6Q6u zLrVt3h6p5ztMLNwzNOkeo5IXzJiXxwfA5qT1Vx7+0diYb+4inX2F8iWmRdojcmU/LQMkvR43itNn PqQSPD+anHtpHW9MaLize4ptpA0ZuvtbdMwNfJAsJAz8PsQllOI8E+W5GJdwuPbindBw7alpQvL6e YPrFCnukVttqKcSwuUVojzRMeqJOCmj961n9pGHRABLY2apecBbZS2p3CjBQYHuArfIFa/LKXxQJe Fv+n3xNfdnPZRzuMGW2w==; 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 1jcUBp-0003HA-W5; Sat, 23 May 2020 13:27:50 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBO-0002wX-57 for linux-arm-kernel@lists.infradead.org; Sat, 23 May 2020 13:27:23 +0000 Received: by mail-wr1-x442.google.com with SMTP id q11so822203wrp.3 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=sDsU550z5EFz5M88+jnuWRjlrL7LbDUVmTGIhNUlaC692uSHlqxJhTBmGf8tdJzNQw NVjoEfa4cGHnd/7HqXYFHDtrMEQ1Btoa1mzzTX+zAI05uDNlfsZyXBQv5y2cBREYqDTp Q1WQvmDEHnUsRQcwDNo8lGAx0FgHYM0JfDzUjdQ3Xcz9cLXN7vxBIIrEzlmqHddr50b3 Fv6Q19wOYpDVdpoa90SBzZFLgK6mzNKcrKve4ZGISdfi0G9vQ9Z2A2vV9NOCsIExslAR VzvLqiTBK7Vp1HDlpyWsJgr4mghmbmenvpg5e+XeuuymbCJKKmv/kHD5khUxGW/1qM+Z hVVw== X-Gm-Message-State: AOAM531V1aIk7ODClwITM3qLcTny5Onxa44OOvIso1fYVb24RTEa0dhf Gwe+uvPsrcJQqqkOXIBHRLU+YA== 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_195659_A41B93B8 X-CRM114-Status: UNSURE ( 9.52 ) 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:442 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-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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: 11566813 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 95CD490 for ; Sat, 23 May 2020 13:28:42 +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 4E73F2072C for ; Sat, 23 May 2020 13:28:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XFiWIgti"; 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 4E73F2072C 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-arm-kernel-bounces+patchwork-linux-arm=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=9rZ3vrCxjgbYMAPstWDoamPmVPYFTEoTRRPOSg1rGWQ=; b=XFiWIgtiJrZhkV 5lkUofztaUZA+vrpR/zSbYY9Izu/MAqQgZ5iZ+CycH7XitaR7YOvhcxd/99k8jLr3Y9dor0MtKolY 8sBEWkxJyGoor1+h4R+rkM9CJ63qQWpBNfEeSvOtBwzMDr+poR9Bpe23SZ7pxKdL1P6AxRoC8DBc/ f/O5TNc45x0rU3A1kcyeDyjEVZqgH/CzWW7JbRqyn+XRQXBxVSlAdERvawFdRifWZGKNcstRiTRhA x4GwpjQhDl3mIdh9u+ioWq30d9irureEdx0JsMW9AsuAP13hR2xpXmRuwNM1mbxY/fk+aAQajXd+w VCNQfxLMi2qBqQd2tDeg==; 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 1jcUCY-0003sa-N7; Sat, 23 May 2020 13:28:34 +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-0002xL-Sa for linux-arm-kernel@lists.infradead.org; Sat, 23 May 2020 13:27:28 +0000 Received: by mail-wr1-x444.google.com with SMTP id g12so11778093wrw.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=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=FhW94UmnKAm4B8uHM0JXLxPQDD3p37Uw/j94nxHoAbfcFKhRC118u0ufOvTZc7cSm6 uir2YBNj2nQw1sil9Gy+lCqwp9Dm8cF+myppV1dafSzDaqlAU64aotAJ24ZDh6UCNkzm DzTp87MXvvJAVbvCFzeAg6DfLJXPWLEy7ZGZgDbtUob2YUHBL8xvesVgdFIqc/y7255x UsFroR/rFMFzEHxumxUNV2h6gNjQ95OgekTDRGpf/XzS3E7lCg6cuFZTGcgNpciDGEac LxdngX8NBHWsrkuYdnpBV/pAS6lPfEoLGYB8oU1BXq4oFy/H44HT1pFOBcyVLwzWCRdw WIZw== X-Gm-Message-State: AOAM531R1uhk+yMfJl0+Asz8BLjzvd2iYS0NQ2MDGbcbs4d4B9BNsb1J qUr/twOu+CA8YhbJ+VERBa4rIA== 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_027634_CAA7DE9F X-CRM114-Status: GOOD ( 16.49 ) 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-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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: 11566809 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 5C8151391 for ; Sat, 23 May 2020 13:28:13 +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 22DCD20727 for ; Sat, 23 May 2020 13:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="n5gBYhKF"; 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 22DCD20727 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-arm-kernel-bounces+patchwork-linux-arm=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=uylnTHrcfb/0jJiNBfr95EXFrC/mw1LGwWQAeyy3czo=; b=n5gBYhKFOOqyjN 2mkIaeXpUx3FcF35jwIF2jaDcwLK1nweCVvOjuvwqdiUObriGnDCedfeW/U0aDSY9zlFY+kQOch/F POwuB+IxJfhEKv2ZzxQBiP0BP6G+74drek+qE0z15C/QDsVzZOJi2p89bVzK4uEDZWt8RiBqKLYrm PBAlp9plWM/8BfG50yXdd0SUMY7mFL9HJqZdNMqMytDXXR0j1+LIS+LnFzjoW5Af04FoUtsGDKORR XLG3GsFl1v53fbS4GccHHuDpoFGfLcdr1PBXFN5q2DcVPn64oRcVHL1w2txS3rKPfDKOUSpEsb30l pYj4UPtbCGGvv9r8YcMg==; 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 1jcUC6-0003WB-AY; Sat, 23 May 2020 13:28:06 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBQ-0002xw-Uf for linux-arm-kernel@lists.infradead.org; Sat, 23 May 2020 13:27:26 +0000 Received: by mail-wm1-x343.google.com with SMTP id u13so2535879wml.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=nWcyD7uLn9gYhXi+7VM1FgMMuxiDvJQJm6LJwkwYcMr4/1AJwFadUbDjbzU1qCg5Rz nizJHoE8bgN/nlgZ0Ti906vlfByJT2VGgjNZYIwKVC6Z0J8GLYzEEiyrf0FRRnJxAMSN z+ZJxEBwgzB8Uz9KFDt/USBGUDHX9inAyzTNp0cd78wMjKYQBZZwxm2SaEOZCBKVvsi/ z9FzfFaFRYRbQ/JQ5ahajUkcB09cTLEkMYeUw1Lir2Q6tVK0b8fwRJifKsZNjqCLbKJY hXyzSWrPZxAEQSwgKnzr1DJ2kGtBJqYXW70J11BdE4BDXOMjejgmXVnNoD9uXgVI0vmE 5YPw== X-Gm-Message-State: AOAM533aUqybJUOg7cCbK3dn0TLSSybV+59VXvS5d/dSm0p14biT6smH 1KN1WBWzw+NBS4g2COLp8fTcJA== 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_062724_997615_66270F9F X-CRM114-Status: GOOD ( 12.99 ) 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:343 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-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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: 11566819 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 C360E90 for ; Sat, 23 May 2020 13:29:03 +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 9FA7B20727 for ; Sat, 23 May 2020 13:29:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MYVSCdKO"; 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 9FA7B20727 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-arm-kernel-bounces+patchwork-linux-arm=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=gOm6clFlNcs8zozwVCU12GSY9edOsVjKLjP1zVmyqXU=; b=MYVSCdKOLasF6B zrzMZ9fSoxAtmnNhH0FbyZG5QksWbtKTjA1vUnldalFWQN+ee29bnjPIG+XpWZm/OTpytanhuTkxW 9BjqFFPDvhK1xG37E6QXqt6TigloRoVO7sS/qGw9kvkNkTjlw7jjnY/lR+nKo5YnBzJkiKM4FpLy8 oKTEAB1p6ny3ymON6ySpK3sKC1WqoxyyG33Hxqxuhur7qJMaR8XCK04S5QeN7xW2wnj3jiOOs2Xh4 ED9X6H1kScbCDaISnYJmx52oJQABsUT5MCP7nAqV5sGcNx1b26b4kZ1SGHYy2YEgHr5Ep4PRurQ6X OgmsdSo3unqwtaE2CC0A==; 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 1jcUCu-0004Bb-5h; Sat, 23 May 2020 13:28:56 +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 1jcUBT-0002zu-0y for linux-arm-kernel@lists.infradead.org; Sat, 23 May 2020 13:27:29 +0000 Received: by mail-wm1-x344.google.com with SMTP id w64so12646829wmg.4 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=GsI/2TDQ+3sVL596BE29h3eIunQQr/D6D1mtkIx5nvsX3eW/wJs4RAhR6dQaTu+y2G zGjuL+JMzhCNRyH8jLr6fz3S96bgvy9CsX93634GjkfM269doBFsNBM1L/RgIaCKxqLT HHByv1uYpP5e9vXP+1LkkGVMcoK86cJ464ZVGGO2FMz4kycgBMSiYnLk6yrNceeYPrfw 3cIiA/QAve4KphzdRweUmnn9d/7awGhxtA/I5gz48/Vz+lxq94PzbvVB5Tg+62Bq9Bkd SfDEgWYjn3DfIavaOruqNBB0yqT0gK1URqRrOifugiYkpHu9EliwDHoYSSw2q9kKjGxA 8zaQ== X-Gm-Message-State: AOAM532QezkoPGa2ayrX0P5wSJpx7vQZ3yL1ffh6p/g1nOD5CFBYeyxz mEVvS6voZggWdFdfN38rRUer8w== 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_062727_232820_27F88CB3 X-CRM114-Status: GOOD ( 14.98 ) 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-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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: 11566821 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 AAED31391 for ; Sat, 23 May 2020 13:29:12 +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 7CAAC20727 for ; Sat, 23 May 2020 13:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z+sRsdq7"; 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 7CAAC20727 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-arm-kernel-bounces+patchwork-linux-arm=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=D+vf/sDeJKWepX7Z2ULEzzdbkAXDD0iB7x0UxVF1Cn4=; b=Z+sRsdq7MkfZMN rXTbxRHBtswQGgm6zsk1UiK8+3HBzaAaxobsvksyO4tANebY+VTDpvzhUoOvYwQcFsO3A/PSxVQDL w3UgZp3VU2nLa6Y6NuS2+tXCt2DC6XZuLBSIBsghuM2pFX10R3SJkGAst5d8Vf6WCkMsmnFpOgnqw rFYjUyYrS0QrNRQCkj7vQrOj2Qee6/8/HOyqC9BLPzaTcZwqnRWOa5wuR+hWZyXFd6MNtWT9cdqLe 6Vx2mPfFO2jqrxDPqWsi9Wu5EWVuU9q5i8emi36NchXfwxdvFAQ+EYKEAwLx+SgJAc4Z/Jbn1RVbn G8s0MgcbqXe1nSllsopg==; 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 1jcUD7-0004OH-6o; Sat, 23 May 2020 13:29:09 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcUBU-00031T-6C for linux-arm-kernel@lists.infradead.org; Sat, 23 May 2020 13:27:30 +0000 Received: by mail-wr1-x442.google.com with SMTP id j16so541376wrb.7 for ; Sat, 23 May 2020 06:27:28 -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=hedDawdhHT31fMeCTP4gOqiIbDse52bMm8aX2qdQ6Opr1nNZHVu1URcoG/DhFa+lre /aHxgNvb5jTf4/vLlt8cgiAJXeriJ8WiuCSRszH4AP0pTWwrhq7/FgCiUq5m6evcswEy suuAtSX+O5YG0i/3kdmHnjkoreLxrE3cdyG/cEaVWpqSzYwPWAPHAy0YHkdit6YnpKUB DCKFalAhCWHyaxb+9KFK2h1XLtzIf4ISOr7Nbsw/76eP+IisgIBy6OkYqtzBLNqwl4Em wGk5mWK2g8UyhtDnTN+nb/2Vob6Mp0VRcGEPRvSkBfz8YlT2BQXYfT72kGLOxV4qpUhX SBlw== X-Gm-Message-State: AOAM531NMdVH81kpfbTLBE9HzzTNfFrsfoSTYwg5sOryXew+PYhXaX3j OxcfOfxJbnsntyAUxOvJM2HqaA== 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_406476_9A74B50E X-CRM114-Status: GOOD ( 13.54 ) 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:442 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-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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[] = {