git: accda7815317 - main - simple_mfd: don't attach children twice

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Fri, 08 Mar 2024 14:10:07 UTC
The branch main has been updated by mhorne:

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

commit accda781531788a814bc438e1e96ef544c12aeaf
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-03-08 14:09:17 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-03-08 14:09:36 +0000

    simple_mfd: don't attach children twice
    
    Trying to probe+attach the child device at the point it is added comes
    before the syscon handle is set up (if relevant). It will therefore be
    unavailable to the attach method which is expecting it, and the first
    attempt to attach the device will fail.
    
    Just rely on the call to bus_generic_attach() at the end of the function
    to perform probe+attach of dev's children.
    
    Reviewed by:    manu
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D44268
---
 sys/dev/fdt/simple_mfd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sys/dev/fdt/simple_mfd.c b/sys/dev/fdt/simple_mfd.c
index 3ca7578d234d..5228c6998821 100644
--- a/sys/dev/fdt/simple_mfd.c
+++ b/sys/dev/fdt/simple_mfd.c
@@ -168,7 +168,6 @@ simple_mfd_attach(device_t dev)
 {
 	struct simple_mfd_softc *sc;
 	phandle_t node, child;
-	device_t cdev;
 	int rid;
 
 	sc = device_get_softc(dev);
@@ -203,9 +202,7 @@ simple_mfd_attach(device_t dev)
 
 	/* Attach child devices */
 	for (child = OF_child(node); child > 0; child = OF_peer(child)) {
-		cdev = simple_mfd_add_device(dev, child, 0, NULL, -1, NULL);
-		if (cdev != NULL)
-			device_probe_and_attach(cdev);
+		(void)simple_mfd_add_device(dev, child, 0, NULL, -1, NULL);
 	}
 
 	if (ofw_bus_is_compatible(dev, "syscon")) {