1
2
3
4
5
6
7
8
9
10
11
12#ifndef __LINUX_DEVFREQ_EVENT_H__
13#define __LINUX_DEVFREQ_EVENT_H__
14
15#include <linux/device.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29struct devfreq_event_dev {
30 struct list_head node;
31
32 struct device dev;
33 struct mutex lock;
34 u32 enable_count;
35
36 const struct devfreq_event_desc *desc;
37};
38
39
40
41
42
43
44
45
46
47
48
49
50struct devfreq_event_data {
51 unsigned long load_count;
52 unsigned long total_count;
53};
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68struct devfreq_event_ops {
69
70 int (*enable)(struct devfreq_event_dev *edev);
71 int (*disable)(struct devfreq_event_dev *edev);
72 int (*reset)(struct devfreq_event_dev *edev);
73
74
75 int (*set_event)(struct devfreq_event_dev *edev);
76 int (*get_event)(struct devfreq_event_dev *edev,
77 struct devfreq_event_data *edata);
78};
79
80
81
82
83
84
85
86
87
88
89
90struct devfreq_event_desc {
91 const char *name;
92 void *driver_data;
93
94 const struct devfreq_event_ops *ops;
95};
96
97#if defined(CONFIG_PM_DEVFREQ_EVENT)
98extern int devfreq_event_enable_edev(struct devfreq_event_dev *edev);
99extern int devfreq_event_disable_edev(struct devfreq_event_dev *edev);
100extern bool devfreq_event_is_enabled(struct devfreq_event_dev *edev);
101extern int devfreq_event_set_event(struct devfreq_event_dev *edev);
102extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
103 struct devfreq_event_data *edata);
104extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
105extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
106 struct device *dev, int index);
107extern int devfreq_event_get_edev_count(struct device *dev);
108extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
109 struct devfreq_event_desc *desc);
110extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
111extern struct devfreq_event_dev *devm_devfreq_event_add_edev(struct device *dev,
112 struct devfreq_event_desc *desc);
113extern void devm_devfreq_event_remove_edev(struct device *dev,
114 struct devfreq_event_dev *edev);
115static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
116{
117 return edev->desc->driver_data;
118}
119#else
120static inline int devfreq_event_enable_edev(struct devfreq_event_dev *edev)
121{
122 return -EINVAL;
123}
124
125static inline int devfreq_event_disable_edev(struct devfreq_event_dev *edev)
126{
127 return -EINVAL;
128}
129
130static inline bool devfreq_event_is_enabled(struct devfreq_event_dev *edev)
131{
132 return false;
133}
134
135static inline int devfreq_event_set_event(struct devfreq_event_dev *edev)
136{
137 return -EINVAL;
138}
139
140static inline int devfreq_event_get_event(struct devfreq_event_dev *edev,
141 struct devfreq_event_data *edata)
142{
143 return -EINVAL;
144}
145
146static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
147{
148 return -EINVAL;
149}
150
151static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
152 struct device *dev, int index)
153{
154 return ERR_PTR(-EINVAL);
155}
156
157static inline int devfreq_event_get_edev_count(struct device *dev)
158{
159 return -EINVAL;
160}
161
162static inline struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
163 struct devfreq_event_desc *desc)
164{
165 return ERR_PTR(-EINVAL);
166}
167
168static inline int devfreq_event_remove_edev(struct devfreq_event_dev *edev)
169{
170 return -EINVAL;
171}
172
173static inline struct devfreq_event_dev *devm_devfreq_event_add_edev(
174 struct device *dev,
175 struct devfreq_event_desc *desc)
176{
177 return ERR_PTR(-EINVAL);
178}
179
180static inline void devm_devfreq_event_remove_edev(struct device *dev,
181 struct devfreq_event_dev *edev)
182{
183}
184
185static inline void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev)
186{
187 return NULL;
188}
189#endif
190
191#endif
192