For readability and to save space, we won't show the error handling code sections here.
Just as in the example with procfs, we must allocate and initialize an instance of our "driver context" data structure (we haven't shown the code here as it's repetitive, so please refer to the GitHub source).
Then, via the generic debugfs_create_file() API, we must create a debugfs file, associating it with a file_operations structure. This, in effects, gets just a read callback registered:
static const struct file_operations dbgfs_drvctx_fops = {
.read = dbgfs_show_drvctx,
};
[...]
// < ... init function ... >
/* Generic debugfs file + passing a pointer to a data structure as a
* demo.. the 4th param is a generic void * ptr; it's contents will be
* stored into the i_private field of the file's inode.
*/
#define DBGFS_FILE1 "llkd_dbgfs_show_drvctx"
file1 = debugfs_create_file(DBGFS_FILE1...