From patchwork Wed Jun 21 15:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13287568 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 451D7EB64DC for ; Wed, 21 Jun 2023 15:37:32 +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:References:In-Reply-To: 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: List-Owner; bh=xBkPgeyY1DAcQrsnr8F0m8CqENfjJwchcNAhTfyRgn0=; b=vVaSdBcHZEN/NW 7VcI/tr8TbY2J3AoWQvkydI4zbOvrEQfd/CuqP1cKY705md0hyUnDZnclZe4yQBMGiY/USDrEVJVN bYHeUqMgXdKWqwFIEpzcYAKALdPIRnqgS1k1MXwrnsccSpNIjIElpnQ3obcCcbqlc0mihrWwDGJEQ j6ErawcoRnhozKq+QqWJaEr/2e3DCyNdepErkST75t1eEHu3rw4dM48Y6CF3zWEhvXY0KLbLVRIy9 dk0cWN+RALfyON2f9DjwH0MRE8plz6oywf+7Ew7L4tI6k9LupVc8ObqNQ4GVmA8zD9VuXPe0ooM3b AQwKw/Z5dvhoXTr/CYFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBztP-00Exoy-27; Wed, 21 Jun 2023 15:37:11 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBztL-00Exlx-2e for linux-arm-kernel@lists.infradead.org; Wed, 21 Jun 2023 15:37:09 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f9b4a715d9so26732375e9.0 for ; Wed, 21 Jun 2023 08:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1687361822; x=1689953822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cfAhAsug9ufzHE7mkap9OTTt62MSzJGSWiVrEWzAwlU=; b=Hkolap0343pI2fTeDMlSL1ecIJgWvi+Cb3axXsbFUnMqYfjB0CdwOKmdaJCFujs4LI 0Rc9dnin8sX/+/MAm7llAX+pu3vF9n0x9GAmBwyyeDeGTFTfpDJ4L9KjfqG2N91gNgYI 55uWZk+4qz6IH6GmNakF9fu2scRuEmaclyvRs4aNEXa8gZ4/TMo0q+TtRFf8qkHzZvd0 tZjiIO5QubenHiHbQcsBfYJcJJ3oQs8Uwa1ETmppDB0V38beg2XzIi4EBzfod8JGFr/n js20442BN7akSbBSzSQKV1H96WRh3TlDX1c5fOPtTYOjTLrF9BaDoUuZxGZtP1rmWoTX xAUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687361822; x=1689953822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cfAhAsug9ufzHE7mkap9OTTt62MSzJGSWiVrEWzAwlU=; b=jA1AdIT7m7b67CExNk8RA27ZGhuUWvzdklWuTweZwpnTpIr3wrzsbViI46/IMryPle uCoNcmZlj5mIIb1w8qjsKcsZzOgUNPLRcTExO4RTTWqjlXTuavdKYYSAJGSk7lgr85Ey bu356qbAirNnjnoIINAnqtsi43T7DoDJ8msFkSg2zneDnlIoeevj1FMB11fgUIkjktUN 98T2uJlue1r7929g+CHCL4S130KZMpU+tthh0IJji5yLNGNBXuBrox+RbKbHFyvAUte1 Xntlm6a8AoKHegJkHgEjBkcAUFmKBsggx8ptS+LxMRcR9pYJKRRafFvukhh+pxnntYeY Y0Cg== X-Gm-Message-State: AC+VfDy7Fmf/+k1azlRnNF668RW2bdbJMMvGXL0Y9mlZ9v24s+Bk3sjB TsGHVm7sp4AF3jSkPO5gg3E7tA== X-Google-Smtp-Source: ACHHUZ61KtPw7PZMSqkd+p+2S3J7vRMgyN38QB8hapuEJIl2U4P060oQ1mu5xvl7D6IGcQD0QKv/mA== X-Received: by 2002:a05:600c:3659:b0:3f7:aee8:c23a with SMTP id y25-20020a05600c365900b003f7aee8c23amr19068795wmq.19.1687361822463; Wed, 21 Jun 2023 08:37:02 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:a69f:8ee3:6907:ccdf]) by smtp.gmail.com with ESMTPSA id l13-20020a1c790d000000b003f7ed463954sm5322491wme.25.2023.06.21.08.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 08:37:02 -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 01/11] net: stmmac: platform: provide stmmac_pltfr_init() Date: Wed, 21 Jun 2023 17:36:40 +0200 Message-Id: <20230621153650.440350-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230621153650.440350-1-brgl@bgdev.pl> References: <20230621153650.440350-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230621_083707_994917_53620ABF X-CRM114-Status: GOOD ( 16.23 ) 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 Provide a helper wrapper around calling the platform's init() callback. This allows users to skip checking if the callback exists. Signed-off-by: Bartosz Golaszewski --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 25 +++++++++++++++++-- .../ethernet/stmicro/stmmac/stmmac_platform.h | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3c6b55b60461..41ca4fc9f863 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -701,6 +701,25 @@ int stmmac_get_platform_resources(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(stmmac_get_platform_resources); +/** + * stmmac_pltfr_init + * @pdev: pointer to the platform device + * @plat: driver data platform structure + * Description: Call the platform's init callback (if any) and propagate + * the return value. + */ +int stmmac_pltfr_init(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) +{ + int ret = 0; + + if (plat->init) + ret = plat->init(pdev, plat->bsp_priv); + + return ret; +} +EXPORT_SYMBOL_GPL(stmmac_pltfr_init); + /** * stmmac_pltfr_remove * @pdev: platform device pointer @@ -755,9 +774,11 @@ static int __maybe_unused stmmac_pltfr_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct stmmac_priv *priv = netdev_priv(ndev); struct platform_device *pdev = to_platform_device(dev); + int ret; - if (priv->plat->init) - priv->plat->init(pdev, priv->plat->bsp_priv); + ret = stmmac_pltfr_init(pdev, priv->plat->bsp_priv); + if (ret) + return ret; return stmmac_resume(dev); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h index f7e457946681..6a2cd47fedcd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h @@ -19,6 +19,9 @@ void stmmac_remove_config_dt(struct platform_device *pdev, int stmmac_get_platform_resources(struct platform_device *pdev, struct stmmac_resources *stmmac_res); +int stmmac_pltfr_init(struct platform_device *pdev, + struct plat_stmmacenet_data *plat); + void stmmac_pltfr_remove(struct platform_device *pdev); extern const struct dev_pm_ops stmmac_pltfr_pm_ops;