diff mbox series

[v1,4/7] ACPI: scan: Use list_first_entry_or_null() in acpi_device_hid()

Message ID 20240325123444.3031851-5-andriy.shevchenko@linux.intel.com
State Accepted
Commit 2649a0f29a39f455ff39eb2296269e20df3bba0d
Headers show
Series ACPI: scan: A few ad-hoc cleanups | expand

Commit Message

Andy Shevchenko March 25, 2024, 12:33 p.m. UTC
To replace list_empty() + list_first_entry() pair to simplify code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/scan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5e4118970285..f5581d3701f1 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1296,10 +1296,10 @@  const char *acpi_device_hid(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hid;
 
-	if (list_empty(&device->pnp.ids))
+	hid = list_first_entry_or_null(&device->pnp.ids, struct acpi_hardware_id, list);
+	if (!hid)
 		return dummy_hid;
 
-	hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
 	return hid->id;
 }
 EXPORT_SYMBOL(acpi_device_hid);