One generally mounts the debugfs as follows:
sudo mount -t debugfs debug /sys/kernel/debug
and then drivers populate this mount point according to their own whim.
To use debugfs in your drivers start with:
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
name being the name of the directory you want to create, and parent typically is NULL (causing the directory to be created in debugfs root).
There are some helper functions to allow one to read/write values as follows:
struct dentry *debugfs_create_u8(const char *name, mode_t mode, struct dentry *parent, u8 *value);The above functions create debugfs files that can be read/written to modify the u8,u16,u32 and bool values.
struct dentry *debugfs_create_u16(const char *name, mode_t mode, struct dentry *parent, u16 *value);
struct dentry *debugfs_create_u32(const char *name, mode_t mode, struct dentry *parent, u32 *value);
struct dentry *debugfs_create_bool(const char *name, mode_t mode, struct dentry *parent, u32 *value);
Debugfs does not tidy up these files when a module is removed, so one has to do this for each file using:
void debugfs_remove(struct dentry *dentry);It's quite a handy little interface, and can be replace printk()'s as a debug interface. As I said earlier in this article, I've used it now for tweaking and twiddling values in the rt73usb WiFi driver with success.