diff options
author | Christoph Hellwig <hch@lst.de> | 2018-04-15 04:27:22 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:24:30 -0400 |
commit | a9170e0a923553cc12c3b00d816834316ebf226b (patch) | |
tree | 4676e2feac88677bccd8610247a9b23707017bcb | |
parent | 1cd6718272903c72f36ac23a7e72ed4cebf1f8e8 (diff) |
bluetooth: switch to proc_create_seq_data
And use proc private data directly instead of doing a detour
through seq->private and private state.
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 84d92a077834..3264e1873219 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -605,15 +605,10 @@ int bt_sock_wait_ready(struct sock *sk, unsigned long flags) | |||
605 | EXPORT_SYMBOL(bt_sock_wait_ready); | 605 | EXPORT_SYMBOL(bt_sock_wait_ready); |
606 | 606 | ||
607 | #ifdef CONFIG_PROC_FS | 607 | #ifdef CONFIG_PROC_FS |
608 | struct bt_seq_state { | ||
609 | struct bt_sock_list *l; | ||
610 | }; | ||
611 | |||
612 | static void *bt_seq_start(struct seq_file *seq, loff_t *pos) | 608 | static void *bt_seq_start(struct seq_file *seq, loff_t *pos) |
613 | __acquires(seq->private->l->lock) | 609 | __acquires(seq->private->l->lock) |
614 | { | 610 | { |
615 | struct bt_seq_state *s = seq->private; | 611 | struct bt_sock_list *l = PDE_DATA(file_inode(seq->file)); |
616 | struct bt_sock_list *l = s->l; | ||
617 | 612 | ||
618 | read_lock(&l->lock); | 613 | read_lock(&l->lock); |
619 | return seq_hlist_start_head(&l->head, *pos); | 614 | return seq_hlist_start_head(&l->head, *pos); |
@@ -621,8 +616,7 @@ static void *bt_seq_start(struct seq_file *seq, loff_t *pos) | |||
621 | 616 | ||
622 | static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 617 | static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
623 | { | 618 | { |
624 | struct bt_seq_state *s = seq->private; | 619 | struct bt_sock_list *l = PDE_DATA(file_inode(seq->file)); |
625 | struct bt_sock_list *l = s->l; | ||
626 | 620 | ||
627 | return seq_hlist_next(v, &l->head, pos); | 621 | return seq_hlist_next(v, &l->head, pos); |
628 | } | 622 | } |
@@ -630,16 +624,14 @@ static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
630 | static void bt_seq_stop(struct seq_file *seq, void *v) | 624 | static void bt_seq_stop(struct seq_file *seq, void *v) |
631 | __releases(seq->private->l->lock) | 625 | __releases(seq->private->l->lock) |
632 | { | 626 | { |
633 | struct bt_seq_state *s = seq->private; | 627 | struct bt_sock_list *l = PDE_DATA(file_inode(seq->file)); |
634 | struct bt_sock_list *l = s->l; | ||
635 | 628 | ||
636 | read_unlock(&l->lock); | 629 | read_unlock(&l->lock); |
637 | } | 630 | } |
638 | 631 | ||
639 | static int bt_seq_show(struct seq_file *seq, void *v) | 632 | static int bt_seq_show(struct seq_file *seq, void *v) |
640 | { | 633 | { |
641 | struct bt_seq_state *s = seq->private; | 634 | struct bt_sock_list *l = PDE_DATA(file_inode(seq->file)); |
642 | struct bt_sock_list *l = s->l; | ||
643 | 635 | ||
644 | if (v == SEQ_START_TOKEN) { | 636 | if (v == SEQ_START_TOKEN) { |
645 | seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Parent"); | 637 | seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Parent"); |
@@ -681,35 +673,13 @@ static const struct seq_operations bt_seq_ops = { | |||
681 | .show = bt_seq_show, | 673 | .show = bt_seq_show, |
682 | }; | 674 | }; |
683 | 675 | ||
684 | static int bt_seq_open(struct inode *inode, struct file *file) | ||
685 | { | ||
686 | struct bt_sock_list *sk_list; | ||
687 | struct bt_seq_state *s; | ||
688 | |||
689 | sk_list = PDE_DATA(inode); | ||
690 | s = __seq_open_private(file, &bt_seq_ops, | ||
691 | sizeof(struct bt_seq_state)); | ||
692 | if (!s) | ||
693 | return -ENOMEM; | ||
694 | |||
695 | s->l = sk_list; | ||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | static const struct file_operations bt_fops = { | ||
700 | .open = bt_seq_open, | ||
701 | .read = seq_read, | ||
702 | .llseek = seq_lseek, | ||
703 | .release = seq_release_private | ||
704 | }; | ||
705 | |||
706 | int bt_procfs_init(struct net *net, const char *name, | 676 | int bt_procfs_init(struct net *net, const char *name, |
707 | struct bt_sock_list *sk_list, | 677 | struct bt_sock_list *sk_list, |
708 | int (* seq_show)(struct seq_file *, void *)) | 678 | int (* seq_show)(struct seq_file *, void *)) |
709 | { | 679 | { |
710 | sk_list->custom_seq_show = seq_show; | 680 | sk_list->custom_seq_show = seq_show; |
711 | 681 | ||
712 | if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list)) | 682 | if (!proc_create_seq_data(name, 0, net->proc_net, &bt_seq_ops, sk_list)) |
713 | return -ENOMEM; | 683 | return -ENOMEM; |
714 | return 0; | 684 | return 0; |
715 | } | 685 | } |