All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	acpica-devel@lists.linux.dev
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	Robert Moore <robert.moore@intel.com>
Subject: [PATCH v1 4/7] ACPI: scan: Use list_first_entry_or_null() in acpi_device_hid()
Date: Mon, 25 Mar 2024 14:33:00 +0200	[thread overview]
Message-ID: <20240325123444.3031851-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240325123444.3031851-1-andriy.shevchenko@linux.intel.com>

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 --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);
-- 
2.43.0.rc1.1.gbec44491f096


  parent reply	other threads:[~2024-03-25 12:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 12:32 [PATCH v1 0/7] ACPI: scan: A few ad-hoc cleanups Andy Shevchenko
2024-03-25 12:32 ` [PATCH v1 1/7] ACPI: bus: Make container_of() no-op where it makes sense Andy Shevchenko
2024-03-25 12:32 ` [PATCH v1 2/7] ACPI: bus: Don't use "proxy" headers Andy Shevchenko
2024-03-25 12:32 ` [PATCH v1 3/7] ACPI: scan: Replace infinite for-loop with finite while-loop Andy Shevchenko
2024-04-04 19:22   ` Rafael J. Wysocki
2024-04-04 19:26     ` Andy Shevchenko
2024-03-25 12:33 ` Andy Shevchenko [this message]
2024-03-25 12:33 ` [PATCH v1 5/7] ACPI: scan: Move misleading comment to acpi_dma_configure_id() Andy Shevchenko
2024-03-25 12:33 ` [PATCH v1 6/7] ACPI: scan: Use standard error checking pattern Andy Shevchenko
2024-03-25 12:33 ` [PATCH v1 7/7] ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members Andy Shevchenko
2024-03-27  5:50 ` [PATCH v1 0/7] ACPI: scan: A few ad-hoc cleanups Kuppuswamy Sathyanarayanan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325123444.3031851-5-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=robert.moore@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.