Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci ichsmb(4): Attach i2c bus only once.



details:   https://anonhg.NetBSD.org/src/rev/9bed96f473e2
branches:  trunk
changeset: 370647:9bed96f473e2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Sep 22 14:44:47 2022 +0000

description:
ichsmb(4): Attach i2c bus only once.

The child could be detached, e.g. with drvctl, and then the bus
rescanned, at which point it would reinitialize a mutex without
destroying it.

diffstat:

 sys/dev/pci/ichsmb.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (42 lines):

diff -r da8af35a777d -r 9bed96f473e2 sys/dev/pci/ichsmb.c
--- a/sys/dev/pci/ichsmb.c      Thu Sep 22 14:43:04 2022 +0000
+++ b/sys/dev/pci/ichsmb.c      Thu Sep 22 14:44:47 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ichsmb.c,v 1.77 2022/09/13 11:47:54 msaitoh Exp $      */
+/*     $NetBSD: ichsmb.c,v 1.78 2022/09/22 14:44:47 riastradh Exp $    */
 /*     $OpenBSD: ichiic.c,v 1.44 2020/10/07 11:23:05 jsg Exp $ */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.77 2022/09/13 11:47:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.78 2022/09/22 14:44:47 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -222,6 +222,11 @@
                        aprint_normal_dev(self, "polling\n");
        }
 
+       /* Attach I2C bus */
+       iic_tag_init(&sc->sc_i2c_tag);
+       sc->sc_i2c_tag.ic_cookie = sc;
+       sc->sc_i2c_tag.ic_exec = ichsmb_i2c_exec;
+
        sc->sc_i2c_device = NULL;
        ichsmb_rescan(self, NULL, NULL);
 
@@ -238,11 +243,6 @@
        if (sc->sc_i2c_device != NULL)
                return 0;
 
-       /* Attach I2C bus */
-       iic_tag_init(&sc->sc_i2c_tag);
-       sc->sc_i2c_tag.ic_cookie = sc;
-       sc->sc_i2c_tag.ic_exec = ichsmb_i2c_exec;
-
        memset(&iba, 0, sizeof(iba));
        iba.iba_tag = &sc->sc_i2c_tag;
        sc->sc_i2c_device = config_found(self, &iba, iicbus_print, CFARGS_NONE);



Home | Main Index | Thread Index | Old Index