xref: /linux-6.15/include/linux/debugfs.h (revision dec9b2f1)
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] 
487f847dd3SArnd Bergmann #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt)		\
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,					\
597f847dd3SArnd Bergmann 	.write	 = debugfs_attr_write,					\
60895ce6c8SGeliang Tang 	.llseek  = no_llseek,						\
617f847dd3SArnd Bergmann }
627f847dd3SArnd Bergmann 
634250b047SKusanagi Kouichi typedef struct vfsmount *(*debugfs_automount_t)(struct dentry *, void *);
644250b047SKusanagi Kouichi 
651da177e4SLinus Torvalds #if defined(CONFIG_DEBUG_FS)
663634634eSHarvey Harrison 
67a7c5437bSOmar Sandoval struct dentry *debugfs_lookup(const char *name, struct dentry *parent);
68a7c5437bSOmar Sandoval 
69f4ae40a6SAl Viro struct dentry *debugfs_create_file(const char *name, umode_t mode,
701da177e4SLinus Torvalds 				   struct dentry *parent, void *data,
7199ac48f5SArjan van de Ven 				   const struct file_operations *fops);
72c6468808SNicolai Stange struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
73c6468808SNicolai Stange 				   struct dentry *parent, void *data,
74c6468808SNicolai Stange 				   const struct file_operations *fops);
751da177e4SLinus Torvalds 
76526ee72dSGreg Kroah-Hartman void debugfs_create_file_size(const char *name, umode_t mode,
77e59b4e91SDavid Howells 			      struct dentry *parent, void *data,
78e59b4e91SDavid Howells 			      const struct file_operations *fops,
79e59b4e91SDavid Howells 			      loff_t file_size);
80e59b4e91SDavid Howells 
811da177e4SLinus Torvalds struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
821da177e4SLinus Torvalds 
8366f54963SPeter Oberparleiter struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
8466f54963SPeter Oberparleiter 				      const char *dest);
8566f54963SPeter Oberparleiter 
8677b3da6eSAl Viro struct dentry *debugfs_create_automount(const char *name,
8777b3da6eSAl Viro 					struct dentry *parent,
8893faccbbSEric W. Biederman 					debugfs_automount_t f,
8977b3da6eSAl Viro 					void *data);
9077b3da6eSAl Viro 
911da177e4SLinus Torvalds void debugfs_remove(struct dentry *dentry);
92a3d1e7ebSAl Viro #define debugfs_remove_recursive debugfs_remove
931da177e4SLinus Torvalds 
94*dec9b2f1SGreg Kroah-Hartman void debugfs_lookup_and_remove(const char *name, struct dentry *parent);
95*dec9b2f1SGreg Kroah-Hartman 
96055ab8e3SNicolai Stange const struct file_operations *debugfs_real_fops(const struct file *filp);
977c8d4698SNicolai Stange 
98e9117a5aSNicolai Stange int debugfs_file_get(struct dentry *dentry);
99e9117a5aSNicolai Stange void debugfs_file_put(struct dentry *dentry);
100e9117a5aSNicolai Stange 
101c6468808SNicolai Stange ssize_t debugfs_attr_read(struct file *file, char __user *buf,
102c6468808SNicolai Stange 			size_t len, loff_t *ppos);
103c6468808SNicolai Stange ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
104c6468808SNicolai Stange 			size_t len, loff_t *ppos);
105c6468808SNicolai Stange 
106cfc94cdfSJan Kara struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
107cfc94cdfSJan Kara                 struct dentry *new_dir, const char *new_name);
108cfc94cdfSJan Kara 
1099655ac4aSGreg Kroah-Hartman void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
1109655ac4aSGreg Kroah-Hartman 		       u8 *value);
111313f5dbbSGreg Kroah-Hartman void debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent,
112313f5dbbSGreg Kroah-Hartman 			u16 *value);
1132b07021aSGreg Kroah-Hartman void debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent,
1142b07021aSGreg Kroah-Hartman 			u32 *value);
115ad26221fSGreg Kroah-Hartman void debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent,
116ad26221fSGreg Kroah-Hartman 			u64 *value);
117fb05b14cSGreg Kroah-Hartman void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
118fb05b14cSGreg Kroah-Hartman 			  unsigned long *value);
119c7c11689SGreg Kroah-Hartman void debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent,
120c7c11689SGreg Kroah-Hartman 		       u8 *value);
121e40d38f2SGreg Kroah-Hartman void debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent,
122e40d38f2SGreg Kroah-Hartman 			u16 *value);
123f5cb0a7eSGreg Kroah-Hartman void debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent,
124f5cb0a7eSGreg Kroah-Hartman 			u32 *value);
1250864c408SGreg Kroah-Hartman void debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent,
1260864c408SGreg Kroah-Hartman 			u64 *value);
1278e580263SGreg Kroah-Hartman void debugfs_create_size_t(const char *name, umode_t mode,
1285e078787SInaky Perez-Gonzalez 			   struct dentry *parent, size_t *value);
1299927c6faSGreg Kroah-Hartman void debugfs_create_atomic_t(const char *name, umode_t mode,
1303a76e5e0SSeth Jennings 			     struct dentry *parent, atomic_t *value);
131393b0638SGreg Kroah-Hartman void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
132393b0638SGreg Kroah-Hartman 			 bool *value);
1339af0440eSPeter Zijlstra void debugfs_create_str(const char *name, umode_t mode,
1349af0440eSPeter Zijlstra 			struct dentry *parent, char **value);
1351da177e4SLinus Torvalds 
136f4ae40a6SAl Viro struct dentry *debugfs_create_blob(const char *name, umode_t mode,
137dd308bc3SMichael Ellerman 				  struct dentry *parent,
138dd308bc3SMichael Ellerman 				  struct debugfs_blob_wrapper *blob);
139c0f92ba9SFrederic Weisbecker 
140ae91c925SGreg Kroah-Hartman void debugfs_create_regset32(const char *name, umode_t mode,
1411a087c6aSAlessandro Rubini 			     struct dentry *parent,
1421a087c6aSAlessandro Rubini 			     struct debugfs_regset32 *regset);
1431a087c6aSAlessandro Rubini 
1449761536eSJoe Perches void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
1451a087c6aSAlessandro Rubini 			  int nregs, void __iomem *base, char *prefix);
1461a087c6aSAlessandro Rubini 
147c9c2c27dSGreg Kroah-Hartman void debugfs_create_u32_array(const char *name, umode_t mode,
148a2b992c8SJakub Kicinski 			      struct dentry *parent,
149a2b992c8SJakub Kicinski 			      struct debugfs_u32_array *array);
1509fe2a701SSrivatsa Vaddagiri 
1510d519cbfSGreg Kroah-Hartman void debugfs_create_devm_seqfile(struct device *dev, const char *name,
15298210b7fSArend van Spriel 				 struct dentry *parent,
1530d519cbfSGreg Kroah-Hartman 				 int (*read_fn)(struct seq_file *s, void *data));
15498210b7fSArend van Spriel 
155c0f92ba9SFrederic Weisbecker bool debugfs_initialized(void);
156c0f92ba9SFrederic Weisbecker 
1570642ef6fSRichard Fitzgerald ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
1580642ef6fSRichard Fitzgerald 			       size_t count, loff_t *ppos);
1590642ef6fSRichard Fitzgerald 
1600642ef6fSRichard Fitzgerald ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
1610642ef6fSRichard Fitzgerald 				size_t count, loff_t *ppos);
1620642ef6fSRichard Fitzgerald 
1639af0440eSPeter Zijlstra ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
1649af0440eSPeter Zijlstra 			      size_t count, loff_t *ppos);
1659af0440eSPeter Zijlstra 
1661da177e4SLinus Torvalds #else
167a7a76cefSRoland Dreier 
168a7a76cefSRoland Dreier #include <linux/err.h>
169a7a76cefSRoland Dreier 
1701da177e4SLinus Torvalds /*
1711da177e4SLinus Torvalds  * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
1721da177e4SLinus Torvalds  * so users have a chance to detect if there was a real error or not.  We don't
1731da177e4SLinus Torvalds  * want to duplicate the design decision mistakes of procfs and devfs again.
1741da177e4SLinus Torvalds  */
1751da177e4SLinus Torvalds 
176a7c5437bSOmar Sandoval static inline struct dentry *debugfs_lookup(const char *name,
177a7c5437bSOmar Sandoval 					    struct dentry *parent)
178a7c5437bSOmar Sandoval {
179a7c5437bSOmar Sandoval 	return ERR_PTR(-ENODEV);
180a7c5437bSOmar Sandoval }
181a7c5437bSOmar Sandoval 
182f4ae40a6SAl Viro static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
183bde11d79SJean Delvare 					struct dentry *parent, void *data,
184bde11d79SJean Delvare 					const struct file_operations *fops)
1851da177e4SLinus Torvalds {
1861da177e4SLinus Torvalds 	return ERR_PTR(-ENODEV);
1871da177e4SLinus Torvalds }
1881da177e4SLinus Torvalds 
189c2a737ebSViresh Kumar static inline struct dentry *debugfs_create_file_unsafe(const char *name,
190c2a737ebSViresh Kumar 					umode_t mode, struct dentry *parent,
191c2a737ebSViresh Kumar 					void *data,
192c2a737ebSViresh Kumar 					const struct file_operations *fops)
193c2a737ebSViresh Kumar {
194c2a737ebSViresh Kumar 	return ERR_PTR(-ENODEV);
195c2a737ebSViresh Kumar }
196c2a737ebSViresh Kumar 
197526ee72dSGreg Kroah-Hartman static inline void debugfs_create_file_size(const char *name, umode_t mode,
198e59b4e91SDavid Howells 					    struct dentry *parent, void *data,
199e59b4e91SDavid Howells 					    const struct file_operations *fops,
200e59b4e91SDavid Howells 					    loff_t file_size)
201526ee72dSGreg Kroah-Hartman { }
202e59b4e91SDavid Howells 
2031da177e4SLinus Torvalds static inline struct dentry *debugfs_create_dir(const char *name,
2041da177e4SLinus Torvalds 						struct dentry *parent)
2051da177e4SLinus Torvalds {
2061da177e4SLinus Torvalds 	return ERR_PTR(-ENODEV);
2071da177e4SLinus Torvalds }
2081da177e4SLinus Torvalds 
20966f54963SPeter Oberparleiter static inline struct dentry *debugfs_create_symlink(const char *name,
21066f54963SPeter Oberparleiter 						    struct dentry *parent,
21166f54963SPeter Oberparleiter 						    const char *dest)
21266f54963SPeter Oberparleiter {
21366f54963SPeter Oberparleiter 	return ERR_PTR(-ENODEV);
21466f54963SPeter Oberparleiter }
21566f54963SPeter Oberparleiter 
21694e1dec7SJiaxing Wang static inline struct dentry *debugfs_create_automount(const char *name,
21794e1dec7SJiaxing Wang 					struct dentry *parent,
2184250b047SKusanagi Kouichi 					debugfs_automount_t f,
21994e1dec7SJiaxing Wang 					void *data)
22094e1dec7SJiaxing Wang {
22194e1dec7SJiaxing Wang 	return ERR_PTR(-ENODEV);
22294e1dec7SJiaxing Wang }
22394e1dec7SJiaxing Wang 
2241da177e4SLinus Torvalds static inline void debugfs_remove(struct dentry *dentry)
2251da177e4SLinus Torvalds { }
2261da177e4SLinus Torvalds 
2279505e637SHaavard Skinnemoen static inline void debugfs_remove_recursive(struct dentry *dentry)
2289505e637SHaavard Skinnemoen { }
2299505e637SHaavard Skinnemoen 
230*dec9b2f1SGreg Kroah-Hartman static inline void debugfs_lookup_and_remove(const char *name,
231*dec9b2f1SGreg Kroah-Hartman 					     struct dentry *parent)
232*dec9b2f1SGreg Kroah-Hartman { }
233*dec9b2f1SGreg Kroah-Hartman 
234f50caa9bSArnd Bergmann const struct file_operations *debugfs_real_fops(const struct file *filp);
235f50caa9bSArnd Bergmann 
236e9117a5aSNicolai Stange static inline int debugfs_file_get(struct dentry *dentry)
237e9117a5aSNicolai Stange {
238e9117a5aSNicolai Stange 	return 0;
239e9117a5aSNicolai Stange }
240e9117a5aSNicolai Stange 
241e9117a5aSNicolai Stange static inline void debugfs_file_put(struct dentry *dentry)
242e9117a5aSNicolai Stange { }
243e9117a5aSNicolai Stange 
2447f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_read(struct file *file, char __user *buf,
2457f847dd3SArnd Bergmann 					size_t len, loff_t *ppos)
2467f847dd3SArnd Bergmann {
2477f847dd3SArnd Bergmann 	return -ENODEV;
2487f847dd3SArnd Bergmann }
2497f847dd3SArnd Bergmann 
2507f847dd3SArnd Bergmann static inline ssize_t debugfs_attr_write(struct file *file,
2517f847dd3SArnd Bergmann 					const char __user *buf,
2527f847dd3SArnd Bergmann 					size_t len, loff_t *ppos)
2537f847dd3SArnd Bergmann {
2547f847dd3SArnd Bergmann 	return -ENODEV;
2557f847dd3SArnd Bergmann }
256c6468808SNicolai Stange 
257cfc94cdfSJan Kara static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
258cfc94cdfSJan Kara                 struct dentry *new_dir, char *new_name)
259cfc94cdfSJan Kara {
260cfc94cdfSJan Kara 	return ERR_PTR(-ENODEV);
261cfc94cdfSJan Kara }
262cfc94cdfSJan Kara 
2639655ac4aSGreg Kroah-Hartman static inline void debugfs_create_u8(const char *name, umode_t mode,
2649655ac4aSGreg Kroah-Hartman 				     struct dentry *parent, u8 *value) { }
2651da177e4SLinus Torvalds 
266313f5dbbSGreg Kroah-Hartman static inline void debugfs_create_u16(const char *name, umode_t mode,
267313f5dbbSGreg Kroah-Hartman 				      struct dentry *parent, u16 *value) { }
2681da177e4SLinus Torvalds 
2692b07021aSGreg Kroah-Hartman static inline void debugfs_create_u32(const char *name, umode_t mode,
2702b07021aSGreg Kroah-Hartman 				      struct dentry *parent, u32 *value) { }
2711da177e4SLinus Torvalds 
272ad26221fSGreg Kroah-Hartman static inline void debugfs_create_u64(const char *name, umode_t mode,
273ad26221fSGreg Kroah-Hartman 				      struct dentry *parent, u64 *value) { }
2748447891fSMichael Ellerman 
275fb05b14cSGreg Kroah-Hartman static inline void debugfs_create_ulong(const char *name, umode_t mode,
276c2a737ebSViresh Kumar 					struct dentry *parent,
277fb05b14cSGreg Kroah-Hartman 					unsigned long *value) { }
278c2a737ebSViresh Kumar 
279c7c11689SGreg Kroah-Hartman static inline void debugfs_create_x8(const char *name, umode_t mode,
280c7c11689SGreg Kroah-Hartman 				     struct dentry *parent, u8 *value) { }
2812ebefc50SRobin Getz 
282e40d38f2SGreg Kroah-Hartman static inline void debugfs_create_x16(const char *name, umode_t mode,
283e40d38f2SGreg Kroah-Hartman 				      struct dentry *parent, u16 *value) { }
2842ebefc50SRobin Getz 
285f5cb0a7eSGreg Kroah-Hartman static inline void debugfs_create_x32(const char *name, umode_t mode,
286f5cb0a7eSGreg Kroah-Hartman 				      struct dentry *parent, u32 *value) { }
2872ebefc50SRobin Getz 
2880864c408SGreg Kroah-Hartman static inline void debugfs_create_x64(const char *name, umode_t mode,
2890864c408SGreg Kroah-Hartman 				      struct dentry *parent, u64 *value) { }
2903159269eSJohannes Berg 
2918e580263SGreg Kroah-Hartman static inline void debugfs_create_size_t(const char *name, umode_t mode,
2928e580263SGreg Kroah-Hartman 					 struct dentry *parent, size_t *value)
2938e580263SGreg Kroah-Hartman { }
2948adb711fSInaky Perez-Gonzalez 
2959927c6faSGreg Kroah-Hartman static inline void debugfs_create_atomic_t(const char *name, umode_t mode,
2969927c6faSGreg Kroah-Hartman 					   struct dentry *parent,
2979927c6faSGreg Kroah-Hartman 					   atomic_t *value)
2989927c6faSGreg Kroah-Hartman { }
2995b880214SWeijie Yang 
300393b0638SGreg Kroah-Hartman static inline void debugfs_create_bool(const char *name, umode_t mode,
301393b0638SGreg Kroah-Hartman 				       struct dentry *parent, bool *value) { }
3021da177e4SLinus Torvalds 
3039af0440eSPeter Zijlstra static inline void debugfs_create_str(const char *name, umode_t mode,
3049af0440eSPeter Zijlstra 				      struct dentry *parent,
3059af0440eSPeter Zijlstra 				      char **value)
3069af0440eSPeter Zijlstra { }
3079af0440eSPeter Zijlstra 
308f4ae40a6SAl Viro static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
309dd308bc3SMichael Ellerman 				  struct dentry *parent,
310dd308bc3SMichael Ellerman 				  struct debugfs_blob_wrapper *blob)
311dd308bc3SMichael Ellerman {
312dd308bc3SMichael Ellerman 	return ERR_PTR(-ENODEV);
313dd308bc3SMichael Ellerman }
314dd308bc3SMichael Ellerman 
315ae91c925SGreg Kroah-Hartman static inline void debugfs_create_regset32(const char *name, umode_t mode,
316ae91c925SGreg Kroah-Hartman 					   struct dentry *parent,
3171a087c6aSAlessandro Rubini 					   struct debugfs_regset32 *regset)
3181a087c6aSAlessandro Rubini {
3191a087c6aSAlessandro Rubini }
3201a087c6aSAlessandro Rubini 
3219761536eSJoe Perches static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
3225b880214SWeijie Yang 			 int nregs, void __iomem *base, char *prefix)
3235b880214SWeijie Yang {
3245b880214SWeijie Yang }
3255b880214SWeijie Yang 
326c0f92ba9SFrederic Weisbecker static inline bool debugfs_initialized(void)
327c0f92ba9SFrederic Weisbecker {
328c0f92ba9SFrederic Weisbecker 	return false;
329c0f92ba9SFrederic Weisbecker }
330c0f92ba9SFrederic Weisbecker 
331c9c2c27dSGreg Kroah-Hartman static inline void debugfs_create_u32_array(const char *name, umode_t mode,
332a2b992c8SJakub Kicinski 					    struct dentry *parent,
333a2b992c8SJakub Kicinski 					    struct debugfs_u32_array *array)
3349fe2a701SSrivatsa Vaddagiri {
3359fe2a701SSrivatsa Vaddagiri }
3369fe2a701SSrivatsa Vaddagiri 
3370d519cbfSGreg Kroah-Hartman static inline void debugfs_create_devm_seqfile(struct device *dev,
33898210b7fSArend van Spriel 					       const char *name,
33998210b7fSArend van Spriel 					       struct dentry *parent,
34098210b7fSArend van Spriel 					       int (*read_fn)(struct seq_file *s,
34198210b7fSArend van Spriel 							      void *data))
34298210b7fSArend van Spriel {
34398210b7fSArend van Spriel }
34498210b7fSArend van Spriel 
3450642ef6fSRichard Fitzgerald static inline ssize_t debugfs_read_file_bool(struct file *file,
3460642ef6fSRichard Fitzgerald 					     char __user *user_buf,
3470642ef6fSRichard Fitzgerald 					     size_t count, loff_t *ppos)
3480642ef6fSRichard Fitzgerald {
3490642ef6fSRichard Fitzgerald 	return -ENODEV;
3500642ef6fSRichard Fitzgerald }
3510642ef6fSRichard Fitzgerald 
3520642ef6fSRichard Fitzgerald static inline ssize_t debugfs_write_file_bool(struct file *file,
3530642ef6fSRichard Fitzgerald 					      const char __user *user_buf,
3540642ef6fSRichard Fitzgerald 					      size_t count, loff_t *ppos)
3550642ef6fSRichard Fitzgerald {
3560642ef6fSRichard Fitzgerald 	return -ENODEV;
3570642ef6fSRichard Fitzgerald }
3580642ef6fSRichard Fitzgerald 
3599af0440eSPeter Zijlstra static inline ssize_t debugfs_read_file_str(struct file *file,
3609af0440eSPeter Zijlstra 					    char __user *user_buf,
3619af0440eSPeter Zijlstra 					    size_t count, loff_t *ppos)
3629af0440eSPeter Zijlstra {
3639af0440eSPeter Zijlstra 	return -ENODEV;
3649af0440eSPeter Zijlstra }
3659af0440eSPeter Zijlstra 
3661da177e4SLinus Torvalds #endif
3671da177e4SLinus Torvalds 
368d3504757SGeert Uytterhoeven /**
369d3504757SGeert Uytterhoeven  * debugfs_create_xul - create a debugfs file that is used to read and write an
370d3504757SGeert Uytterhoeven  * unsigned long value, formatted in hexadecimal
371d3504757SGeert Uytterhoeven  * @name: a pointer to a string containing the name of the file to create.
372d3504757SGeert Uytterhoeven  * @mode: the permission that the file should have
373d3504757SGeert Uytterhoeven  * @parent: a pointer to the parent dentry for this file.  This should be a
374d3504757SGeert Uytterhoeven  *          directory dentry if set.  If this parameter is %NULL, then the
375d3504757SGeert Uytterhoeven  *          file will be created in the root of the debugfs filesystem.
376d3504757SGeert Uytterhoeven  * @value: a pointer to the variable that the file should read to and write
377d3504757SGeert Uytterhoeven  *         from.
378d3504757SGeert Uytterhoeven  */
379d3504757SGeert Uytterhoeven static inline void debugfs_create_xul(const char *name, umode_t mode,
380d3504757SGeert Uytterhoeven 				      struct dentry *parent,
381d3504757SGeert Uytterhoeven 				      unsigned long *value)
382d3504757SGeert Uytterhoeven {
383d3504757SGeert Uytterhoeven 	if (sizeof(*value) == sizeof(u32))
384d3504757SGeert Uytterhoeven 		debugfs_create_x32(name, mode, parent, (u32 *)value);
385d3504757SGeert Uytterhoeven 	else
386d3504757SGeert Uytterhoeven 		debugfs_create_x64(name, mode, parent, (u64 *)value);
387d3504757SGeert Uytterhoeven }
388d3504757SGeert Uytterhoeven 
3891da177e4SLinus Torvalds #endif
390