spmi: Add API to create controller specific debugfs files
Add API function 'spmi_dfs_create_file' for SPMI controller drivers to create their own implementation specific files under the SPMI debugfs directory. Change-Id: Ib4d0557333371a2a29b6dc6ae6ca6a41ebf13c34 Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
This commit is contained in:
parent
50a1e06c93
commit
ea9edaf5b0
|
@ -36,6 +36,7 @@
|
|||
#include <linux/debugfs.h>
|
||||
#include <linux/spmi.h>
|
||||
#include <linux/ctype.h>
|
||||
#include "spmi-dbgfs.h"
|
||||
|
||||
#define ADDR_LEN 6 /* 5 byte address + 1 space character */
|
||||
#define CHARS_PER_ITEM 3 /* Format is 'XX ' */
|
||||
|
@ -58,6 +59,7 @@ struct spmi_log_buffer {
|
|||
struct spmi_ctrl_data {
|
||||
u32 cnt;
|
||||
u32 addr;
|
||||
struct dentry *dir;
|
||||
struct list_head node;
|
||||
struct spmi_controller *ctrl;
|
||||
};
|
||||
|
@ -655,6 +657,7 @@ int spmi_dfs_add_controller(struct spmi_controller *ctrl)
|
|||
}
|
||||
|
||||
ctrl_data->cnt = 1;
|
||||
ctrl_data->dir = dir;
|
||||
ctrl_data->ctrl = ctrl;
|
||||
|
||||
file = debugfs_create_u32("count", DFS_MODE, dir, &ctrl_data->cnt);
|
||||
|
@ -693,6 +696,25 @@ err_create_dir_failed:
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* spmi_dfs_create_file: creates a new file in the SPMI debugfs
|
||||
* @returns valid dentry pointer on success or NULL
|
||||
*/
|
||||
struct dentry *spmi_dfs_create_file(struct spmi_controller *ctrl,
|
||||
const char *name, void *data,
|
||||
const struct file_operations *fops)
|
||||
{
|
||||
struct spmi_ctrl_data *ctrl_data;
|
||||
|
||||
list_for_each_entry(ctrl_data, &dbgfs_data.ctrl, node) {
|
||||
if (ctrl_data->ctrl == ctrl)
|
||||
return debugfs_create_file(name,
|
||||
DFS_MODE, ctrl_data->dir, data, fops);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void __exit spmi_dfs_delete_all_ctrl(struct list_head *head)
|
||||
{
|
||||
struct list_head *pos, *tmp;
|
||||
|
|
|
@ -12,10 +12,16 @@
|
|||
#ifndef _SPMI_DBGFS_H
|
||||
#define _SPMI_DBGFS_H
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
int spmi_dfs_add_controller(struct spmi_controller *ctrl);
|
||||
#else
|
||||
int spmi_dfs_add_controller(struct spmi_controller *ctrl) { return 0; }
|
||||
static int spmi_dfs_add_controller(struct spmi_controller *ctrl) { return 0; }
|
||||
#endif
|
||||
|
||||
struct dentry *spmi_dfs_create_file(struct spmi_controller *ctrl,
|
||||
const char *name, void *data,
|
||||
const struct file_operations *fops);
|
||||
|
||||
#endif /* _SPMI_DBGFS_H */
|
||||
|
|
Loading…
Reference in New Issue