diff options
author | David Howells <dhowells@redhat.com> | 2013-04-12 12:27:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-01 17:29:46 -0400 |
commit | a8ca16ea7b0abb0a7e49492d1123b715f0ec62e8 (patch) | |
tree | fe201353c71385cab2f3cc0d7235c76121f51789 | |
parent | 8d8b97ba499cb69fccb5fd9f2b439e3265fc3f27 (diff) |
proc: Supply a function to remove a proc entry by PDE
Supply a function (proc_remove()) to remove a proc entry (and any subtree
rooted there) by proc_dir_entry pointer rather than by name and (optionally)
root dir entry pointer. This allows us to eliminate all remaining pde->name
accesses outside of procfs.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Grant Likely <grant.likely@linaro.or>
cc: linux-acpi@vger.kernel.org
cc: openipmi-developer@lists.sourceforge.net
cc: devicetree-discuss@lists.ozlabs.org
cc: linux-pci@vger.kernel.org
cc: netdev@vger.kernel.org
cc: netfilter-devel@vger.kernel.org
cc: alsa-devel@alsa-project.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/acpi/sbs.c | 21 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 2 | ||||
-rw-r--r-- | drivers/misc/sgi-gru/gruprocfs.c | 2 | ||||
-rw-r--r-- | drivers/of/base.c | 11 | ||||
-rw-r--r-- | drivers/pci/proc.c | 12 | ||||
-rw-r--r-- | fs/proc/generic.c | 7 | ||||
-rw-r--r-- | fs/proc/vmcore.c | 2 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 2 | ||||
-rw-r--r-- | kernel/irq/proc.c | 6 | ||||
-rw-r--r-- | net/8021q/vlanproc.c | 9 | ||||
-rw-r--r-- | net/core/pktgen.c | 6 | ||||
-rw-r--r-- | net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 | ||||
-rw-r--r-- | net/ipv6/proc.c | 3 | ||||
-rw-r--r-- | sound/core/info.c | 19 |
14 files changed, 33 insertions, 73 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index a296e08d76b6..b6241eeb1132 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, | |||
521 | return 0; | 521 | return 0; |
522 | } | 522 | } |
523 | 523 | ||
524 | static void | ||
525 | acpi_sbs_remove_fs(struct proc_dir_entry **dir, | ||
526 | struct proc_dir_entry *parent_dir) | ||
527 | { | ||
528 | if (*dir) { | ||
529 | remove_proc_entry(ACPI_SBS_FILE_INFO, *dir); | ||
530 | remove_proc_entry(ACPI_SBS_FILE_STATE, *dir); | ||
531 | remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir); | ||
532 | remove_proc_entry((*dir)->name, parent_dir); | ||
533 | *dir = NULL; | ||
534 | } | ||
535 | } | ||
536 | |||
537 | /* Smart Battery Interface */ | 524 | /* Smart Battery Interface */ |
538 | static struct proc_dir_entry *acpi_battery_dir = NULL; | 525 | static struct proc_dir_entry *acpi_battery_dir = NULL; |
539 | 526 | ||
@@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | |||
836 | power_supply_unregister(&battery->bat); | 823 | power_supply_unregister(&battery->bat); |
837 | } | 824 | } |
838 | #ifdef CONFIG_ACPI_PROCFS_POWER | 825 | #ifdef CONFIG_ACPI_PROCFS_POWER |
839 | if (battery->proc_entry) | 826 | proc_remove(battery->proc_entry); |
840 | acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); | 827 | battery->proc_entry = NULL; |
841 | #endif | 828 | #endif |
842 | } | 829 | } |
843 | 830 | ||
@@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) | |||
873 | if (sbs->charger.dev) | 860 | if (sbs->charger.dev) |
874 | power_supply_unregister(&sbs->charger); | 861 | power_supply_unregister(&sbs->charger); |
875 | #ifdef CONFIG_ACPI_PROCFS_POWER | 862 | #ifdef CONFIG_ACPI_PROCFS_POWER |
876 | if (sbs->charger_entry) | 863 | proc_remove(sbs->charger_entry); |
877 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); | 864 | sbs->charger_entry = NULL; |
878 | #endif | 865 | #endif |
879 | } | 866 | } |
880 | 867 | ||
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 1420bbbe1a61..4d439d2fcfd6 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void) | |||
4541 | del_timer_sync(&ipmi_timer); | 4541 | del_timer_sync(&ipmi_timer); |
4542 | 4542 | ||
4543 | #ifdef CONFIG_PROC_FS | 4543 | #ifdef CONFIG_PROC_FS |
4544 | remove_proc_entry(proc_ipmi_root->name, NULL); | 4544 | proc_remove(proc_ipmi_root); |
4545 | #endif /* CONFIG_PROC_FS */ | 4545 | #endif /* CONFIG_PROC_FS */ |
4546 | 4546 | ||
4547 | driver_unregister(&ipmidriver.driver); | 4547 | driver_unregister(&ipmidriver.driver); |
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c index 950dbe9ecb36..797d7962cc88 100644 --- a/drivers/misc/sgi-gru/gruprocfs.c +++ b/drivers/misc/sgi-gru/gruprocfs.c | |||
@@ -355,7 +355,7 @@ static void delete_proc_files(void) | |||
355 | for (p = proc_files; p->name; p++) | 355 | for (p = proc_files; p->name; p++) |
356 | if (p->entry) | 356 | if (p->entry) |
357 | remove_proc_entry(p->name, proc_gru); | 357 | remove_proc_entry(p->name, proc_gru); |
358 | remove_proc_entry("gru", proc_gru->parent); | 358 | proc_remove(proc_gru); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
diff --git a/drivers/of/base.c b/drivers/of/base.c index 321d3ef05006..9c704369eda8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np) | |||
1452 | #ifdef CONFIG_PROC_DEVICETREE | 1452 | #ifdef CONFIG_PROC_DEVICETREE |
1453 | static void of_remove_proc_dt_entry(struct device_node *dn) | 1453 | static void of_remove_proc_dt_entry(struct device_node *dn) |
1454 | { | 1454 | { |
1455 | struct device_node *parent = dn->parent; | 1455 | proc_remove(dn->pde); |
1456 | struct property *prop = dn->properties; | ||
1457 | |||
1458 | while (prop) { | ||
1459 | remove_proc_entry(prop->name, dn->pde); | ||
1460 | prop = prop->next; | ||
1461 | } | ||
1462 | |||
1463 | if (dn->pde) | ||
1464 | remove_proc_entry(dn->pde->name, parent->pde); | ||
1465 | } | 1456 | } |
1466 | #else | 1457 | #else |
1467 | static void of_remove_proc_dt_entry(struct device_node *dn) | 1458 | static void of_remove_proc_dt_entry(struct device_node *dn) |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 7cde7c131fd0..08126087ec31 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev) | |||
427 | 427 | ||
428 | int pci_proc_detach_device(struct pci_dev *dev) | 428 | int pci_proc_detach_device(struct pci_dev *dev) |
429 | { | 429 | { |
430 | struct proc_dir_entry *e; | 430 | proc_remove(dev->procent); |
431 | 431 | dev->procent = NULL; | |
432 | if ((e = dev->procent)) { | ||
433 | remove_proc_entry(e->name, dev->bus->procdir); | ||
434 | dev->procent = NULL; | ||
435 | } | ||
436 | return 0; | 432 | return 0; |
437 | } | 433 | } |
438 | 434 | ||
439 | int pci_proc_detach_bus(struct pci_bus* bus) | 435 | int pci_proc_detach_bus(struct pci_bus* bus) |
440 | { | 436 | { |
441 | struct proc_dir_entry *de = bus->procdir; | 437 | proc_remove(bus->procdir); |
442 | if (de) | ||
443 | remove_proc_entry(de->name, proc_bus_pci_dir); | ||
444 | return 0; | 438 | return 0; |
445 | } | 439 | } |
446 | 440 | ||
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 75e08d36b2f1..d9631d9b7aff 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -624,3 +624,10 @@ void *proc_get_parent_data(const struct inode *inode) | |||
624 | return de->parent->data; | 624 | return de->parent->data; |
625 | } | 625 | } |
626 | EXPORT_SYMBOL_GPL(proc_get_parent_data); | 626 | EXPORT_SYMBOL_GPL(proc_get_parent_data); |
627 | |||
628 | void proc_remove(struct proc_dir_entry *de) | ||
629 | { | ||
630 | if (de) | ||
631 | remove_proc_subtree(de->name, de->parent); | ||
632 | } | ||
633 | EXPORT_SYMBOL(proc_remove); | ||
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 38edddc25816..17f7e080d7ff 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -699,7 +699,7 @@ void vmcore_cleanup(void) | |||
699 | struct list_head *pos, *next; | 699 | struct list_head *pos, *next; |
700 | 700 | ||
701 | if (proc_vmcore) { | 701 | if (proc_vmcore) { |
702 | remove_proc_entry(proc_vmcore->name, proc_vmcore->parent); | 702 | proc_remove(proc_vmcore); |
703 | proc_vmcore = NULL; | 703 | proc_vmcore = NULL; |
704 | } | 704 | } |
705 | 705 | ||
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index bae820742341..cb78d5be6859 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -67,6 +67,7 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, | |||
67 | struct proc_dir_entry *parent, | 67 | struct proc_dir_entry *parent, |
68 | const struct file_operations *proc_fops, | 68 | const struct file_operations *proc_fops, |
69 | void *data); | 69 | void *data); |
70 | extern void proc_remove(struct proc_dir_entry *); | ||
70 | extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); | 71 | extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); |
71 | extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent); | 72 | extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent); |
72 | 73 | ||
@@ -101,6 +102,7 @@ static inline struct proc_dir_entry *proc_create_data(const char *name, | |||
101 | { | 102 | { |
102 | return NULL; | 103 | return NULL; |
103 | } | 104 | } |
105 | static inline void proc_remove(struct proc_dir_entry *de) {} | ||
104 | #define remove_proc_entry(name, parent) do {} while (0) | 106 | #define remove_proc_entry(name, parent) do {} while (0) |
105 | #define remove_proc_subtree(name, parent) do {} while (0) | 107 | #define remove_proc_subtree(name, parent) do {} while (0) |
106 | 108 | ||
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index d59ae3751a33..19ed5c425c3b 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -366,11 +366,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) | |||
366 | 366 | ||
367 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) | 367 | void unregister_handler_proc(unsigned int irq, struct irqaction *action) |
368 | { | 368 | { |
369 | if (action->dir) { | 369 | proc_remove(action->dir); |
370 | struct irq_desc *desc = irq_to_desc(irq); | ||
371 | |||
372 | remove_proc_entry(action->dir->name, desc->dir); | ||
373 | } | ||
374 | } | 370 | } |
375 | 371 | ||
376 | static void register_default_affinity_proc(void) | 372 | static void register_default_affinity_proc(void) |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 959ddbb0ca4d..1d0e89213a28 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -184,14 +184,9 @@ int vlan_proc_add_dev(struct net_device *vlandev) | |||
184 | */ | 184 | */ |
185 | int vlan_proc_rem_dev(struct net_device *vlandev) | 185 | int vlan_proc_rem_dev(struct net_device *vlandev) |
186 | { | 186 | { |
187 | struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id); | ||
188 | |||
189 | /** NOTE: This will consume the memory pointed to by dent, it seems. */ | 187 | /** NOTE: This will consume the memory pointed to by dent, it seems. */ |
190 | if (vlan_dev_priv(vlandev)->dent) { | 188 | proc_remove(vlan_dev_priv(vlandev)->dent); |
191 | remove_proc_entry(vlan_dev_priv(vlandev)->dent->name, | 189 | vlan_dev_priv(vlandev)->dent = NULL; |
192 | vn->proc_vlan_dir); | ||
193 | vlan_dev_priv(vlandev)->dent = NULL; | ||
194 | } | ||
195 | return 0; | 190 | return 0; |
196 | } | 191 | } |
197 | 192 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index f6af4fe59f2e..6c41e979dc88 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -1904,7 +1904,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d | |||
1904 | if (pkt_dev->odev != dev) | 1904 | if (pkt_dev->odev != dev) |
1905 | continue; | 1905 | continue; |
1906 | 1906 | ||
1907 | remove_proc_entry(pkt_dev->entry->name, pn->proc_dir); | 1907 | proc_remove(pkt_dev->entry); |
1908 | 1908 | ||
1909 | pkt_dev->entry = proc_create_data(dev->name, 0600, | 1909 | pkt_dev->entry = proc_create_data(dev->name, 0600, |
1910 | pn->proc_dir, | 1910 | pn->proc_dir, |
@@ -3576,8 +3576,6 @@ static void _rem_dev_from_if_list(struct pktgen_thread *t, | |||
3576 | static int pktgen_remove_device(struct pktgen_thread *t, | 3576 | static int pktgen_remove_device(struct pktgen_thread *t, |
3577 | struct pktgen_dev *pkt_dev) | 3577 | struct pktgen_dev *pkt_dev) |
3578 | { | 3578 | { |
3579 | struct pktgen_net *pn = t->net; | ||
3580 | |||
3581 | pr_debug("remove_device pkt_dev=%p\n", pkt_dev); | 3579 | pr_debug("remove_device pkt_dev=%p\n", pkt_dev); |
3582 | 3580 | ||
3583 | if (pkt_dev->running) { | 3581 | if (pkt_dev->running) { |
@@ -3597,7 +3595,7 @@ static int pktgen_remove_device(struct pktgen_thread *t, | |||
3597 | _rem_dev_from_if_list(t, pkt_dev); | 3595 | _rem_dev_from_if_list(t, pkt_dev); |
3598 | 3596 | ||
3599 | if (pkt_dev->entry) | 3597 | if (pkt_dev->entry) |
3600 | remove_proc_entry(pkt_dev->entry->name, pn->proc_dir); | 3598 | proc_remove(pkt_dev->entry); |
3601 | 3599 | ||
3602 | #ifdef CONFIG_XFRM | 3600 | #ifdef CONFIG_XFRM |
3603 | free_SAs(pkt_dev); | 3601 | free_SAs(pkt_dev); |
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index e4738fef070a..0b732efd32e2 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -105,7 +105,7 @@ clusterip_config_entry_put(struct clusterip_config *c) | |||
105 | * functions are also incrementing the refcount on their own, | 105 | * functions are also incrementing the refcount on their own, |
106 | * so it's safe to remove the entry even if it's in use. */ | 106 | * so it's safe to remove the entry even if it's in use. */ |
107 | #ifdef CONFIG_PROC_FS | 107 | #ifdef CONFIG_PROC_FS |
108 | remove_proc_entry(c->pde->name, c->pde->parent); | 108 | proc_remove(c->pde); |
109 | #endif | 109 | #endif |
110 | return; | 110 | return; |
111 | } | 111 | } |
@@ -736,7 +736,7 @@ static void __exit clusterip_tg_exit(void) | |||
736 | { | 736 | { |
737 | pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION); | 737 | pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION); |
738 | #ifdef CONFIG_PROC_FS | 738 | #ifdef CONFIG_PROC_FS |
739 | remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent); | 739 | proc_remove(clusterip_procdir); |
740 | #endif | 740 | #endif |
741 | nf_unregister_hook(&cip_arp_ops); | 741 | nf_unregister_hook(&cip_arp_ops); |
742 | xt_unregister_target(&clusterip_tg_reg); | 742 | xt_unregister_target(&clusterip_tg_reg); |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 7ea6e180139c..537d9ee7209f 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -287,8 +287,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev) | |||
287 | return -ENOENT; | 287 | return -ENOENT; |
288 | if (!idev->stats.proc_dir_entry) | 288 | if (!idev->stats.proc_dir_entry) |
289 | return -EINVAL; | 289 | return -EINVAL; |
290 | remove_proc_entry(idev->stats.proc_dir_entry->name, | 290 | proc_remove(idev->stats.proc_dir_entry); |
291 | net->mib.proc_net_devsnmp6); | ||
292 | idev->stats.proc_dir_entry = NULL; | 291 | idev->stats.proc_dir_entry = NULL; |
293 | return 0; | 292 | return 0; |
294 | } | 293 | } |
diff --git a/sound/core/info.c b/sound/core/info.c index c7f41c3bbd5c..3c9bd6b10a96 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root); | |||
153 | struct snd_info_entry *snd_oss_root; | 153 | struct snd_info_entry *snd_oss_root; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | static void snd_remove_proc_entry(struct proc_dir_entry *parent, | ||
157 | struct proc_dir_entry *de) | ||
158 | { | ||
159 | if (de) | ||
160 | remove_proc_entry(de->name, parent); | ||
161 | } | ||
162 | |||
163 | static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) | 156 | static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) |
164 | { | 157 | { |
165 | struct snd_info_private_data *data; | 158 | struct snd_info_private_data *data; |
@@ -580,7 +573,7 @@ int __exit snd_info_done(void) | |||
580 | #ifdef CONFIG_SND_OSSEMUL | 573 | #ifdef CONFIG_SND_OSSEMUL |
581 | snd_info_free_entry(snd_oss_root); | 574 | snd_info_free_entry(snd_oss_root); |
582 | #endif | 575 | #endif |
583 | snd_remove_proc_entry(NULL, snd_proc_root); | 576 | proc_remove(snd_proc_root); |
584 | } | 577 | } |
585 | return 0; | 578 | return 0; |
586 | } | 579 | } |
@@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card) | |||
642 | { | 635 | { |
643 | mutex_lock(&info_mutex); | 636 | mutex_lock(&info_mutex); |
644 | if (card->proc_root_link) { | 637 | if (card->proc_root_link) { |
645 | snd_remove_proc_entry(snd_proc_root, card->proc_root_link); | 638 | proc_remove(card->proc_root_link); |
646 | card->proc_root_link = NULL; | 639 | card->proc_root_link = NULL; |
647 | } | 640 | } |
648 | if (strcmp(card->id, card->proc_root->name)) | 641 | if (strcmp(card->id, card->proc_root->name)) |
@@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card) | |||
661 | if (!card) | 654 | if (!card) |
662 | return; | 655 | return; |
663 | mutex_lock(&info_mutex); | 656 | mutex_lock(&info_mutex); |
664 | if (card->proc_root_link) { | 657 | proc_remove(card->proc_root_link); |
665 | snd_remove_proc_entry(snd_proc_root, card->proc_root_link); | 658 | card->proc_root_link = NULL; |
666 | card->proc_root_link = NULL; | ||
667 | } | ||
668 | if (card->proc_root) | 659 | if (card->proc_root) |
669 | snd_info_disconnect(card->proc_root); | 660 | snd_info_disconnect(card->proc_root); |
670 | mutex_unlock(&info_mutex); | 661 | mutex_unlock(&info_mutex); |
@@ -856,7 +847,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry) | |||
856 | list_del_init(&entry->list); | 847 | list_del_init(&entry->list); |
857 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; | 848 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; |
858 | snd_BUG_ON(!root); | 849 | snd_BUG_ON(!root); |
859 | snd_remove_proc_entry(root, entry->p); | 850 | proc_remove(entry->p); |
860 | entry->p = NULL; | 851 | entry->p = NULL; |
861 | } | 852 | } |
862 | 853 | ||