Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4542353rwb; Mon, 8 Aug 2022 02:59:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fVzjWNwYzkRoL15szWr7AnoL4GIQ74OKtQUwsDQzgS9tGTdC9HNZ98H5uI61lBvB9x5A1 X-Received: by 2002:a50:ee92:0:b0:43d:ffb:2258 with SMTP id f18-20020a50ee92000000b0043d0ffb2258mr16934549edr.416.1659952740340; Mon, 08 Aug 2022 02:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659952740; cv=none; d=google.com; s=arc-20160816; b=LrGmaT2vr3XNPsaQLUREADbGq5TKeOzTBft3yGr8alS1tjVHST3NotOv9bYov0L2Tm kT4wuqomegRFOjgHZJCzUMGZ+l6cIbexEJy9HEyPTTjweYybv6Naee2Y9yWN7gcvnD4N Udf2L3M7463kU0w8lH2fJh1i7x2Bd9v5oiBqfnv09nV/yxO1p2FNIDRLEOijXbGsr2LB y87y1Kk++I2b3aHoSe6ro9QTlvgryj5RWXHrlBukgb/sHlm323EFm6OEi3oDgCLkwwjG b/Xq5TkCFm6RVlXHt+iDZm0+ziPa6VrCJz2hrbofX0vdn5NK9VRr09pgeph1rnU6gIM4 hXlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=AtDWgxoDxyykGPLbYKd4p5lP7HO+IcS9F8+g5AkzyfQ=; b=Vbknrb27R2YQqQ9YfaozWLVkSazHKrIqQ4H65ZLBPd1imFtuZ3K5dhTN6UeyrEp3RY XIRkfsZhlz2w2Vjpxq8KKMeTpQcmK/QtihnYDQ3nGoR1aBiqnUrKIowy4KbJtT1bLVYr HcO+bFBuRpOEs3jmZ6JqdgkJSPJYVlnkL0wy/CgEDjHb6c038zbvmJtOQD9+PeKDHvAt Qrnc4RsMiXrUPpMu4X+ho9q0wd+xUSbWwkKfr3lVW6fsy4UxB9lvoAjvUtEMQkUn+/3t N9D3VqE9xxyi7SPFuzRDOFWnG88BCTPBV1OjH+a35yjPq/aDOxo6VfSGLbnnRg9BnnA7 wDXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b="bWq/IobP"; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a056402190700b0044066d82f6dsi6395735edz.21.2022.08.08.02.58.09; Mon, 08 Aug 2022 02:59:00 -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=@cirrus.com header.s=PODMain02222019 header.b="bWq/IobP"; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242166AbiHHJyO (ORCPT + 99 others); Mon, 8 Aug 2022 05:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238743AbiHHJyM (ORCPT ); Mon, 8 Aug 2022 05:54:12 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BC3BF6A for ; Mon, 8 Aug 2022 02:54:11 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2786txmB008165; Mon, 8 Aug 2022 04:53:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=PODMain02222019; bh=AtDWgxoDxyykGPLbYKd4p5lP7HO+IcS9F8+g5AkzyfQ=; b=bWq/IobPoNPmXsQPF3np9cHWYftzODCEbA/RipZ+fh/ta1LGhR9V+6bx5yqbw2u2jSKz Bq1KsnqY/D4pevH+xIZ6hUYkk0tm5M3BmafHYYCqrHHbGmBZu0bNatIO0rZAlAYnogOh 7jowWBrZP2TBbSX4QixcXecDkfyHA2aiPgppFEmVtAc8LdE5bi15RsKIDgood4+zL+v4 houl7XSuSB+TJptxpl8KSeV6LCCxb8UayUEgHPt5JotsOvPsymQ76KHr4EIPWHGeOmzn 5CjK1PLCDX6VfNsXh3lhwtxRoN93n0/v2kgPJzxkr50vehEhGzDl58ljKchKvGp5d/XQ lQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3hsnq1stxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Aug 2022 04:53:57 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Mon, 8 Aug 2022 04:53:55 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.9 via Frontend Transport; Mon, 8 Aug 2022 04:53:55 -0500 Received: from [198.90.251.95] (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.95]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 68979475; Mon, 8 Aug 2022 09:53:55 +0000 (UTC) Message-ID: <94394206-a018-27b0-5a21-97976fc4a3bc@opensource.cirrus.com> Date: Mon, 8 Aug 2022 10:53:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 20/28] mfd: arizona: Remove #ifdef guards for PM related functions Content-Language: en-US To: Paul Cercueil , Lee Jones CC: , References: <20220807145247.46107-1-paul@crapouillou.net> <20220807145247.46107-21-paul@crapouillou.net> From: Richard Fitzgerald In-Reply-To: <20220807145247.46107-21-paul@crapouillou.net> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: Rnhq03DVNjIVWP5hHdq_bpsPWvt6353l X-Proofpoint-GUID: Rnhq03DVNjIVWP5hHdq_bpsPWvt6353l X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 07/08/2022 15:52, Paul Cercueil wrote: > Only export the arizona_pm_ops if CONFIG_PM is set, but leave the > suspend/resume functions (and related code) outside #ifdef guards. > > If CONFIG_PM is not set, the arizona_pm_ops will be defined as > "static __maybe_unused", and the structure plus all the callbacks will > be automatically dropped by the compiler. > > The advantage is then that these functions are now always compiled > independently of any Kconfig option, and thanks to that bugs and > regressions are easier to catch. > > Signed-off-by: Paul Cercueil > Cc: patches@opensource.cirrus.com > --- > drivers/mfd/arizona-core.c | 21 +++++++++++---------- > drivers/mfd/arizona-i2c.c | 2 +- > drivers/mfd/arizona-spi.c | 2 +- > 3 files changed, 13 insertions(+), 12 deletions(-) > > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c > index cbf1dd90b70d..c1acc9521f83 100644 > --- a/drivers/mfd/arizona-core.c > +++ b/drivers/mfd/arizona-core.c > @@ -480,7 +480,6 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona) > return 0; > } > > -#ifdef CONFIG_PM > static int arizona_isolate_dcvdd(struct arizona *arizona) __maybe_unused? > { > int ret; > @@ -742,9 +741,7 @@ static int arizona_runtime_suspend(struct device *dev) __maybe_unused? > > return 0; > } > -#endif > > -#ifdef CONFIG_PM_SLEEP > static int arizona_suspend(struct device *dev) __maybe_unused? > { > struct arizona *arizona = dev_get_drvdata(dev); > @@ -784,17 +781,21 @@ static int arizona_resume(struct device *dev) __maybe_unused? > > return 0; > } > -#endif > > +#ifndef CONFIG_PM > +static __maybe_unused > +#endif No need to ifdef a __maybe_unused. > const struct dev_pm_ops arizona_pm_ops = { > - SET_RUNTIME_PM_OPS(arizona_runtime_suspend, > - arizona_runtime_resume, > - NULL) > - SET_SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume) > - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq, > - arizona_resume_noirq) > + RUNTIME_PM_OPS(arizona_runtime_suspend, > + arizona_runtime_resume, > + NULL) > + SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume) > + NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq, > + arizona_resume_noirq) > }; > +#ifdef CONFIG_PM > EXPORT_SYMBOL_GPL(arizona_pm_ops); > +#endif This ifdeffing is ugly. Why must the structure only be exported if CONFIG_PM is set? > > #ifdef CONFIG_OF > static int arizona_of_get_core_pdata(struct arizona *arizona) > diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c > index 6d83e6b9a692..8799d9183bee 100644 > --- a/drivers/mfd/arizona-i2c.c > +++ b/drivers/mfd/arizona-i2c.c > @@ -119,7 +119,7 @@ static const struct of_device_id arizona_i2c_of_match[] = { > static struct i2c_driver arizona_i2c_driver = { > .driver = { > .name = "arizona", > - .pm = &arizona_pm_ops, > + .pm = pm_ptr(&arizona_pm_ops), > .of_match_table = of_match_ptr(arizona_i2c_of_match), > }, > .probe = arizona_i2c_probe, > diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c > index 941b0267d09d..da05b966d48c 100644 > --- a/drivers/mfd/arizona-spi.c > +++ b/drivers/mfd/arizona-spi.c > @@ -282,7 +282,7 @@ static const struct of_device_id arizona_spi_of_match[] = { > static struct spi_driver arizona_spi_driver = { > .driver = { > .name = "arizona", > - .pm = &arizona_pm_ops, > + .pm = pm_ptr(&arizona_pm_ops), > .of_match_table = of_match_ptr(arizona_spi_of_match), > .acpi_match_table = ACPI_PTR(arizona_acpi_match), > },