Subject: [PATCH] [acpi driver model] Add per-driver sysfs structures - Define struct acpi_driver_sysfs for declaring arrays of attributes to add for each device that is bound to that driver. - Add macros for helping define the structure, and helpers for including them in the driver structure. Signed-off-by: Patrick Mochel --- include/acpi/sysfs.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) applies-to: 1756a404c4002067c87fb2c8a56efec36c41c724 478d97931714683fb87b10a381d7fca0cc4c4f11 diff --git a/include/acpi/sysfs.h b/include/acpi/sysfs.h index c4dd447..bca6af1 100644 --- a/include/acpi/sysfs.h +++ b/include/acpi/sysfs.h @@ -72,3 +72,56 @@ struct acpi_dev_attr { .ad_store = __name##_store, \ .ad_test = __name##_test, \ } + + + +/* + * This is the per-driver structure that defines all the files + * to be added for each device that the driver is bound to. + */ + +struct acpi_driver_sysfs { + struct acpi_dev_attr * s_attrs; + u32 s_num_attrs; +}; + + +/* + * A driver should use these macros to declare a sysfs interface + * for itself. If a driver doesn't have a sysfs interface, then + * it should use the acpi_driver_sysfs_none() macro. + */ + +#define acpi_driver_sysfs(__name) \ +struct acpi_driver_sysfs __name##_sysfs = { \ + .s_attrs = __name##_attrs, \ + .s_num_attrs = ARRAY_SIZE(__name##_attrs), \ +} + +#define acpi_driver_sysfs_none(__name) \ +struct acpi_driver_sysfs __name##_sysfs = { \ + .s_num_attrs = 0, \ +} + + + +/* + * These macros are used by include/acpi/driver.h to + * simplify the acpi driver declaration macro by providing + * for the case where the ACPI sysfs interface is enabled or + * disabled. + */ + +#ifdef CONFIG_ACPI_DM_SYSFS + +#define acpi_driver_sysfs_extern(__name) \ +extern struct acpi_driver_sysfs __name##_sysfs + +#define acpi_driver_sysfs_ref(__name) & __name##_sysfs + +#else /* CONFIG_ACPI_DM_SYSFS */ + +#define acpi_driver_sysfs_extern(__name) +#define acpi_driver_sysfs_ref(__name) NULL + +#endif /* CONFIG_ACPI_DM_SYSFS */ --- 0.99.9.GIT