[Bug 280290] hms(4): Broken fresh after boot, fixed by resume
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 280290] hms(4): Broken fresh after boot, fixed by resume"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Oct 2024 14:10:04 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280290
--- Comment #31 from Edward Tomasz Napierala <trasz@FreeBSD.org> ---
Okay, after talking to jhb@ it appears the child devices are attaching too
early, and the easiest way to solve it is to move the call to
bus_generic_attach() further down, after power off. Here's the proposed patch:
diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c
index fc9f5c2a68b3..a2c0878697f6 100644
--- a/sys/dev/iicbus/iichid.c
+++ b/sys/dev/iicbus/iichid.c
@@ -1124,7 +1124,7 @@ iichid_attach(device_t dev)
if (error) {
device_printf(dev, "failed to reset hardware: %d\n", error);
error = ENXIO;
- goto done;
+ goto fail;
}
sc->power_on = true;
@@ -1162,7 +1162,7 @@ iichid_attach(device_t dev)
bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid,
sc->irq_res);
error = ENXIO;
- goto done;
+ goto fail;
#endif
}
@@ -1195,16 +1195,21 @@ iichid_attach(device_t dev)
device_printf(sc->dev, "Could not add I2C device\n");
iichid_detach(dev);
error = ENOMEM;
- goto done;
+ goto fail;
}
+ (void)iichid_set_power(sc, I2C_HID_POWER_OFF);
+ sc->power_on = false;
+
device_set_ivars(child, &sc->hw);
error = bus_generic_attach(dev);
if (error) {
device_printf(dev, "failed to attach child: error %d\n",
error);
iichid_detach(dev);
}
-done:
+ return (error);
+
+fail:
(void)iichid_set_power(sc, I2C_HID_POWER_OFF);
sc->power_on = false;
return (error);
--
You are receiving this mail because:
You are the assignee for the bug.