From c75c99aafef5f36520547f9f319f774035cfea9c Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 14 Jul 2026 20:53:40 +0200 Subject: [PATCH] ACPI: utils: Introduce acpi_dev_is_video_device() helper There are a couple of users that open code functionality of matching a given handle against ACPI video device IDs. The current approach duplicates ID table along with the matching code. Consolidate it under the acpi_dev_is_video_device() helper's hood. Signed-off-by: Andy Shevchenko [ rjw: Moved the static var declaration into the function body ] Link: https://patch.msgid.link/20260714185915.865396-2-andriy.shevchenko@linux.intel.com Signed-off-by: Rafael J. Wysocki --- drivers/acpi/utils.c | 17 +++++++++++++++++ include/linux/acpi.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 6ab27e4826d1..d499b72574ab 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -1047,6 +1047,23 @@ static int __init acpi_backlight(char *str) } __setup("acpi_backlight=", acpi_backlight); +/** + * acpi_dev_is_video_device - test if device matches against ACPI video device IDs + * @adev: ACPI device to test + * + * Return: true when matches, otherwise false. + */ +bool acpi_dev_is_video_device(struct acpi_device *adev) +{ + static const struct acpi_device_id video_device_ids[] = { + { .id = ACPI_VIDEO_HID }, + { } + }; + + return adev && !acpi_match_device_ids(adev, video_device_ids); +} +EXPORT_SYMBOL(acpi_dev_is_video_device); + /** * acpi_match_platform_list - Check if the system matches with a given list * @plat: pointer to acpi_platform_list table terminated by a NULL entry diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 67effb91fa98..c6bd5ee1688d 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -448,6 +448,7 @@ extern char *wmi_get_acpi_device_uid(const char *guid); #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 extern char acpi_video_backlight_string[]; +extern bool acpi_dev_is_video_device(struct acpi_device *adev); extern long acpi_is_video_device(acpi_handle handle); extern void acpi_osi_setup(char *str);