Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4035315imm; Mon, 14 May 2018 01:23:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6aMBiUgc/rHNC6HH1qjANUcaz/v7D4fogR3Jrlw7YRqmcb+UpFGjaXC+/2iB09MuUWs4r X-Received: by 2002:a65:4bc6:: with SMTP id p6-v6mr6282828pgr.24.1526286218920; Mon, 14 May 2018 01:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526286218; cv=none; d=google.com; s=arc-20160816; b=lQi2PZ4vFBONvs68wUIm3sXvxbdrPYYElfb/Exqs7BsxqNonVF9G95etwvbupNAyhE M+4AsjdJXS7+ma6UzfG9+oRWl0xepfRTTfNMTtbXtT1sVQjP2okgx4H6hJ7vOASMN/Q1 ju8KqPrwh/RaNBuZxeQP/bgXDyl8H6qO2nIbmS3QmCjVBMIUcG5dxWDnn88GV5IwikXt jsQyiiiwHs+Xv59RsP5gSmv8/Sa9+3JNAGWUcIddf68HfLA8Ox6pZ0WIaW+oSIzHCxTc yM1dMx31uY+t4yjcyN6rAGXK4kQuvlfXNFC0DnzEh5Wy4pbjobE4lJZ/nBuwOj2WmGIm UMyg== 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:message-id:date :subject:cc:to:from:content-transfer-encoding:mime-version :dkim-signature:dkim-filter:arc-authentication-results; bh=MONq6v2PCwSpXjsC2kIRus/bMH7dDFpFT+SFW/mD9fU=; b=T+7loVIb8v+M6Z6q86N3IpSXNq1b6kBd6re7pOjVno8x5Dr1D5TSBNAONGpR+Fis/J ZJkE/2rJb5uouDCxuY480YXxkG9ynESwBeDLEXp7XF8djMm9dJtpIep4JT2G0WISmhTt Gi3jIipVQVyysvW/UDhPOwkSVp8fx7XiZTcARcWyKpNTdoldrlOZRh7P5yJUiEYTrm7G i22soQLUFjWulmFbbiFNslxamwVnp0omBQpTujiidYdSfO7hrZkRowpdyAlOp0onTMC0 A7hCRnHv/AY6eXqqXyjoN50G9WJkTKYxW2Ga0T1TKM39AxW3YyDZYrKktaJiAlU3BJ5q fLvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=G6QGaA7X; 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 q17-v6si8879426pff.301.2018.05.14.01.23.24; Mon, 14 May 2018 01:23:38 -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=G6QGaA7X; 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 S1752094AbeENIWJ (ORCPT + 99 others); Mon, 14 May 2018 04:22:09 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58817 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751954AbeENIWF (ORCPT ); Mon, 14 May 2018 04:22:05 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180514082202euoutp01baaea2a78cc77650b366e7124efad5b8~udSRcXzZj1327313273euoutp01R; Mon, 14 May 2018 08:22:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180514082202euoutp01baaea2a78cc77650b366e7124efad5b8~udSRcXzZj1327313273euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526286122; bh=MONq6v2PCwSpXjsC2kIRus/bMH7dDFpFT+SFW/mD9fU=; h=From:To:Cc:Subject:Date:References:From; b=G6QGaA7Xxvc1GwPVZCpHOYqf8rhsx0bZnFpRPE9tDKXeC2MlXJAW6vlM/yDBUbC7v OBhfYfZPoykyb3B3G9oJwStyK2d94fFtRd1dTWv0ipk7RNvaS+WFl2dVx2Bo4T5u5Y rRgC7SnPMCeiH56fbAec7+OreQHQ3FmqrtYOfCHQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180514082202eucas1p199c1a5f52685b2e72ec969c925d73ab0~udSQ7vQxe1774517745eucas1p1x; Mon, 14 May 2018 08:22:02 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DF.43.10409.92749FA5; Mon, 14 May 2018 09:22:01 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f~udSQQRG181649916499eucas1p1N; Mon, 14 May 2018 08:22:01 +0000 (GMT) X-AuditID: cbfec7f5-b45ff700000028a9-cf-5af947298de4 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CB.FE.04178.92749FA5; Mon, 14 May 2018 09:22:01 +0100 (BST) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="UTF-8" Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P8P005ISLWOTB90@eusync3.samsung.com>; Mon, 14 May 2018 09:22:01 +0100 (BST) From: Andrzej Hajda To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Arnd Bergmann Subject: [PATCH] PM / core: refactor PM_OPS initializers Date: Mon, 14 May 2018 10:21:46 +0200 Message-id: <20180514082146.4318-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHIsWRmVeSWpSXmKPExsWy7djP87qa7j+jDC43WVncWneO1eLvpGPs FhtnrGe1mDVlL5PF5V1z2Cw+9x5htFh75C67xd1TR9kszpy+xOrA6fH71yRGj8V7XjJ5bLna zuLRt2UVo8eK1d/ZPT5vkgtgi+KySUnNySxLLdK3S+DKOLF+DUvBdamKIxO/sjYwXhHrYuTk kBAwkbh1dRlLFyMXh5DACkaJDXNfMIEkhAQ+M0rc+ycDU7R2zmRWiKJljBLb/n5lAUnwCghK /Jh8D8jm4GAWkJc4cikbJMwsoCmxdfd6doj6/4wSkxb2sIMk2IASfzffZANJiAgsZZS4PPUN 2FRmgbWMEj9a9rOBVAkLWEg8/7SaDWQqi4CqxJx1RRDLzCX23VjFDnGRvMSz6fPANkgI7GGT mNq0mA0i4SKx7+chFghbWOLV8S1QDTISnR0HmSDsaombL5pYIJo7GCXu/26HaraWOHz8IivE D3wSk7ZNZwY5QkKAV6KjTQiixEOi58MORgjbUWLe/ePQ4IqV2LRgAfMERplZSAEzCxEws5AC ZgEj8ypG8dTS4tz01GLjvNRyveLE3OLSvHS95PzcTYzAVHH63/GvOxj3/Uk6xCjAwajEw7ti 5Y8oIdbEsuLK3EOMEhzMSiK8u41+RgnxpiRWVqUW5ccXleakFh9ilOZgURLnjdOoixISSE8s Sc1OTS1ILYLJMnFwSjUwylesVT01M0rs8+W3WhyTYrymrjnMnPw+PPka45Xe+Rcm9XzqTwk7 MsP1NnfGvcSO/3s8Xh9YY8yqk+T4Z7ZsPF8T796wxy6y1fnTrghtr1ye/zHEecvFM1siNiVs Nz1z89jT9uqOoHlM/L+i88snfZmVc0HwhneyjFVNsqXljcvr/k9Y+yfXV4mlOCPRUIu5qDgR AC5coRQRAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsVy+t/xq7qa7j+jDH6elbK4te4cq8XfScfY LTbOWM9qMWvKXiaLy7vmsFl87j3CaLH2yF12i7unjrJZnDl9idWB0+P3r0mMHov3vGTy2HK1 ncWjb8sqRo8Vq7+ze3zeJBfAFsVlk5Kak1mWWqRvl8CVcWL9GpaC61IVRyZ+ZW1gvCLWxcjJ ISFgIrF2zmTWLkYuDiGBJYwSv249YgNJ8AoISvyYfI+li5GDg1lAXuLIpWyQMLOAusSkeYuY IeobmSR+bVvKApJgE9CU+Lv5JliviMBSRoljd+VAipgF1jJKvL3TzgiSEBawkHj+aTUbyFAW AVWJOeuKIHaZS+y7sYod4iB5iWfT57FPYOSdheSMWQhnzEJyxgJG5lWMIqmlxbnpucWGesWJ ucWleel6yfm5mxiBYbvt2M/NOxgvbQw+xCjAwajEw7ti5Y8oIdbEsuLK3EOMEhzMSiK8u41+ RgnxpiRWVqUW5ccXleakFh9ilOZgURLnPW9QGSUkkJ5YkpqdmlqQWgSTZeLglGpgnJoffjhH tv9m/dQdys6HFyhOK9jSbuqxXFzC6P4BVq1tRxSP3D7Yrdyhw7A/aNKLyyWF8xbe+iW7dW7F 7FDmCvbTbem6+43zcybI3Txzm8nl0SS2lfVJpZOE9FOjTBZMbLPV0DjlMEnSQYuH55v18vvX 3cRXHrnx6e+bA2eV31i/8vEv8TmQpcRSnJFoqMVcVJwIAFB4w7tXAgAA X-CMS-MailID: 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f X-RootMTR: 20180514082201eucas1p1549ae992aeeef0906a2cccb5da96533f References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 -- 2.17.0