diff options
| author | Christoph Hellwig <hch@lst.de> | 2018-04-18 00:09:21 -0400 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:24:30 -0400 |
| commit | a2d03aac5197e708711c65718fbcadc91b5b0b06 (patch) | |
| tree | d90805f12625b872cac79dc934b9e72eba638647 /net/atm | |
| parent | ce9fe43875d758c89f222d6b704bf63758f57635 (diff) | |
atm: switch to proc_create_seq_private
And remove proc boilerplate code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'net/atm')
| -rw-r--r-- | net/atm/proc.c | 72 |
1 files changed, 13 insertions, 59 deletions
diff --git a/net/atm/proc.c b/net/atm/proc.c index f272b0f59d82..0b0495a41bbe 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c | |||
| @@ -68,7 +68,6 @@ static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) | |||
| 68 | struct vcc_state { | 68 | struct vcc_state { |
| 69 | int bucket; | 69 | int bucket; |
| 70 | struct sock *sk; | 70 | struct sock *sk; |
| 71 | int family; | ||
| 72 | }; | 71 | }; |
| 73 | 72 | ||
| 74 | static inline int compare_family(struct sock *sk, int family) | 73 | static inline int compare_family(struct sock *sk, int family) |
| @@ -106,23 +105,13 @@ out: | |||
| 106 | return (l < 0); | 105 | return (l < 0); |
| 107 | } | 106 | } |
| 108 | 107 | ||
| 109 | static inline void *vcc_walk(struct vcc_state *state, loff_t l) | 108 | static inline void *vcc_walk(struct seq_file *seq, loff_t l) |
| 110 | { | 109 | { |
| 111 | return __vcc_walk(&state->sk, state->family, &state->bucket, l) ? | 110 | struct vcc_state *state = seq->private; |
| 112 | state : NULL; | 111 | int family = (uintptr_t)(PDE_DATA(file_inode(seq->file))); |
| 113 | } | ||
| 114 | |||
| 115 | static int __vcc_seq_open(struct inode *inode, struct file *file, | ||
| 116 | int family, const struct seq_operations *ops) | ||
| 117 | { | ||
| 118 | struct vcc_state *state; | ||
| 119 | |||
| 120 | state = __seq_open_private(file, ops, sizeof(*state)); | ||
| 121 | if (state == NULL) | ||
| 122 | return -ENOMEM; | ||
| 123 | 112 | ||
| 124 | state->family = family; | 113 | return __vcc_walk(&state->sk, family, &state->bucket, l) ? |
| 125 | return 0; | 114 | state : NULL; |
| 126 | } | 115 | } |
| 127 | 116 | ||
| 128 | static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) | 117 | static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) |
| @@ -133,7 +122,7 @@ static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) | |||
| 133 | 122 | ||
| 134 | read_lock(&vcc_sklist_lock); | 123 | read_lock(&vcc_sklist_lock); |
| 135 | state->sk = SEQ_START_TOKEN; | 124 | state->sk = SEQ_START_TOKEN; |
| 136 | return left ? vcc_walk(state, left) : SEQ_START_TOKEN; | 125 | return left ? vcc_walk(seq, left) : SEQ_START_TOKEN; |
| 137 | } | 126 | } |
| 138 | 127 | ||
| 139 | static void vcc_seq_stop(struct seq_file *seq, void *v) | 128 | static void vcc_seq_stop(struct seq_file *seq, void *v) |
| @@ -144,9 +133,7 @@ static void vcc_seq_stop(struct seq_file *seq, void *v) | |||
| 144 | 133 | ||
| 145 | static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 134 | static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 146 | { | 135 | { |
| 147 | struct vcc_state *state = seq->private; | 136 | v = vcc_walk(seq, 1); |
| 148 | |||
| 149 | v = vcc_walk(state, 1); | ||
| 150 | *pos += !!PTR_ERR(v); | 137 | *pos += !!PTR_ERR(v); |
| 151 | return v; | 138 | return v; |
| 152 | } | 139 | } |
| @@ -280,18 +267,6 @@ static const struct seq_operations pvc_seq_ops = { | |||
| 280 | .show = pvc_seq_show, | 267 | .show = pvc_seq_show, |
| 281 | }; | 268 | }; |
| 282 | 269 | ||
| 283 | static int pvc_seq_open(struct inode *inode, struct file *file) | ||
| 284 | { | ||
| 285 | return __vcc_seq_open(inode, file, PF_ATMPVC, &pvc_seq_ops); | ||
| 286 | } | ||
| 287 | |||
| 288 | static const struct file_operations pvc_seq_fops = { | ||
| 289 | .open = pvc_seq_open, | ||
| 290 | .read = seq_read, | ||
| 291 | .llseek = seq_lseek, | ||
| 292 | .release = seq_release_private, | ||
| 293 | }; | ||
| 294 | |||
| 295 | static int vcc_seq_show(struct seq_file *seq, void *v) | 270 | static int vcc_seq_show(struct seq_file *seq, void *v) |
| 296 | { | 271 | { |
| 297 | if (v == SEQ_START_TOKEN) { | 272 | if (v == SEQ_START_TOKEN) { |
| @@ -314,18 +289,6 @@ static const struct seq_operations vcc_seq_ops = { | |||
| 314 | .show = vcc_seq_show, | 289 | .show = vcc_seq_show, |
| 315 | }; | 290 | }; |
| 316 | 291 | ||
| 317 | static int vcc_seq_open(struct inode *inode, struct file *file) | ||
| 318 | { | ||
| 319 | return __vcc_seq_open(inode, file, 0, &vcc_seq_ops); | ||
| 320 | } | ||
| 321 | |||
| 322 | static const struct file_operations vcc_seq_fops = { | ||
| 323 | .open = vcc_seq_open, | ||
| 324 | .read = seq_read, | ||
| 325 | .llseek = seq_lseek, | ||
| 326 | .release = seq_release_private, | ||
| 327 | }; | ||
| 328 | |||
| 329 | static int svc_seq_show(struct seq_file *seq, void *v) | 292 | static int svc_seq_show(struct seq_file *seq, void *v) |
| 330 | { | 293 | { |
| 331 | static const char atm_svc_banner[] = | 294 | static const char atm_svc_banner[] = |
| @@ -349,18 +312,6 @@ static const struct seq_operations svc_seq_ops = { | |||
| 349 | .show = svc_seq_show, | 312 | .show = svc_seq_show, |
| 350 | }; | 313 | }; |
| 351 | 314 | ||
| 352 | static int svc_seq_open(struct inode *inode, struct file *file) | ||
| 353 | { | ||
| 354 | return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops); | ||
| 355 | } | ||
| 356 | |||
| 357 | static const struct file_operations svc_seq_fops = { | ||
| 358 | .open = svc_seq_open, | ||
| 359 | .read = seq_read, | ||
| 360 | .llseek = seq_lseek, | ||
| 361 | .release = seq_release_private, | ||
| 362 | }; | ||
| 363 | |||
| 364 | static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, | 315 | static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, |
| 365 | size_t count, loff_t *pos) | 316 | size_t count, loff_t *pos) |
| 366 | { | 317 | { |
| @@ -434,9 +385,12 @@ int __init atm_proc_init(void) | |||
| 434 | if (!atm_proc_root) | 385 | if (!atm_proc_root) |
| 435 | return -ENOMEM; | 386 | return -ENOMEM; |
| 436 | proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops); | 387 | proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops); |
| 437 | proc_create("pvc", 0444, atm_proc_root, &pvc_seq_fops); | 388 | proc_create_seq_private("pvc", 0444, atm_proc_root, &pvc_seq_ops, |
| 438 | proc_create("svc", 0444, atm_proc_root, &svc_seq_fops); | 389 | sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMPVC); |
| 439 | proc_create("vc", 0444, atm_proc_root, &vcc_seq_fops); | 390 | proc_create_seq_private("svc", 0444, atm_proc_root, &svc_seq_ops, |
| 391 | sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMSVC); | ||
| 392 | proc_create_seq_private("vc", 0444, atm_proc_root, &vcc_seq_ops, | ||
| 393 | sizeof(struct vcc_state), NULL); | ||
| 440 | return 0; | 394 | return 0; |
| 441 | } | 395 | } |
| 442 | 396 | ||
