From nobody Fri Sep 19 03:48:22 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 961B1C433FE for ; Tue, 29 Nov 2022 19:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236782AbiK2TUx (ORCPT ); Tue, 29 Nov 2022 14:20:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236779AbiK2TUA (ORCPT ); Tue, 29 Nov 2022 14:20:00 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2684A6A757 for ; Tue, 29 Nov 2022 11:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1669749486; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GXp3V8OWFSqCNWUIleivToEKqZcIGzXiTpP98hO8E8c=; b=EeGei6LnJKO6mGWa8RpkBRQ03VjBEPFJ8KX5roLt5+FwPmqMgbiRHeDmknPTUtKfE0R4Gn atNTFJtzdna062bv1oyeN8nvEIQ8j8DBbwvBNcz0qrridF8rCq1fMWx49oJxr5vmZF4HXk GKoE0/QZRxvzqzIr8VpmvJQPvJnklB4= From: Paul Cercueil To: David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Paul Cercueil , Lucas Stach , Russell King , Christian Gmeiner , etnaviv@lists.freedesktop.org Subject: [PATCH v2 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions Date: Tue, 29 Nov 2022 19:17:19 +0000 Message-Id: <20221129191733.137897-13-paul@crapouillou.net> In-Reply-To: <20221129191733.137897-1-paul@crapouillou.net> References: <20221129191733.137897-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use the RUNTIME_PM_OPS() and pm_ptr() macros to handle the .runtime_suspend/.runtime_resume callbacks. These macros allow the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM is disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. Some #ifdef CONFIG_PM guards were protecting simple statements, and were also converted to "if (IS_ENABLED(CONFIG_PM))". Signed-off-by: Paul Cercueil --- Cc: Lucas Stach Cc: Russell King Cc: Christian Gmeiner Cc: etnaviv@lists.freedesktop.org --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 +++++++++++---------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnavi= v/etnaviv_gpu.c index 51320eeebfcf..310382812029 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1629,7 +1629,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu = *gpu) return etnaviv_gpu_clk_disable(gpu); } =20 -#ifdef CONFIG_PM static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu) { int ret; @@ -1645,7 +1644,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *= gpu) =20 return 0; } -#endif =20 static int etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev, @@ -1713,11 +1711,10 @@ static int etnaviv_gpu_bind(struct device *dev, str= uct device *master, if (ret) goto out_workqueue; =20 -#ifdef CONFIG_PM - ret =3D pm_runtime_get_sync(gpu->dev); -#else - ret =3D etnaviv_gpu_clk_enable(gpu); -#endif + if (IS_ENABLED(CONFIG_PM)) + ret =3D pm_runtime_get_sync(gpu->dev); + else + ret =3D etnaviv_gpu_clk_enable(gpu); if (ret < 0) goto out_sched; =20 @@ -1761,12 +1758,12 @@ static void etnaviv_gpu_unbind(struct device *dev, = struct device *master, =20 etnaviv_sched_fini(gpu); =20 -#ifdef CONFIG_PM - pm_runtime_get_sync(gpu->dev); - pm_runtime_put_sync_suspend(gpu->dev); -#else - etnaviv_gpu_hw_suspend(gpu); -#endif + if (IS_ENABLED(CONFIG_PM)) { + pm_runtime_get_sync(gpu->dev); + pm_runtime_put_sync_suspend(gpu->dev); + } else { + etnaviv_gpu_hw_suspend(gpu); + } =20 if (gpu->mmu_context) etnaviv_iommu_context_put(gpu->mmu_context); @@ -1880,7 +1877,6 @@ static int etnaviv_gpu_platform_remove(struct platfor= m_device *pdev) return 0; } =20 -#ifdef CONFIG_PM static int etnaviv_gpu_rpm_suspend(struct device *dev) { struct etnaviv_gpu *gpu =3D dev_get_drvdata(dev); @@ -1923,18 +1919,16 @@ static int etnaviv_gpu_rpm_resume(struct device *de= v) =20 return 0; } -#endif =20 static const struct dev_pm_ops etnaviv_gpu_pm_ops =3D { - SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, - NULL) + RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, NULL) }; =20 struct platform_driver etnaviv_gpu_driver =3D { .driver =3D { .name =3D "etnaviv-gpu", .owner =3D THIS_MODULE, - .pm =3D &etnaviv_gpu_pm_ops, + .pm =3D pm_ptr(&etnaviv_gpu_pm_ops), .of_match_table =3D etnaviv_gpu_match, }, .probe =3D etnaviv_gpu_platform_probe, --=20 2.35.1