[PATCH v6 05/16] ACPI: processor: Add acpi_get_processor_handle() helper

Jonathan Cameron Jonathan.Cameron at huawei.com
Wed Apr 17 06:18:58 PDT 2024


If CONFIG_ACPI_PROCESSOR provide a helper to retriever the
acpi_handle for a given CPU allowing access to methods
in DSDT.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron at huawei.com>
---
v6: New patch
---
 drivers/acpi/acpi_processor.c | 10 ++++++++++
 include/linux/acpi.h          |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 2c164451ab53..7ecb13775d7f 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -35,6 +35,16 @@ EXPORT_PER_CPU_SYMBOL(processors);
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
+acpi_handle acpi_get_processor_handle(int cpu)
+{
+	acpi_handle handle = NULL;
+	struct acpi_processor *pr = per_cpu(processors, cpu);;
+
+	if (pr)
+		handle = pr->handle;
+
+	return handle;
+}
 static int acpi_processor_errata_piix4(struct pci_dev *dev)
 {
 	u8 value1 = 0;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 34829f2c517a..9844a3f9c4e5 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -309,6 +309,8 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
 int acpi_unmap_cpu(int cpu);
 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
 
+acpi_handle acpi_get_processor_handle(int cpu);
+
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
 int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
 #endif
@@ -1077,6 +1079,11 @@ static inline bool acpi_sleep_state_supported(u8 sleep_state)
 	return false;
 }
 
+static inline acpi_handle acpi_get_processor_handle(int cpu)
+{
+	return NULL;
+}
+
 #endif	/* !CONFIG_ACPI */
 
 extern void arch_post_acpi_subsys_init(void);
-- 
2.39.2




More information about the linux-arm-kernel mailing list