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

thermal: Introduce dummy functions when thermal is not defined

When CONFIG_THERMAL is not enabled, it is better to introduce
equivalent dummy functions in the exported header than to
introduce #ifdeffery in drivers using the function.

This will prevent issues such as that reported in:
http://www.spinics.net/lists/linux-next/msg31573.html

While at it switch over to IS_ENABLED for thermal macros
to allow for thermal framework to be built as framework
and relevant APIs be usable by relevant drivers as a result.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Nishanth Menon and committed by
Eduardo Valentin
12ca7188 9ca9be2b

+53 -1
+53 -1
include/linux/thermal.h
··· 314 314 } 315 315 316 316 #endif 317 + 318 + #if IS_ENABLED(CONFIG_THERMAL) 317 319 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, 318 320 void *, struct thermal_zone_device_ops *, 319 321 const struct thermal_zone_params *, int, int); ··· 342 340 struct thermal_cooling_device *, int); 343 341 void thermal_cdev_update(struct thermal_cooling_device *); 344 342 void thermal_notify_framework(struct thermal_zone_device *, int); 343 + #else 344 + static inline struct thermal_zone_device *thermal_zone_device_register( 345 + const char *type, int trips, int mask, void *devdata, 346 + struct thermal_zone_device_ops *ops, 347 + const struct thermal_zone_params *tzp, 348 + int passive_delay, int polling_delay) 349 + { return ERR_PTR(-ENODEV); } 350 + static inline void thermal_zone_device_unregister( 351 + struct thermal_zone_device *tz) 352 + { } 353 + static inline int thermal_zone_bind_cooling_device( 354 + struct thermal_zone_device *tz, int trip, 355 + struct thermal_cooling_device *cdev, 356 + unsigned long upper, unsigned long lower) 357 + { return -ENODEV; } 358 + static inline int thermal_zone_unbind_cooling_device( 359 + struct thermal_zone_device *tz, int trip, 360 + struct thermal_cooling_device *cdev) 361 + { return -ENODEV; } 362 + static inline void thermal_zone_device_update(struct thermal_zone_device *tz) 363 + { } 364 + static inline struct thermal_cooling_device * 365 + thermal_cooling_device_register(char *type, void *devdata, 366 + const struct thermal_cooling_device_ops *ops) 367 + { return ERR_PTR(-ENODEV); } 368 + static inline struct thermal_cooling_device * 369 + thermal_of_cooling_device_register(struct device_node *np, 370 + char *type, void *devdata, const struct thermal_cooling_device_ops *ops) 371 + { return ERR_PTR(-ENODEV); } 372 + static inline void thermal_cooling_device_unregister( 373 + struct thermal_cooling_device *cdev) 374 + { } 375 + static inline struct thermal_zone_device *thermal_zone_get_zone_by_name( 376 + const char *name) 377 + { return ERR_PTR(-ENODEV); } 378 + static inline int thermal_zone_get_temp( 379 + struct thermal_zone_device *tz, unsigned long *temp) 380 + { return -ENODEV; } 381 + static inline int get_tz_trend(struct thermal_zone_device *tz, int trip) 382 + { return -ENODEV; } 383 + static inline struct thermal_instance * 384 + get_thermal_instance(struct thermal_zone_device *tz, 385 + struct thermal_cooling_device *cdev, int trip) 386 + { return ERR_PTR(-ENODEV); } 387 + static inline void thermal_cdev_update(struct thermal_cooling_device *cdev) 388 + { } 389 + static inline void thermal_notify_framework(struct thermal_zone_device *tz, 390 + int trip) 391 + { } 392 + #endif /* CONFIG_THERMAL */ 345 393 346 - #ifdef CONFIG_NET 394 + #if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL) 347 395 extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, 348 396 enum events event); 349 397 #else