ACPI: add support for configfs
authorOctavian Purdila <octavian.purdila@intel.com>
Fri, 8 Jul 2016 16:13:13 +0000 (19:13 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 Jul 2016 19:52:35 +0000 (21:52 +0200)
Register the ACPI subsystem with configfs.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/ABI/testing/configfs-acpi [new file with mode: 0644]
MAINTAINERS
drivers/acpi/Kconfig
drivers/acpi/Makefile
drivers/acpi/configfs.c [new file with mode: 0644]

diff --git a/Documentation/ABI/testing/configfs-acpi b/Documentation/ABI/testing/configfs-acpi
new file mode 100644 (file)
index 0000000..17b19dc
--- /dev/null
@@ -0,0 +1,7 @@
+What:          /config/acpi
+Date:          July 2016
+KernelVersion: 4.8
+Contact:       linux-acpi@vger.kernel.org
+Description:
+               This represents the ACPI subsystem entry point directory. It
+               contains sub-groups corresponding to ACPI configurable options.
index e1b090f86e0dd1ae4bf328f93b74f5d00236dbc8..d01d8e2cf268be9ec0dee3ea3fb7234317eee06f 100644 (file)
@@ -288,6 +288,7 @@ F:  include/linux/acpi.h
 F:     include/acpi/
 F:     Documentation/acpi/
 F:     Documentation/ABI/testing/sysfs-bus-acpi
+F:     Documentation/ABI/testing/configfs-acpi
 F:     drivers/pci/*acpi*
 F:     drivers/pci/*/*acpi*
 F:     drivers/pci/*/*/*acpi*
index 0a8e41a52d09bf0b8c6755e5763c77336a903a93..b420e5dd8a56921c6af9aed2575d984d1ba42b45 100644 (file)
@@ -524,4 +524,12 @@ config XPOWER_PMIC_OPREGION
 
 endif
 
+config ACPI_CONFIGFS
+       tristate "ACPI configfs support"
+       select CONFIGFS_FS
+       help
+         Select this option to enable support for ACPI configuration from
+         userspace. The configurable ACPI groups will be visible under
+         /config/acpi, assuming configfs is mounted under /config.
+
 endif  # ACPI
index 251ce85a66fbb4460e6c379d39f7ddd0e2062ce8..1dc2173ad8d027f63bc30b25404f771dc140f309 100644 (file)
@@ -99,5 +99,6 @@ obj-$(CONFIG_ACPI_EXTLOG)     += acpi_extlog.o
 obj-$(CONFIG_PMIC_OPREGION)    += pmic/intel_pmic.o
 obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
+obj-$(CONFIG_ACPI_CONFIGFS)    += configfs.o
 
 video-objs                     += acpi_video.o video_detect.o
diff --git a/drivers/acpi/configfs.c b/drivers/acpi/configfs.c
new file mode 100644 (file)
index 0000000..44b463f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ACPI configfs support
+ *
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/configfs.h>
+#include <linux/acpi.h>
+
+static struct config_item_type acpi_root_group_type = {
+       .ct_owner = THIS_MODULE,
+};
+
+static struct configfs_subsystem acpi_configfs = {
+       .su_group = {
+               .cg_item = {
+                       .ci_namebuf = "acpi",
+                       .ci_type = &acpi_root_group_type,
+               },
+       },
+       .su_mutex = __MUTEX_INITIALIZER(acpi_configfs.su_mutex),
+};
+
+static int __init acpi_configfs_init(void)
+{
+       int ret;
+       struct config_group *root = &acpi_configfs.su_group;
+
+       config_group_init(root);
+
+       ret = configfs_register_subsystem(&acpi_configfs);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+module_init(acpi_configfs_init);
+
+static void __exit acpi_configfs_exit(void)
+{
+       configfs_unregister_subsystem(&acpi_configfs);
+}
+module_exit(acpi_configfs_exit);
+
+MODULE_AUTHOR("Octavian Purdila <octavian.purdila@intel.com>");
+MODULE_DESCRIPTION("ACPI configfs support");
+MODULE_LICENSE("GPL v2");