mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
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>
This commit is contained in:
parent
8d8b97ba49
commit
a8ca16ea7b
14 changed files with 33 additions and 73 deletions
|
|
@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
acpi_sbs_remove_fs(struct proc_dir_entry **dir,
|
|
||||||
struct proc_dir_entry *parent_dir)
|
|
||||||
{
|
|
||||||
if (*dir) {
|
|
||||||
remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
|
|
||||||
remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
|
|
||||||
remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
|
|
||||||
remove_proc_entry((*dir)->name, parent_dir);
|
|
||||||
*dir = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Smart Battery Interface */
|
/* Smart Battery Interface */
|
||||||
static struct proc_dir_entry *acpi_battery_dir = NULL;
|
static struct proc_dir_entry *acpi_battery_dir = NULL;
|
||||||
|
|
||||||
|
|
@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
|
||||||
power_supply_unregister(&battery->bat);
|
power_supply_unregister(&battery->bat);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_ACPI_PROCFS_POWER
|
#ifdef CONFIG_ACPI_PROCFS_POWER
|
||||||
if (battery->proc_entry)
|
proc_remove(battery->proc_entry);
|
||||||
acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
|
battery->proc_entry = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
|
||||||
if (sbs->charger.dev)
|
if (sbs->charger.dev)
|
||||||
power_supply_unregister(&sbs->charger);
|
power_supply_unregister(&sbs->charger);
|
||||||
#ifdef CONFIG_ACPI_PROCFS_POWER
|
#ifdef CONFIG_ACPI_PROCFS_POWER
|
||||||
if (sbs->charger_entry)
|
proc_remove(sbs->charger_entry);
|
||||||
acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
|
sbs->charger_entry = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void)
|
||||||
del_timer_sync(&ipmi_timer);
|
del_timer_sync(&ipmi_timer);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
remove_proc_entry(proc_ipmi_root->name, NULL);
|
proc_remove(proc_ipmi_root);
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
driver_unregister(&ipmidriver.driver);
|
driver_unregister(&ipmidriver.driver);
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ static void delete_proc_files(void)
|
||||||
for (p = proc_files; p->name; p++)
|
for (p = proc_files; p->name; p++)
|
||||||
if (p->entry)
|
if (p->entry)
|
||||||
remove_proc_entry(p->name, proc_gru);
|
remove_proc_entry(p->name, proc_gru);
|
||||||
remove_proc_entry("gru", proc_gru->parent);
|
proc_remove(proc_gru);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np)
|
||||||
#ifdef CONFIG_PROC_DEVICETREE
|
#ifdef CONFIG_PROC_DEVICETREE
|
||||||
static void of_remove_proc_dt_entry(struct device_node *dn)
|
static void of_remove_proc_dt_entry(struct device_node *dn)
|
||||||
{
|
{
|
||||||
struct device_node *parent = dn->parent;
|
proc_remove(dn->pde);
|
||||||
struct property *prop = dn->properties;
|
|
||||||
|
|
||||||
while (prop) {
|
|
||||||
remove_proc_entry(prop->name, dn->pde);
|
|
||||||
prop = prop->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dn->pde)
|
|
||||||
remove_proc_entry(dn->pde->name, parent->pde);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void of_remove_proc_dt_entry(struct device_node *dn)
|
static void of_remove_proc_dt_entry(struct device_node *dn)
|
||||||
|
|
|
||||||
|
|
@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
|
||||||
|
|
||||||
int pci_proc_detach_device(struct pci_dev *dev)
|
int pci_proc_detach_device(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *e;
|
proc_remove(dev->procent);
|
||||||
|
|
||||||
if ((e = dev->procent)) {
|
|
||||||
remove_proc_entry(e->name, dev->bus->procdir);
|
|
||||||
dev->procent = NULL;
|
dev->procent = NULL;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pci_proc_detach_bus(struct pci_bus* bus)
|
int pci_proc_detach_bus(struct pci_bus* bus)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *de = bus->procdir;
|
proc_remove(bus->procdir);
|
||||||
if (de)
|
|
||||||
remove_proc_entry(de->name, proc_bus_pci_dir);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -624,3 +624,10 @@ void *proc_get_parent_data(const struct inode *inode)
|
||||||
return de->parent->data;
|
return de->parent->data;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(proc_get_parent_data);
|
EXPORT_SYMBOL_GPL(proc_get_parent_data);
|
||||||
|
|
||||||
|
void proc_remove(struct proc_dir_entry *de)
|
||||||
|
{
|
||||||
|
if (de)
|
||||||
|
remove_proc_subtree(de->name, de->parent);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(proc_remove);
|
||||||
|
|
|
||||||
|
|
@ -699,7 +699,7 @@ void vmcore_cleanup(void)
|
||||||
struct list_head *pos, *next;
|
struct list_head *pos, *next;
|
||||||
|
|
||||||
if (proc_vmcore) {
|
if (proc_vmcore) {
|
||||||
remove_proc_entry(proc_vmcore->name, proc_vmcore->parent);
|
proc_remove(proc_vmcore);
|
||||||
proc_vmcore = NULL;
|
proc_vmcore = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
|
||||||
struct proc_dir_entry *parent,
|
struct proc_dir_entry *parent,
|
||||||
const struct file_operations *proc_fops,
|
const struct file_operations *proc_fops,
|
||||||
void *data);
|
void *data);
|
||||||
|
extern void proc_remove(struct proc_dir_entry *);
|
||||||
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
|
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
|
||||||
extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
|
extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
|
||||||
|
|
||||||
|
|
@ -101,6 +102,7 @@ static inline struct proc_dir_entry *proc_create_data(const char *name,
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
static inline void proc_remove(struct proc_dir_entry *de) {}
|
||||||
#define remove_proc_entry(name, parent) do {} while (0)
|
#define remove_proc_entry(name, parent) do {} while (0)
|
||||||
#define remove_proc_subtree(name, parent) do {} while (0)
|
#define remove_proc_subtree(name, parent) do {} while (0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -366,11 +366,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
|
||||||
|
|
||||||
void unregister_handler_proc(unsigned int irq, struct irqaction *action)
|
void unregister_handler_proc(unsigned int irq, struct irqaction *action)
|
||||||
{
|
{
|
||||||
if (action->dir) {
|
proc_remove(action->dir);
|
||||||
struct irq_desc *desc = irq_to_desc(irq);
|
|
||||||
|
|
||||||
remove_proc_entry(action->dir->name, desc->dir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_default_affinity_proc(void)
|
static void register_default_affinity_proc(void)
|
||||||
|
|
|
||||||
|
|
@ -184,14 +184,9 @@ int vlan_proc_add_dev(struct net_device *vlandev)
|
||||||
*/
|
*/
|
||||||
int vlan_proc_rem_dev(struct net_device *vlandev)
|
int vlan_proc_rem_dev(struct net_device *vlandev)
|
||||||
{
|
{
|
||||||
struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
|
|
||||||
|
|
||||||
/** NOTE: This will consume the memory pointed to by dent, it seems. */
|
/** NOTE: This will consume the memory pointed to by dent, it seems. */
|
||||||
if (vlan_dev_priv(vlandev)->dent) {
|
proc_remove(vlan_dev_priv(vlandev)->dent);
|
||||||
remove_proc_entry(vlan_dev_priv(vlandev)->dent->name,
|
|
||||||
vn->proc_vlan_dir);
|
|
||||||
vlan_dev_priv(vlandev)->dent = NULL;
|
vlan_dev_priv(vlandev)->dent = NULL;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1904,7 +1904,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
|
||||||
if (pkt_dev->odev != dev)
|
if (pkt_dev->odev != dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
|
proc_remove(pkt_dev->entry);
|
||||||
|
|
||||||
pkt_dev->entry = proc_create_data(dev->name, 0600,
|
pkt_dev->entry = proc_create_data(dev->name, 0600,
|
||||||
pn->proc_dir,
|
pn->proc_dir,
|
||||||
|
|
@ -3576,8 +3576,6 @@ static void _rem_dev_from_if_list(struct pktgen_thread *t,
|
||||||
static int pktgen_remove_device(struct pktgen_thread *t,
|
static int pktgen_remove_device(struct pktgen_thread *t,
|
||||||
struct pktgen_dev *pkt_dev)
|
struct pktgen_dev *pkt_dev)
|
||||||
{
|
{
|
||||||
struct pktgen_net *pn = t->net;
|
|
||||||
|
|
||||||
pr_debug("remove_device pkt_dev=%p\n", pkt_dev);
|
pr_debug("remove_device pkt_dev=%p\n", pkt_dev);
|
||||||
|
|
||||||
if (pkt_dev->running) {
|
if (pkt_dev->running) {
|
||||||
|
|
@ -3597,7 +3595,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
|
||||||
_rem_dev_from_if_list(t, pkt_dev);
|
_rem_dev_from_if_list(t, pkt_dev);
|
||||||
|
|
||||||
if (pkt_dev->entry)
|
if (pkt_dev->entry)
|
||||||
remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
|
proc_remove(pkt_dev->entry);
|
||||||
|
|
||||||
#ifdef CONFIG_XFRM
|
#ifdef CONFIG_XFRM
|
||||||
free_SAs(pkt_dev);
|
free_SAs(pkt_dev);
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ clusterip_config_entry_put(struct clusterip_config *c)
|
||||||
* functions are also incrementing the refcount on their own,
|
* functions are also incrementing the refcount on their own,
|
||||||
* so it's safe to remove the entry even if it's in use. */
|
* so it's safe to remove the entry even if it's in use. */
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
remove_proc_entry(c->pde->name, c->pde->parent);
|
proc_remove(c->pde);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -736,7 +736,7 @@ static void __exit clusterip_tg_exit(void)
|
||||||
{
|
{
|
||||||
pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
|
pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
|
proc_remove(clusterip_procdir);
|
||||||
#endif
|
#endif
|
||||||
nf_unregister_hook(&cip_arp_ops);
|
nf_unregister_hook(&cip_arp_ops);
|
||||||
xt_unregister_target(&clusterip_tg_reg);
|
xt_unregister_target(&clusterip_tg_reg);
|
||||||
|
|
|
||||||
|
|
@ -287,8 +287,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
if (!idev->stats.proc_dir_entry)
|
if (!idev->stats.proc_dir_entry)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
remove_proc_entry(idev->stats.proc_dir_entry->name,
|
proc_remove(idev->stats.proc_dir_entry);
|
||||||
net->mib.proc_net_devsnmp6);
|
|
||||||
idev->stats.proc_dir_entry = NULL;
|
idev->stats.proc_dir_entry = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root);
|
||||||
struct snd_info_entry *snd_oss_root;
|
struct snd_info_entry *snd_oss_root;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void snd_remove_proc_entry(struct proc_dir_entry *parent,
|
|
||||||
struct proc_dir_entry *de)
|
|
||||||
{
|
|
||||||
if (de)
|
|
||||||
remove_proc_entry(de->name, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
|
static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
|
||||||
{
|
{
|
||||||
struct snd_info_private_data *data;
|
struct snd_info_private_data *data;
|
||||||
|
|
@ -580,7 +573,7 @@ int __exit snd_info_done(void)
|
||||||
#ifdef CONFIG_SND_OSSEMUL
|
#ifdef CONFIG_SND_OSSEMUL
|
||||||
snd_info_free_entry(snd_oss_root);
|
snd_info_free_entry(snd_oss_root);
|
||||||
#endif
|
#endif
|
||||||
snd_remove_proc_entry(NULL, snd_proc_root);
|
proc_remove(snd_proc_root);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card)
|
||||||
{
|
{
|
||||||
mutex_lock(&info_mutex);
|
mutex_lock(&info_mutex);
|
||||||
if (card->proc_root_link) {
|
if (card->proc_root_link) {
|
||||||
snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
|
proc_remove(card->proc_root_link);
|
||||||
card->proc_root_link = NULL;
|
card->proc_root_link = NULL;
|
||||||
}
|
}
|
||||||
if (strcmp(card->id, card->proc_root->name))
|
if (strcmp(card->id, card->proc_root->name))
|
||||||
|
|
@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card)
|
||||||
if (!card)
|
if (!card)
|
||||||
return;
|
return;
|
||||||
mutex_lock(&info_mutex);
|
mutex_lock(&info_mutex);
|
||||||
if (card->proc_root_link) {
|
proc_remove(card->proc_root_link);
|
||||||
snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
|
|
||||||
card->proc_root_link = NULL;
|
card->proc_root_link = NULL;
|
||||||
}
|
|
||||||
if (card->proc_root)
|
if (card->proc_root)
|
||||||
snd_info_disconnect(card->proc_root);
|
snd_info_disconnect(card->proc_root);
|
||||||
mutex_unlock(&info_mutex);
|
mutex_unlock(&info_mutex);
|
||||||
|
|
@ -856,7 +847,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry)
|
||||||
list_del_init(&entry->list);
|
list_del_init(&entry->list);
|
||||||
root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
|
root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
|
||||||
snd_BUG_ON(!root);
|
snd_BUG_ON(!root);
|
||||||
snd_remove_proc_entry(root, entry->p);
|
proc_remove(entry->p);
|
||||||
entry->p = NULL;
|
entry->p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue