From patchwork Wed Jul 5 09:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 116049 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1755872vqx; Wed, 5 Jul 2023 03:06:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqcPjFrg8Mo4aqkSu6ezzMSS4KSigdBpcxaNqn52AmG8U8KNYxdEchJpWR3ficlJ6MuH+/ X-Received: by 2002:a05:6a20:60b:b0:12e:5d45:82e0 with SMTP id 11-20020a056a20060b00b0012e5d4582e0mr8947207pzl.29.1688551609839; Wed, 05 Jul 2023 03:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688551609; cv=none; d=google.com; s=arc-20160816; b=zwQSQH0fn52JczWAE90eACzmtbT1JUsVcG2V/aZJT5f6O7s9kbbpBV7dGqb0sXz+dm 7aTdKgC1F0hfx51TIaCqi5yjQzdrMyAwxShHlh1D9TMo3qzo2KrjJ1TG5Tlz9XJcIfDk t3buPxaHbnyRSk8I6IcZnUp+/MA7pTfLM17b5THKXN7IzctZbXFO8qt5Oufnq4CHclBa gL0HIsVc8sEzwZ29T3/Y44R/cjJyDx76R+/IMBD/kyqtRnTgzIJg51SPn9NeCpbGHA3L MZx3MxlRL1Xpx0t0+coi6iyU1vUzMX22kjZCQVqayzPfRHlGKVa1Wd9g9iLrCV9N2t51 /0JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qEjY0pJ03KTFVE3D2Oet2dG8L0f1BpiJtlSNubHAZYw=; fh=GtjaMYw2TYloLzK30vS75IDngJXbdOYxBF5PTOLPdxc=; b=XNrswmC7JYHch1ICxdGW3A/jlHsC4IB/OX/OAGgTT2E+Lwjzs/wUgUE6w+h/Gfn3jK 1YrjlQhImN40nhzOincuWepH+DdB3xkoQILrRs14bgkW6yMM0HZ9/sW+vPlvkza7QE7E XahRhbCBND3E1vO937eV5SJSJZlXuJ8Ppw3k6/M2HpKD8iaL0AnA0Tow+j3H5QEJBr8W gm+g4jrTxWBCTHlOS7OZ/9WIs5UqzpIcp40L/f07I9CNAKPWkFQXB327PG8Ii1sxhKJz OSSfL1YFQocI77GOzD/W8l568kdFr6+235OOmvMlpaRU2tfkO99trMbS9F6+GLO4M/2o w4Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mV4KH6Ti; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6300cf000000b0055acc7f8085si21257618pga.367.2023.07.05.03.06.19; Wed, 05 Jul 2023 03:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mV4KH6Ti; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231785AbjGEJmu (ORCPT + 99 others); Wed, 5 Jul 2023 05:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbjGEJmo (ORCPT ); Wed, 5 Jul 2023 05:42:44 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8006E1713 for ; Wed, 5 Jul 2023 02:42:43 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8EA8C6606FAF; Wed, 5 Jul 2023 10:42:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688550162; bh=ZA49h1P49IwOFaurPRFCaUbkBJXDbiP3QFwn/8w9YXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mV4KH6Tik3DJS6rQUo6x4eQBUvBlEjRnSNfVO1frmedsbfOBDMoo2yxZK0XyKrfdt lYTtOyvhF3QKiYdLAHENTAEMBmU1tcWRJi+VWgda/IyKk1aDeRunniLePfLUpNz3op alYtJ0kzCTgh0xRek8LIexewmkpnf8dWwhrc+x3WSchMIKG/P1gZMl5UuTua+0YxvV YrezsM7OTDUARq6baWioqk9TM2w/tFLb2rM7bntHXP35Nkgh792soERTl2XlSYwlia IKFRxUKrYcuTe66eXCsogXK3DP+90qICQ7Y6RRA4GmNDo3W7eQbJEAzPYLyaa2jMZ/ ELOF2YTBuf7xQ== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Alexandre Mergnat , CK Hu Subject: [PATCH v2 3/3] drm/mediatek: Use devm variant for pm_runtime_enable() when possible Date: Wed, 5 Jul 2023 11:42:32 +0200 Message-Id: <20230705094232.75904-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230705094232.75904-1-angelogioacchino.delregno@collabora.com> References: <20230705094232.75904-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770574692818730108?= X-GMAIL-MSGID: =?utf-8?q?1770574692818730108?= Simplify the error path of return functions and drop the call to pm_runtime_disable() in remove functions by switching to devm_pm_runtime_enable() where possible. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat Reviewed-by: CK Hu --- drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 9 ++++----- drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 11 ++++------- drivers/gpu/drm/mediatek/mtk_mdp_rdma.c | 10 +++++----- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index 1993b688befa..14e8ad6c78c3 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -519,13 +519,13 @@ static int mtk_disp_ovl_adaptor_probe(struct platform_device *pdev) component_master_add_with_match(dev, &mtk_disp_ovl_adaptor_master_ops, match); - pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; ret = component_add(dev, &mtk_disp_ovl_adaptor_comp_ops); - if (ret) { - pm_runtime_disable(dev); + if (ret) return dev_err_probe(dev, ret, "Failed to add component\n"); - } return 0; } @@ -533,7 +533,6 @@ static int mtk_disp_ovl_adaptor_probe(struct platform_device *pdev) static int mtk_disp_ovl_adaptor_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &mtk_disp_ovl_adaptor_master_ops); - pm_runtime_disable(&pdev->dev); return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c index cfbc037a0f6d..0469076cf715 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c @@ -360,13 +360,13 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); - pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; ret = component_add(dev, &mtk_disp_rdma_component_ops); - if (ret) { - pm_runtime_disable(dev); + if (ret) return dev_err_probe(dev, ret, "Failed to add component\n"); - } return 0; } @@ -374,9 +374,6 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev) static int mtk_disp_rdma_remove(struct platform_device *pdev) { component_del(&pdev->dev, &mtk_disp_rdma_component_ops); - - pm_runtime_disable(&pdev->dev); - return 0; } diff --git a/drivers/gpu/drm/mediatek/mtk_mdp_rdma.c b/drivers/gpu/drm/mediatek/mtk_mdp_rdma.c index ae05d9660592..a5d811c37207 100644 --- a/drivers/gpu/drm/mediatek/mtk_mdp_rdma.c +++ b/drivers/gpu/drm/mediatek/mtk_mdp_rdma.c @@ -299,20 +299,20 @@ static int mtk_mdp_rdma_probe(struct platform_device *pdev) #endif platform_set_drvdata(pdev, priv); - pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; ret = component_add(dev, &mtk_mdp_rdma_component_ops); - if (ret) { - pm_runtime_disable(dev); + if (ret) return dev_err_probe(dev, ret, "Failed to add component\n"); - } + return 0; } static int mtk_mdp_rdma_remove(struct platform_device *pdev) { component_del(&pdev->dev, &mtk_mdp_rdma_component_ops); - pm_runtime_disable(&pdev->dev); return 0; }