mpls: Return error for RTA_GATEWAY attribute
[linux-stable.git] / drivers / thermal / thermal_core.h
blob0df190ed82a70b342eea53ecca8407e3179df657
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * thermal_core.h
5 * Copyright (C) 2012 Intel Corp
6 * Author: Durgadoss R <durgadoss.r@intel.com>
7 */
9 #ifndef __THERMAL_CORE_H__
10 #define __THERMAL_CORE_H__
12 #include <linux/device.h>
13 #include <linux/thermal.h>
15 /* Initial state of a cooling device during binding */
16 #define THERMAL_NO_TARGET -1UL
19 * This structure is used to describe the behavior of
20 * a certain cooling device on a certain trip point
21 * in a certain thermal zone
23 struct thermal_instance {
24 int id;
25 char name[THERMAL_NAME_LENGTH];
26 struct thermal_zone_device *tz;
27 struct thermal_cooling_device *cdev;
28 int trip;
29 bool initialized;
30 unsigned long upper; /* Highest cooling state for this trip point */
31 unsigned long lower; /* Lowest cooling state for this trip point */
32 unsigned long target; /* expected cooling state */
33 char attr_name[THERMAL_NAME_LENGTH];
34 struct device_attribute attr;
35 char weight_attr_name[THERMAL_NAME_LENGTH];
36 struct device_attribute weight_attr;
37 struct list_head tz_node; /* node in tz->thermal_instances */
38 struct list_head cdev_node; /* node in cdev->thermal_instances */
39 unsigned int weight; /* The weight of the cooling device */
42 #define to_thermal_zone(_dev) \
43 container_of(_dev, struct thermal_zone_device, device)
45 #define to_cooling_device(_dev) \
46 container_of(_dev, struct thermal_cooling_device, device)
48 int thermal_register_governor(struct thermal_governor *);
49 void thermal_unregister_governor(struct thermal_governor *);
50 void thermal_zone_device_rebind_exception(struct thermal_zone_device *,
51 const char *, size_t);
52 void thermal_zone_device_unbind_exception(struct thermal_zone_device *,
53 const char *, size_t);
54 int thermal_zone_device_set_policy(struct thermal_zone_device *, char *);
55 int thermal_build_list_of_policies(char *buf);
57 /* sysfs I/F */
58 int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
59 void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
60 void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *);
61 void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev);
62 /* used only at binding time */
63 ssize_t trip_point_show(struct device *, struct device_attribute *, char *);
64 ssize_t weight_show(struct device *, struct device_attribute *, char *);
65 ssize_t weight_store(struct device *, struct device_attribute *, const char *,
66 size_t);
68 #ifdef CONFIG_THERMAL_STATISTICS
69 void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
70 unsigned long new_state);
71 #else
72 static inline void
73 thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
74 unsigned long new_state) {}
75 #endif /* CONFIG_THERMAL_STATISTICS */
77 #ifdef CONFIG_THERMAL_GOV_STEP_WISE
78 int thermal_gov_step_wise_register(void);
79 void thermal_gov_step_wise_unregister(void);
80 #else
81 static inline int thermal_gov_step_wise_register(void) { return 0; }
82 static inline void thermal_gov_step_wise_unregister(void) {}
83 #endif /* CONFIG_THERMAL_GOV_STEP_WISE */
85 #ifdef CONFIG_THERMAL_GOV_FAIR_SHARE
86 int thermal_gov_fair_share_register(void);
87 void thermal_gov_fair_share_unregister(void);
88 #else
89 static inline int thermal_gov_fair_share_register(void) { return 0; }
90 static inline void thermal_gov_fair_share_unregister(void) {}
91 #endif /* CONFIG_THERMAL_GOV_FAIR_SHARE */
93 #ifdef CONFIG_THERMAL_GOV_BANG_BANG
94 int thermal_gov_bang_bang_register(void);
95 void thermal_gov_bang_bang_unregister(void);
96 #else
97 static inline int thermal_gov_bang_bang_register(void) { return 0; }
98 static inline void thermal_gov_bang_bang_unregister(void) {}
99 #endif /* CONFIG_THERMAL_GOV_BANG_BANG */
101 #ifdef CONFIG_THERMAL_GOV_USER_SPACE
102 int thermal_gov_user_space_register(void);
103 void thermal_gov_user_space_unregister(void);
104 #else
105 static inline int thermal_gov_user_space_register(void) { return 0; }
106 static inline void thermal_gov_user_space_unregister(void) {}
107 #endif /* CONFIG_THERMAL_GOV_USER_SPACE */
109 #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
110 int thermal_gov_power_allocator_register(void);
111 void thermal_gov_power_allocator_unregister(void);
112 #else
113 static inline int thermal_gov_power_allocator_register(void) { return 0; }
114 static inline void thermal_gov_power_allocator_unregister(void) {}
115 #endif /* CONFIG_THERMAL_GOV_POWER_ALLOCATOR */
117 /* device tree support */
118 #ifdef CONFIG_THERMAL_OF
119 int of_parse_thermal_zones(void);
120 void of_thermal_destroy_zones(void);
121 int of_thermal_get_ntrips(struct thermal_zone_device *);
122 bool of_thermal_is_trip_valid(struct thermal_zone_device *, int);
123 const struct thermal_trip *
124 of_thermal_get_trip_points(struct thermal_zone_device *);
125 #else
126 static inline int of_parse_thermal_zones(void) { return 0; }
127 static inline void of_thermal_destroy_zones(void) { }
128 static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
130 return 0;
132 static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz,
133 int trip)
135 return false;
137 static inline const struct thermal_trip *
138 of_thermal_get_trip_points(struct thermal_zone_device *tz)
140 return NULL;
142 #endif
144 #endif /* __THERMAL_CORE_H__ */