Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: cmos: avoid unused function warning

A bug fix for the ACPI side of this driver caused a harmless
build warning:

drivers/rtc/rtc-cmos.c:1115:13: error: 'cmos_check_acpi_rtc_status' defined but not used [-Werror=unused-function]
static void cmos_check_acpi_rtc_status(struct device *dev,

We can avoid the warning and simplify the driver at the same time
by removing the #ifdef for CONFIG_PM and rely on the SIMPLE_DEV_PM_OPS()
to set everything up correctly. cmos_resume() has to get marked
as __maybe_unused so we don't introduce another warning, and
the two variants of cmos_poweroff() can get merged into one using
an IS_ENABLED() check.

Fixes: 983bf1256edb ("rtc: cmos: Clear ACPI-driven alarms upon resume")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Arnd Bergmann and committed by
Alexandre Belloni
00f7f90c 473195f8

+4 -17
+4 -17
drivers/rtc/rtc-cmos.c
··· 848 848 return retval; 849 849 } 850 850 851 - #ifdef CONFIG_PM 852 - 853 851 static int cmos_suspend(struct device *dev) 854 852 { 855 853 struct cmos_rtc *cmos = dev_get_drvdata(dev); ··· 896 898 */ 897 899 static inline int cmos_poweroff(struct device *dev) 898 900 { 901 + if (!IS_ENABLED(CONFIG_PM)) 902 + return -ENOSYS; 903 + 899 904 return cmos_suspend(dev); 900 905 } 901 - 902 - #ifdef CONFIG_PM_SLEEP 903 906 904 907 static void cmos_check_wkalrm(struct device *dev) 905 908 { ··· 921 922 static void cmos_check_acpi_rtc_status(struct device *dev, 922 923 unsigned char *rtc_control); 923 924 924 - static int cmos_resume(struct device *dev) 925 + static int __maybe_unused cmos_resume(struct device *dev) 925 926 { 926 927 struct cmos_rtc *cmos = dev_get_drvdata(dev); 927 928 unsigned char tmp; ··· 973 974 974 975 return 0; 975 976 } 976 - 977 - #endif 978 - #else 979 - 980 - static inline int cmos_poweroff(struct device *dev) 981 - { 982 - return -ENOSYS; 983 - } 984 - 985 - #endif 986 977 987 978 static SIMPLE_DEV_PM_OPS(cmos_pm_ops, cmos_suspend, cmos_resume); 988 979 ··· 1267 1278 .shutdown = cmos_platform_shutdown, 1268 1279 .driver = { 1269 1280 .name = driver_name, 1270 - #ifdef CONFIG_PM 1271 1281 .pm = &cmos_pm_ops, 1272 - #endif 1273 1282 .of_match_table = of_match_ptr(of_cmos_match), 1274 1283 } 1275 1284 };