Subject: [PATCH] [acpi driver model] Allow an empty proc interface - Add acpi_driver_proc_none() macro for defining an empty structure - Check for ->p_num_files == 0 when adding driver and device proc directories and files. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/core/proc.c | 13 +++++++++---- include/acpi/proc.h | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) applies-to: ac499b90feb42a4b13c3274efa75eb682474ef24 310327177f7905ead8eda998cd64334192cd551d diff --git a/drivers/acpi/drivers/core/proc.c b/drivers/acpi/drivers/core/proc.c index 65bfc12..7e6bab5 100644 --- a/drivers/acpi/drivers/core/proc.c +++ b/drivers/acpi/drivers/core/proc.c @@ -27,6 +27,9 @@ int acpi_driver_proc_add(struct acpi_dev struct proc_dir_entry * dir; int ret = 0; + if (!adp->p_num_files) + return 0; + dir = proc_mkdir(adp->p_name, acpi_root_dir); if (dir) adp->p_parent = dir; @@ -49,8 +52,10 @@ void acpi_driver_proc_remove(struct acpi { struct acpi_driver_proc * adp = d->d_proc; - adp->p_parent = NULL; - remove_proc_entry(adp->p_name, acpi_root_dir); + if (adp->p_num_files) { + adp->p_parent = NULL; + remove_proc_entry(adp->p_name, acpi_root_dir); + } } @@ -78,7 +83,7 @@ int acpi_device_proc_add(struct acpi_dev char * dir_name; int i; - if (!adp) + if (!adp || !adp->p_num_files) return 0; dir_name = acpi_dev_bid(ad); @@ -129,7 +134,7 @@ void acpi_device_proc_remove(struct acpi struct acpi_driver_proc * adp = drv->d_proc; struct proc_dir_entry * dir = ad->proc_dir; - if (adp) { + if (adp && adp->p_num_files) { char * dir_name = acpi_dev_bid(ad); int i; diff --git a/include/acpi/proc.h b/include/acpi/proc.h index cdb3dac..b0b4b89 100644 --- a/include/acpi/proc.h +++ b/include/acpi/proc.h @@ -132,6 +132,18 @@ struct acpi_driver_proc __name##_proc = .p_num_files = ARRAY_SIZE(__name##_files), \ } + +/** + * This is the macro to use for defining an empty proc + * structure (if the driver doesn't have a proc interface). + */ + +#define acpi_driver_proc_none(__name) \ +struct acpi_driver_proc __name##_proc = { \ + .p_num_files = 0, \ +} + + /* * These macros are used by include/acpi/device.h to simplify the * acpi driver declaration macro, and to provide for the case where --- 0.99.9.GIT