Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/pci/piixpm.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/pci/piixpm.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.37.6.1 retrieving revision 1.38 diff -u -p -r1.37.6.1 -r1.38 --- src/sys/dev/pci/piixpm.c 2012/02/18 07:34:50 1.37.6.1 +++ src/sys/dev/pci/piixpm.c 2012/01/07 15:59:46 1.38 @@ -1,4 +1,4 @@ -/* $NetBSD: piixpm.c,v 1.37.6.1 2012/02/18 07:34:50 mrg Exp $ */ +/* $NetBSD: piixpm.c,v 1.38 2012/01/07 15:59:46 pgoyette Exp $ */ /* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */ /* @@ -22,13 +22,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.37.6.1 2012/02/18 07:34:50 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.38 2012/01/07 15:59:46 pgoyette Exp $"); #include #include #include #include -#include +#include #include #include @@ -82,7 +82,7 @@ struct piixpm_softc { pcireg_t sc_id; struct i2c_controller sc_i2c_tag; - kmutex_t sc_i2c_mutex; + krwlock_t sc_i2c_rwlock; struct { i2c_op_t op; void * buf; @@ -158,6 +158,7 @@ piixpm_attach(device_t parent, device_t pcireg_t base, conf; pcireg_t pmmisc; pci_intr_handle_t ih; + char devinfo[256]; const char *intrstr = NULL; sc->sc_dev = self; @@ -165,7 +166,11 @@ piixpm_attach(device_t parent, device_t sc->sc_pc = pa->pa_pc; sc->sc_pcitag = pa->pa_tag; - pci_aprint_devinfo(pa, NULL); + aprint_naive("\n"); + + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); + aprint_normal(": %s (rev. 0x%02x)\n", devinfo, + PCI_REVISION(pa->pa_class)); if (!pmf_device_register(self, piixpm_suspend, piixpm_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); @@ -251,7 +256,7 @@ nopowermanagement: attach_i2c: /* Attach I2C bus */ - mutex_init(&sc->sc_i2c_mutex, MUTEX_DEFAULT, IPL_NONE); + rw_init(&sc->sc_i2c_rwlock); sc->sc_i2c_tag.ic_cookie = sc; sc->sc_i2c_tag.ic_acquire_bus = piixpm_i2c_acquire_bus; sc->sc_i2c_tag.ic_release_bus = piixpm_i2c_release_bus; @@ -331,7 +336,6 @@ piixpm_sb800_init(struct piixpm_softc *s aprint_error_dev(sc->sc_dev, "can't map smbus I/O space\n"); return EBUSY; } - aprint_normal_dev(sc->sc_dev, "polling (SB800)\n"); sc->sc_poll = 1; return 0; @@ -363,9 +367,10 @@ piixpm_i2c_acquire_bus(void *cookie, int { struct piixpm_softc *sc = cookie; - if (!cold) - mutex_enter(&sc->sc_i2c_mutex); + if (cold || sc->sc_poll || (flags & I2C_F_POLL)) + return (0); + rw_enter(&sc->sc_i2c_rwlock, RW_WRITER); return 0; } @@ -374,8 +379,10 @@ piixpm_i2c_release_bus(void *cookie, int { struct piixpm_softc *sc = cookie; - if (!cold) - mutex_exit(&sc->sc_i2c_mutex); + if (cold || sc->sc_poll || (flags & I2C_F_POLL)) + return; + + rw_exit(&sc->sc_i2c_rwlock); } static int