From d9dda78bad879595d8c4220a067fc029d6484a16 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 18:16:14 -0400 Subject: procfs: new helper - PDE_DATA(inode) The only part of proc_dir_entry the code outside of fs/proc really cares about is PDE(inode)->data. Provide a helper for that; static inline for now, eventually will be moved to fs/proc, along with the knowledge of struct proc_dir_entry layout. Signed-off-by: Al Viro --- net/bluetooth/af_bluetooth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/bluetooth/af_bluetooth.c') diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index d3ee69b35a7..82040e46b24 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -617,7 +617,7 @@ static int bt_seq_open(struct inode *inode, struct file *file) struct bt_sock_list *sk_list; struct bt_seq_state *s; - sk_list = PDE(inode)->data; + sk_list = PDE_DATA(inode); s = __seq_open_private(file, &bt_seq_ops, sizeof(struct bt_seq_state)); if (!s) -- cgit v1.2.3-18-g5258 From 14805359c790977199e0d74fe689c2c17e6a0954 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 4 Apr 2013 19:12:06 -0400 Subject: bluetooth: don't bother with ->owner for procfs fops Signed-off-by: Al Viro --- net/bluetooth/af_bluetooth.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'net/bluetooth/af_bluetooth.c') diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 82040e46b24..8ab94c6f6f3 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -627,6 +627,13 @@ static int bt_seq_open(struct inode *inode, struct file *file) return 0; } +static const struct file_operations bt_fops = { + .open = bt_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private +}; + int bt_procfs_init(struct module* module, struct net *net, const char *name, struct bt_sock_list* sk_list, int (* seq_show)(struct seq_file *, void *)) @@ -635,13 +642,7 @@ int bt_procfs_init(struct module* module, struct net *net, const char *name, sk_list->custom_seq_show = seq_show; - sk_list->fops.owner = module; - sk_list->fops.open = bt_seq_open; - sk_list->fops.read = seq_read; - sk_list->fops.llseek = seq_lseek; - sk_list->fops.release = seq_release_private; - - pde = proc_create(name, 0, net->proc_net, &sk_list->fops); + pde = proc_create(name, 0, net->proc_net, &bt_fops); if (!pde) return -ENOMEM; -- cgit v1.2.3-18-g5258 From b03166152f6da91cec8b66837b309dd3923ea536 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 4 Apr 2013 19:14:33 -0400 Subject: bluetooth: kill unused 'module' argument of bt_procfs_init() Signed-off-by: Al Viro --- net/bluetooth/af_bluetooth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net/bluetooth/af_bluetooth.c') diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 8ab94c6f6f3..68e6fefb365 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -634,7 +634,7 @@ static const struct file_operations bt_fops = { .release = seq_release_private }; -int bt_procfs_init(struct module* module, struct net *net, const char *name, +int bt_procfs_init(struct net *net, const char *name, struct bt_sock_list* sk_list, int (* seq_show)(struct seq_file *, void *)) { @@ -656,7 +656,7 @@ void bt_procfs_cleanup(struct net *net, const char *name) remove_proc_entry(name, net->proc_net); } #else -int bt_procfs_init(struct module* module, struct net *net, const char *name, +int bt_procfs_init(struct net *net, const char *name, struct bt_sock_list* sk_list, int (* seq_show)(struct seq_file *, void *)) { -- cgit v1.2.3-18-g5258 From 4d006263d3d61413e63784a454b6e3310bd8e6ee Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 4 Apr 2013 19:16:06 -0400 Subject: bluetooth: fix race in bt_procfs_init() use proc_create_data() rather than set ->data after the file has been created Signed-off-by: Al Viro --- net/bluetooth/af_bluetooth.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'net/bluetooth/af_bluetooth.c') diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 68e6fefb365..438a8c56938 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -638,16 +638,10 @@ int bt_procfs_init(struct net *net, const char *name, struct bt_sock_list* sk_list, int (* seq_show)(struct seq_file *, void *)) { - struct proc_dir_entry * pde; - sk_list->custom_seq_show = seq_show; - pde = proc_create(name, 0, net->proc_net, &bt_fops); - if (!pde) + if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list)) return -ENOMEM; - - pde->data = sk_list; - return 0; } -- cgit v1.2.3-18-g5258