Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4260771imm; Mon, 14 May 2018 05:10:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoI2hFZ7plh0voQw11jp+3PyUKLr+rl2nWGEN4iIfTt/B1PiSNIP+BXnw4OGRxeKkXwr/dx X-Received: by 2002:a65:4102:: with SMTP id w2-v6mr8285234pgp.31.1526299806710; Mon, 14 May 2018 05:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526299806; cv=none; d=google.com; s=arc-20160816; b=QQaLz8xebzRrBEUgOfBG8ElSDz/aGRZaWlNigdi5CRkBsuFXQVSCts7Wu1JoMX0NLX lK66oP5diBcxnp8JeK9fOf5a8P8yHC8gI8mMh13M1L0q/JB2CpHRwCQyQIbOyKNqFQyw LrLbG092IXbzujAn7tApn0Lx1KnfCt5psylqOQWDXHmENzB4fw2OvdG/0sUG6+s12PKo f5xU0BcQuJ8MUVHRFooP07Q7QKIbj75sbspTGE2tPZT4246wW+y5Gxmrd93jWJcc/zBE 7A85OygE85v5+gEQJ6FgBaIuzSQS+ekiU8vwIDG23BJj6v7ldcikLIj9yqJVdcHubzUt W5eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=UH+qDWW7YtaduBhJOmt4MGov3uqJl1AueU2FgL44bN4=; b=BJvjuYKmS96O8+CuUQ6oV/UEGu4mrStypSfMulsg/HzTxeEmNGx2HaKk/L/Iu8IXeB fQdr5dN8pRzEQYg2pVQZZKPsAyW0jIU1ZZs3G18lFLZkkJLmySKC0C6doRMPSPN69Cd+ 6e9siUTGUwIyQcBQc2JMQdKIlGAbqQ8ygVATFoBh1Ac8UktsDBhl5oS4pgAokdU/LDOx t5TARQgmubBaxo+ztXcgZUaD942USmKIL5lyQx3yBCwiS/86ACb+YYbff5v44vIvyXa1 mOZ7x0U7BlQ/HJDIuqRgzIu/G/3WqtSYrsgULRTf3uTrMTYa+t9+pGs43WX+Z8uq/oQC b6/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=EU1cYOaM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4-v6si7312185pgt.613.2018.05.14.05.09.52; Mon, 14 May 2018 05:10:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=EU1cYOaM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752846AbeENMIH (ORCPT + 99 others); Mon, 14 May 2018 08:08:07 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40180 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752011AbeENMIE (ORCPT ); Mon, 14 May 2018 08:08:04 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180514120802euoutp02837f396736c0f1c48b70f124541aa464~ugXln5g341687516875euoutp02H for ; Mon, 14 May 2018 12:08:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180514120802euoutp02837f396736c0f1c48b70f124541aa464~ugXln5g341687516875euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526299682; bh=UH+qDWW7YtaduBhJOmt4MGov3uqJl1AueU2FgL44bN4=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=EU1cYOaMuArOMFMQjUfFYID3HhCHpg0tUGTW462BnZar8TiWCaFHjyXxKdc9fiMDA YgDWFX3n6HL5RTmftloT89EEny1xDCkptLaWk7/TMg1PvZjt3XCcld4V6L7mkFu7NT 1hQzMiWuXX53Tf3A7LuC3THY07GxtPwlSsdiZ1pE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180514120800eucas1p1b76af220aff1b100b5ca5bdeea7b262b~ugXkLuhWu0327703277eucas1p1d; Mon, 14 May 2018 12:08:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FC.42.17380.F1C79FA5; Mon, 14 May 2018 13:08:00 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180514120759eucas1p1875a9756c2d7cb33b39b5ac78b8beb09~ugXi5aWxi0331603316eucas1p1W; Mon, 14 May 2018 12:07:59 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180514120758eusmtrp16201d7543a7de403788f8399e08a3115~ugXiLnyTB3084730847eusmtrp1V; Mon, 14 May 2018 12:07:58 +0000 (GMT) X-AuditID: cbfec7f4-b4fc79c0000043e4-af-5af97c1f2bbb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 68.83.04183.E1C79FA5; Mon, 14 May 2018 13:07:58 +0100 (BST) Received: from [106.120.43.17] (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180514120758eusmtip1859ab55e99eaa7fb331028cfd3b980cb~ugXhxz2cC2228622286eusmtip1h; Mon, 14 May 2018 12:07:57 +0000 (GMT) Subject: Re: [PATCH] PM / core: refactor PM_OPS initializers To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , Arnd Bergmann From: Andrzej Hajda Message-ID: <9e1f4be2-436e-0d60-eb28-44c229a3178c@samsung.com> Date: Mon, 14 May 2018 14:07:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180514082146.4318-1-a.hajda@samsung.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGKsWRmVeSWpSXmKPExsWy7djPc7oKNT+jDFZeYLL4O+kYu8XGGetZ LWZN2ctkcXnXHDaLz71HGC3WHrnLbnH31FE2izOnL7E6cHj8/jWJ0WPxnpdMHluutrN49G1Z xeixYvV3do/Pm+QC2KK4bFJSczLLUov07RK4Mj6dv89U8EGu4tqtD6wNjGckuxg5OSQETCQ+ bPzH1MXIxSEksIJR4n/LSnYI5wujxJ0ZPSwQzmdGiVnPlzPBtHzqnATVspxRov/GV2YI5y2j RMeSd6xdjBwcwgI2Eu9/a4DERQSWMkpcnvqGFcRhFmhjlLjZcJERZBSbgKbE38032UBsXgE7 if9T9rKD2CwCqhJ73u1kAbFFBSIkmp7/ZIeoEZQ4OfMJWJxTwELi4YfLYL3MAvISzVtnM0PY 4hK3nswHO09CYB+7xJQVi9gg7naRWPX9NpQtLPHq+BZ2CFtG4vTkHhYIu1ri5osmFojmDkaJ +7/boRqsJQ4fvwj2GjPQ1et36UOEbSX2rjnMBhKWEOCTuPFWEOIGPolJ26YzQ4R5JTrahCCq FSXun93KDGGLSyy98JVt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Q1OzW1ILUIpo+Jg1OqgfEk75mVjakdl0wj77d6H8hcXug8 6asj4y2+ajfNtNgI+XyHt4IfvkfV9vU9d02Mjr8pbCFVn9/R8+tLyUQ15wVpceIy3wTfbbm4 UkL7NnfEC6uzQetfn5Ou/qf9Zf2SvV3WCVeqCib5eorM50idyPMs6CcDz5GnB/rP/Vz4utTj 0jLzT8pmYUosxRmJhlrMRcWJAL/NUhnaAgAA X-CMS-MailID: 20180514120759eucas1p1875a9756c2d7cb33b39b5ac78b8beb09 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180514120759eucas1p1875a9756c2d7cb33b39b5ac78b8beb09 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f X-RootMTR: 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f References: <20180514082146.4318-1-a.hajda@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.05.2018 10:21, Andrzej Hajda wrote: > With current implementation of PM_OPS initializers users should annotate > all PM callbacks with __maybe_unused attribute to prevent compiler from > complaining in case respective option is not enabled. Using ternary > operator with IS_ENABLED(symbol) as a condition allows to avoid marking > these functions with __maybe_unused. > Solution was tested successfully with multiple versions of gcc since > 4.9.4 up to 7.2.1. No functional changes has been observed and callbacks > were compiled out if not used, as before. The kernel does not compile with the patch applied if the driver defines PM callback inside "#ifdef CONFIG_PM(_SLEEP)" - initializers assume that callbacks are defined, even if they are not used. So if the idea is OK I should figure it out how to make proper transition, any ideas welcome :) Regards Andrzej > > Signed-off-by: Andrzej Hajda > --- > include/linux/pm.h | 61 ++++++++++++++++++---------------------------- > 1 file changed, 24 insertions(+), 37 deletions(-) > > diff --git a/include/linux/pm.h b/include/linux/pm.h > index e723b78d8357..59f333922c15 100644 > --- a/include/linux/pm.h > +++ b/include/linux/pm.h > @@ -313,50 +313,37 @@ struct dev_pm_ops { > int (*runtime_idle)(struct device *dev); > }; > > -#ifdef CONFIG_PM_SLEEP > +#define PM_SLEEP_PTR(ptr) (IS_ENABLED(CONFIG_PM_SLEEP) ? (ptr) : NULL) > +#define PM_PTR(ptr) (IS_ENABLED(CONFIG_PM) ? (ptr) : NULL) > + > #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ > - .suspend = suspend_fn, \ > - .resume = resume_fn, \ > - .freeze = suspend_fn, \ > - .thaw = resume_fn, \ > - .poweroff = suspend_fn, \ > - .restore = resume_fn, > -#else > -#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) > -#endif > + .suspend = PM_SLEEP_PTR(suspend_fn), \ > + .resume = PM_SLEEP_PTR(resume_fn), \ > + .freeze = PM_SLEEP_PTR(suspend_fn), \ > + .thaw = PM_SLEEP_PTR(resume_fn), \ > + .poweroff = PM_SLEEP_PTR(suspend_fn), \ > + .restore = PM_SLEEP_PTR(resume_fn), > > -#ifdef CONFIG_PM_SLEEP > #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ > - .suspend_late = suspend_fn, \ > - .resume_early = resume_fn, \ > - .freeze_late = suspend_fn, \ > - .thaw_early = resume_fn, \ > - .poweroff_late = suspend_fn, \ > - .restore_early = resume_fn, > -#else > -#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) > -#endif > + .suspend_late = PM_SLEEP_PTR(suspend_fn), \ > + .resume_early = PM_SLEEP_PTR(resume_fn), \ > + .freeze_late = PM_SLEEP_PTR(suspend_fn), \ > + .thaw_early = PM_SLEEP_PTR(resume_fn), \ > + .poweroff_late = PM_SLEEP_PTR(suspend_fn), \ > + .restore_early = PM_SLEEP_PTR(resume_fn), > > -#ifdef CONFIG_PM_SLEEP > #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ > - .suspend_noirq = suspend_fn, \ > - .resume_noirq = resume_fn, \ > - .freeze_noirq = suspend_fn, \ > - .thaw_noirq = resume_fn, \ > - .poweroff_noirq = suspend_fn, \ > - .restore_noirq = resume_fn, > -#else > -#define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) > -#endif > + .suspend_noirq = PM_SLEEP_PTR(suspend_fn), \ > + .resume_noirq = PM_SLEEP_PTR(resume_fn), \ > + .freeze_noirq = PM_SLEEP_PTR(suspend_fn), \ > + .thaw_noirq = PM_SLEEP_PTR(resume_fn), \ > + .poweroff_noirq = PM_SLEEP_PTR(suspend_fn), \ > + .restore_noirq = PM_SLEEP_PTR(resume_fn), > > -#ifdef CONFIG_PM > #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ > - .runtime_suspend = suspend_fn, \ > - .runtime_resume = resume_fn, \ > - .runtime_idle = idle_fn, > -#else > -#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) > -#endif > + .runtime_suspend = PM_PTR(suspend_fn), \ > + .runtime_resume = PM_PTR(resume_fn), \ > + .runtime_idle = PM_PTR(idle_fn), > > /* > * Use this if you want to use the same suspend and resume callbacks for suspend