Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/error-inject: convert to DEFINE_SEQ_ATTRIBUTE

Use DEFINE_SEQ_ATTRIBUTE helper macro to simplify the code.

Link: https://lkml.kernel.org/r/20220612052015.23283-1-wuchi.zero@gmail.com
Signed-off-by: wuchi <wuchi.zero@gmail.com>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

wuchi and committed by
akpm
00c9d563 f858e23a

+3 -13
+3 -13
lib/error-inject.c
··· 197 197 return 0; 198 198 } 199 199 200 - static const struct seq_operations ei_seq_ops = { 200 + static const struct seq_operations ei_sops = { 201 201 .start = ei_seq_start, 202 202 .next = ei_seq_next, 203 203 .stop = ei_seq_stop, 204 204 .show = ei_seq_show, 205 205 }; 206 206 207 - static int ei_open(struct inode *inode, struct file *filp) 208 - { 209 - return seq_open(filp, &ei_seq_ops); 210 - } 211 - 212 - static const struct file_operations debugfs_ei_ops = { 213 - .open = ei_open, 214 - .read = seq_read, 215 - .llseek = seq_lseek, 216 - .release = seq_release, 217 - }; 207 + DEFINE_SEQ_ATTRIBUTE(ei); 218 208 219 209 static int __init ei_debugfs_init(void) 220 210 { ··· 214 224 if (!dir) 215 225 return -ENOMEM; 216 226 217 - file = debugfs_create_file("list", 0444, dir, NULL, &debugfs_ei_ops); 227 + file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops); 218 228 if (!file) { 219 229 debugfs_remove(dir); 220 230 return -ENOMEM;