git: 9319a8a11a6f - stable/14 - simple_mfd: don't attach children twice

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 18 Apr 2024 18:12:30 UTC
The branch stable/14 has been updated by mhorne:

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

commit 9319a8a11a6fcebc87109f8bf0f5dc362dd1fe07
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-03-08 14:09:17 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-04-18 18:11:31 +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
    
    (cherry picked from commit accda781531788a814bc438e1e96ef544c12aeaf)
---
 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 888de7756f39..865cd0e2b9ab 100644
--- a/sys/dev/fdt/simple_mfd.c
+++ b/sys/dev/fdt/simple_mfd.c
@@ -169,7 +169,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);
@@ -204,9 +203,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")) {