diff options
author | Nishanth Menon <nm@ti.com> | 2015-02-13 20:28:02 -0500 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2015-02-24 13:40:42 -0500 |
commit | 12ca7188468ee29c4e717f73db4bf43c90954fc7 (patch) | |
tree | 739998e96fa3c1d9fd2c7ec33806e41a064e1b1c | |
parent | 9ca9be2b09ea1b5289b936e917c8a93119a65736 (diff) |
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>
-rw-r--r-- | include/linux/thermal.h | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index fc52e307efab..5eac316490ea 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -314,6 +314,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev, | |||
314 | } | 314 | } |
315 | 315 | ||
316 | #endif | 316 | #endif |
317 | |||
318 | #if IS_ENABLED(CONFIG_THERMAL) | ||
317 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, | 319 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, |
318 | void *, struct thermal_zone_device_ops *, | 320 | void *, struct thermal_zone_device_ops *, |
319 | const struct thermal_zone_params *, int, int); | 321 | const struct thermal_zone_params *, int, int); |
@@ -340,8 +342,58 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, | |||
340 | struct thermal_cooling_device *, int); | 342 | struct thermal_cooling_device *, int); |
341 | void thermal_cdev_update(struct thermal_cooling_device *); | 343 | void thermal_cdev_update(struct thermal_cooling_device *); |
342 | void thermal_notify_framework(struct thermal_zone_device *, int); | 344 | void thermal_notify_framework(struct thermal_zone_device *, int); |
343 | 345 | #else | |
344 | #ifdef CONFIG_NET | 346 | static inline struct thermal_zone_device *thermal_zone_device_register( |
347 | const char *type, int trips, int mask, void *devdata, | ||
348 | struct thermal_zone_device_ops *ops, | ||
349 | const struct thermal_zone_params *tzp, | ||
350 | int passive_delay, int polling_delay) | ||
351 | { return ERR_PTR(-ENODEV); } | ||
352 | static inline void thermal_zone_device_unregister( | ||
353 | struct thermal_zone_device *tz) | ||
354 | { } | ||
355 | static inline int thermal_zone_bind_cooling_device( | ||
356 | struct thermal_zone_device *tz, int trip, | ||
357 | struct thermal_cooling_device *cdev, | ||
358 | unsigned long upper, unsigned long lower) | ||
359 | { return -ENODEV; } | ||
360 | static inline int thermal_zone_unbind_cooling_device( | ||
361 | struct thermal_zone_device *tz, int trip, | ||
362 | struct thermal_cooling_device *cdev) | ||
363 | { return -ENODEV; } | ||
364 | static inline void thermal_zone_device_update(struct thermal_zone_device *tz) | ||
365 | { } | ||
366 | static inline struct thermal_cooling_device * | ||
367 | thermal_cooling_device_register(char *type, void *devdata, | ||
368 | const struct thermal_cooling_device_ops *ops) | ||
369 | { return ERR_PTR(-ENODEV); } | ||
370 | static inline struct thermal_cooling_device * | ||
371 | thermal_of_cooling_device_register(struct device_node *np, | ||
372 | char *type, void *devdata, const struct thermal_cooling_device_ops *ops) | ||
373 | { return ERR_PTR(-ENODEV); } | ||
374 | static inline void thermal_cooling_device_unregister( | ||
375 | struct thermal_cooling_device *cdev) | ||
376 | { } | ||
377 | static inline struct thermal_zone_device *thermal_zone_get_zone_by_name( | ||
378 | const char *name) | ||
379 | { return ERR_PTR(-ENODEV); } | ||
380 | static inline int thermal_zone_get_temp( | ||
381 | struct thermal_zone_device *tz, unsigned long *temp) | ||
382 | { return -ENODEV; } | ||
383 | static inline int get_tz_trend(struct thermal_zone_device *tz, int trip) | ||
384 | { return -ENODEV; } | ||
385 | static inline struct thermal_instance * | ||
386 | get_thermal_instance(struct thermal_zone_device *tz, | ||
387 | struct thermal_cooling_device *cdev, int trip) | ||
388 | { return ERR_PTR(-ENODEV); } | ||
389 | static inline void thermal_cdev_update(struct thermal_cooling_device *cdev) | ||
390 | { } | ||
391 | static inline void thermal_notify_framework(struct thermal_zone_device *tz, | ||
392 | int trip) | ||
393 | { } | ||
394 | #endif /* CONFIG_THERMAL */ | ||
395 | |||
396 | #if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL) | ||
345 | extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, | 397 | extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, |
346 | enum events event); | 398 | enum events event); |
347 | #else | 399 | #else |