[PATCH RFC 2/3] amba: bus: Move empty @amba_proxy_drv's definition to the front

From: Zijun Hu
Date: Sun Sep 08 2024 - 19:38:55 EST


From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>

Move empty @amba_proxy_drv's definition to the front in preparation for
referring to it without forward declaration.

Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
---
drivers/amba/bus.c | 72 +++++++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index cc3c57f83798..033d626aff46 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -205,6 +205,42 @@ static int amba_read_periphid(struct amba_device *dev)
return ret;
}

+static int amba_proxy_probe(struct amba_device *adev,
+ const struct amba_id *id)
+{
+ WARN(1, "Stub driver should never match any device.\n");
+ return -ENODEV;
+}
+
+static const struct amba_id amba_stub_drv_ids[] = {
+ { 0, 0 },
+};
+
+static struct amba_driver amba_proxy_drv = {
+ .drv = {
+ .name = "amba-proxy",
+ },
+ .probe = amba_proxy_probe,
+ .id_table = amba_stub_drv_ids,
+};
+
+static int __init amba_stub_drv_init(void)
+{
+ if (!IS_ENABLED(CONFIG_MODULES))
+ return 0;
+
+ /*
+ * The amba_match() function will get called only if there is at least
+ * one amba driver registered. If all amba drivers are modules and are
+ * only loaded based on uevents, then we'll hit a chicken-and-egg
+ * situation where amba_match() is waiting on drivers and drivers are
+ * waiting on amba_match(). So, register a stub driver to make sure
+ * amba_match() is called even if no amba driver has been registered.
+ */
+ return __amba_driver_register(&amba_proxy_drv, NULL);
+}
+late_initcall_sync(amba_stub_drv_init);
+
static int amba_match(struct device *dev, const struct device_driver *drv)
{
struct amba_device *pcdev = to_amba_device(dev);
@@ -456,42 +492,6 @@ static int __init amba_init(void)

postcore_initcall(amba_init);

-static int amba_proxy_probe(struct amba_device *adev,
- const struct amba_id *id)
-{
- WARN(1, "Stub driver should never match any device.\n");
- return -ENODEV;
-}
-
-static const struct amba_id amba_stub_drv_ids[] = {
- { 0, 0 },
-};
-
-static struct amba_driver amba_proxy_drv = {
- .drv = {
- .name = "amba-proxy",
- },
- .probe = amba_proxy_probe,
- .id_table = amba_stub_drv_ids,
-};
-
-static int __init amba_stub_drv_init(void)
-{
- if (!IS_ENABLED(CONFIG_MODULES))
- return 0;
-
- /*
- * The amba_match() function will get called only if there is at least
- * one amba driver registered. If all amba drivers are modules and are
- * only loaded based on uevents, then we'll hit a chicken-and-egg
- * situation where amba_match() is waiting on drivers and drivers are
- * waiting on amba_match(). So, register a stub driver to make sure
- * amba_match() is called even if no amba driver has been registered.
- */
- return __amba_driver_register(&amba_proxy_drv, NULL);
-}
-late_initcall_sync(amba_stub_drv_init);
-
/**
* __amba_driver_register - register an AMBA device driver
* @drv: amba device driver structure

--
2.34.1