13bce94fdSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * debugfs.h - a tiny little debug file system
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
61da177e4SLinus Torvalds * Copyright (C) 2004 IBM Inc.
71da177e4SLinus Torvalds *
81da177e4SLinus Torvalds * debugfs is for people to use instead of /proc or /sys.
9e1b4fc7aSMauro Carvalho Chehab * See Documentation/filesystems/ for more details.
101da177e4SLinus Torvalds */
111da177e4SLinus Torvalds
121da177e4SLinus Torvalds #ifndef _DEBUGFS_H_
131da177e4SLinus Torvalds #define _DEBUGFS_H_
141da177e4SLinus Torvalds
151da177e4SLinus Torvalds #include <linux/fs.h>
161a087c6aSAlessandro Rubini #include <linux/seq_file.h>
171da177e4SLinus Torvalds
18a7a76cefSRoland Dreier #include <linux/types.h>
1949d200deSNicolai Stange #include <linux/compiler.h>
20a7a76cefSRoland Dreier
21f30d0a81SArend van Spriel struct device;
22a7a76cefSRoland Dreier struct file_operations;
23a7a76cefSRoland Dreier
24dd308bc3SMichael Ellerman struct debugfs_blob_wrapper {
25dd308bc3SMichael Ellerman void *data;
26dd308bc3SMichael Ellerman unsigned long size;
27dd308bc3SMichael Ellerman };
28dd308bc3SMichael Ellerman
291a087c6aSAlessandro Rubini struct debugfs_reg32 {
301a087c6aSAlessandro Rubini char *name;
311a087c6aSAlessandro Rubini unsigned long offset;
321a087c6aSAlessandro Rubini };
331a087c6aSAlessandro Rubini
341a087c6aSAlessandro Rubini struct debugfs_regset32 {
35833d6e01SFelipe Balbi const struct debugfs_reg32 *regs;
361a087c6aSAlessandro Rubini int nregs;
371a087c6aSAlessandro Rubini void __iomem *base;
3830332eeeSGeert Uytterhoeven struct device *dev; /* Optional device for Runtime PM */
391a087c6aSAlessandro Rubini };
401a087c6aSAlessandro Rubini
41a2b992c8SJakub Kicinski struct debugfs_u32_array {
42a2b992c8SJakub Kicinski u32 *array;
43a2b992c8SJakub Kicinski u32 n_elements;
44a2b992c8SJakub Kicinski };
45a2b992c8SJakub Kicinski
46ae79cdaaSvenkatesh.pallipadi@intel.com extern struct dentry *arch_debugfs_dir;
47ae79cdaaSvenkatesh.pallipadi@intel.com
48*d472cf79SAkinobu Mita #define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed) \
497f847dd3SArnd Bergmann static int __fops ## _open(struct inode *inode, struct file *file) \
507f847dd3SArnd Bergmann { \
517f847dd3SArnd Bergmann __simple_attr_check_format(__fmt, 0ull); \
527f847dd3SArnd Bergmann return simple_attr_open(inode, file, __get, __set, __fmt); \
537f847dd3SArnd Bergmann } \
547f847dd3SArnd Bergmann static const struct file_operations __fops = { \
557f847dd3SArnd Bergmann .owner = THIS_MODULE, \
567f847dd3SArnd Bergmann .open = __fops ## _open, \
577f847dd3SArnd Bergmann .release = simple_attr_release, \
587f847dd3SArnd Bergmann .read = debugfs_attr_read, \
59*d472cf79SAkinobu Mita .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \
60895ce6c8SGeliang Tang .llseek = no_llseek, \
617f847dd3SArnd Bergmann }
627f847dd3SArnd Bergmann
63*d472cf79SAkinobu Mita #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
64*d472cf79SAkinobu Mita DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
65*d472cf79SAkinobu Mita
66*d472cf79SAkinobu Mita #define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \
67*d472cf79SAkinobu Mita DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
68*d472cf79SAkinobu Mita
694250b047SKusanagi Kouichi typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *);
704250b047SKusanagi Kouichi
711da177e4SLinus Torvalds #if defined(CONFIG_DEBUG_FS)
723634634eSHarvey Harrison
73a7c5437bSOmar Sandoval struct dentry *debugfs_lookup(const char *name, struct dentry *parent);
74a7c5437bSOmar Sandoval
75f4ae40a6SAl Viro struct dentry *debugfs_create_file(const char *name, umode_t mode,
761da177e4SLinus Torvalds struct dentry *parent, void *data,
7799ac48f5SArjan van de Ven const struct file_operations *fops);
78c6468808SNicolai Stange struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
79c6468808SNicolai Stange struct dentry *parent, void *data,
80c6468808SNicolai Stange const struct file_operations *fops);
811da177e4SLinus Torvalds
82526ee72dSGreg Kroah-Hartman void debugfs_create_file_size(const char *name, umode_t mode,
83e59b4e91SDavid Howells struct dentry *parent, void *data,
84e59b4e91SDavid Howells const struct file_operations *fops,
85e59b4e91SDavid Howells loff_t file_size);
86e59b4e91SDavid Howells
871da177e4SLinus Torvalds struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
881da177e4SLinus Torvalds
8966f54963SPeter Oberparleiter struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
9066f54963SPeter Oberparleiter const char *dest);
9166f54963SPeter Oberparleiter
9277b3da6eSAl Viro struct dentry *debugfs_create_automount(const char *name,
9377b3da6eSAl Viro struct dentry *parent,
9493faccbbSEric W. Biederman debugfs_automount_t f,
9577b3da6eSAl Viro void *data);
9677b3da6eSAl Viro
971da177e4SLinus Torvalds void debugfs_remove(struct dentry *dentry);
98a3d1e7ebSAl Viro #define debugfs_remove_recursive debugfs_remove
991da177e4SLinus Torvalds
100dec9b2f1SGreg Kroah-Hartman void debugfs_lookup_and_remove(const char *name, struct dentry *parent);
101dec9b2f1SGreg Kroah-Hartman
102055ab8e3SNicolai Stange const struct file_operations *debugfs_real_fops(const struct file *filp);
1037c8d4698SNicolai Stange
104e9117a5aSNicolai Stange int debugfs_file_get(struct dentry *dentry);
105e9117a5aSNicolai Stange void debugfs_file_put(struct dentry *dentry);
106e9117a5aSNicolai Stange
107c6468808SNicolai Stange ssize_t debugfs_attr_read(struct file *file, char __user *buf,
108c6468808SNicolai Stange size_t len, loff_t *ppos);
109c6468808SNicolai Stange ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
110c6468808SNicolai Stange size_t len, loff_t *ppos);
111*d472cf79SAkinobu Mita ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
112*d472cf79SAkinobu Mita size_t len, loff_t *ppos);
113c6468808SNicolai Stange
114cfc94cdfSJan Kara struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
115cfc94cdfSJan Kara struct dentry *new_dir, const char *new_name);
116cfc94cdfSJan Kara
1179655ac4aSGreg Kroah-Hartman void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
1189655ac4aSGreg Kroah-Hartman u8 *value);
119313f5dbbSGreg Kroah-Hartman void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent,
120313f5dbbSGreg Kroah-Hartman u16 *value);
1212b07021aSGreg Kroah-Hartman void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent,
1222b07021aSGreg Kroah-Hartman u32 *value);
123ad26221fSGreg Kroah-Hartman void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent,
124ad26221fSGreg Kroah-Hartman u64 *value);
125fb05b14cSGreg Kroah-Hartman void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
126fb05b14cSGreg Kroah-Hartman unsigned long *value);
127c7c11689SGreg Kroah-Hartman void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent,
128c7c11689SGreg Kroah-Hartman u8 *value);
129e40d38f2SGreg Kroah-Hartman void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent,
130e40d38f2SGreg Kroah-Hartman u16 *value);
131f5cb0a7eSGreg Kroah-Hartman void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent,
132f5cb0a7eSGreg Kroah-Hartman u32 *value);
1330864c408SGreg Kroah-Hartman void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent,
1340864c408SGreg Kroah-Hartman u64 *value);
1358e580263SGreg Kroah-Hartman void debugfs_create_size_t(const char *name, umode_t mode,
1365e078787SInaky Perez-Gonzalez struct dentry *parent, size_t *value);
1379927c6faSGreg Kroah-Hartman void debugfs_create_atomic_t(const char *name, umode_t mode,
1383a76e5e0SSeth Jennings struct dentry *parent, atomic_t *value);
139393b0638SGreg Kroah-Hartman void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
140393b0638SGreg Kroah-Hartman bool *value);
1419af0440eSPeter Zijlstra void debugfs_create_str(const char *name, umode_t mode,
1429af0440eSPeter Zijlstra struct dentry *parent, char **value);
1431da177e4SLinus Torvalds
144f4ae40a6SAl Viro struct dentry *debugfs_create_blob(const char *name, umode_t mode,
145dd308bc3SMichael Ellerman struct dentry *parent,
146dd308bc3SMichael Ellerman struct debugfs_blob_wrapper *blob);
147c0f92ba9SFrederic Weisbecker
148ae91c925SGreg Kroah-Hartman void debugfs_create_regset32(const char *name, umode_t mode,
1491a087c6aSAlessandro Rubini struct dentry *parent,
1501a087c6aSAlessandro Rubini struct debugfs_regset32 *regset);
1511a087c6aSAlessandro Rubini
1529761536eSJoe Perches void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
1531a087c6aSAlessandro Rubini int nregs, void __iomem *base, char *prefix);
1541a087c6aSAlessandro Rubini
155c9c2c27dSGreg Kroah-Hartman void debugfs_create_u32_array(const char *name, umode_t mode,
156a2b992c8SJakub Kicinski struct dentry *parent,
157a2b992c8SJakub Kicinski struct debugfs_u32_array *array);
1589fe2a701SSrivatsa Vaddagiri
1590d519cbfSGreg Kroah-Hartman void debugfs_create_devm_seqfile(struct device *dev, const char *name,
16098210b7fSArend van Spriel struct dentry *parent,
1610d519cbfSGreg Kroah-Hartman int (*read_fn)(struct seq_file *s, void *data));
16298210b7fSArend van Spriel
163c0f92ba9SFrederic Weisbecker bool debugfs_initialized(void);
164c0f92ba9SFrederic Weisbecker
1650642ef6fSRichard Fitzgerald ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
1660642ef6fSRichard Fitzgerald size_t count, loff_t *ppos);
1670642ef6fSRichard Fitzgerald
1680642ef6fSRichard Fitzgerald ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
1690642ef6fSRichard Fitzgerald size_t count, loff_t *ppos);
1700642ef6fSRichard Fitzgerald
1719af0440eSPeter Zijlstra ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
1729af0440eSPeter Zijlstra size_t count, loff_t *ppos);
1739af0440eSPeter Zijlstra
1741da177e4SLinus Torvalds #else
175a7a76cefSRoland Dreier
176a7a76cefSRoland Dreier #include <linux/err.h>
177a7a76cefSRoland Dreier
1781da177e4SLinus Torvalds /*
1791da177e4SLinus Torvalds * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
1801da177e4SLinus Torvalds * so users have a chance to detect if there was a real error or not. We don't
1811da177e4SLinus Torvalds * want to duplicate the design decision mistakes of procfs and devfs again.
1821da177e4SLinus Torvalds */
1831da177e4SLinus Torvalds
184a7c5437bSOmar Sandoval static inline struct dentry *debugfs_lookup(const char *name,
185a7c5437bSOmar Sandoval struct dentry *parent)
186a7c5437bSOmar Sandoval {
187a7c5437bSOmar Sandoval return ERR_PTR(-ENODEV);
188a7c5437bSOmar Sandoval }
189a7c5437bSOmar Sandoval
190f4ae40a6SAl Viro static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
191bde11d79SJean Delvare struct dentry *parent, void *data,
192bde11d79SJean Delvare const struct file_operations *fops)
1931da177e4SLinus Torvalds {
1941da177e4SLinus Torvalds return ERR_PTR(-ENODEV);
1951da177e4SLinus Torvalds }
1961da177e4SLinus Torvalds
197c2a737ebSViresh Kumar static inline struct dentry *debugfs_create_file_unsafe(const char *name,
198c2a737ebSViresh Kumar umode_t mode, struct dentry *parent,
199c2a737ebSViresh Kumar void *data,
200c2a737ebSViresh Kumar const struct file_operations *fops)
201c2a737ebSViresh Kumar {
202c2a737ebSViresh Kumar return ERR_PTR(-ENODEV);
203c2a737ebSViresh Kumar }
204c2a737ebSViresh Kumar
205526ee72dSGreg Kroah-Hartman static inline void debugfs_create_file_size(const char *name, umode_t mode,
206e59b4e91SDavid Howells struct dentry *parent, void *data,
207e59b4e91SDavid Howells const struct file_operations *fops,
208e59b4e91SDavid Howells loff_t file_size)
209526ee72dSGreg Kroah-Hartman { }
210e59b4e91SDavid Howells
2111da177e4SLinus Torvalds static inline struct dentry *debugfs_create_dir(const char *name,
2121da177e4SLinus Torvalds struct dentry *parent)
2131da177e4SLinus Torvalds {
2141da177e4SLinus Torvalds return ERR_PTR(-ENODEV);
2151da177e4SLinus Torvalds }
2161da177e4SLinus Torvalds
21766f54963SPeter Oberparleiter static inline struct dentry *debugfs_create_symlink(const char *name,
21866f54963SPeter Oberparleiter struct dentry *parent,
21966f54963SPeter Oberparleiter const char *dest)
22066f54963SPeter Oberparleiter {
22166f54963SPeter Oberparleiter return ERR_PTR(-ENODEV);
22266f54963SPeter Oberparleiter }
22366f54963SPeter Oberparleiter
22494e1dec7SJiaxing Wang static inline struct dentry *debugfs_create_automount(const char *name,
22594e1dec7SJiaxing Wang struct dentry *parent,
2264250b047SKusanagi Kouichi debugfs_automount_t f,
22794e1dec7SJiaxing Wang void *data)
22894e1dec7SJiaxing Wang {
22994e1dec7SJiaxing Wang return ERR_PTR(-ENODEV);
23094e1dec7SJiaxing Wang }
23194e1dec7SJiaxing Wang
2321da177e4SLinus Torvalds static inline void debugfs_remove(struct dentry *dentry)
2331da177e4SLinus Torvalds { }
2341da177e4SLinus Torvalds
2359505e637SHaavard Skinnemoen static inline void debugfs_remove_recursive(struct dentry *dentry)
2369505e637SHaavard Skinnemoen { }
2379505e637SHaavard Skinnemoen
238dec9b2f1SGreg Kroah-Hartman static inline void debugfs_lookup_and_remove(const char *name,
239dec9b2f1SGreg Kroah-Hartman struct dentry *parent)
240dec9b2f1SGreg Kroah-Hartman { }
241dec9b2f1SGreg Kroah-Hartman
242f50caa9bSArnd Bergmann const struct file_operations *debugfs_real_fops(const struct file *filp);
243f50caa9bSArnd Bergmann
244e9117a5aSNicolai Stange static inline int debugfs_file_get(struct dentry *dentry)
245e9117a5aSNicolai Stange {
246e9117a5aSNicolai Stange return 0;
247e9117a5aSNicolai Stange }
248e9117a5aSNicolai Stange
249e9117a5aSNicolai Stange static inline void debugfs_file_put(struct dentry *dentry)
250e9117a5aSNicolai Stange { }
251e9117a5aSNicolai Stange
2527f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_read(struct file *file, char __user *buf,
2537f847dd3SArnd Bergmann size_t len, loff_t *ppos)
2547f847dd3SArnd Bergmann {
2557f847dd3SArnd Bergmann return -ENODEV;
2567f847dd3SArnd Bergmann }
2577f847dd3SArnd Bergmann
2587f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_write(struct file *file,
2597f847dd3SArnd Bergmann const char __user *buf,
2607f847dd3SArnd Bergmann size_t len, loff_t *ppos)
2617f847dd3SArnd Bergmann {
2627f847dd3SArnd Bergmann return -ENODEV;
2637f847dd3SArnd Bergmann }
264c6468808SNicolai Stange
265*d472cf79SAkinobu Mita static inline ssize_t debugfs_attr_write_signed(struct file *file,
266*d472cf79SAkinobu Mita const char __user *buf,
267*d472cf79SAkinobu Mita size_t len, loff_t *ppos)
268*d472cf79SAkinobu Mita {
269*d472cf79SAkinobu Mita return -ENODEV;
270*d472cf79SAkinobu Mita }
271*d472cf79SAkinobu Mita
272cfc94cdfSJan Kara static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
273cfc94cdfSJan Kara struct dentry *new_dir, char *new_name)
274cfc94cdfSJan Kara {
275cfc94cdfSJan Kara return ERR_PTR(-ENODEV);
276cfc94cdfSJan Kara }
277cfc94cdfSJan Kara
2789655ac4aSGreg Kroah-Hartman static inline void debugfs_create_u8(const char *name, umode_t mode,
2799655ac4aSGreg Kroah-Hartman struct dentry *parent, u8 *value) { }
2801da177e4SLinus Torvalds
281313f5dbbSGreg Kroah-Hartman static inline void debugfs_create_u16(const char *name, umode_t mode,
282313f5dbbSGreg Kroah-Hartman struct dentry *parent, u16 *value) { }
2831da177e4SLinus Torvalds
2842b07021aSGreg Kroah-Hartman static inline void debugfs_create_u32(const char *name, umode_t mode,
2852b07021aSGreg Kroah-Hartman struct dentry *parent, u32 *value) { }
2861da177e4SLinus Torvalds
287ad26221fSGreg Kroah-Hartman static inline void debugfs_create_u64(const char *name, umode_t mode,
288ad26221fSGreg Kroah-Hartman struct dentry *parent, u64 *value) { }
2898447891fSMichael Ellerman
290fb05b14cSGreg Kroah-Hartman static inline void debugfs_create_ulong(const char *name, umode_t mode,
291c2a737ebSViresh Kumar struct dentry *parent,
292fb05b14cSGreg Kroah-Hartman unsigned long *value) { }
293c2a737ebSViresh Kumar
294c7c11689SGreg Kroah-Hartman static inline void debugfs_create_x8(const char *name, umode_t mode,
295c7c11689SGreg Kroah-Hartman struct dentry *parent, u8 *value) { }
2962ebefc50SRobin Getz
297e40d38f2SGreg Kroah-Hartman static inline void debugfs_create_x16(const char *name, umode_t mode,
298e40d38f2SGreg Kroah-Hartman struct dentry *parent, u16 *value) { }
2992ebefc50SRobin Getz
300f5cb0a7eSGreg Kroah-Hartman static inline void debugfs_create_x32(const char *name, umode_t mode,
301f5cb0a7eSGreg Kroah-Hartman struct dentry *parent, u32 *value) { }
3022ebefc50SRobin Getz
3030864c408SGreg Kroah-Hartman static inline void debugfs_create_x64(const char *name, umode_t mode,
3040864c408SGreg Kroah-Hartman struct dentry *parent, u64 *value) { }
3053159269eSJohannes Berg
3068e580263SGreg Kroah-Hartman static inline void debugfs_create_size_t(const char *name, umode_t mode,
3078e580263SGreg Kroah-Hartman struct dentry *parent, size_t *value)
3088e580263SGreg Kroah-Hartman { }
3098adb711fSInaky Perez-Gonzalez
3109927c6faSGreg Kroah-Hartman static inline void debugfs_create_atomic_t(const char *name, umode_t mode,
3119927c6faSGreg Kroah-Hartman struct dentry *parent,
3129927c6faSGreg Kroah-Hartman atomic_t *value)
3139927c6faSGreg Kroah-Hartman { }
3145b880214SWeijie Yang
315393b0638SGreg Kroah-Hartman static inline void debugfs_create_bool(const char *name, umode_t mode,
316393b0638SGreg Kroah-Hartman struct dentry *parent, bool *value) { }
3171da177e4SLinus Torvalds
3189af0440eSPeter Zijlstra static inline void debugfs_create_str(const char *name, umode_t mode,
3199af0440eSPeter Zijlstra struct dentry *parent,
3209af0440eSPeter Zijlstra char **value)
3219af0440eSPeter Zijlstra { }
3229af0440eSPeter Zijlstra
323f4ae40a6SAl Viro static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
324dd308bc3SMichael Ellerman struct dentry *parent,
325dd308bc3SMichael Ellerman struct debugfs_blob_wrapper *blob)
326dd308bc3SMichael Ellerman {
327dd308bc3SMichael Ellerman return ERR_PTR(-ENODEV);
328dd308bc3SMichael Ellerman }
329dd308bc3SMichael Ellerman
330ae91c925SGreg Kroah-Hartman static inline void debugfs_create_regset32(const char *name, umode_t mode,
331ae91c925SGreg Kroah-Hartman struct dentry *parent,
3321a087c6aSAlessandro Rubini struct debugfs_regset32 *regset)
3331a087c6aSAlessandro Rubini {
3341a087c6aSAlessandro Rubini }
3351a087c6aSAlessandro Rubini
3369761536eSJoe Perches static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
3375b880214SWeijie Yang int nregs, void __iomem *base, char *prefix)
3385b880214SWeijie Yang {
3395b880214SWeijie Yang }
3405b880214SWeijie Yang
341c0f92ba9SFrederic Weisbecker static inline bool debugfs_initialized(void)
342c0f92ba9SFrederic Weisbecker {
343c0f92ba9SFrederic Weisbecker return false;
344c0f92ba9SFrederic Weisbecker }
345c0f92ba9SFrederic Weisbecker
346c9c2c27dSGreg Kroah-Hartman static inline void debugfs_create_u32_array(const char *name, umode_t mode,
347a2b992c8SJakub Kicinski struct dentry *parent,
348a2b992c8SJakub Kicinski struct debugfs_u32_array *array)
3499fe2a701SSrivatsa Vaddagiri {
3509fe2a701SSrivatsa Vaddagiri }
3519fe2a701SSrivatsa Vaddagiri
3520d519cbfSGreg Kroah-Hartman static inline void debugfs_create_devm_seqfile(struct device *dev,
35398210b7fSArend van Spriel const char *name,
35498210b7fSArend van Spriel struct dentry *parent,
35598210b7fSArend van Spriel int (*read_fn)(struct seq_file *s,
35698210b7fSArend van Spriel void *data))
35798210b7fSArend van Spriel {
35898210b7fSArend van Spriel }
35998210b7fSArend van Spriel
3600642ef6fSRichard Fitzgerald static inline ssize_t debugfs_read_file_bool(struct file *file,
3610642ef6fSRichard Fitzgerald char __user *user_buf,
3620642ef6fSRichard Fitzgerald size_t count, loff_t *ppos)
3630642ef6fSRichard Fitzgerald {
3640642ef6fSRichard Fitzgerald return -ENODEV;
3650642ef6fSRichard Fitzgerald }
3660642ef6fSRichard Fitzgerald
3670642ef6fSRichard Fitzgerald static inline ssize_t debugfs_write_file_bool(struct file *file,
3680642ef6fSRichard Fitzgerald const char __user *user_buf,
3690642ef6fSRichard Fitzgerald size_t count, loff_t *ppos)
3700642ef6fSRichard Fitzgerald {
3710642ef6fSRichard Fitzgerald return -ENODEV;
3720642ef6fSRichard Fitzgerald }
3730642ef6fSRichard Fitzgerald
3749af0440eSPeter Zijlstra static inline ssize_t debugfs_read_file_str(struct file *file,
3759af0440eSPeter Zijlstra char __user *user_buf,
3769af0440eSPeter Zijlstra size_t count, loff_t *ppos)
3779af0440eSPeter Zijlstra {
3789af0440eSPeter Zijlstra return -ENODEV;
3799af0440eSPeter Zijlstra }
3809af0440eSPeter Zijlstra
3811da177e4SLinus Torvalds #endif
3821da177e4SLinus Torvalds
383d3504757SGeert Uytterhoeven /**
384d3504757SGeert Uytterhoeven * debugfs_create_xul - create a debugfs file that is used to read and write an
385d3504757SGeert Uytterhoeven * unsigned long value, formatted in hexadecimal
386d3504757SGeert Uytterhoeven * @name: a pointer to a string containing the name of the file to create.
387d3504757SGeert Uytterhoeven * @mode: the permission that the file should have
388d3504757SGeert Uytterhoeven * @parent: a pointer to the parent dentry for this file. This should be a
389d3504757SGeert Uytterhoeven * directory dentry if set. If this parameter is %NULL, then the
390d3504757SGeert Uytterhoeven * file will be created in the root of the debugfs filesystem.
391d3504757SGeert Uytterhoeven * @value: a pointer to the variable that the file should read to and write
392d3504757SGeert Uytterhoeven * from.
393d3504757SGeert Uytterhoeven */
debugfs_create_xul(const char * name,umode_t mode,struct dentry * parent,unsigned long * value)394d3504757SGeert Uytterhoeven static inline void debugfs_create_xul(const char *name, umode_t mode,
395d3504757SGeert Uytterhoeven struct dentry *parent,
396d3504757SGeert Uytterhoeven unsigned long *value)
397d3504757SGeert Uytterhoeven {
398d3504757SGeert Uytterhoeven if (sizeof(*value) == sizeof(u32))
399d3504757SGeert Uytterhoeven debugfs_create_x32(name, mode, parent, (u32 *)value);
400d3504757SGeert Uytterhoeven else
401d3504757SGeert Uytterhoeven debugfs_create_x64(name, mode, parent, (u64 *)value);
402d3504757SGeert Uytterhoeven }
403d3504757SGeert Uytterhoeven
4041da177e4SLinus Torvalds #endif
405