From patchwork Fri Jun 23 10:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13290248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 109F0EB64D7 for ; Fri, 23 Jun 2023 10:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=HG0jtAKFh1StIqEK/XthN7G7Za2TOF+pCj8J6dR1zKg=; b=3ya+KuaJW2L4Ai ++aJL6kbvT8UzcCjp/1QWt4IzfgP3JWa02pNms1GgVz19DH+EbkpeQphunET3AGQR5mH/vvYsc1db UOTzQD6i5REOV4HzoQ3WE5Cm4qP9WLsyihDFb6e9FtXuIYH4J0dM0qlxepZcpo5IJYoU0ctIbIJNl iCfk7Ie/GhR3hfEciRxdTkj7SeYv48VSYY5Xs71uSA/qNwPaKw1Sm7E3bt5IQsGCbMPglyqG8gKpP j0KOpmz1bHp5rEaE/qbcqeRhEmCNO7ptv3KzHIj5Uc3vJHYDEwZ50369ee99usvSSMtrQPUjOQTuc b88DNRbtWmFWm24jrVHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCdeV-00365y-1f; Fri, 23 Jun 2023 10:04:27 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCdeS-00364J-0w for linux-arm-kernel@lists.infradead.org; Fri, 23 Jun 2023 10:04:26 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31129591288so443951f8f.1 for ; Fri, 23 Jun 2023 03:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1687514661; x=1690106661; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6qjTp+QHdjXZsiJdy1c6W+7WSusbljTMLadetQu+CGU=; b=B6Vux4DTtLobjKhHj6oCnNVAbEFhOtLv2CIz60kfoOv3rrspOnjmptB7E+HMXkTef9 6x6TEzMfr8hLctZVfvXhjGBeOTTrl7jocsfNoBlRXeOWCkiQk8m3zt2c7w6By4kTERXw jiNCT8Lu1y0RkHDjuDoynGjYwDks2UiYs6uQcA1SIIcv7S8Wu888LKLj426BRvV0jiQH x+wPzd3OcM9wKAvIrFwiYT88ItGISPz+L47qwA6Lk1tr19SzOLFIA2NiLgE2aob3mjwd bh8fKTLLwONkWlpV+VhtQl5wquRlsKBZuV0No/Ev5su9n3TgIj30xB+MLCwc/eUFuosK DLEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687514661; x=1690106661; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6qjTp+QHdjXZsiJdy1c6W+7WSusbljTMLadetQu+CGU=; b=cXLg5Tq1LP2d5AUe5BaqMqqPeE862TFi1OuGdEvP4N8Xvj9pU7bkURmIIvkBEbd8UO S+Qib6gdG4FP9NRpwtqIwhRfgFXjPRzq3L5y0+4Rkapk7Tz94LBYWzCEp8PfvCcRvatV /hFKAqS1IyIslE3YPzHTiUjJOWUJzcJ6cUK10G7KiL0ygXFlNy5idFiFHQ2egNjpqi+O 0DbKe0/SkonOs12D72T4z9KDEHJ6z9cKNmAhrGVkB/BbCgtyMcmlD+mYJXzRsdOrLaia 22+nUm1RDU1bRU5+aFNGxXVFh8uPcAU5NhyygSHftVSlB2st/Q8lWAs/aEZtNYGbktBI WPpw== X-Gm-Message-State: AC+VfDwKCgA+Kn7TPYEtCREsKtf3yqMB2Ch+Y+mQgOevGJgbmKtT4YWO 0C3SAF3X60gW1l4FrIXiOqZ+gkoIOla9IDf1kMI= X-Google-Smtp-Source: ACHHUZ6wSeHhdjH2GIsP0ttor7xJzJ+HpgcGwNpZ1USLEMTkAVBXlUFw+HYK1QZiuLPDn1mzeq8JtA== X-Received: by 2002:a5d:444b:0:b0:30a:f143:25d2 with SMTP id x11-20020a5d444b000000b0030af14325d2mr14823232wrr.5.1687514661474; Fri, 23 Jun 2023 03:04:21 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ddc2:ce92:1ed6:27bd]) by smtp.gmail.com with ESMTPSA id x8-20020a5d54c8000000b0030fae360f14sm9079360wrv.68.2023.06.23.03.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 03:04:21 -0700 (PDT) From: Bartosz Golaszewski To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Junxiao Chang , Vinod Koul , Bhupesh Sharma Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH net-next v2 00/11] net: stmmac: introduce devres helpers for stmmac platform drivers Date: Fri, 23 Jun 2023 12:04:06 +0200 Message-Id: <20230623100417.93592-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230623_030424_556804_66FACD47 X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski The goal of this series is two-fold: to make the API for stmmac platforms more logically correct (by providing functions that acquire resources with release counterparts that undo only their actions and nothing more) and to provide devres variants of commonly use registration functions that allows to significantly simplify the platform drivers. The current pattern for stmmac platform drivers is to call stmmac_probe_config_dt(), possibly the platform's init() callback and then call stmmac_drv_probe(). The resources allocated by these calls will then be released by calling stmmac_pltfr_remove(). This goes against the commonly accepted way of providing each function that allocated a resource with a function that frees it. First: provide wrappers around platform's init() and exit() callbacks that allow users to skip checking if the callbacks exist manually. Second: provide stmmac_pltfr_probe() which calls the platform init() callback and then calls stmmac_drv_probe() together with a variant of stmmac_pltfr_remove() that DOES NOT call stmmac_remove_config_dt(). For now this variant is called stmmac_pltfr_remove_no_dt() but once all users of the old stmmac_pltfr_remove() are converted to the devres helper, it will be renamed back to stmmac_pltfr_remove() and the no_dt function removed. Finally use the devres helpers in dwmac-qco-ethqos to show how much simplier the driver's probe() becomes. This series obviously just starts the conversion process and other platform drivers will need to be converted once the helpers land in net/. v1 -> v2: - fix build for !CONFIG_OF Bartosz Golaszewski (11): net: stmmac: platform: provide stmmac_pltfr_init() net: stmmac: dwmac-generic: use stmmac_pltfr_init() net: stmmac: platform: provide stmmac_pltfr_exit() net: stmmac: dwmac-generic: use stmmac_pltfr_exit() net: stmmac: platform: provide stmmac_pltfr_probe() net: stmmac: dwmac-generic: use stmmac_pltfr_probe() net: stmmac: platform: provide stmmac_pltfr_remove_no_dt() net: stmmac: platform: provide devm_stmmac_probe_config_dt() net: stmmac: dwmac-qco-ethqos: use devm_stmmac_probe_config_dt() net: stmmac: platform: provide devm_stmmac_pltfr_probe() net: stmmac: dwmac-qcom-ethqos: use devm_stmmac_pltfr_probe() .../ethernet/stmicro/stmmac/dwmac-generic.c | 14 +- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 48 ++--- .../ethernet/stmicro/stmmac/stmmac_platform.c | 164 +++++++++++++++++- .../ethernet/stmicro/stmmac/stmmac_platform.h | 14 ++ 4 files changed, 185 insertions(+), 55 deletions(-)