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 <[email protected]>
Acked-by: Grant Likely <[email protected]>
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
David Howells 2013-04-12 17:27:28 +01:00 • committed by Al Viro
commit a8ca16ea7b
14 changed files with 33 additions and 73 deletions

View file

@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
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 */
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);
}
#ifdef CONFIG_ACPI_PROCFS_POWER
if (battery->proc_entry)
acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
proc_remove(battery->proc_entry);
battery->proc_entry = NULL;
#endif
}
@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
if (sbs->charger.dev)
power_supply_unregister(&sbs->charger);
#ifdef CONFIG_ACPI_PROCFS_POWER
if (sbs->charger_entry)
acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
proc_remove(sbs->charger_entry);
sbs->charger_entry = NULL;
#endif
}