From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 852DCC4361B for ; Mon, 7 Dec 2020 12:34:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FD74233EB for ; Mon, 7 Dec 2020 12:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbgLGMeW convert rfc822-to-8bit (ORCPT ); Mon, 7 Dec 2020 07:34:22 -0500 Received: from aposti.net ([89.234.176.197]:53508 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbgLGMeW (ORCPT ); Mon, 7 Dec 2020 07:34:22 -0500 Date: Mon, 07 Dec 2020 12:33:18 +0000 From: Paul Cercueil Subject: Re: [PATCH] mmc: mediatek: mark PM functions as __maybe_unused To: Arnd Bergmann Cc: Ulf Hansson , Chaotian Jing , Matthias Brugger , Wenbin Mei , Arnd Bergmann , Chun-Hung Wu , yong mao , Amey Narkhede , Marek Vasut , linux-mmc@vger.kernel.org, Linux ARM , ARM/Mediatek SoC support , Linux Kernel Mailing List , "Rafael J. Wysocki" Message-Id: In-Reply-To: References: <20201203222922.1067522-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, Le ven. 4 déc. 2020 à 15:14, Arnd Bergmann a écrit : > On Fri, Dec 4, 2020 at 11:02 AM Ulf Hansson > wrote: >> On Thu, 3 Dec 2020 at 23:29, Arnd Bergmann wrote: > >> > -#ifdef CONFIG_PM >> > static void msdc_save_reg(struct msdc_host *host) >> >> Shouldn't msdc_save|restore_reg() be turned into "__maybe_unused" >> as well? > > There is no need since the compiler can figure that out already when > there > is a reference to the function from dead code. > >> > >> > -static int msdc_resume(struct device *dev) >> > +static int __maybe_unused msdc_resume(struct device *dev) >> > { >> > return pm_runtime_force_resume(dev); >> > } >> > -#endif >> > >> > static const struct dev_pm_ops msdc_dev_pm_ops = { >> >> You may also change this to a __maybe_unused, as long as you also >> assign the .pm pointer in the mt_msdc_driver with >> pm_ptr(&msdc_dev_pm_ops). >> >> Ideally the compiler should drop these functions/datas entirely >> then. > > I don't see a lot of other instances of that yet, and it's fairly new. > Maybe we should fix it before it gets propagated further. > > I would suggest we redefine pm_ptr like > > #define pm_ptr(_ptr) (IS_ENABLED(CONFIG_PM) ? (_ptr) : NULL) By the way, as I'm ending up doing the same in a different context, I think it would be useful to have a IF_ENABLED() macro defined like this: #define IF_ENABLED(_cfg, _ptr) (IS_ENABLED(_cfg) ? (_ptr) : NULL) Then the pm_ptr(_ptr) macro could be defined like this: #define pm_ptr(_ptr) IF_ENABLED(CONFIG_PM, _ptr) Cheers, -Paul > and remove the __maybe_unused annotations on those that we > already have. This also has the effect of dropping the unused > data from the object, but without having to an an #ifdef or > __maybe_unused. > > Adding Paul and Rafael to Cc for clarification on this. > > Arnd