Source
28
28
dev_name(dev));
29
29
else
30
30
snprintf(name, NAME_MAX, "%s", dev_name(dev));
31
31
}
32
32
33
33
void opp_debug_remove_one(struct dev_pm_opp *opp)
34
34
{
35
35
debugfs_remove_recursive(opp->dentry);
36
36
}
37
37
38
-
static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
38
+
static void opp_debug_create_supplies(struct dev_pm_opp *opp,
39
39
struct opp_table *opp_table,
40
40
struct dentry *pdentry)
41
41
{
42
42
struct dentry *d;
43
43
int i;
44
44
45
45
for (i = 0; i < opp_table->regulator_count; i++) {
46
46
char name[15];
47
47
48
48
snprintf(name, sizeof(name), "supply-%d", i);
49
49
50
50
/* Create per-opp directory */
51
51
d = debugfs_create_dir(name, pdentry);
52
52
53
-
if (!d)
54
-
return false;
53
+
debugfs_create_ulong("u_volt_target", S_IRUGO, d,
54
+
&opp->supplies[i].u_volt);
55
55
56
-
if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
57
-
&opp->supplies[i].u_volt))
58
-
return false;
56
+
debugfs_create_ulong("u_volt_min", S_IRUGO, d,
57
+
&opp->supplies[i].u_volt_min);
59
58
60
-
if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
61
-
&opp->supplies[i].u_volt_min))
62
-
return false;
59
+
debugfs_create_ulong("u_volt_max", S_IRUGO, d,
60
+
&opp->supplies[i].u_volt_max);
63
61
64
-
if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
65
-
&opp->supplies[i].u_volt_max))
66
-
return false;
67
-
68
-
if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
69
-
&opp->supplies[i].u_amp))
70
-
return false;
62
+
debugfs_create_ulong("u_amp", S_IRUGO, d,
63
+
&opp->supplies[i].u_amp);
71
64
}
72
-
73
-
return true;
74
65
}
75
66
76
-
int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
67
+
void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
77
68
{
78
69
struct dentry *pdentry = opp_table->dentry;
79
70
struct dentry *d;
80
71
unsigned long id;
81
72
char name[25]; /* 20 chars for 64 bit value + 5 (opp:\0) */
82
73
83
74
/*
84
75
* Get directory name for OPP.
85
76
*
86
77
* - Normally rate is unique to each OPP, use it to get unique opp-name.
88
79
*/
89
80
if (likely(opp->rate))
90
81
id = opp->rate;
91
82
else
92
83
id = _get_opp_count(opp_table);
93
84
94
85
snprintf(name, sizeof(name), "opp:%lu", id);
95
86
96
87
/* Create per-opp directory */
97
88
d = debugfs_create_dir(name, pdentry);
98
-
if (!d)
99
-
return -ENOMEM;
100
-
101
-
if (!debugfs_create_bool("available", S_IRUGO, d, &opp->available))
102
-
return -ENOMEM;
103
-
104
-
if (!debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic))
105
-
return -ENOMEM;
106
-
107
-
if (!debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo))
108
-
return -ENOMEM;
109
-
110
-
if (!debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend))
111
-
return -ENOMEM;
112
-
113
-
if (!debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate))
114
-
return -ENOMEM;
115
89
116
-
if (!debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate))
117
-
return -ENOMEM;
90
+
debugfs_create_bool("available", S_IRUGO, d, &opp->available);
91
+
debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic);
92
+
debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo);
93
+
debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend);
94
+
debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate);
95
+
debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate);
96
+
debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
97
+
&opp->clock_latency_ns);
118
98
119
-
if (!opp_debug_create_supplies(opp, opp_table, d))
120
-
return -ENOMEM;
121
-
122
-
if (!debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
123
-
&opp->clock_latency_ns))
124
-
return -ENOMEM;
99
+
opp_debug_create_supplies(opp, opp_table, d);
125
100
126
101
opp->dentry = d;
127
-
return 0;
128
102
}
129
103
130
-
static int opp_list_debug_create_dir(struct opp_device *opp_dev,
131
-
struct opp_table *opp_table)
104
+
static void opp_list_debug_create_dir(struct opp_device *opp_dev,
105
+
struct opp_table *opp_table)
132
106
{
133
107
const struct device *dev = opp_dev->dev;
134
108
struct dentry *d;
135
109
136
110
opp_set_dev_name(dev, opp_table->dentry_name);
137
111
138
112
/* Create device specific directory */
139
113
d = debugfs_create_dir(opp_table->dentry_name, rootdir);
140
-
if (!d) {
141
-
dev_err(dev, "%s: Failed to create debugfs dir\n", __func__);
142
-
return -ENOMEM;
143
-
}
144
114
145
115
opp_dev->dentry = d;
146
116
opp_table->dentry = d;
147
-
148
-
return 0;
149
117
}
150
118
151
-
static int opp_list_debug_create_link(struct opp_device *opp_dev,
152
-
struct opp_table *opp_table)
119
+
static void opp_list_debug_create_link(struct opp_device *opp_dev,
120
+
struct opp_table *opp_table)
153
121
{
154
-
const struct device *dev = opp_dev->dev;
155
122
char name[NAME_MAX];
156
-
struct dentry *d;
157
123
158
124
opp_set_dev_name(opp_dev->dev, name);
159
125
160
126
/* Create device specific directory link */
161
-
d = debugfs_create_symlink(name, rootdir, opp_table->dentry_name);
162
-
if (!d) {
163
-
dev_err(dev, "%s: Failed to create link\n", __func__);
164
-
return -ENOMEM;
165
-
}
166
-
167
-
opp_dev->dentry = d;
168
-
169
-
return 0;
127
+
opp_dev->dentry = debugfs_create_symlink(name, rootdir,
128
+
opp_table->dentry_name);
170
129
}
171
130
172
131
/**
173
132
* opp_debug_register - add a device opp node to the debugfs 'opp' directory
174
133
* @opp_dev: opp-dev pointer for device
175
134
* @opp_table: the device-opp being added
176
135
*
177
136
* Dynamically adds device specific directory in debugfs 'opp' directory. If the
178
137
* device-opp is shared with other devices, then links will be created for all
179
138
* devices except the first.
180
-
*
181
-
* Return: 0 on success, otherwise negative error.
182
139
*/
183
-
int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table)
140
+
void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table)
184
141
{
185
-
if (!rootdir) {
186
-
pr_debug("%s: Uninitialized rootdir\n", __func__);
187
-
return -EINVAL;
188
-
}
189
-
190
142
if (opp_table->dentry)
191
-
return opp_list_debug_create_link(opp_dev, opp_table);
192
-
193
-
return opp_list_debug_create_dir(opp_dev, opp_table);
143
+
opp_list_debug_create_link(opp_dev, opp_table);
144
+
else
145
+
opp_list_debug_create_dir(opp_dev, opp_table);
194
146
}
195
147
196
148
static void opp_migrate_dentry(struct opp_device *opp_dev,
197
149
struct opp_table *opp_table)
198
150
{
199
151
struct opp_device *new_dev;
200
152
const struct device *dev;
201
153
struct dentry *dentry;
202
154
203
155
/* Look for next opp-dev */
245
197
debugfs_remove_recursive(opp_dev->dentry);
246
198
247
199
out:
248
200
opp_dev->dentry = NULL;
249
201
}
250
202
251
203
static int __init opp_debug_init(void)
252
204
{
253
205
/* Create /sys/kernel/debug/opp directory */
254
206
rootdir = debugfs_create_dir("opp", NULL);
255
-
if (!rootdir) {
256
-
pr_err("%s: Failed to create root directory\n", __func__);
257
-
return -ENOMEM;
258
-
}
259
207
260
208
return 0;
261
209
}
262
210
core_initcall(opp_debug_init);