Subject: [PATCH] [acpi driver model] Add interface for registering proc directories - Create drivers/acpi/drivers/core/proc.c and implement acpi_driver_proc_{add,remove} that are to be called when a driver is registered and unregistered. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/core/Makefile | 1 + drivers/acpi/drivers/core/proc.c | 54 ++++++++++++++++++++++++++++++++++++ drivers/acpi/drivers/core/proc.h | 26 +++++++++++++++++ 3 files changed, 81 insertions(+), 0 deletions(-) create mode 100644 drivers/acpi/drivers/core/proc.c create mode 100644 drivers/acpi/drivers/core/proc.h applies-to: 093741e077bbf6377c23f2098a0c0b8ce7877ed5 ee20481e40253422d456a07b41b3b419b3a3250d diff --git a/drivers/acpi/drivers/core/Makefile b/drivers/acpi/drivers/core/Makefile index b9c847a..caed047 100644 --- a/drivers/acpi/drivers/core/Makefile +++ b/drivers/acpi/drivers/core/Makefile @@ -3,6 +3,7 @@ obj-y := bus.o device.o driver.o event.o obj-y += lib.o obj-$(CONFIG_ACPI_DM_SYSFS) += sysfs.o +obj-$(CONFIG_ACPI_DM_SYSFS) += proc.o ifeq ($(CONFIG_ACPI_DM_DEBUG),y) diff --git a/drivers/acpi/drivers/core/proc.c b/drivers/acpi/drivers/core/proc.c new file mode 100644 index 0000000..ad6c09a --- /dev/null +++ b/drivers/acpi/drivers/core/proc.c @@ -0,0 +1,54 @@ +/** + * drivers/acpi/drivers/core/proc.c - ACPI proc file management + * + * Copyright (C) 2006 Patrick Mochel + * + */ + +#include "core.h" + + +/** + * acpi_driver_proc_add - Create a driver's proc directory. + * @d: The ACPI driver. + * + * This creates a directory in /proc/acpi/ with the name + * in the acpi_driver_proc structure (usually the name of + * the driver). + * + * It uses that directory to set ->d_parent in the + * acpi_driver_proc structure, for use by the functions to + * add/remove device directories. + */ + +int acpi_driver_proc_add(struct acpi_device_driver * d) +{ + struct acpi_driver_proc * adp = d->d_proc; + struct proc_dir_entry * dir; + int ret = 0; + + dir = proc_mkdir(adp->p_name, acpi_root_dir); + if (dir) + adp->p_parent = dir; + else + return -ENODEV; + return ret; +} + + +/** + * acpi_driver_proc_remove - Remove a driver's proc directory. + * @d: The ACPI driver. + * + * Remove the driver's directory from /proc/acpi/ and + * set p_parent == NULL in the driver's acpi_driver_proc + * structure. + */ + +void acpi_driver_proc_remove(struct acpi_device_driver * d) +{ + struct acpi_driver_proc * adp = d->d_proc; + + adp->p_parent = NULL; + remove_proc_entry(adp->p_name, acpi_root_dir); +} diff --git a/drivers/acpi/drivers/core/proc.h b/drivers/acpi/drivers/core/proc.h new file mode 100644 index 0000000..53c1e25 --- /dev/null +++ b/drivers/acpi/drivers/core/proc.h @@ -0,0 +1,26 @@ +/** + * drivers/acpi/drivers/core/proc.h + * + * proc filesystem directory and file management for + * ACPI drivers and devices. + */ + +#ifdef CONFIG_ACPI_DM_PROC + +extern int acpi_driver_proc_add(struct acpi_device_driver *); +extern void acpi_driver_proc_remove(struct acpi_device_driver *); + +#else /* CONFIG_ACPI_DM_PROC */ + +static inline int acpi_driver_proc_add(struct acpi_device_driver * drv) +{ + return 0; +} + +static inline void acpi_driver_proc_remove(struct acpi_device_driver * drv) +{ + +} + + +#endif /* CONFIG_ACPI_DM_PROC */ --- 0.99.9.GIT