aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2005-06-22 21:26:47 -0400
committerSteve French <sfrench@us.ibm.com>2005-06-22 21:26:47 -0400
commitea0daab4ae4a2f853f06c76961c0ed324fd0804c (patch)
treef6fbe2db5772695181b7a7257b05e43343bd8d75 /fs/debugfs
parent58aab753de605c14b9878a897e7349c3063afeff (diff)
parent1bdf7a78c2b21fb94dfe7994dbe89310b18479d2 (diff)
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git
Diffstat (limited to 'fs/debugfs')
-rw-r--r--fs/debugfs/file.c67
1 files changed, 29 insertions, 38 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 548556ff2506..efc97d9b7860 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -45,44 +45,15 @@ struct file_operations debugfs_file_operations = {
45 .open = default_open, 45 .open = default_open,
46}; 46};
47 47
48#define simple_type(type, format, temptype, strtolfn) \ 48static void debugfs_u8_set(void *data, u64 val)
49static ssize_t read_file_##type(struct file *file, char __user *user_buf, \ 49{
50 size_t count, loff_t *ppos) \ 50 *(u8 *)data = val;
51{ \ 51}
52 char buf[32]; \ 52static u64 debugfs_u8_get(void *data)
53 type *val = file->private_data; \ 53{
54 \ 54 return *(u8 *)data;
55 snprintf(buf, sizeof(buf), format "\n", *val); \ 55}
56 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));\ 56DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
57} \
58static ssize_t write_file_##type(struct file *file, const char __user *user_buf,\
59 size_t count, loff_t *ppos) \
60{ \
61 char *endp; \
62 char buf[32]; \
63 int buf_size; \
64 type *val = file->private_data; \
65 temptype tmp; \
66 \
67 memset(buf, 0x00, sizeof(buf)); \
68 buf_size = min(count, (sizeof(buf)-1)); \
69 if (copy_from_user(buf, user_buf, buf_size)) \
70 return -EFAULT; \
71 \
72 tmp = strtolfn(buf, &endp, 0); \
73 if ((endp == buf) || ((type)tmp != tmp)) \
74 return -EINVAL; \
75 *val = tmp; \
76 return count; \
77} \
78static struct file_operations fops_##type = { \
79 .read = read_file_##type, \
80 .write = write_file_##type, \
81 .open = default_open, \
82};
83simple_type(u8, "%c", unsigned long, simple_strtoul);
84simple_type(u16, "%hi", unsigned long, simple_strtoul);
85simple_type(u32, "%i", unsigned long, simple_strtoul);
86 57
87/** 58/**
88 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 59 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
@@ -116,6 +87,16 @@ struct dentry *debugfs_create_u8(const char *name, mode_t mode,
116} 87}
117EXPORT_SYMBOL_GPL(debugfs_create_u8); 88EXPORT_SYMBOL_GPL(debugfs_create_u8);
118 89
90static void debugfs_u16_set(void *data, u64 val)
91{
92 *(u16 *)data = val;
93}
94static u64 debugfs_u16_get(void *data)
95{
96 return *(u16 *)data;
97}
98DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
99
119/** 100/**
120 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 101 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
121 * 102 *
@@ -148,6 +129,16 @@ struct dentry *debugfs_create_u16(const char *name, mode_t mode,
148} 129}
149EXPORT_SYMBOL_GPL(debugfs_create_u16); 130EXPORT_SYMBOL_GPL(debugfs_create_u16);
150 131
132static void debugfs_u32_set(void *data, u64 val)
133{
134 *(u32 *)data = val;
135}
136static u64 debugfs_u32_get(void *data)
137{
138 return *(u32 *)data;
139}
140DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
141
151/** 142/**
152 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 143 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
153 * 144 *