diff options
author | David Howells <dhowells@redhat.com> | 2013-04-12 09:06:01 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-01 17:29:42 -0400 |
commit | 4a520d2769beb736ba2bd084b8293ce148a1a7ae (patch) | |
tree | 023a339c1f2ecf7bd1b051a725f4c720f1908c0f | |
parent | b25f774d889e3856c6d81ffc679912f8bdef6adc (diff) |
proc: Supply an accessor for getting the data from a PDE's parent
Supply an accessor function for getting the private data from the parent
proc_dir_entry struct of the proc_dir_entry struct associated with an inode.
ReiserFS, for instance, stores the super_block pointer in the proc directory
it makes for that super_block, and a pointer to the respective seq_file show
function in each of the proc files in that directory.
This allows a reduction in the number of file_operations structs, open
functions and seq_operations structs required. The problem otherwise is that
each show function requires two pieces of data but only has storage for one
per PDE (and this has no release function).
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cc: Jerry Chuang <jerry-chuang@realtek.com>
cc: Maxim Mikityanskiy <maxtram95@gmail.com>
cc: YAMANE Toshiaki <yamanetoshi@gmail.com>
cc: linux-wireless@vger.kernel.org
cc: linux-scsi@vger.kernel.org
cc: devel@driverdev.osuosl.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/scsi/megaraid.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_core.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8192u/r8192U_core.c | 2 | ||||
-rw-r--r-- | fs/proc/generic.c | 7 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 1 |
5 files changed, 11 insertions, 3 deletions
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index ef3384d39e11..7373255aa1e8 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -2760,7 +2760,7 @@ proc_show_rdrv_40(struct seq_file *m, void *v) | |||
2760 | */ | 2760 | */ |
2761 | static int mega_proc_open(struct inode *inode, struct file *file) | 2761 | static int mega_proc_open(struct inode *inode, struct file *file) |
2762 | { | 2762 | { |
2763 | adapter_t *adapter = PDE(inode)->parent->data; | 2763 | adapter_t *adapter = proc_get_parent_data(inode); |
2764 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); | 2764 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); |
2765 | 2765 | ||
2766 | return single_open(file, show, adapter); | 2766 | return single_open(file, show, adapter); |
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index ab469ceae88c..f7c1d9905ec6 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c | |||
@@ -296,7 +296,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) | |||
296 | */ | 296 | */ |
297 | static int rtl8180_proc_open(struct inode *inode, struct file *file) | 297 | static int rtl8180_proc_open(struct inode *inode, struct file *file) |
298 | { | 298 | { |
299 | struct net_device *dev = PDE(inode)->parent->data; | 299 | struct net_device *dev = proc_get_parent_data(inode); |
300 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); | 300 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); |
301 | 301 | ||
302 | return single_open(file, show, dev); | 302 | return single_open(file, show, dev); |
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 27ba2a3111d2..145923397556 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c | |||
@@ -637,7 +637,7 @@ void rtl8192_proc_module_remove(void) | |||
637 | */ | 637 | */ |
638 | static int rtl8192_proc_open(struct inode *inode, struct file *file) | 638 | static int rtl8192_proc_open(struct inode *inode, struct file *file) |
639 | { | 639 | { |
640 | struct net_device *dev = PDE(inode)->parent->data; | 640 | struct net_device *dev = proc_get_parent_data(inode); |
641 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); | 641 | int (*show)(struct seq_file *, void *) = PDE_DATA(inode); |
642 | 642 | ||
643 | return single_open(file, show, dev); | 643 | return single_open(file, show, dev); |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 4074da57c99e..75e08d36b2f1 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -617,3 +617,10 @@ int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) | |||
617 | return 0; | 617 | return 0; |
618 | } | 618 | } |
619 | EXPORT_SYMBOL(remove_proc_subtree); | 619 | EXPORT_SYMBOL(remove_proc_subtree); |
620 | |||
621 | void *proc_get_parent_data(const struct inode *inode) | ||
622 | { | ||
623 | struct proc_dir_entry *de = PDE(inode); | ||
624 | return de->parent->data; | ||
625 | } | ||
626 | EXPORT_SYMBOL_GPL(proc_get_parent_data); | ||
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index a0fb1c2f1d8e..bae820742341 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -86,6 +86,7 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, | |||
86 | 86 | ||
87 | extern void proc_set_size(struct proc_dir_entry *, loff_t); | 87 | extern void proc_set_size(struct proc_dir_entry *, loff_t); |
88 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); | 88 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); |
89 | extern void *proc_get_parent_data(const struct inode *); | ||
89 | #else | 90 | #else |
90 | 91 | ||
91 | static inline void proc_flush_task(struct task_struct *task) | 92 | static inline void proc_flush_task(struct task_struct *task) |