Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1536979pxp; Sun, 6 Mar 2022 18:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJye+/gxU+WPPOlf14VkbV5XlV5jLaiS7CRBMEW9Zmj2qHLLyqfjrDXj3ZQ/GFBIiHkT/y+S X-Received: by 2002:a17:906:4e8a:b0:6da:a1df:98fe with SMTP id v10-20020a1709064e8a00b006daa1df98femr7530005eju.66.1646620078205; Sun, 06 Mar 2022 18:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646620078; cv=none; d=google.com; s=arc-20160816; b=uu2Kfs4BO1sWZMMJ3ic1DnKjZetGZbWEC6Q358XDD8x9zHyLtUXiyzzINWJoC4cYTa DwdCziszUQF1j2VUCO9yH1WrG5uv24LhOVd7NsAnHjwgWaKZZ9GZrF5/VLYQGhCjwa6+ 1egRD9S6FtvzPwfxO/NtcMS3W2v80uaYUaii5avn4QuwVTzQaYdwkPrIHlRBpbtjkywP TLUMlDPSovMJfvz9dbLBMN7smG9KzVT0NFupT/iFoBJFCCmLj6IfpVkoWgJ8j+QrEfnS VZqlqxZwNdaIdqihQpefXmRM1NASHijxXO7IPv7bu+wUG7r1PuDYoRqcQd4mzV2eVrJZ D5NA== 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:cc:to:subject:from:date; bh=8hZvGWHIgrBIceNZs3F6OzZF86WtAvdCM1BlArY4lyQ=; b=m5a3SDEFyZul3dUUljgwELtMZ6m5LXbvMw9dPAiWpkWofRTqJMXZG+RmO1Z2gcuZQk mYH2nZzcuhKFlGb9xFy1h2klgCbgBP7Vs3Z77VMjhDII9Ql1QA4LIdiQ8NgrJIjiJXeV rgjUcRgYaaL37lI6hxrpOTmfqrJLK2OuwCXQqNFwkkoZc+WDeT+Y+w4nCeCS+WR/VKxl Vp41h3okFCvuGTrYdBcP/QdSYbVTUi9vGVVot5puy3qc/kF/V77WuJBkaDIDM5hRG/5b QNWYsM746n4ofMgiBRGiu2FPLjqPG5seu/mjiB41dbrcL2nhg1gH91kjj/Sn6/hS3hT2 Tb3w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170906795100b006db166ef563si2453389ejo.16.2022.03.06.18.27.36; Sun, 06 Mar 2022 18:27:58 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233717AbiCFPaW convert rfc822-to-8bit (ORCPT + 99 others); Sun, 6 Mar 2022 10:30:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiCFPaU (ORCPT ); Sun, 6 Mar 2022 10:30:20 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB4E7403F9 for ; Sun, 6 Mar 2022 07:29:28 -0800 (PST) Date: Sun, 06 Mar 2022 15:29:17 +0000 From: Paul Cercueil Subject: Re: [PATCH -next] misc: rtsx: fix build for CONFIG_PM not set To: Jonathan Cameron Cc: Arnd Bergmann , Randy Dunlap , Linux Kernel Mailing List , Wei WANG , Kai-Heng Feng , Greg Kroah-Hartman , "Rafael J. Wysocki" Message-Id: In-Reply-To: <20220306151212.00003e6f@Huawei.com> References: <20220226222457.13668-1-rdunlap@infradead.org> <449d6ceb-7308-9543-c23c-831bebffda21@infradead.org> <0D5Z7R.NUOWBMRT4GQ2@crapouillou.net> <7U5Z7R.RNKITPUWCPX32@crapouillou.net> <20220306151212.00003e6f@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Hi Jonathan, Le dim., mars 6 2022 at 15:12:12 +0000, Jonathan Cameron a ?crit : > On Sun, 27 Feb 2022 17:56:31 +0000 > Paul Cercueil wrote: > >> Le dim., f?vr. 27 2022 at 18:51:38 +0100, Arnd Bergmann >> a ?crit : >> > On Sun, Feb 27, 2022 at 6:46 PM Paul Cercueil >> >> > wrote: >> >> Le dim., f?vr. 27 2022 at 18:30:16 +0100, Arnd Bergmann >> >> >> >> There could be a DEFINE_DEV_PM_OPS(), but I don't think that's >> >> really >> >> needed - you can very well declare your struct dev_pm_ops >> without >> >> using >> >> one of these macros. Just make sure to use the >> SYSTEM_SLEEP_PM_OPS / >> >> RUNTIME_PM_OPS macros for the callbacks and pm_ptr() for the >> >> device.pm >> >> pointer. >> > >> > Ah, of course, so it comes down to >> > s/SET_SYSTEM_SLEEP_PM_OPS/SYSTEM_SLEEP_PM_OPS/ while >> > removing all the #ifdef an __maybe_unused annotations. The >> pm_ptr() >> > in driver.pm makes this slightly more optimized AFAICT, but has no >> > effect on behavior, right? >> >> The use of SYSTEM_SLEEP_PM_OPS makes sure that the callbacks are >> dropped if the dev_pm_ops is dead code, and the pm_ptr() must be >> used >> for the compiler to know that the dev_pm_ops is dead code. >> >> -Paul >> >> > > Hi Paul, > > We have one remaining case which is still ugly to do. > Where both SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS are set and > the dev_pm_ops structure is exported. > > For that one we still need to expose #ifdef fun in the > drivers I think. > > Any suggestions on a clean solution for that? Use the _EXPORT_DEV_PM_OPS() macro? If you make it call __EXPORT_SYMBOL() (with two underscores instead of one) you can specify the namespace as well. All you need then is a nice wrapper macro in pm_runtime.h, that can be used in the driver. Cheers, -Paul > Currently I have this... > > #ifdef CONFIG_PM > const struct dev_pm_ops bmc150_magn_pm_ops = { > SYSTEM_SLEEP_PM_OPS(...) > RUNTIME_PM_OPS(...) > }; > EXPORT_SYMBOL_NS(bmc150_magn_pm_ops, IIO_BMC150_MAGN); > #else > static const __maybe_unused dev_pm_ops bmc150_magn_pm_ops = { > SYSTEM_SLEEP_PM_OPS(...) > RUNTIME_PM_OPS(...) > }; > #endif > Not super clean but perhaps we do need > EXPORT_NS_DEV_PM_OPS > EXPORT_NS_GPL_DEV_PM_OPS > and potentially the non namespaced versions. > > Thanks, > > Jonathan