git: 3514f98940a0 - main - newbus: Introduce bus_get_pass() and hide bus_current_pass
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 02 Nov 2024 18:25:14 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=3514f98940a0d43264ef9e13990c8c70a4252e04
commit 3514f98940a0d43264ef9e13990c8c70a4252e04
Author: Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2024-10-06 00:19:04 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-11-02 18:25:34 +0000
newbus: Introduce bus_get_pass() and hide bus_current_pass
There's no reason to write to bus_current_pass outside of the controlled
times subr_bus.c does it, so move to an accessor and make
bus_current_pass private to newbus.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1457
---
sys/arm/freescale/imx/imx6_anatop.c | 2 +-
sys/arm/nvidia/drm2/tegra_host1x.c | 2 +-
sys/arm/ti/omap4/omap4_prcm_clks.c | 2 +-
sys/kern/subr_bus.c | 18 ++++++++++++++++--
sys/sys/bus.h | 4 +---
5 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c
index d0daa7c951de..740f185bfb8b 100644
--- a/sys/arm/freescale/imx/imx6_anatop.c
+++ b/sys/arm/freescale/imx/imx6_anatop.c
@@ -670,7 +670,7 @@ imx6_anatop_new_pass(device_t dev)
* that attach on the CPU pass).
*/
sc = device_get_softc(dev);
- if (!sc->cpu_init_done && bus_current_pass >= cpu_init_pass) {
+ if (!sc->cpu_init_done && bus_get_pass() >= cpu_init_pass) {
sc->cpu_init_done = true;
cpufreq_initialize(sc);
initialize_tempmon(sc);
diff --git a/sys/arm/nvidia/drm2/tegra_host1x.c b/sys/arm/nvidia/drm2/tegra_host1x.c
index 4384ab0bc976..e04a50e4c003 100644
--- a/sys/arm/nvidia/drm2/tegra_host1x.c
+++ b/sys/arm/nvidia/drm2/tegra_host1x.c
@@ -448,7 +448,7 @@ host1x_new_pass(device_t dev)
* but some of our FDT resources are not ready until BUS_PASS_DEFAULT
*/
sc = device_get_softc(dev);
- if (sc->attach_done || bus_current_pass < BUS_PASS_DEFAULT) {
+ if (sc->attach_done || bus_get_pass() < BUS_PASS_DEFAULT) {
bus_generic_new_pass(dev);
return;
}
diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c
index 73ef67a19d47..63c679f178bc 100644
--- a/sys/arm/ti/omap4/omap4_prcm_clks.c
+++ b/sys/arm/ti/omap4/omap4_prcm_clks.c
@@ -1459,7 +1459,7 @@ omap4_prcm_new_pass(device_t dev)
unsigned int freq;
if (sc->attach_done ||
- bus_current_pass < (BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY)) {
+ bus_get_pass() < (BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY)) {
bus_generic_new_pass(dev);
return;
}
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index c1f75dd30126..2dbe1072aa83 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -437,7 +437,7 @@ bus_topo_unlock(void)
*/
static driver_list_t passes = TAILQ_HEAD_INITIALIZER(passes);
-int bus_current_pass = BUS_PASS_ROOT;
+static int bus_current_pass = BUS_PASS_ROOT;
/**
* @internal
@@ -474,6 +474,20 @@ driver_register_pass(struct driverlink *new)
TAILQ_INSERT_TAIL(&passes, new, passlink);
}
+/**
+ * @brief Retrieve the current bus pass
+ *
+ * Retrieves the current bus pass level. Call the BUS_NEW_PASS()
+ * method on the root bus to kick off a new device tree scan for each
+ * new pass level that has at least one driver.
+ */
+int
+bus_get_pass(void)
+{
+
+ return (bus_current_pass);
+}
+
/**
* @brief Raise the current bus pass
*
@@ -481,7 +495,7 @@ driver_register_pass(struct driverlink *new)
* method on the root bus to kick off a new device tree scan for each
* new pass level that has at least one driver.
*/
-void
+static void
bus_set_pass(int pass)
{
struct driverlink *dl;
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 4f34990cd10f..1f5e074cfe5a 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -818,9 +818,7 @@ void bus_data_generation_update(void);
#define BUS_LOCATOR_UEFI "UEFI"
#define BUS_LOCATOR_OFW "OFW"
-extern int bus_current_pass;
-
-void bus_set_pass(int pass);
+int bus_get_pass(void);
/**
* Routines to lock / unlock the newbus lock.