Hi Jonathan,
Cc'd Arnd who may have some interest in the topic.
Le mar., nov. 23 2021 at 21:09:30 +0000, Jonathan Cameron
<jic23@xxxxxxxxxx> a écrit :
From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
Note this series includes many drivers that are quite old and I'm not
sure have active maintainers. Hence if anyone has time to look at
some
of these beyond their own drivers and sanity check them it would be
much
appreciated!
Two motivations behind this set.
1 - General code reduction and improvement in readability in these
drivers.
2 - Reduce change I'll have to ask people to change how they do this
in
future patches.
Mostly this is just a case of letting the compiler work out it can
remove
the PM related functions rather than using #ifdefs in the code to do
so.
The __maybe_unused markings make it clear we are intentionally
building
functions that the compiler can see are unused and remove in some
build
configurations.
The new pm_ptr() macro is rather convenient to got futher than many of
the drivers were and when CONFIG_PM is not define ensure that the
struct dev_pm_ops can also be removed. Note there is a subtlty in
that
we only remove that whe CONFIG_PM is not defined whereas a few of
these
drivers were using CONFIG_PM_SLEEP which is a tighter condition (will
remove the structure in more configurations). I think that's a small
price to pay for the convenience this macro brings.
I did this set as one patch per driver, as personally I prefer that
option for all but the most trivial patches because it makes backports
that cross with this series simpler and also avoid the complex
tag giving we get for sets touching code from many authors.
All comments welcome.
One word about the pm_ptr() macro. Right now it's defined as:
#ifdef CONFIG_PM
#define pm_ptr(_ptr) (_ptr)
#else
#define pm_ptr(_ptr) NULL
#endif
It could be possible to define it like this instead:
#define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
The difference is that if !CONFIG_PM, in the first case the (_ptr) is
not visible by the compiler and the __maybe_unused is required, while
in the second case the (_ptr) is always visible by the compiler, but
discarded as dead code. The reason we'd want that is the same reason we
use IS_ENABLED() instead of macro guards; and you wouldn't need the
__maybe_unused attribute anywhere.
The problem then is that the SET_*_PM_OPS macros are defined
differently according to CONFIG_PM, so their definition would need to
be changed to use the (redefined) pm_ptr() macro and a corresponding
pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros are
used everywhere with code wrapped around #ifdef CONFIG_PM guards, it
wouldn't be easy to change them, and it would just be easier to
introduce new macros.
The patchset looks fine as-is and I am not asking you to work on
anything I just said, I just thought it was worth mentioning.
Cheers,
-Paul
Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
Cc: Anson Huang <anson.huang@xxxxxxx>
Cc: Brian Masney <masneyb@xxxxxxxxxxxxx>
Cc: Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx>
Cc: Hans de Goede <hdegoede@xxxxxxxxxx>
Cc: Heiko Stuebner <heiko.stuebner@xxxxxxxxxxxxxxxxxxxxx>
Cc: Icenowy Zheng <icenowy@xxxxxxx>
Cc: Jonathan Albrieux <jonathan.albrieux@xxxxxxxxx>
Cc: Krzysztof Kozlowski <krzk@xxxxxxxxxx>
Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
Cc: Luca Weiss <luca@xxxxxxxxx>
Cc: Ludovic Desroches <ludovic.desroches@xxxxxxxxxxxxx>
Cc: Manivannan Sadhasivam <mani@xxxxxxxxxx>
Cc: Martijn Braam <martijn@xxxxxxxxx>
Cc: Maslov Dmitry <maslovdmitry@xxxxxxxx>
Cc: Matt Ranostay <matt.ranostay@xxxxxxxxxxxx
Cc: Olivier Moysan <olivier.moysan@xxxxxxxxxxx>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@xxxxxxx>
Cc: Vaishnav M A <vaishnav@xxxxxxxxxxxxxxx>
Jonathan Cameron (49):
iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:dmard10: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to
pm_ptr() /
__maybe_unused
iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
__maybe_unused
iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to
pm_ptr() /
__maybe_unused
iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to
pm_ptr() /
__maybe_unused
iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr()
/
__maybe_unused
iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to
pm_ptr()
/ __maybe_unused
iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to
pm_ptr() /
__maybe_unused
iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to
pm_ptr()
/ __maybe_unused
iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to
pm_ptr()
/ __maybe_unused
iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() /
__maybe_unused
drivers/iio/accel/da280.c | 6 ++----
drivers/iio/accel/da311.c | 8 +++-----
drivers/iio/accel/dmard06.c | 12 ++++--------
drivers/iio/accel/dmard10.c | 9 ++++-----
drivers/iio/accel/kxsd9-i2c.c | 2 +-
drivers/iio/accel/kxsd9-spi.c | 2 +-
drivers/iio/accel/kxsd9.c | 8 +++-----
drivers/iio/accel/mc3230.c | 8 +++-----
drivers/iio/accel/mma7660.c | 12 +++---------
drivers/iio/accel/mma9551.c | 16
++++++----------
drivers/iio/accel/mma9553.c | 16
++++++----------
drivers/iio/accel/stk8ba50.c | 12 +++---------
drivers/iio/adc/ab8500-gpadc.c | 10 ++++------
drivers/iio/adc/ad7606.c | 8 ++------
drivers/iio/adc/ad7606.h | 5 -----
drivers/iio/adc/ad7606_par.c | 2 +-
drivers/iio/adc/ad7606_spi.c | 2 +-
drivers/iio/adc/at91_adc.c | 8 +++-----
drivers/iio/adc/exynos_adc.c | 8 +++-----
drivers/iio/adc/palmas_gpadc.c | 14 ++++++--------
drivers/iio/adc/rcar-gyroadc.c | 10 ++++------
drivers/iio/adc/rockchip_saradc.c | 8 +++-----
drivers/iio/adc/stm32-adc-core.c | 12 +++++-------
drivers/iio/adc/stm32-adc.c | 16
++++++----------
drivers/iio/adc/twl6030-gpadc.c | 8 +++-----
drivers/iio/adc/vf610_adc.c | 8 +++-----
drivers/iio/chemical/atlas-sensor.c | 10 ++++------
drivers/iio/common/ssp_sensors/ssp_dev.c | 12 ++++--------
drivers/iio/dac/vf610_dac.c | 8 +++-----
drivers/iio/gyro/mpu3050-core.c | 8 +++-----
drivers/iio/gyro/mpu3050-i2c.c | 2 +-
drivers/iio/light/apds9300.c | 11 +++--------
drivers/iio/light/bh1780.c | 10 ++++------
drivers/iio/light/cm3232.c | 13 ++++---------
drivers/iio/light/isl29018.c | 11 +++--------
drivers/iio/light/isl29125.c | 8 +++-----
drivers/iio/light/jsa1212.c | 12 +++---------
drivers/iio/light/ltr501.c | 8 +++-----
drivers/iio/light/stk3310.c | 12 +++---------
drivers/iio/light/tcs3414.c | 8 +++-----
drivers/iio/light/tcs3472.c | 8 +++-----
drivers/iio/light/tsl2563.c | 11 +++--------
drivers/iio/light/tsl4531.c | 11 +++--------
drivers/iio/light/us5182d.c | 10 ++++------
drivers/iio/magnetometer/ak8975.c | 10 ++++------
drivers/iio/magnetometer/hmc5843.h | 5 -----
drivers/iio/magnetometer/hmc5843_i2c.c | 2 +-
drivers/iio/magnetometer/hmc5843_spi.c | 2 +-
drivers/iio/magnetometer/mag3110.c | 11 +++--------
drivers/iio/magnetometer/mmc35240.c | 12 ++++--------
drivers/iio/pressure/bmp280-core.c | 6 ++----
drivers/iio/pressure/bmp280-i2c.c | 2 +-
drivers/iio/pressure/bmp280-spi.c | 2 +-
drivers/iio/pressure/mpl3115.c | 11 +++--------
drivers/iio/proximity/as3935.c | 12 +++---------
.../iio/proximity/pulsedlight-lidar-lite-v2.c | 10 ++++------
drivers/iio/proximity/rfd77402.c | 8 +++-----
drivers/iio/proximity/sx9500.c | 12 ++++--------
drivers/iio/temperature/tmp006.c | 8 +++-----
drivers/iio/temperature/tmp007.c | 8 +++-----
60 files changed, 180 insertions(+), 344 deletions(-)
--
2.34.0