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 <[email protected]>
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
46ae79cdaaS[email protected] extern struct dentry *arch_debugfs_dir;
47ae79cdaaS[email protected]
48d472cf79SAkinobu 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, \
59d472cf79SAkinobu Mita .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \
607f847dd3SArnd Bergmann }
617f847dd3SArnd Bergmann
62d472cf79SAkinobu Mita #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
63d472cf79SAkinobu Mita DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
64d472cf79SAkinobu Mita
65d472cf79SAkinobu Mita #define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \
66d472cf79SAkinobu Mita DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
67d472cf79SAkinobu Mita
684250b047SKusanagi Kouichi typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *);
694250b047SKusanagi Kouichi
708dc6d81cSJohannes Berg struct debugfs_short_fops {
718dc6d81cSJohannes Berg ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
728dc6d81cSJohannes Berg ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
738dc6d81cSJohannes Berg loff_t (*llseek) (struct file *, loff_t, int);
748dc6d81cSJohannes Berg };
758dc6d81cSJohannes Berg
76d1433c7bSAl Viro #if defined(CONFIG_DEBUG_FS)
77d1433c7bSAl Viro
78d1433c7bSAl Viro struct dentry *debugfs_lookup(const char *name, struct dentry *parent);
79d1433c7bSAl Viro
808dc6d81cSJohannes Berg struct dentry *debugfs_create_file_full(const char *name, umode_t mode,
811da177e4SLinus Torvalds struct dentry *parent, void *data,
8212c92098SAl Viro const void *aux,
8399ac48f5SArjan van de Ven const struct file_operations *fops);
848dc6d81cSJohannes Berg struct dentry *debugfs_create_file_short(const char *name, umode_t mode,
858dc6d81cSJohannes Berg struct dentry *parent, void *data,
8612c92098SAl Viro const void *aux,
878dc6d81cSJohannes Berg const struct debugfs_short_fops *fops);
888dc6d81cSJohannes Berg
898dc6d81cSJohannes Berg /**
908dc6d81cSJohannes Berg * debugfs_create_file - create a file in the debugfs filesystem
918dc6d81cSJohannes Berg * @name: a pointer to a string containing the name of the file to create.
928dc6d81cSJohannes Berg * @mode: the permission that the file should have.
938dc6d81cSJohannes Berg * @parent: a pointer to the parent dentry for this file. This should be a
948dc6d81cSJohannes Berg * directory dentry if set. If this parameter is NULL, then the
958dc6d81cSJohannes Berg * file will be created in the root of the debugfs filesystem.
968dc6d81cSJohannes Berg * @data: a pointer to something that the caller will want to get to later
978dc6d81cSJohannes Berg * on. The inode.i_private pointer will point to this value on
988dc6d81cSJohannes Berg * the open() call.
998dc6d81cSJohannes Berg * @fops: a pointer to a struct file_operations or struct debugfs_short_fops that
1008dc6d81cSJohannes Berg * should be used for this file.
1018dc6d81cSJohannes Berg *
1028dc6d81cSJohannes Berg * This is the basic "create a file" function for debugfs. It allows for a
1038dc6d81cSJohannes Berg * wide range of flexibility in creating a file, or a directory (if you want
1048dc6d81cSJohannes Berg * to create a directory, the debugfs_create_dir() function is
1058dc6d81cSJohannes Berg * recommended to be used instead.)
1068dc6d81cSJohannes Berg *
1078dc6d81cSJohannes Berg * This function will return a pointer to a dentry if it succeeds. This
1088dc6d81cSJohannes Berg * pointer must be passed to the debugfs_remove() function when the file is
1098dc6d81cSJohannes Berg * to be removed (no automatic cleanup happens if your module is unloaded,
1108dc6d81cSJohannes Berg * you are responsible here.) If an error occurs, ERR_PTR(-ERROR) will be
1118dc6d81cSJohannes Berg * returned.
1128dc6d81cSJohannes Berg *
1138dc6d81cSJohannes Berg * If debugfs is not enabled in the kernel, the value -%ENODEV will be
1148dc6d81cSJohannes Berg * returned.
1158dc6d81cSJohannes Berg *
1168dc6d81cSJohannes Berg * If fops points to a struct debugfs_short_fops, then simple_open() will be
1178dc6d81cSJohannes Berg * used for the open, and only read/write/llseek are supported and are proxied,
1188dc6d81cSJohannes Berg * so no module reference or release are needed.
1198dc6d81cSJohannes Berg *
1208dc6d81cSJohannes Berg * NOTE: it's expected that most callers should _ignore_ the errors returned
1218dc6d81cSJohannes Berg * by this function. Other debugfs functions handle the fact that the "dentry"
1228dc6d81cSJohannes Berg * passed to them could be an error and they don't crash in that case.
1238dc6d81cSJohannes Berg * Drivers should generally work fine even if debugfs fails to init anyway.
1248dc6d81cSJohannes Berg */
1258dc6d81cSJohannes Berg #define debugfs_create_file(name, mode, parent, data, fops) \
1268dc6d81cSJohannes Berg _Generic(fops, \
1278dc6d81cSJohannes Berg const struct file_operations *: debugfs_create_file_full, \
1288dc6d81cSJohannes Berg const struct debugfs_short_fops *: debugfs_create_file_short, \
1298dc6d81cSJohannes Berg struct file_operations *: debugfs_create_file_full, \
1308dc6d81cSJohannes Berg struct debugfs_short_fops *: debugfs_create_file_short) \
13112c92098SAl Viro (name, mode, parent, data, NULL, fops)
13212c92098SAl Viro
13312c92098SAl Viro #define debugfs_create_file_aux(name, mode, parent, data, aux, fops) \
13412c92098SAl Viro _Generic(fops, \
13512c92098SAl Viro const struct file_operations *: debugfs_create_file_full, \
13612c92098SAl Viro const struct debugfs_short_fops *: debugfs_create_file_short, \
13712c92098SAl Viro struct file_operations *: debugfs_create_file_full, \
13812c92098SAl Viro struct debugfs_short_fops *: debugfs_create_file_short) \
13912c92098SAl Viro (name, mode, parent, data, aux, fops)
1408dc6d81cSJohannes Berg
141c6468808SNicolai Stange struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
142c6468808SNicolai Stange struct dentry *parent, void *data,
143c6468808SNicolai Stange const struct file_operations *fops);
1441da177e4SLinus Torvalds
145526ee72dSGreg Kroah-Hartman void debugfs_create_file_size(const char *name, umode_t mode,
146e59b4e91SDavid Howells struct dentry *parent, void *data,
147e59b4e91SDavid Howells const struct file_operations *fops,
148e59b4e91SDavid Howells loff_t file_size);
149e59b4e91SDavid Howells
1501da177e4SLinus Torvalds struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
1511da177e4SLinus Torvalds
15266f54963SPeter Oberparleiter struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
15366f54963SPeter Oberparleiter const char *dest);
15466f54963SPeter Oberparleiter
15577b3da6eSAl Viro struct dentry *debugfs_create_automount(const char *name,
15677b3da6eSAl Viro struct dentry *parent,
15793faccbbSEric W. Biederman debugfs_automount_t f,
15877b3da6eSAl Viro void *data);
15977b3da6eSAl Viro
1601da177e4SLinus Torvalds void debugfs_remove(struct dentry *dentry);
161a3d1e7ebSAl Viro #define debugfs_remove_recursive debugfs_remove
1621da177e4SLinus Torvalds
163dec9b2f1SGreg Kroah-Hartman void debugfs_lookup_and_remove(const char *name, struct dentry *parent);
164dec9b2f1SGreg Kroah-Hartman
165055ab8e3SNicolai Stange const struct file_operations *debugfs_real_fops(const struct file *filp);
16612c92098SAl Viro const void *debugfs_get_aux(const struct file *file);
1677c8d4698SNicolai Stange
168e9117a5aSNicolai Stange int debugfs_file_get(struct dentry *dentry);
169e9117a5aSNicolai Stange void debugfs_file_put(struct dentry *dentry);
170e9117a5aSNicolai Stange
171c6468808SNicolai Stange ssize_t debugfs_attr_read(struct file *file, char __user *buf,
172c6468808SNicolai Stange size_t len, loff_t *ppos);
173c6468808SNicolai Stange ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
174c6468808SNicolai Stange size_t len, loff_t *ppos);
175d472cf79SAkinobu Mita ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
176d472cf79SAkinobu Mita size_t len, loff_t *ppos);
177c6468808SNicolai Stange
178*f7862dfeSAl Viro int debugfs_change_name(struct dentry *dentry, const char *fmt, ...) __printf(2, 3);
179cfc94cdfSJan Kara
1809655ac4aSGreg Kroah-Hartman void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
1819655ac4aSGreg Kroah-Hartman u8 *value);
182313f5dbbSGreg Kroah-Hartman void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent,
183313f5dbbSGreg Kroah-Hartman u16 *value);
1842b07021aSGreg Kroah-Hartman void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent,
1852b07021aSGreg Kroah-Hartman u32 *value);
186ad26221fSGreg Kroah-Hartman void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent,
187ad26221fSGreg Kroah-Hartman u64 *value);
188fb05b14cSGreg Kroah-Hartman void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
189fb05b14cSGreg Kroah-Hartman unsigned long *value);
190c7c11689SGreg Kroah-Hartman void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent,
191c7c11689SGreg Kroah-Hartman u8 *value);
192e40d38f2SGreg Kroah-Hartman void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent,
193e40d38f2SGreg Kroah-Hartman u16 *value);
194f5cb0a7eSGreg Kroah-Hartman void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent,
195f5cb0a7eSGreg Kroah-Hartman u32 *value);
1960864c408SGreg Kroah-Hartman void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent,
1970864c408SGreg Kroah-Hartman u64 *value);
1988e580263SGreg Kroah-Hartman void debugfs_create_size_t(const char *name, umode_t mode,
1995e078787SInaky Perez-Gonzalez struct dentry *parent, size_t *value);
2009927c6faSGreg Kroah-Hartman void debugfs_create_atomic_t(const char *name, umode_t mode,
2013a76e5e0SSeth Jennings struct dentry *parent, atomic_t *value);
202393b0638SGreg Kroah-Hartman void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
203393b0638SGreg Kroah-Hartman bool *value);
2049af0440eSPeter Zijlstra void debugfs_create_str(const char *name, umode_t mode,
2059af0440eSPeter Zijlstra struct dentry *parent, char **value);
2061da177e4SLinus Torvalds
207f4ae40a6SAl Viro struct dentry *debugfs_create_blob(const char *name, umode_t mode,
208dd308bc3SMichael Ellerman struct dentry *parent,
209dd308bc3SMichael Ellerman struct debugfs_blob_wrapper *blob);
210c0f92ba9SFrederic Weisbecker
211ae91c925SGreg Kroah-Hartman void debugfs_create_regset32(const char *name, umode_t mode,
2121a087c6aSAlessandro Rubini struct dentry *parent,
2131a087c6aSAlessandro Rubini struct debugfs_regset32 *regset);
2141a087c6aSAlessandro Rubini
2159761536eSJoe Perches void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
2161a087c6aSAlessandro Rubini int nregs, void __iomem *base, char *prefix);
2171a087c6aSAlessandro Rubini
218c9c2c27dSGreg Kroah-Hartman void debugfs_create_u32_array(const char *name, umode_t mode,
219a2b992c8SJakub Kicinski struct dentry *parent,
220a2b992c8SJakub Kicinski struct debugfs_u32_array *array);
2219fe2a701SSrivatsa Vaddagiri
2220d519cbfSGreg Kroah-Hartman void debugfs_create_devm_seqfile(struct device *dev, const char *name,
22398210b7fSArend van Spriel struct dentry *parent,
2240d519cbfSGreg Kroah-Hartman int (*read_fn)(struct seq_file *s, void *data));
22598210b7fSArend van Spriel
226c0f92ba9SFrederic Weisbecker bool debugfs_initialized(void);
227c0f92ba9SFrederic Weisbecker
2280642ef6fSRichard Fitzgerald ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
2290642ef6fSRichard Fitzgerald size_t count, loff_t *ppos);
2300642ef6fSRichard Fitzgerald
2310642ef6fSRichard Fitzgerald ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
2320642ef6fSRichard Fitzgerald size_t count, loff_t *ppos);
2330642ef6fSRichard Fitzgerald
2349af0440eSPeter Zijlstra ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
2359af0440eSPeter Zijlstra size_t count, loff_t *ppos);
2369af0440eSPeter Zijlstra
2378c88a474SJohannes Berg /**
2388c88a474SJohannes Berg * struct debugfs_cancellation - cancellation data
2398c88a474SJohannes Berg * @list: internal, for keeping track
2408c88a474SJohannes Berg * @cancel: callback to call
2418c88a474SJohannes Berg * @cancel_data: extra data for the callback to call
2428c88a474SJohannes Berg */
2438c88a474SJohannes Berg struct debugfs_cancellation {
2448c88a474SJohannes Berg struct list_head list;
2458c88a474SJohannes Berg void (*cancel)(struct dentry *, void *);
2468c88a474SJohannes Berg void *cancel_data;
2478c88a474SJohannes Berg };
2488c88a474SJohannes Berg
2498c88a474SJohannes Berg void __acquires(cancellation)
2508c88a474SJohannes Berg debugfs_enter_cancellation(struct file *file,
2518c88a474SJohannes Berg struct debugfs_cancellation *cancellation);
2528c88a474SJohannes Berg void __releases(cancellation)
2538c88a474SJohannes Berg debugfs_leave_cancellation(struct file *file,
2548c88a474SJohannes Berg struct debugfs_cancellation *cancellation);
2558c88a474SJohannes Berg
2561da177e4SLinus Torvalds #else
257a7a76cefSRoland Dreier
258a7a76cefSRoland Dreier #include <linux/err.h>
259a7a76cefSRoland Dreier
2601da177e4SLinus Torvalds /*
2611da177e4SLinus Torvalds * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
2621da177e4SLinus Torvalds * so users have a chance to detect if there was a real error or not. We don't
2631da177e4SLinus Torvalds * want to duplicate the design decision mistakes of procfs and devfs again.
2641da177e4SLinus Torvalds */
2651da177e4SLinus Torvalds
debugfs_lookup(const char * name,struct dentry * parent)266a7c5437bSOmar Sandoval static inline struct dentry *debugfs_lookup(const char *name,
267a7c5437bSOmar Sandoval struct dentry *parent)
268a7c5437bSOmar Sandoval {
269a7c5437bSOmar Sandoval return ERR_PTR(-ENODEV);
270a7c5437bSOmar Sandoval }
271a7c5437bSOmar Sandoval
debugfs_create_file_aux(const char * name,umode_t mode,struct dentry * parent,void * data,void * aux,const void * fops)27212c92098SAl Viro static inline struct dentry *debugfs_create_file_aux(const char *name,
27312c92098SAl Viro umode_t mode, struct dentry *parent,
27412c92098SAl Viro void *data, void *aux,
27512c92098SAl Viro const void *fops)
27612c92098SAl Viro {
27712c92098SAl Viro return ERR_PTR(-ENODEV);
27812c92098SAl Viro }
27912c92098SAl Viro
debugfs_create_file(const char * name,umode_t mode,struct dentry * parent,void * data,const void * fops)280f4ae40a6SAl Viro static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
281bde11d79SJean Delvare struct dentry *parent, void *data,
2828dc6d81cSJohannes Berg const void *fops)
2831da177e4SLinus Torvalds {
2841da177e4SLinus Torvalds return ERR_PTR(-ENODEV);
2851da177e4SLinus Torvalds }
2861da177e4SLinus Torvalds
debugfs_create_file_unsafe(const char * name,umode_t mode,struct dentry * parent,void * data,const struct file_operations * fops)287c2a737ebSViresh Kumar static inline struct dentry *debugfs_create_file_unsafe(const char *name,
288c2a737ebSViresh Kumar umode_t mode, struct dentry *parent,
289c2a737ebSViresh Kumar void *data,
290c2a737ebSViresh Kumar const struct file_operations *fops)
291c2a737ebSViresh Kumar {
292c2a737ebSViresh Kumar return ERR_PTR(-ENODEV);
293c2a737ebSViresh Kumar }
294c2a737ebSViresh Kumar
debugfs_create_file_size(const char * name,umode_t mode,struct dentry * parent,void * data,const struct file_operations * fops,loff_t file_size)295526ee72dSGreg Kroah-Hartman static inline void debugfs_create_file_size(const char *name, umode_t mode,
296e59b4e91SDavid Howells struct dentry *parent, void *data,
297e59b4e91SDavid Howells const struct file_operations *fops,
298e59b4e91SDavid Howells loff_t file_size)
299526ee72dSGreg Kroah-Hartman { }
300e59b4e91SDavid Howells
debugfs_create_dir(const char * name,struct dentry * parent)3011da177e4SLinus Torvalds static inline struct dentry *debugfs_create_dir(const char *name,
3021da177e4SLinus Torvalds struct dentry *parent)
3031da177e4SLinus Torvalds {
3041da177e4SLinus Torvalds return ERR_PTR(-ENODEV);
3051da177e4SLinus Torvalds }
3061da177e4SLinus Torvalds
debugfs_create_symlink(const char * name,struct dentry * parent,const char * dest)30766f54963SPeter Oberparleiter static inline struct dentry *debugfs_create_symlink(const char *name,
30866f54963SPeter Oberparleiter struct dentry *parent,
30966f54963SPeter Oberparleiter const char *dest)
31066f54963SPeter Oberparleiter {
31166f54963SPeter Oberparleiter return ERR_PTR(-ENODEV);
31266f54963SPeter Oberparleiter }
31366f54963SPeter Oberparleiter
debugfs_create_automount(const char * name,struct dentry * parent,debugfs_automount_t f,void * data)31494e1dec7SJiaxing Wang static inline struct dentry *debugfs_create_automount(const char *name,
31594e1dec7SJiaxing Wang struct dentry *parent,
3164250b047SKusanagi Kouichi debugfs_automount_t f,
31794e1dec7SJiaxing Wang void *data)
31894e1dec7SJiaxing Wang {
31994e1dec7SJiaxing Wang return ERR_PTR(-ENODEV);
32094e1dec7SJiaxing Wang }
32194e1dec7SJiaxing Wang
debugfs_remove(struct dentry * dentry)3221da177e4SLinus Torvalds static inline void debugfs_remove(struct dentry *dentry)
3231da177e4SLinus Torvalds { }
3241da177e4SLinus Torvalds
debugfs_remove_recursive(struct dentry * dentry)3259505e637SHaavard Skinnemoen static inline void debugfs_remove_recursive(struct dentry *dentry)
3269505e637SHaavard Skinnemoen { }
3279505e637SHaavard Skinnemoen
debugfs_lookup_and_remove(const char * name,struct dentry * parent)328dec9b2f1SGreg Kroah-Hartman static inline void debugfs_lookup_and_remove(const char *name,
329dec9b2f1SGreg Kroah-Hartman struct dentry *parent)
330dec9b2f1SGreg Kroah-Hartman { }
331dec9b2f1SGreg Kroah-Hartman
332f50caa9bSArnd Bergmann const struct file_operations *debugfs_real_fops(const struct file *filp);
33312c92098SAl Viro void *debugfs_get_aux(const struct file *file);
334f50caa9bSArnd Bergmann
debugfs_file_get(struct dentry * dentry)335e9117a5aSNicolai Stange static inline int debugfs_file_get(struct dentry *dentry)
336e9117a5aSNicolai Stange {
337e9117a5aSNicolai Stange return 0;
338e9117a5aSNicolai Stange }
339e9117a5aSNicolai Stange
debugfs_file_put(struct dentry * dentry)340e9117a5aSNicolai Stange static inline void debugfs_file_put(struct dentry *dentry)
341e9117a5aSNicolai Stange { }
342e9117a5aSNicolai Stange
debugfs_attr_read(struct file * file,char __user * buf,size_t len,loff_t * ppos)3437f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_read(struct file *file, char __user *buf,
3447f847dd3SArnd Bergmann size_t len, loff_t *ppos)
3457f847dd3SArnd Bergmann {
3467f847dd3SArnd Bergmann return -ENODEV;
3477f847dd3SArnd Bergmann }
3487f847dd3SArnd Bergmann
debugfs_attr_write(struct file * file,const char __user * buf,size_t len,loff_t * ppos)3497f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_write(struct file *file,
3507f847dd3SArnd Bergmann const char __user *buf,
3517f847dd3SArnd Bergmann size_t len, loff_t *ppos)
3527f847dd3SArnd Bergmann {
3537f847dd3SArnd Bergmann return -ENODEV;
3547f847dd3SArnd Bergmann }
355c6468808SNicolai Stange
debugfs_attr_write_signed(struct file * file,const char __user * buf,size_t len,loff_t * ppos)356d472cf79SAkinobu Mita static inline ssize_t debugfs_attr_write_signed(struct file *file,
357d472cf79SAkinobu Mita const char __user *buf,
358d472cf79SAkinobu Mita size_t len, loff_t *ppos)
359d472cf79SAkinobu Mita {
360d472cf79SAkinobu Mita return -ENODEV;
361d472cf79SAkinobu Mita }
362d472cf79SAkinobu Mita
debugfs_change_name(struct dentry * dentry,const char * fmt,...)363*f7862dfeSAl Viro static inline int __printf(2, 3) debugfs_change_name(struct dentry *dentry,
364*f7862dfeSAl Viro const char *fmt, ...)
365cfc94cdfSJan Kara {
366*f7862dfeSAl Viro return -ENODEV;
367cfc94cdfSJan Kara }
368cfc94cdfSJan Kara
debugfs_create_u8(const char * name,umode_t mode,struct dentry * parent,u8 * value)3699655ac4aSGreg Kroah-Hartman static inline void debugfs_create_u8(const char *name, umode_t mode,
3709655ac4aSGreg Kroah-Hartman struct dentry *parent, u8 *value) { }
3711da177e4SLinus Torvalds
debugfs_create_u16(const char * name,umode_t mode,struct dentry * parent,u16 * value)372313f5dbbSGreg Kroah-Hartman static inline void debugfs_create_u16(const char *name, umode_t mode,
373313f5dbbSGreg Kroah-Hartman struct dentry *parent, u16 *value) { }
3741da177e4SLinus Torvalds
debugfs_create_u32(const char * name,umode_t mode,struct dentry * parent,u32 * value)3752b07021aSGreg Kroah-Hartman static inline void debugfs_create_u32(const char *name, umode_t mode,
3762b07021aSGreg Kroah-Hartman struct dentry *parent, u32 *value) { }
3771da177e4SLinus Torvalds
debugfs_create_u64(const char * name,umode_t mode,struct dentry * parent,u64 * value)378ad26221fSGreg Kroah-Hartman static inline void debugfs_create_u64(const char *name, umode_t mode,
379ad26221fSGreg Kroah-Hartman struct dentry *parent, u64 *value) { }
3808447891fSMichael Ellerman
debugfs_create_ulong(const char * name,umode_t mode,struct dentry * parent,unsigned long * value)381fb05b14cSGreg Kroah-Hartman static inline void debugfs_create_ulong(const char *name, umode_t mode,
382c2a737ebSViresh Kumar struct dentry *parent,
383fb05b14cSGreg Kroah-Hartman unsigned long *value) { }
384c2a737ebSViresh Kumar
debugfs_create_x8(const char * name,umode_t mode,struct dentry * parent,u8 * value)385c7c11689SGreg Kroah-Hartman static inline void debugfs_create_x8(const char *name, umode_t mode,
386c7c11689SGreg Kroah-Hartman struct dentry *parent, u8 *value) { }
3872ebefc50SRobin Getz
debugfs_create_x16(const char * name,umode_t mode,struct dentry * parent,u16 * value)388e40d38f2SGreg Kroah-Hartman static inline void debugfs_create_x16(const char *name, umode_t mode,
389e40d38f2SGreg Kroah-Hartman struct dentry *parent, u16 *value) { }
3902ebefc50SRobin Getz
debugfs_create_x32(const char * name,umode_t mode,struct dentry * parent,u32 * value)391f5cb0a7eSGreg Kroah-Hartman static inline void debugfs_create_x32(const char *name, umode_t mode,
392f5cb0a7eSGreg Kroah-Hartman struct dentry *parent, u32 *value) { }
3932ebefc50SRobin Getz
debugfs_create_x64(const char * name,umode_t mode,struct dentry * parent,u64 * value)3940864c408SGreg Kroah-Hartman static inline void debugfs_create_x64(const char *name, umode_t mode,
3950864c408SGreg Kroah-Hartman struct dentry *parent, u64 *value) { }
3963159269eSJohannes Berg
debugfs_create_size_t(const char * name,umode_t mode,struct dentry * parent,size_t * value)3978e580263SGreg Kroah-Hartman static inline void debugfs_create_size_t(const char *name, umode_t mode,
3988e580263SGreg Kroah-Hartman struct dentry *parent, size_t *value)
3998e580263SGreg Kroah-Hartman { }
4008adb711fSInaky Perez-Gonzalez
debugfs_create_atomic_t(const char * name,umode_t mode,struct dentry * parent,atomic_t * value)4019927c6faSGreg Kroah-Hartman static inline void debugfs_create_atomic_t(const char *name, umode_t mode,
4029927c6faSGreg Kroah-Hartman struct dentry *parent,
4039927c6faSGreg Kroah-Hartman atomic_t *value)
4049927c6faSGreg Kroah-Hartman { }
4055b880214SWeijie Yang
debugfs_create_bool(const char * name,umode_t mode,struct dentry * parent,bool * value)406393b0638SGreg Kroah-Hartman static inline void debugfs_create_bool(const char *name, umode_t mode,
407393b0638SGreg Kroah-Hartman struct dentry *parent, bool *value) { }
4081da177e4SLinus Torvalds
debugfs_create_str(const char * name,umode_t mode,struct dentry * parent,char ** value)4099af0440eSPeter Zijlstra static inline void debugfs_create_str(const char *name, umode_t mode,
4109af0440eSPeter Zijlstra struct dentry *parent,
4119af0440eSPeter Zijlstra char **value)
4129af0440eSPeter Zijlstra { }
4139af0440eSPeter Zijlstra
debugfs_create_blob(const char * name,umode_t mode,struct dentry * parent,struct debugfs_blob_wrapper * blob)414f4ae40a6SAl Viro static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
415dd308bc3SMichael Ellerman struct dentry *parent,
416dd308bc3SMichael Ellerman struct debugfs_blob_wrapper *blob)
417dd308bc3SMichael Ellerman {
418dd308bc3SMichael Ellerman return ERR_PTR(-ENODEV);
419dd308bc3SMichael Ellerman }
420dd308bc3SMichael Ellerman
debugfs_create_regset32(const char * name,umode_t mode,struct dentry * parent,struct debugfs_regset32 * regset)421ae91c925SGreg Kroah-Hartman static inline void debugfs_create_regset32(const char *name, umode_t mode,
422ae91c925SGreg Kroah-Hartman struct dentry *parent,
4231a087c6aSAlessandro Rubini struct debugfs_regset32 *regset)
4241a087c6aSAlessandro Rubini {
4251a087c6aSAlessandro Rubini }
4261a087c6aSAlessandro Rubini
debugfs_print_regs32(struct seq_file * s,const struct debugfs_reg32 * regs,int nregs,void __iomem * base,char * prefix)4279761536eSJoe Perches static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
4285b880214SWeijie Yang int nregs, void __iomem *base, char *prefix)
4295b880214SWeijie Yang {
4305b880214SWeijie Yang }
4315b880214SWeijie Yang
debugfs_initialized(void)432c0f92ba9SFrederic Weisbecker static inline bool debugfs_initialized(void)
433c0f92ba9SFrederic Weisbecker {
434c0f92ba9SFrederic Weisbecker return false;
435c0f92ba9SFrederic Weisbecker }
436c0f92ba9SFrederic Weisbecker
debugfs_create_u32_array(const char * name,umode_t mode,struct dentry * parent,struct debugfs_u32_array * array)437c9c2c27dSGreg Kroah-Hartman static inline void debugfs_create_u32_array(const char *name, umode_t mode,
438a2b992c8SJakub Kicinski struct dentry *parent,
439a2b992c8SJakub Kicinski struct debugfs_u32_array *array)
4409fe2a701SSrivatsa Vaddagiri {
4419fe2a701SSrivatsa Vaddagiri }
4429fe2a701SSrivatsa Vaddagiri
debugfs_create_devm_seqfile(struct device * dev,const char * name,struct dentry * parent,int (* read_fn)(struct seq_file * s,void * data))4430d519cbfSGreg Kroah-Hartman static inline void debugfs_create_devm_seqfile(struct device *dev,
44498210b7fSArend van Spriel const char *name,
44598210b7fSArend van Spriel struct dentry *parent,
44698210b7fSArend van Spriel int (*read_fn)(struct seq_file *s,
44798210b7fSArend van Spriel void *data))
44898210b7fSArend van Spriel {
44998210b7fSArend van Spriel }
45098210b7fSArend van Spriel
debugfs_read_file_bool(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)4510642ef6fSRichard Fitzgerald static inline ssize_t debugfs_read_file_bool(struct file *file,
4520642ef6fSRichard Fitzgerald char __user *user_buf,
4530642ef6fSRichard Fitzgerald size_t count, loff_t *ppos)
4540642ef6fSRichard Fitzgerald {
4550642ef6fSRichard Fitzgerald return -ENODEV;
4560642ef6fSRichard Fitzgerald }
4570642ef6fSRichard Fitzgerald
debugfs_write_file_bool(struct file * file,const char __user * user_buf,size_t count,loff_t * ppos)4580642ef6fSRichard Fitzgerald static inline ssize_t debugfs_write_file_bool(struct file *file,
4590642ef6fSRichard Fitzgerald const char __user *user_buf,
4600642ef6fSRichard Fitzgerald size_t count, loff_t *ppos)
4610642ef6fSRichard Fitzgerald {
4620642ef6fSRichard Fitzgerald return -ENODEV;
4630642ef6fSRichard Fitzgerald }
4640642ef6fSRichard Fitzgerald
debugfs_read_file_str(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)4659af0440eSPeter Zijlstra static inline ssize_t debugfs_read_file_str(struct file *file,
4669af0440eSPeter Zijlstra char __user *user_buf,
4679af0440eSPeter Zijlstra size_t count, loff_t *ppos)
4689af0440eSPeter Zijlstra {
4699af0440eSPeter Zijlstra return -ENODEV;
4709af0440eSPeter Zijlstra }
4719af0440eSPeter Zijlstra
4721da177e4SLinus Torvalds #endif
4731da177e4SLinus Torvalds
47412c92098SAl Viro #define debugfs_create_file_aux_num(name, mode, parent, data, n, fops) \
47512c92098SAl Viro debugfs_create_file_aux(name, mode, parent, data, \
47612c92098SAl Viro (void *)(unsigned long)n, fops)
47712c92098SAl Viro #define debugfs_get_aux_num(f) (unsigned long)debugfs_get_aux(f)
47812c92098SAl Viro
479d3504757SGeert Uytterhoeven /**
480d3504757SGeert Uytterhoeven * debugfs_create_xul - create a debugfs file that is used to read and write an
481d3504757SGeert Uytterhoeven * unsigned long value, formatted in hexadecimal
482d3504757SGeert Uytterhoeven * @name: a pointer to a string containing the name of the file to create.
483d3504757SGeert Uytterhoeven * @mode: the permission that the file should have
484d3504757SGeert Uytterhoeven * @parent: a pointer to the parent dentry for this file. This should be a
485d3504757SGeert Uytterhoeven * directory dentry if set. If this parameter is %NULL, then the
486d3504757SGeert Uytterhoeven * file will be created in the root of the debugfs filesystem.
487d3504757SGeert Uytterhoeven * @value: a pointer to the variable that the file should read to and write
488d3504757SGeert Uytterhoeven * from.
489d3504757SGeert Uytterhoeven */
debugfs_create_xul(const char * name,umode_t mode,struct dentry * parent,unsigned long * value)490d3504757SGeert Uytterhoeven static inline void debugfs_create_xul(const char *name, umode_t mode,
491d3504757SGeert Uytterhoeven struct dentry *parent,
492d3504757SGeert Uytterhoeven unsigned long *value)
493d3504757SGeert Uytterhoeven {
494d3504757SGeert Uytterhoeven if (sizeof(*value) == sizeof(u32))
495d3504757SGeert Uytterhoeven debugfs_create_x32(name, mode, parent, (u32 *)value);
496d3504757SGeert Uytterhoeven else
497d3504757SGeert Uytterhoeven debugfs_create_x64(name, mode, parent, (u64 *)value);
498d3504757SGeert Uytterhoeven }
499d3504757SGeert Uytterhoeven
5001da177e4SLinus Torvalds #endif
501