hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/linux/debugfs.h
....@@ -35,6 +35,12 @@
3535 const struct debugfs_reg32 *regs;
3636 int nregs;
3737 void __iomem *base;
38
+ struct device *dev; /* Optional device for Runtime PM */
39
+};
40
+
41
+struct debugfs_u32_array {
42
+ u32 *array;
43
+ u32 n_elements;
3844 };
3945
4046 extern struct dentry *arch_debugfs_dir;
....@@ -67,10 +73,10 @@
6773 struct dentry *parent, void *data,
6874 const struct file_operations *fops);
6975
70
-struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
71
- struct dentry *parent, void *data,
72
- const struct file_operations *fops,
73
- loff_t file_size);
76
+void debugfs_create_file_size(const char *name, umode_t mode,
77
+ struct dentry *parent, void *data,
78
+ const struct file_operations *fops,
79
+ loff_t file_size);
7480
7581 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
7682
....@@ -83,7 +89,9 @@
8389 void *data);
8490
8591 void debugfs_remove(struct dentry *dentry);
86
-void debugfs_remove_recursive(struct dentry *dentry);
92
+#define debugfs_remove_recursive debugfs_remove
93
+
94
+void debugfs_lookup_and_remove(const char *name, struct dentry *parent);
8795
8896 const struct file_operations *debugfs_real_fops(const struct file *filp);
8997
....@@ -98,28 +106,28 @@
98106 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
99107 struct dentry *new_dir, const char *new_name);
100108
101
-struct dentry *debugfs_create_u8(const char *name, umode_t mode,
102
- struct dentry *parent, u8 *value);
103
-struct dentry *debugfs_create_u16(const char *name, umode_t mode,
104
- struct dentry *parent, u16 *value);
105
-struct dentry *debugfs_create_u32(const char *name, umode_t mode,
106
- struct dentry *parent, u32 *value);
107
-struct dentry *debugfs_create_u64(const char *name, umode_t mode,
108
- struct dentry *parent, u64 *value);
109
+void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
110
+ u8 *value);
111
+void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent,
112
+ u16 *value);
113
+void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent,
114
+ u32 *value);
115
+void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent,
116
+ u64 *value);
109117 struct dentry *debugfs_create_ulong(const char *name, umode_t mode,
110118 struct dentry *parent, unsigned long *value);
111
-struct dentry *debugfs_create_x8(const char *name, umode_t mode,
112
- struct dentry *parent, u8 *value);
113
-struct dentry *debugfs_create_x16(const char *name, umode_t mode,
114
- struct dentry *parent, u16 *value);
115
-struct dentry *debugfs_create_x32(const char *name, umode_t mode,
116
- struct dentry *parent, u32 *value);
117
-struct dentry *debugfs_create_x64(const char *name, umode_t mode,
118
- struct dentry *parent, u64 *value);
119
-struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
120
- struct dentry *parent, size_t *value);
121
-struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
122
- struct dentry *parent, atomic_t *value);
119
+void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent,
120
+ u8 *value);
121
+void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent,
122
+ u16 *value);
123
+void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent,
124
+ u32 *value);
125
+void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent,
126
+ u64 *value);
127
+void debugfs_create_size_t(const char *name, umode_t mode,
128
+ struct dentry *parent, size_t *value);
129
+void debugfs_create_atomic_t(const char *name, umode_t mode,
130
+ struct dentry *parent, atomic_t *value);
123131 struct dentry *debugfs_create_bool(const char *name, umode_t mode,
124132 struct dentry *parent, bool *value);
125133
....@@ -127,25 +135,20 @@
127135 struct dentry *parent,
128136 struct debugfs_blob_wrapper *blob);
129137
130
-struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
131
- struct dentry *parent,
132
- struct debugfs_regset32 *regset);
138
+void debugfs_create_regset32(const char *name, umode_t mode,
139
+ struct dentry *parent,
140
+ struct debugfs_regset32 *regset);
133141
134142 void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
135143 int nregs, void __iomem *base, char *prefix);
136144
137
-struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
138
- struct dentry *parent,
139
- u32 *array, u32 elements);
145
+void debugfs_create_u32_array(const char *name, umode_t mode,
146
+ struct dentry *parent,
147
+ struct debugfs_u32_array *array);
140148
141
-struct dentry *debugfs_create_u32_array_hex(const char *name, umode_t mode,
142
- struct dentry *parent,
143
- u32 *array, u32 elements);
144
-
145
-struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
146
- struct dentry *parent,
147
- int (*read_fn)(struct seq_file *s,
148
- void *data));
149
+void debugfs_create_devm_seqfile(struct device *dev, const char *name,
150
+ struct dentry *parent,
151
+ int (*read_fn)(struct seq_file *s, void *data));
149152
150153 bool debugfs_initialized(void);
151154
....@@ -186,13 +189,11 @@
186189 return ERR_PTR(-ENODEV);
187190 }
188191
189
-static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
190
- struct dentry *parent, void *data,
191
- const struct file_operations *fops,
192
- loff_t file_size)
193
-{
194
- return ERR_PTR(-ENODEV);
195
-}
192
+static inline void debugfs_create_file_size(const char *name, umode_t mode,
193
+ struct dentry *parent, void *data,
194
+ const struct file_operations *fops,
195
+ loff_t file_size)
196
+{ }
196197
197198 static inline struct dentry *debugfs_create_dir(const char *name,
198199 struct dentry *parent)
....@@ -219,6 +220,10 @@
219220 { }
220221
221222 static inline void debugfs_remove_recursive(struct dentry *dentry)
223
+{ }
224
+
225
+static inline void debugfs_lookup_and_remove(const char *name,
226
+ struct dentry *parent)
222227 { }
223228
224229 const struct file_operations *debugfs_real_fops(const struct file *filp);
....@@ -250,33 +255,17 @@
250255 return ERR_PTR(-ENODEV);
251256 }
252257
253
-static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode,
254
- struct dentry *parent,
255
- u8 *value)
256
-{
257
- return ERR_PTR(-ENODEV);
258
-}
258
+static inline void debugfs_create_u8(const char *name, umode_t mode,
259
+ struct dentry *parent, u8 *value) { }
259260
260
-static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode,
261
- struct dentry *parent,
262
- u16 *value)
263
-{
264
- return ERR_PTR(-ENODEV);
265
-}
261
+static inline void debugfs_create_u16(const char *name, umode_t mode,
262
+ struct dentry *parent, u16 *value) { }
266263
267
-static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode,
268
- struct dentry *parent,
269
- u32 *value)
270
-{
271
- return ERR_PTR(-ENODEV);
272
-}
264
+static inline void debugfs_create_u32(const char *name, umode_t mode,
265
+ struct dentry *parent, u32 *value) { }
273266
274
-static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode,
275
- struct dentry *parent,
276
- u64 *value)
277
-{
278
- return ERR_PTR(-ENODEV);
279
-}
267
+static inline void debugfs_create_u64(const char *name, umode_t mode,
268
+ struct dentry *parent, u64 *value) { }
280269
281270 static inline struct dentry *debugfs_create_ulong(const char *name,
282271 umode_t mode,
....@@ -286,46 +275,26 @@
286275 return ERR_PTR(-ENODEV);
287276 }
288277
289
-static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode,
290
- struct dentry *parent,
291
- u8 *value)
292
-{
293
- return ERR_PTR(-ENODEV);
294
-}
278
+static inline void debugfs_create_x8(const char *name, umode_t mode,
279
+ struct dentry *parent, u8 *value) { }
295280
296
-static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode,
297
- struct dentry *parent,
298
- u16 *value)
299
-{
300
- return ERR_PTR(-ENODEV);
301
-}
281
+static inline void debugfs_create_x16(const char *name, umode_t mode,
282
+ struct dentry *parent, u16 *value) { }
302283
303
-static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode,
304
- struct dentry *parent,
305
- u32 *value)
306
-{
307
- return ERR_PTR(-ENODEV);
308
-}
284
+static inline void debugfs_create_x32(const char *name, umode_t mode,
285
+ struct dentry *parent, u32 *value) { }
309286
310
-static inline struct dentry *debugfs_create_x64(const char *name, umode_t mode,
311
- struct dentry *parent,
312
- u64 *value)
313
-{
314
- return ERR_PTR(-ENODEV);
315
-}
287
+static inline void debugfs_create_x64(const char *name, umode_t mode,
288
+ struct dentry *parent, u64 *value) { }
316289
317
-static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
318
- struct dentry *parent,
319
- size_t *value)
320
-{
321
- return ERR_PTR(-ENODEV);
322
-}
290
+static inline void debugfs_create_size_t(const char *name, umode_t mode,
291
+ struct dentry *parent, size_t *value)
292
+{ }
323293
324
-static inline struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
325
- struct dentry *parent, atomic_t *value)
326
-{
327
- return ERR_PTR(-ENODEV);
328
-}
294
+static inline void debugfs_create_atomic_t(const char *name, umode_t mode,
295
+ struct dentry *parent,
296
+ atomic_t *value)
297
+{ }
329298
330299 static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode,
331300 struct dentry *parent,
....@@ -341,11 +310,10 @@
341310 return ERR_PTR(-ENODEV);
342311 }
343312
344
-static inline struct dentry *debugfs_create_regset32(const char *name,
345
- umode_t mode, struct dentry *parent,
346
- struct debugfs_regset32 *regset)
313
+static inline void debugfs_create_regset32(const char *name, umode_t mode,
314
+ struct dentry *parent,
315
+ struct debugfs_regset32 *regset)
347316 {
348
- return ERR_PTR(-ENODEV);
349317 }
350318
351319 static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
....@@ -358,27 +326,18 @@
358326 return false;
359327 }
360328
361
-static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
362
- struct dentry *parent,
363
- u32 *array, u32 elements)
329
+static inline void debugfs_create_u32_array(const char *name, umode_t mode,
330
+ struct dentry *parent,
331
+ struct debugfs_u32_array *array)
364332 {
365
- return ERR_PTR(-ENODEV);
366333 }
367334
368
-static inline struct dentry *debugfs_create_u32_array_hex(const char *name, umode_t mode,
369
- struct dentry *parent,
370
- u32 *array, u32 elements)
335
+static inline void debugfs_create_devm_seqfile(struct device *dev,
336
+ const char *name,
337
+ struct dentry *parent,
338
+ int (*read_fn)(struct seq_file *s,
339
+ void *data))
371340 {
372
- return ERR_PTR(-ENODEV);
373
-}
374
-
375
-static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
376
- const char *name,
377
- struct dentry *parent,
378
- int (*read_fn)(struct seq_file *s,
379
- void *data))
380
-{
381
- return ERR_PTR(-ENODEV);
382341 }
383342
384343 static inline ssize_t debugfs_read_file_bool(struct file *file,
....@@ -397,4 +356,25 @@
397356
398357 #endif
399358
359
+/**
360
+ * debugfs_create_xul - create a debugfs file that is used to read and write an
361
+ * unsigned long value, formatted in hexadecimal
362
+ * @name: a pointer to a string containing the name of the file to create.
363
+ * @mode: the permission that the file should have
364
+ * @parent: a pointer to the parent dentry for this file. This should be a
365
+ * directory dentry if set. If this parameter is %NULL, then the
366
+ * file will be created in the root of the debugfs filesystem.
367
+ * @value: a pointer to the variable that the file should read to and write
368
+ * from.
369
+ */
370
+static inline void debugfs_create_xul(const char *name, umode_t mode,
371
+ struct dentry *parent,
372
+ unsigned long *value)
373
+{
374
+ if (sizeof(*value) == sizeof(u32))
375
+ debugfs_create_x32(name, mode, parent, (u32 *)value);
376
+ else
377
+ debugfs_create_x64(name, mode, parent, (u64 *)value);
378
+}
379
+
400380 #endif