From b495a98be001058cf45d7ed7bfadc89926ccf8bb Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Thu, 9 Mar 2023 12:06:57 -0500 Subject: [PATCH] ACPI: LPSS: Replace loop with first entry retrieval Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554 commit da13b3361bb609f5e3fde3f57b8e2b42001513a3 Author: Andy Shevchenko Date: Mon, 29 Aug 2022 17:11:28 +0300 After the commit 6505e452371d ("ACPI: LPSS: Use the helper acpi_dev_get_memory_resources()") the list is empty or contains only resource of IORESOURCE_MEM type. Hence, no need to check for the type, and since we break after the first found, no need to iterate over full list. That said, replace loop with first entry retrieval. Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki Signed-off-by: Mark Langsdorf --- drivers/acpi/acpi_lpss.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 9dc7defcc425..fd29777fa4d0 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -655,16 +655,14 @@ static int acpi_lpss_create_device(struct acpi_device *adev, if (ret < 0) goto err_out; - list_for_each_entry(rentry, &resource_list, node) - if (resource_type(rentry->res) == IORESOURCE_MEM) { - if (dev_desc->prv_size_override) - pdata->mmio_size = dev_desc->prv_size_override; - else - pdata->mmio_size = resource_size(rentry->res); - pdata->mmio_base = ioremap(rentry->res->start, - pdata->mmio_size); - break; - } + rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node); + if (rentry) { + if (dev_desc->prv_size_override) + pdata->mmio_size = dev_desc->prv_size_override; + else + pdata->mmio_size = resource_size(rentry->res); + pdata->mmio_base = ioremap(rentry->res->start, pdata->mmio_size); + } acpi_dev_free_resource_list(&resource_list);