The branch main has been updated by jhb:

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

commit 13a1dbfed57b167a6dc4d68b60115eb0e070b9b6
Author:     John Baldwin <j...@freebsd.org>
AuthorDate: 2024-10-31 19:49:41 +0000
Commit:     John Baldwin <j...@freebsd.org>
CommitDate: 2024-10-31 19:49:41 +0000

    vf_i2c: Don't hold a mutex across bus_generic_detach
    
    This was also leaking the lock if bus_generic_detach failed.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D47221
---
 sys/dev/iicbus/controller/vybrid/vf_i2c.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/iicbus/controller/vybrid/vf_i2c.c 
b/sys/dev/iicbus/controller/vybrid/vf_i2c.c
index 0a0b9d0cb35a..ea0e1eeac7fb 100644
--- a/sys/dev/iicbus/controller/vybrid/vf_i2c.c
+++ b/sys/dev/iicbus/controller/vybrid/vf_i2c.c
@@ -207,13 +207,6 @@ i2c_detach(device_t dev)
        sc = device_get_softc(dev);
        vf_i2c_dbg(sc, "i2c detach\n");
 
-       mtx_lock(&sc->mutex);
-
-       if (sc->freq == 0) {
-               vf_i2c_dbg(sc, "Writing 0x00 to clock divider register\n");
-               WRITE1(sc, I2C_IBFD, 0x00);
-       }
-
        error = bus_generic_detach(dev);
        if (error != 0) {
                device_printf(dev, "cannot detach child devices.\n");
@@ -226,6 +219,13 @@ i2c_detach(device_t dev)
                return (error);
        }
 
+       mtx_lock(&sc->mutex);
+
+       if (sc->freq == 0) {
+               vf_i2c_dbg(sc, "Writing 0x00 to clock divider register\n");
+               WRITE1(sc, I2C_IBFD, 0x00);
+       }
+
        bus_release_resources(dev, i2c_spec, sc->res);
 
        mtx_unlock(&sc->mutex);

Reply via email to