All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: cip-dev@lists.cip-project.org,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Pavel Machek <pavel@denx.de>
Cc: Chris Paterson <chris.paterson2@renesas.com>,
	Biju Das <biju.das.jz@bp.renesas.com>,
	Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Subject: [PATCH 5.10.y-cip 13/23] PM: core: Redefine pm_ptr() macro
Date: Fri, 19 May 2023 09:20:48 +0100	[thread overview]
Message-ID: <20230519082058.109760-14-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20230519082058.109760-1-biju.das.jz@bp.renesas.com>

From: Paul Cercueil <paul@crapouillou.net>

commit c06ef740d401d0f4ab188882bf6f8d9cf0f75eaf upstream.

The pm_ptr() macro was previously conditionally defined, according to
the value of the CONFIG_PM option. This meant that the pointed structure
was either referenced (if CONFIG_PM was set), or never referenced (if
CONFIG_PM was not set), causing it to be detected as unused by the
compiler.

This worked fine, but required the __maybe_unused compiler attribute to
be used to every symbol pointed to by a pointer wrapped with pm_ptr().

We can do better. With this change, the pm_ptr() is now defined the
same, independently of the value of CONFIG_PM. It now uses the (?:)
ternary operator to conditionally resolve to its argument. Since the
condition is known at compile time, the compiler will then choose to
discard the unused symbols, which won't need to be tagged with
__maybe_unused anymore.

This pm_ptr() macro is usually used with pointers to dev_pm_ops
structures created with SIMPLE_DEV_PM_OPS() or similar macros. These do
use a __maybe_unused flag, which is now useless with this change, so it
later can be removed. However in the meantime it causes no harm, and all
the drivers still compile fine with the new pm_ptr() macro.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 include/linux/pm.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 52d9724db9dc..5ac2c9ba5baf 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -374,11 +374,7 @@ const struct dev_pm_ops __maybe_unused name = { \
 	SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 }
 
-#ifdef CONFIG_PM
-#define pm_ptr(_ptr) (_ptr)
-#else
-#define pm_ptr(_ptr) NULL
-#endif
+#define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
 
 /*
  * PM_EVENT_ messages
-- 
2.25.1



  parent reply	other threads:[~2023-05-19  8:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19  8:20 [PATCH 5.10.y-cip 00/23] Add RZ/V2M I2C and WDT support Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 01/23] clk: renesas: r9a09g011: Add TIM clock and reset entries Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 02/23] arm64: dts: renesas: r9a09g011: Fix unit address format error Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 03/23] arm64: dts: renesas: r9a09g011: Reword ethernet status Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 04/23] arm64: dts: renesas: r9a09g011: Add L2 Cache node Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 05/23] arm64: dts: renesas: r9a09g011: Add system controller node Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 06/23] clk: renesas: r9a09g011: Add WDT clock and reset entries Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 07/23] dt-bindings: watchdog: renesas,wdt: Add r9a09g011 (RZ/V2M) support Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 08/23] watchdog: rzg2l_wdt: Add rzv2m support Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 09/23] watchdog: rzg2l_wdt: Handle TYPE-B reset for RZ/V2M Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 10/23] arm64: dts: renesas: r9a09g011: Add watchdog node Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 11/23] arm64: dts: renesas: rzv2mevk2: Enable watchdog Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 12/23] driver core: add a helper to setup both the of_node and fwnode of a device Biju Das
2023-05-19  8:20 ` Biju Das [this message]
2023-05-19  8:20 ` [PATCH 5.10.y-cip 14/23] PM: core: Add new *_PM_OPS macros, deprecate old ones Biju Das
2023-05-19 22:13   ` Pavel Machek
2023-05-20 15:00     ` Biju Das
2023-05-23 13:19       ` Pavel Machek
2023-05-23 14:05         ` Biju Das
2023-05-24  7:43           ` Pavel Machek
2023-05-24  7:46             ` Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 15/23] clk: renesas: r9a09g011: Add IIC clock and reset entries Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 16/23] dt-bindings: i2c: Document RZ/V2M I2C controller Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 17/23] dt-bindings: i2c: renesas,rzv2m: Fix SoC specific string Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 18/23] dt-bindings: i2c: renesas,rzv2m: Change maintainer to Fabrizio Castro Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 19/23] i2c: Add Renesas RZ/V2M controller Biju Das
2023-05-24  7:50   ` Pavel Machek
2023-05-24 12:35     ` Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 20/23] arm64: dts: renesas: r9a09g011: Add i2c nodes Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 21/23] arm64: dts: renesas: r9a09g011: Fix I2C SoC specific strings Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 22/23] arm64: dts: renesas: rzv2m evk: Enable i2c Biju Das
2023-05-19  8:20 ` [PATCH 5.10.y-cip 23/23] arm64: defconfig: Enable additional support for Renesas platforms Biju Das
2023-05-21 18:55 ` [PATCH 5.10.y-cip 00/23] Add RZ/V2M I2C and WDT support Pavel Machek
     [not found] ` <17613D7F1DB6F5FD.16124@lists.cip-project.org>
2023-05-22 20:12   ` [cip-dev] " Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230519082058.109760-14-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=chris.paterson2@renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.