Patch "PM: core: Redefine pm_ptr() macro" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    PM: core: Redefine pm_ptr() macro

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pm-core-redefine-pm_ptr-macro.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e00842f7c10a45fd93086c7b3f32e5d7786cc590
Author: Paul Cercueil <paul@xxxxxxxxxxxxxxx>
Date:   Tue Dec 7 00:20:59 2021 +0000

    PM: core: Redefine pm_ptr() macro
    
    [ Upstream commit c06ef740d401d0f4ab188882bf6f8d9cf0f75eaf ]
    
    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@xxxxxxxxxxxxxxx>
    Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Stable-dep-of: 6b8cffdc4a31 ("iio: accel: mxc4005: Reset chip on probe() and resume()")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 52d9724db9dc6..5ac2c9ba5baf7 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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux