aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2011-07-26 19:09:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:46 -0400
commit8307fc257cf3931d87e172bd8663e80c3d1e56a3 (patch)
tree4f265586a0617284be4baec5b5d6990cdea13b31 /lib
parent6b16f748a0d4546726bb53cad58525adfd6425e9 (diff)
fault-injection: cleanup simple attribute of stacktrace_depth
Minor cosmetic changes for simple attribute of stacktrace_depth: - use min_t() - reduce #ifdef by moving a function - do not use partly capitalized function name Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/fault-inject.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index e6430e1ce180..882fd3b6a6ad 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -139,16 +139,6 @@ static int debugfs_ul_set(void *data, u64 val)
139 return 0; 139 return 0;
140} 140}
141 141
142#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
143static int debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val)
144{
145 *(unsigned long *)data =
146 val < MAX_STACK_TRACE_DEPTH ?
147 val : MAX_STACK_TRACE_DEPTH;
148 return 0;
149}
150#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
151
152static int debugfs_ul_get(void *data, u64 *val) 142static int debugfs_ul_get(void *data, u64 *val)
153{ 143{
154 *val = *(unsigned long *)data; 144 *val = *(unsigned long *)data;
@@ -164,16 +154,26 @@ static struct dentry *debugfs_create_ul(const char *name, mode_t mode,
164} 154}
165 155
166#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER 156#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
167DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get,
168 debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n");
169 157
170static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH( 158static int debugfs_stacktrace_depth_set(void *data, u64 val)
159{
160 *(unsigned long *)data =
161 min_t(unsigned long, val, MAX_STACK_TRACE_DEPTH);
162
163 return 0;
164}
165
166DEFINE_SIMPLE_ATTRIBUTE(fops_stacktrace_depth, debugfs_ul_get,
167 debugfs_stacktrace_depth_set, "%llu\n");
168
169static struct dentry *debugfs_create_stacktrace_depth(
171 const char *name, mode_t mode, 170 const char *name, mode_t mode,
172 struct dentry *parent, unsigned long *value) 171 struct dentry *parent, unsigned long *value)
173{ 172{
174 return debugfs_create_file(name, mode, parent, value, 173 return debugfs_create_file(name, mode, parent, value,
175 &fops_ul_MAX_STACK_TRACE_DEPTH); 174 &fops_stacktrace_depth);
176} 175}
176
177#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ 177#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
178 178
179static int debugfs_atomic_t_set(void *data, u64 val) 179static int debugfs_atomic_t_set(void *data, u64 val)
@@ -281,7 +281,7 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
281#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER 281#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
282 282
283 attr->dentries.stacktrace_depth_file = 283 attr->dentries.stacktrace_depth_file =
284 debugfs_create_ul_MAX_STACK_TRACE_DEPTH( 284 debugfs_create_stacktrace_depth(
285 "stacktrace-depth", mode, dir, &attr->stacktrace_depth); 285 "stacktrace-depth", mode, dir, &attr->stacktrace_depth);
286 286
287 attr->dentries.require_start_file = 287 attr->dentries.require_start_file =