Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Initialize the mutex before calling xxx_rescan()...



details:   https://anonhg.NetBSD.org/src/rev/666175df3698
branches:  trunk
changeset: 342156:666175df3698
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Dec 10 05:29:41 2015 +0000

description:
Initialize the mutex before calling xxx_rescan().  Otherwise if we
load/attach an i2cbus at a later time (ie, load the iic module),
we'll end-up re-initializing the mutex.

(Caught with a LOCKDEBUG kernel)

diffstat:

 sys/dev/pci/ichsmb.c |  6 +++---
 sys/dev/pci/piixpm.c |  6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diffs (68 lines):

diff -r 7104aef16dc4 -r 666175df3698 sys/dev/pci/ichsmb.c
--- a/sys/dev/pci/ichsmb.c      Thu Dec 10 01:20:12 2015 +0000
+++ b/sys/dev/pci/ichsmb.c      Thu Dec 10 05:29:41 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ichsmb.c,v 1.44 2015/12/01 10:08:03 msaitoh Exp $      */
+/*     $NetBSD: ichsmb.c,v 1.45 2015/12/10 05:29:41 pgoyette Exp $     */
 /*     $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.44 2015/12/01 10:08:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.45 2015/12/10 05:29:41 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -188,6 +188,7 @@
 
        sc->sc_i2c_device = NULL;
        flags = 0;
+       mutex_init(&sc->sc_i2c_mutex, MUTEX_DEFAULT, IPL_NONE);
        ichsmb_rescan(self, "i2cbus", &flags);
 
 out:   if (!pmf_device_register(self, NULL, NULL))
@@ -207,7 +208,6 @@
                return 0;
 
        /* Attach I2C bus */
-       mutex_init(&sc->sc_i2c_mutex, MUTEX_DEFAULT, IPL_NONE);
        sc->sc_i2c_tag.ic_cookie = sc;
        sc->sc_i2c_tag.ic_acquire_bus = ichsmb_i2c_acquire_bus;
        sc->sc_i2c_tag.ic_release_bus = ichsmb_i2c_release_bus;
diff -r 7104aef16dc4 -r 666175df3698 sys/dev/pci/piixpm.c
--- a/sys/dev/pci/piixpm.c      Thu Dec 10 01:20:12 2015 +0000
+++ b/sys/dev/pci/piixpm.c      Thu Dec 10 05:29:41 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.46 2015/05/03 22:51:11 pgoyette Exp $ */
+/* $NetBSD: piixpm.c,v 1.47 2015/12/10 05:29:41 pgoyette Exp $ */
 /*     $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $      */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.46 2015/05/03 22:51:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.47 2015/12/10 05:29:41 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -257,6 +257,7 @@
                sc->sc_i2c_device[i] = NULL;
 
        flags = 0;
+       mutex_init(&sc->sc_i2c_mutex, MUTEX_DEFAULT, IPL_NONE);
        piixpm_rescan(self, "i2cbus", &flags);
 }
 
@@ -271,7 +272,6 @@
                return 0;
 
        /* Attach I2C bus */
-       mutex_init(&sc->sc_i2c_mutex, MUTEX_DEFAULT, IPL_NONE);
 
        for (i = 0; i < sc->sc_numbusses; i++) {
                if (sc->sc_i2c_device[i])



Home | Main Index | Thread Index | Old Index