From patchwork Sun Oct 23 09:48:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 7986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1558409wrr; Sun, 23 Oct 2022 03:30:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74POre+Oqlf/cEWeGz0jUvz8sGzZIsNDe/li4TuX3guAWU2r70E976RPKMo2NVnkL2UKaW X-Received: by 2002:a17:907:3f8f:b0:78d:f741:7f5a with SMTP id hr15-20020a1709073f8f00b0078df7417f5amr23040852ejc.71.1666521003668; Sun, 23 Oct 2022 03:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666521003; cv=none; d=google.com; s=arc-20160816; b=HPyN/XxqrDdSpLALVs5E7op/ivj1I/4yhIaioL7L1dbDagavnrb0/1GsFTnwQDQPaX C/RB+To4JKHfeR1A8W5IzOqDdmLOC9IA91S3sr1wxuy+thWv/GDhYY/R6EKSq+RV0wff jw/AJB8wPj9VmGEe77Ml+Hs7pzjXChlErG1eBFKnfdni186QPKxBvfOnd+oxZ87syuJl ksxS4QA0FLLoYY9hF3wByoNo05wfjHtvcBOSJLk0EnD5/3upRXUoblnsHPLW6KTk+dzO eV62Atmtg8xjrUP3+g9jV5aFVd0UwZOJAAq4VLg/5UVoZeQen3g8LuRe4EwYns1kqS8r vuEQ== 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=YSXFtUMP2239U1R0Zna0E84HFug4CfOI1c/yuHZa1WY=; b=jDHtVsK7BrN5gjx+V5nWDN6YNKwd82QK7YMC6jprLqrJmCU9xe7FJhLxoJjFji3xjT mg4bX5PgSTIrsR587bgSbJADXq0nkQeY60rgUhU1vBfZK7cJFG6oUqxeo+YX46gac3NF 83GwvCrE/9lnkjsGeVZ4cf7okp2j1/Te0rd6+7FebHhmGellsaZb+iYfag0ju8QxpHsN dVqt7PPnJ+EmXbMNrHzHAYV3KMTOYejxFLcgg8242yb0e7kAdhuSfCYMC3KxH4U5/G7K wAUpLrh5fcC8OmxOf3UgCJgApAQ7zU+Ne9jCcK6kMM70NIrzarUrTToChtrGIl8Ox6JA szQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=QOwuLGTh; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020aa7c2d6000000b0044e9fd71b82si21357440edp.280.2022.10.23.03.29.39; Sun, 23 Oct 2022 03:30:03 -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=@crapouillou.net header.s=mail header.b=QOwuLGTh; 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=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbiJWJzK (ORCPT + 99 others); Sun, 23 Oct 2022 05:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbiJWJy6 (ORCPT ); Sun, 23 Oct 2022 05:54:58 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B3D022516 for ; Sun, 23 Oct 2022 02:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666518558; 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=YSXFtUMP2239U1R0Zna0E84HFug4CfOI1c/yuHZa1WY=; b=QOwuLGThnniJS2rm7pVt7LxJYscZhBKEE7Tv34kOWnFNg4Qiz4BxDRIvnRFQJWm4Vjeave jRY7bIDtV1wqowQozXM0Zt9yfBDxihcCiPy9yhGzUSrj76q0r6YVLc1XMtj/Hs3oaYI4+C Oqz7GOeo7RU3/xKrtYb7ogh96xfqmGA= From: Paul Cercueil To: Lee Jones Cc: linux-kernel@vger.kernel.org, Paul Cercueil , Maxime Coquelin , Alexandre Torgue , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 25/28] mfd: stmpe: Remove #ifdef guards for PM related functions Date: Sun, 23 Oct 2022 10:48:49 +0100 Message-Id: <20221023094852.8035-26-paul@crapouillou.net> In-Reply-To: <20221023094852.8035-1-paul@crapouillou.net> References: <20221023094852.8035-1-paul@crapouillou.net> 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_PASS,SPF_PASS 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?1747473928289798533?= X-GMAIL-MSGID: =?utf-8?q?1747473928289798533?= Use the new EXPORT_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle the .suspend/.resume callbacks. These macros allow the suspend and resume functions to be automatically dropped by the compiler when CONFIG_SUSPEND 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. Signed-off-by: Paul Cercueil --- V2: remove duplicated "const". Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org drivers/mfd/stmpe-i2c.c | 4 +--- drivers/mfd/stmpe-spi.c | 4 +--- drivers/mfd/stmpe.c | 8 ++------ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index d3eedf3d607e..bf094cc9f9de 100644 --- a/drivers/mfd/stmpe-i2c.c +++ b/drivers/mfd/stmpe-i2c.c @@ -116,9 +116,7 @@ MODULE_DEVICE_TABLE(i2c, stmpe_i2c_id); static struct i2c_driver stmpe_i2c_driver = { .driver = { .name = "stmpe-i2c", -#ifdef CONFIG_PM - .pm = &stmpe_dev_pm_ops, -#endif + .pm = pm_sleep_ptr(&stmpe_dev_pm_ops), .of_match_table = stmpe_of_match, }, .probe = stmpe_i2c_probe, diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c index ad8055a0e286..e9cbf33502b3 100644 --- a/drivers/mfd/stmpe-spi.c +++ b/drivers/mfd/stmpe-spi.c @@ -135,9 +135,7 @@ static struct spi_driver stmpe_spi_driver = { .driver = { .name = "stmpe-spi", .of_match_table = of_match_ptr(stmpe_spi_of_match), -#ifdef CONFIG_PM - .pm = &stmpe_dev_pm_ops, -#endif + .pm = pm_sleep_ptr(&stmpe_dev_pm_ops), }, .probe = stmpe_spi_probe, .remove = stmpe_spi_remove, diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 0c4f74197d3e..c304d20bb988 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -1495,7 +1495,6 @@ void stmpe_remove(struct stmpe *stmpe) mfd_remove_devices(stmpe->dev); } -#ifdef CONFIG_PM static int stmpe_suspend(struct device *dev) { struct stmpe *stmpe = dev_get_drvdata(dev); @@ -1516,8 +1515,5 @@ static int stmpe_resume(struct device *dev) return 0; } -const struct dev_pm_ops stmpe_dev_pm_ops = { - .suspend = stmpe_suspend, - .resume = stmpe_resume, -}; -#endif +EXPORT_GPL_SIMPLE_DEV_PM_OPS(stmpe_dev_pm_ops, + stmpe_suspend, stmpe_resume);