Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: Define acpi_put_table cleanup handler and acpi_get_table_pointer() helper

Define a cleanup helper for use with __free to release the acpi table when
the pointer goes out of scope. Also, introduce the helper
acpi_get_table_pointer() to simplify a commonly used pattern involving
acpi_get_table().

These are first used in a subsequent commit.

Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Ben Horgan and committed by
Catalin Marinas
96f4a4d5 f5915600

+12
+12
include/linux/acpi.h
··· 8 8 #ifndef _LINUX_ACPI_H 9 9 #define _LINUX_ACPI_H 10 10 11 + #include <linux/cleanup.h> 11 12 #include <linux/errno.h> 12 13 #include <linux/ioport.h> /* for struct resource */ 13 14 #include <linux/resource_ext.h> ··· 221 220 void acpi_reserve_initial_tables (void); 222 221 void acpi_table_init_complete (void); 223 222 int acpi_table_init (void); 223 + 224 + static inline struct acpi_table_header *acpi_get_table_pointer(char *signature, u32 instance) 225 + { 226 + struct acpi_table_header *table; 227 + int status = acpi_get_table(signature, instance, &table); 228 + 229 + if (ACPI_FAILURE(status)) 230 + return ERR_PTR(-ENOENT); 231 + return table; 232 + } 233 + DEFINE_FREE(acpi_put_table, struct acpi_table_header *, if (!IS_ERR_OR_NULL(_T)) acpi_put_table(_T)) 224 234 225 235 int acpi_table_parse(char *id, acpi_tbl_table_handler handler); 226 236 int __init_or_acpilib acpi_table_parse_entries(char *id,