git: 381840e88072 - main - acpi_timer: Remove unneeded acpi_timer_freq global variable
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Sep 2026 16:05:18 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=381840e88072a90df7ffb5731c08935412edbc19
commit 381840e88072a90df7ffb5731c08935412edbc19
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-09-30 16:04:59 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-09-30 16:04:59 +0000
acpi_timer: Remove unneeded acpi_timer_freq global variable
This was just an alias of acpi_timer_timecounter.tc_frequency. While
here, register the machdep.acpi_timer_freq sysctl node dynamically
only if the driver attaches rather than making the handler fail with
EOPNOTSUPP if the driver had not attached.
Differential Revision: https://reviews.freebsd.org/D59935
---
sys/dev/acpica/acpi_timer.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index cc782f6d5ba6..68513e437282 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -60,7 +60,7 @@ static device_t acpi_timer_dev;
static struct resource *acpi_timer_reg;
static eventhandler_tag acpi_timer_eh;
-static u_int acpi_timer_frequency = 14318182 / 4;
+#define ACPI_TIMER_FREQUENCY (14318182 / 4)
static void acpi_timer_identify(driver_t *driver, device_t parent);
static int acpi_timer_probe(device_t dev);
@@ -157,7 +157,7 @@ acpi_timer_probe(device_t dev)
device_set_descf(dev, "%d-bit timer at %u.%06uMHz",
(AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24,
- acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000);
+ ACPI_TIMER_FREQUENCY / 1000000, ACPI_TIMER_FREQUENCY % 1000000);
return (0);
}
@@ -194,10 +194,14 @@ acpi_timer_attach(device_t dev)
acpi_timer_timecounter.tc_counter_mask = 0xffffffff;
else
acpi_timer_timecounter.tc_counter_mask = 0x00ffffff;
- acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
+ acpi_timer_timecounter.tc_frequency = ACPI_TIMER_FREQUENCY;
tc_init(&acpi_timer_timecounter);
+ SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO,
+ "acpi_timer_freq", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
+ NULL, 0, acpi_timer_sysctl_freq, "I", "ACPI timer frequency");
+
return (0);
}
@@ -268,19 +272,11 @@ acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
int error;
u_int freq;
- if (acpi_timer_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = acpi_timer_frequency;
+ freq = acpi_timer_timecounter.tc_frequency;
error = sysctl_handle_int(oidp, &freq, 0, req);
if (error == 0 && req->newptr != NULL) {
- acpi_timer_frequency = freq;
- acpi_timer_timecounter.tc_frequency = acpi_timer_frequency;
+ acpi_timer_timecounter.tc_frequency = freq;
}
return (error);
}
-
-SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq,
- CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
- acpi_timer_sysctl_freq, "I",
- "ACPI timer frequency");