ACPI: add some helper macros and functions
Subsystems (2)
PATCH 1/8 ACPI: add some helper macros and functions
From: Zhang Rui <[email protected]>
Add some helper macros and functions for ACPI device sysfs duplication.
Signed-off-by Zhang Rui <[email protected]>
--- drivers/acpi/scan.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
include/acpi/acpi_drivers.h +44 -0
@@ -45,6 +45,50 @@#define ACPI_VIDEO_HID "video"#define ACPI_BAY_HID "bay"/* -------------------------------------------------------------------------- +Sysfs +-------------------------------------------------------------------------- */ +typedef ssize_t (*acpi_show )(struct acpi_device *dev,char *buf); +typedef ssize_t (*acpi_store )(struct acpi_device *dev,const char *buf,size_t count); + +struct acpi_device_attr { +struct device_attribute attr; +acpi_show show; +acpi_store store; +}; + +ssize_t __acpi_show (struct device *dev,struct device_attribute *attr,char *buf); +ssize_t __acpi_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t countf); + +#define ACPI_DEVICE_ATTR (_name, _mode, _show, _store) \ +struct acpi_device_attr _name##_attr = \ +{ \ + .attr = __ATTR(_name, _mode, __acpi_show, __acpi_store), \ + .show = _show, \ + .store = _store, \ +} + +#define GET_ATTR (_name) &(_name##_attr.attr.attr) +#define GET_DEV_ATTR (_name) &(_name##_attr.attr) + +int acpi_device_add_sysfs (struct acpi_device *device,struct device_attribute **dev_attr); +void acpi_device_remove_sysfs (struct acpi_device *device,struct device_attribute **dev_attr); + +#ifndef CONFIG_ACPI_PROCFS +#define DECLARE_ACPI_DEVICE_PROCFS (_name) \ +static int acpi_##_name##_add_procfs(struct acpi_device *device) { \ + return 0; \ +} \ +static void acpi_##_name##_remove_procfs(struct acpi_device *device) { \ + return ; \ +} \ +static int acpi_##_name##_procfs_init(void) { \ + return 0; \ +} \ +static void acpi_##_name##_procfs_exit(void) { \ + return ; \ +} +#endif +/* -------------------------------------------------------------------------- PCI -------------------------------------------------------------------------- */
drivers/acpi/scan.c +55 -0
61 lines not on this page · raw message