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

firmware loader: fix compile warning when CONFIG_PM=n

This patch replaces the previous macro of CONFIG_PM with
CONFIG_PM_SLEEP becasue firmware cache is only used in
system sleep situations.

Also this patch fixes the below compile warning when
CONFIG_PM=n:

drivers/base/firmware_class.c:1147: warning: 'device_cache_fw_images'
defined but not used
drivers/base/firmware_class.c:1212: warning:
'device_uncache_fw_images_delay' defined but not used

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ming Lei and committed by
Greg Kroah-Hartman
cfe016b1 ef4158c5

+22 -11
+22 -11
drivers/base/firmware_class.c
··· 96 96 /* firmware_buf instance will be added into the below list */ 97 97 spinlock_t lock; 98 98 struct list_head head; 99 + int state; 99 100 101 + #ifdef CONFIG_PM_SLEEP 100 102 /* 101 103 * Names of firmware images which have been cached successfully 102 104 * will be added into the below list so that device uncache ··· 108 106 spinlock_t name_lock; 109 107 struct list_head fw_names; 110 108 111 - int state; 112 - 113 109 wait_queue_head_t wait_queue; 114 110 int cnt; 115 111 struct delayed_work work; 116 112 117 113 struct notifier_block pm_notify; 114 + #endif 118 115 }; 119 116 120 117 struct firmware_buf { ··· 623 622 (unsigned int)buf->size); 624 623 } 625 624 625 + #ifdef CONFIG_PM_SLEEP 626 626 static void fw_name_devm_release(struct device *dev, void *res) 627 627 { 628 628 struct fw_name_devm *fwn = res; ··· 672 670 673 671 return 0; 674 672 } 673 + #else 674 + static int fw_add_devm_name(struct device *dev, const char *name) 675 + { 676 + return 0; 677 + } 678 + #endif 675 679 676 680 static void _request_firmware_cleanup(const struct firmware **firmware_p) 677 681 { ··· 1054 1046 return -EINVAL; 1055 1047 } 1056 1048 1049 + #ifdef CONFIG_PM_SLEEP 1057 1050 static struct fw_cache_entry *alloc_fw_cache_entry(const char *name) 1058 1051 { 1059 1052 struct fw_cache_entry *fce; ··· 1267 1258 msecs_to_jiffies(delay)); 1268 1259 } 1269 1260 1270 - #ifdef CONFIG_PM 1271 1261 static int fw_pm_notify(struct notifier_block *notify_block, 1272 1262 unsigned long mode, void *unused) 1273 1263 { ··· 1293 1285 1294 1286 return 0; 1295 1287 } 1296 - #else 1297 - static int fw_pm_notify(struct notifier_block *notify_block, 1298 - unsigned long mode, void *unused) 1299 - { 1300 - return 0; 1301 - } 1302 - #endif 1303 1288 1304 1289 /* stop caching firmware once syscore_suspend is reached */ 1305 1290 static int fw_suspend(void) ··· 1304 1303 static struct syscore_ops fw_syscore_ops = { 1305 1304 .suspend = fw_suspend, 1306 1305 }; 1306 + #else 1307 + static int fw_cache_piggyback_on_request(const char *name) 1308 + { 1309 + return 0; 1310 + } 1311 + #endif 1307 1312 1308 1313 static void __init fw_cache_init(void) 1309 1314 { 1310 1315 spin_lock_init(&fw_cache.lock); 1311 1316 INIT_LIST_HEAD(&fw_cache.head); 1317 + fw_cache.state = FW_LOADER_NO_CACHE; 1312 1318 1319 + #ifdef CONFIG_PM_SLEEP 1313 1320 spin_lock_init(&fw_cache.name_lock); 1314 1321 INIT_LIST_HEAD(&fw_cache.fw_names); 1315 1322 fw_cache.cnt = 0; 1316 - fw_cache.state = FW_LOADER_NO_CACHE; 1317 1323 1318 1324 init_waitqueue_head(&fw_cache.wait_queue); 1319 1325 INIT_DELAYED_WORK(&fw_cache.work, ··· 1330 1322 register_pm_notifier(&fw_cache.pm_notify); 1331 1323 1332 1324 register_syscore_ops(&fw_syscore_ops); 1325 + #endif 1333 1326 } 1334 1327 1335 1328 static int __init firmware_class_init(void) ··· 1341 1332 1342 1333 static void __exit firmware_class_exit(void) 1343 1334 { 1335 + #ifdef CONFIG_PM_SLEEP 1344 1336 unregister_syscore_ops(&fw_syscore_ops); 1345 1337 unregister_pm_notifier(&fw_cache.pm_notify); 1338 + #endif 1346 1339 class_unregister(&firmware_class); 1347 1340 } 1348 1341