All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] ACPI: LPSS: Replace loop with first entry retrieval
@ 2022-08-29 14:11 Andy Shevchenko
  2022-08-29 14:11 ` [PATCH v1 2/2] ACPI: LPSS: Deduplicate skipping device in acpi_lpss_create_device() Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-08-29 14:11 UTC (permalink / raw)
  To: linux-acpi, linux-kernel; +Cc: Rafael J. Wysocki, Len Brown, Andy Shevchenko

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 <andriy.shevchenko@linux.intel.com>
---
 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 4f6cba8fe8de..c39a0a88f3a3 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -656,16 +656,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);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-03 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 14:11 [PATCH v1 1/2] ACPI: LPSS: Replace loop with first entry retrieval Andy Shevchenko
2022-08-29 14:11 ` [PATCH v1 2/2] ACPI: LPSS: Deduplicate skipping device in acpi_lpss_create_device() Andy Shevchenko
2022-09-03 18:49   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.