^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ACPI configfs support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2016 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define pr_fmt(fmt) "ACPI configfs: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/configfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "acpica/accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "acpica/actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static struct config_group *acpi_table_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct acpi_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct config_item cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct acpi_table_header *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static ssize_t acpi_table_aml_write(struct config_item *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) const void *data, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) const struct acpi_table_header *header = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct acpi_table *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int ret = security_locked_down(LOCKDOWN_ACPI_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) table = container_of(cfg, struct acpi_table, cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if (table->header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) pr_err("table already loaded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (header->length != size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) pr_err("invalid table length\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (memcmp(header->signature, ACPI_SIG_SSDT, 4)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) pr_err("invalid table signature\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) table = container_of(cfg, struct acpi_table, cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) table->header = kmemdup(header, header->length, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (!table->header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ret = acpi_load_table(table->header, &table->index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) kfree(table->header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) table->header = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static inline struct acpi_table_header *get_header(struct config_item *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct acpi_table *table = container_of(cfg, struct acpi_table, cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (!table->header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) pr_err("table not loaded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return table->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static ssize_t acpi_table_aml_read(struct config_item *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) void *data, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) memcpy(data, h, h->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return h->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define MAX_ACPI_TABLE_SIZE (128 * 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) CONFIGFS_BIN_ATTR(acpi_table_, aml, NULL, MAX_ACPI_TABLE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static struct configfs_bin_attribute *acpi_table_bin_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) &acpi_table_attr_aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static ssize_t acpi_table_length_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return sprintf(str, "%d\n", h->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return sprintf(str, "%d\n", h->revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return sprintf(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return sprintf(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return sprintf(str, "%d\n", h->oem_revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct acpi_table_header *h = get_header(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return sprintf(str, "%d\n", h->asl_compiler_revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) CONFIGFS_ATTR_RO(acpi_table_, signature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) CONFIGFS_ATTR_RO(acpi_table_, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) CONFIGFS_ATTR_RO(acpi_table_, revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) CONFIGFS_ATTR_RO(acpi_table_, oem_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) CONFIGFS_ATTR_RO(acpi_table_, oem_table_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) CONFIGFS_ATTR_RO(acpi_table_, oem_revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static struct configfs_attribute *acpi_table_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) &acpi_table_attr_signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) &acpi_table_attr_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) &acpi_table_attr_revision,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) &acpi_table_attr_oem_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) &acpi_table_attr_oem_table_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) &acpi_table_attr_oem_revision,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) &acpi_table_attr_asl_compiler_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) &acpi_table_attr_asl_compiler_revision,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static const struct config_item_type acpi_table_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .ct_owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .ct_bin_attrs = acpi_table_bin_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) .ct_attrs = acpi_table_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static struct config_item *acpi_table_make_item(struct config_group *group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct acpi_table *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) table = kzalloc(sizeof(*table), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (!table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) config_item_init_type_name(&table->cfg, name, &acpi_table_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return &table->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static void acpi_table_drop_item(struct config_group *group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct config_item *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct acpi_table *table = container_of(cfg, struct acpi_table, cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ACPI_INFO(("Host-directed Dynamic ACPI Table Unload"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) acpi_unload_table(table->index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) config_item_put(cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static struct configfs_group_operations acpi_table_group_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) .make_item = acpi_table_make_item,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) .drop_item = acpi_table_drop_item,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static const struct config_item_type acpi_tables_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .ct_owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .ct_group_ops = &acpi_table_group_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static const struct config_item_type acpi_root_group_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) .ct_owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static struct configfs_subsystem acpi_configfs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .su_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .cg_item = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .ci_namebuf = "acpi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .ci_type = &acpi_root_group_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .su_mutex = __MUTEX_INITIALIZER(acpi_configfs.su_mutex),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static int __init acpi_configfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct config_group *root = &acpi_configfs.su_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) config_group_init(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ret = configfs_register_subsystem(&acpi_configfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) acpi_table_group = configfs_register_default_group(root, "table",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) &acpi_tables_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (IS_ERR(acpi_table_group)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) configfs_unregister_subsystem(&acpi_configfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) return PTR_ERR(acpi_table_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) module_init(acpi_configfs_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static void __exit acpi_configfs_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) configfs_unregister_default_group(acpi_table_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) configfs_unregister_subsystem(&acpi_configfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) module_exit(acpi_configfs_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) MODULE_AUTHOR("Octavian Purdila <octavian.purdila@intel.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) MODULE_DESCRIPTION("ACPI configfs support");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) MODULE_LICENSE("GPL v2");