From: Jim C. <jim...@gm...> - 2012-05-15 07:51:41
|
Signed-off-by: Jim Cromie <jim...@gm...> --- debugfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/debugfs.c b/debugfs.c index 10fff7f..8ecaf32 100644 --- a/debugfs.c +++ b/debugfs.c @@ -33,6 +33,9 @@ void acx_debugfs_remove_adev(struct acx_device *adev) { return 0; } * match/strcmp against the callback. The acx_device *ptr is * retrieved from the file's parent's private data, and passed to the * callback so it knows what vif to print data for. + * + * Similarly, a singe write handler retrieves the acx_device_t pointer + * and file-index, and dispatches to the file handler for that index. */ enum file_index { @@ -83,6 +86,7 @@ static int acx_dbgfs_open(struct inode *inode, struct file *file) static int acx_dbgfs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { + /* retrieve file-index and adev from private fields */ int fidx = (int) file->f_path.dentry->d_inode->i_private; struct acx_device *adev = (struct acx_device *) file->f_path.dentry->d_parent->d_inode->i_private; @@ -130,7 +134,8 @@ int acx_debugfs_add_adev(struct acx_device *adev) pr_err("debugfs_create_dir() failed\n"); return -ENOMEM; } - pr_info("adev:%p nm:%s dirp:%p\n", adev, devname, acx_dbgfs_devdir); + pr_info("adev:%p nm:%s dirp:%p\n", adev, devname, + acx_dbgfs_devdir); if (acx_dbgfs_devdir->d_inode->i_private) { /* this shouldnt happen */ @@ -138,12 +143,14 @@ int acx_debugfs_add_adev(struct acx_device *adev) acx_dbgfs_devdir->d_inode->i_private); goto fail; } + /* save adev in dir's private field */ acx_dbgfs_devdir->d_inode->i_private = (void*) adev; for (i = 0; i < ARRAY_SIZE(dbgfs_files); i++) { fmode = (acx_proc_write_funcs[i]) ? 0644 : 0444; + /* save file-index in in file's private field */ file = debugfs_create_file(dbgfs_files[i], fmode, acx_dbgfs_devdir, (void*) i, &acx_fops); -- 1.7.10.1.487.ga3935e6 |