git: 11757b1487e3 - main - acpi: Statically initialize acpi_ioctl_hooks

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 26 Dec 2025 15:43:53 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=11757b1487e3e8ca0479dff5da0815b42aea3fe0

commit 11757b1487e3e8ca0479dff5da0815b42aea3fe0
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-12-26 15:37:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-26 15:37:10 +0000

    acpi: Statically initialize acpi_ioctl_hooks
    
    Reviewed by:    imp
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D54313
---
 sys/dev/acpica/acpi.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 0aae1db9e96e..8380f701d226 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -4197,8 +4197,8 @@ struct acpi_ioctl_hook
     void			 *arg;
 };
 
-static TAILQ_HEAD(,acpi_ioctl_hook)	acpi_ioctl_hooks;
-static int				acpi_ioctl_hooks_initted;
+static TAILQ_HEAD(,acpi_ioctl_hook) acpi_ioctl_hooks =
+	TAILQ_HEAD_INITIALIZER(acpi_ioctl_hooks);
 
 int
 acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg)
@@ -4211,10 +4211,6 @@ acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg)
     hp->arg = arg;
 
     ACPI_LOCK(acpi);
-    if (acpi_ioctl_hooks_initted == 0) {
-	TAILQ_INIT(&acpi_ioctl_hooks);
-	acpi_ioctl_hooks_initted = 1;
-    }
     TAILQ_FOREACH(thp, &acpi_ioctl_hooks, link) {
 	if (thp->cmd == cmd) {
 	    ACPI_UNLOCK(acpi);
@@ -4274,11 +4270,10 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
      * Scan the list of registered ioctls, looking for handlers.
      */
     ACPI_LOCK(acpi);
-    if (acpi_ioctl_hooks_initted)
-	TAILQ_FOREACH(hp, &acpi_ioctl_hooks, link) {
-	    if (hp->cmd == cmd)
-		break;
-	}
+    TAILQ_FOREACH(hp, &acpi_ioctl_hooks, link) {
+	if (hp->cmd == cmd)
+	    break;
+    }
     ACPI_UNLOCK(acpi);
     if (hp)
 	return (hp->fn(cmd, addr, hp->arg));