From patchwork Mon Jun 22 10:00:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11617667 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 8C6C06C1 for ; Mon, 22 Jun 2020 13:11:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 2B8762070E for ; Mon, 22 Jun 2020 13:11:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yc9vC2Qx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bwQHLAU6"; 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="rxCKkG6S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B8762070E 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=g9y9kleAhORVtLyOegwdnvkmmZhEhkYMCECZrDNPeyA=; b=yc9vC2QxieZTyiZwOY+C1dnVR4 GjcfSHk71cUlOC7HKkaHb/rC3kfR2txxl17D5WbZVMSvinQyUvL/vefUfI//ZKbDUGmNDamEe6dwA w0TbFUdwYyme2XawuiQd1UvYD2nwjqaSUQbqCJUeNIdhHpaKVklF9MzzmpucIdK/cxYLiawQfyFu4 jNGk4k0d0TGOpjG7pDwKMmYjG0+O0ivMe/YUXmal2T66qK4gjNdlfiLYpxlPSdoWoDUxEbXpMiX0a 1++hjwuK7QrgH03d3Ov2lGz3TM8VIyQD20+QovkK/LSoMKuaA+WiGYJ8gcI97KMhS79RaUPlYWX06 n64mGZqw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnMEm-0003Co-IU; Mon, 22 Jun 2020 13:11:48 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnLvO-0003zv-1k for linux-mediatek@merlin.infradead.org; Mon, 22 Jun 2020 12:51:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=0a5wnHY7CslRA6Iynsfhb3yG1izm8FY/pWdetFoi42c=; b=bwQHLAU68u98JDVDt5Ie1ucOkW f+xJU7OuroLXZhExg2Nzpuis3OtmtnVZQdSUFgiWrZgfYOiJbCrgAylyB8UHq4+VCvwP/mZ0SM4A6 iqVhnOMJU8Xiqy11KQksMeIAWKy+W6AjDZNQQgGhIyD/e7I6+qfXNNPSzzA4jPmZZxbUNQc722h/e 4V2ddB53F2loEC18JAvSuw+juBTP6NQ9zrKUsCDBtOF/S+ZsOqQj/1qPxnjEAajA/nxH6KHWROCQi C2PELNYNO+KOHjN8Nueee1xM2LKL2WKS/EyOMzzJHbiIR68sJM08aE6gC3x7q8AHl72d91a3XWhtl 23GLIwiQ==; Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnJGF-0004fJ-LM for linux-mediatek@lists.infradead.org; Mon, 22 Jun 2020 10:01:09 +0000 Received: by mail-wm1-x342.google.com with SMTP id r15so15091292wmh.5 for ; Mon, 22 Jun 2020 03:01:07 -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:mime-version :content-transfer-encoding; bh=0a5wnHY7CslRA6Iynsfhb3yG1izm8FY/pWdetFoi42c=; b=rxCKkG6SfwCZOTa1iL5Lojz3NDEQwyb2IxWpdYBFS7nvwaSmH3nUs6LKzmpIqO9fmz T0E4/NHNhWS1FxOj6Knq7vaDIfED18iz4zDTKFADfGdZ87o9VBNoHn9xKkFZ5ABiLuMo spikJGn8iabnLkYyJ4CKFueyLxhkCPXnn+tT0IIM62ri0cxtQBzPXWPE2OKAi+/WB4Hb Zm7iXcDn1Km9OIDru3YUscj0Ip3rFJhgBzUhsF68MWUFQB29eaTMLMdCy2o5sHrQdX4O +4gvt10n83RfLFmg67wO7WMqC6KCkbs7hPXvMxFl4ifmIlhRhWH6of7y0Q6ilwx8joXN aa9A== 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:mime-version :content-transfer-encoding; bh=0a5wnHY7CslRA6Iynsfhb3yG1izm8FY/pWdetFoi42c=; b=JUjm8hU8mDCHMGic7CmEnKzvhF3lyxnAP7uAbgjjjbY9x/8W5unsHEsxBlYDpYMjth UFuUhCIyhxNar5KOz0j2isE+KB664PgD2cXxG2frFsJ6aG49laOcLm2Qjb0wd9tSE2oI TvbjBwvfpylq73AdExS+MmOYzbQCsrlScQYCp8Rpfci/NuAJIg56fljqZ1oVBq5cgKXc UBHkKkr9PNOHQTsghrIpKoMzP7KMOyETItiH+Nfby9ADmOT1L5GNhllJulYZ7iSEzjeM aMTDmJuiE9rGQH3UjzwHgYyPYbVuETSuE/ZraSBgTRijHiC/VUKvMDSQmTWaqcta0X9p qnnA== X-Gm-Message-State: AOAM5300Nm2ZFCPv1ra2olYUv+hyRALMFoZHTWzRxgCZpKiHYEr3zR/d 1JxXjIka/VaX+ET6v7ostgXngA== X-Google-Smtp-Source: ABdhPJwltFZXM/3VYa9tIy2MbCHj//CBC2paauuUY5AwGyYeKiWa1AZvShK5hzeRuXlvCn791GVruA== X-Received: by 2002:a1c:c1:: with SMTP id 184mr17443220wma.74.1592820065387; Mon, 22 Jun 2020 03:01:05 -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 x205sm16822187wmx.21.2020.06.22.03.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 03:01:04 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , Jeff Kirsher , "David S . Miller" , Jakub Kicinski , John Crispin , Sean Wang , Mark Lee , Matthias Brugger , Realtek linux nic maintainers , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Russell King , Rob Herring , Frank Rowand Subject: [PATCH 00/11] net: improve devres helpers Date: Mon, 22 Jun 2020 12:00:45 +0200 Message-Id: <20200622100056.10151-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200622_110107_803034_827B8AE5 X-CRM114-Status: GOOD ( 15.80 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) 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:342 listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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, Bartosz Golaszewski , Stephane Le Provost , linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Fabien Parent , linux-mediatek@lists.infradead.org, Andrew Perepech , Pedro Tsai , intel-wired-lan@lists.osuosl.org, 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 When I first submitted the series adding devm_register_netdev() I was told during review that it should check if the underlying struct net_device is managed too before proceeding. I initially accepted this as the right approach but in the back of my head something seemed wrong about this. I started looking around and noticed how devm_mdiobus_register() is implemented. It turned out that struct mii_bus contains information about whether it's managed or not and the release callback of devm_mdiobus_alloc() is responsible for calling mdiobus_unregister(). This seems wrong to me as managed structures shouldn't care about who manages them. It's devres' code task to correctly undo whatever it registers/allocates. With this series I propose to make the release callbacks of mdiobus devm helpers only release the resources they actually allocate themselves as it the standard in devm routines. I also propose to not check whether the structures passed to devm_mdiobus_register() and devm_register_netdev() are already managed as they could have been allocated over devres as part of bigger memory chunk. I see this as an unnecessary limitation. First two patches aim at removing the only use of devm_mdiobus_free(). It modifies the ixgbe driver. I only compile tested it as I don't have the relevant hw. Next two patches relax devm_register_netdev() - we stop checking whether struct net_device was registered using devm_etherdev_alloc(). We then document the mdio devres helper that's missing in devres.rst list and un-inline the current implementation of devm_mdiobus_register(). Patch 8 re-implements the devres helpers for mdio conforming to common devres patterns. Patches 9 and 10 provide devm_of_mdiobus_register() and the last patch adds its first user. Bartosz Golaszewski (11): net: ethernet: ixgbe: check the return value of ixgbe_mii_bus_init() net: ethernet: ixgbe: don't call devm_mdiobus_free() net: devres: relax devm_register_netdev() net: devres: rename the release callback of devm_register_netdev() Documentation: devres: add missing mdio helper phy: un-inline devm_mdiobus_register() phy: mdio: add kerneldoc for __devm_mdiobus_register() net: phy: don't abuse devres in devm_mdiobus_register() of: mdio: remove the 'extern' keyword from function declarations of: mdio: provide devm_of_mdiobus_register() net: ethernet: mtk-star-emac: use devm_of_mdiobus_register() .../driver-api/driver-model/devres.rst | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 +- drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 14 +--- drivers/net/ethernet/mediatek/mtk_star_emac.c | 13 +-- drivers/net/ethernet/realtek/r8169_main.c | 2 +- drivers/net/phy/Makefile | 2 +- drivers/net/phy/mdio_bus.c | 73 ---------------- drivers/net/phy/mdio_devres.c | 83 +++++++++++++++++++ drivers/of/of_mdio.c | 43 ++++++++++ include/linux/of_mdio.h | 40 ++++----- include/linux/phy.h | 21 +---- net/devres.c | 23 +---- 12 files changed, 167 insertions(+), 156 deletions(-) create mode 100644 drivers/net/phy/mdio_devres.c