Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Since there are no RW_READERs for the device's r...



details:   https://anonhg.NetBSD.org/src/rev/1963ade70118
branches:  trunk
changeset: 777999:1963ade70118
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Mar 11 22:46:22 2012 +0000

description:
Since there are no RW_READERs for the device's rw_lock, convert it to a
mutex and reduce the overhead.

Also, even if we're polling, we need to use the lock to control access to
the bus, otherwise we get anomolous results.

(These same changes were made several weeks ago to other drivers;  I
missed this one.)

diffstat:

 sys/dev/pci/alipm.c |  20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diffs (66 lines):

diff -r 636cb96f609c -r 1963ade70118 sys/dev/pci/alipm.c
--- a/sys/dev/pci/alipm.c       Sun Mar 11 22:19:53 2012 +0000
+++ b/sys/dev/pci/alipm.c       Sun Mar 11 22:46:22 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $ */
+/*     $NetBSD: alipm.c,v 1.9 2012/03/11 22:46:22 pgoyette Exp $ */
 /*     $OpenBSD: alipm.c,v 1.13 2007/05/03 12:19:01 dlg Exp $  */
 
 /*
@@ -18,12 +18,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: alipm.c,v 1.9 2012/03/11 22:46:22 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
-#include <sys/rwlock.h>
+#include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
 
@@ -104,7 +104,7 @@
        bus_space_handle_t sc_ioh;
 
        struct i2c_controller sc_smb_tag;
-       krwlock_t sc_smb_lock;
+       kmutex_t sc_smb_mutex;
 };
 
 static int     alipm_match(device_t, cfdata_t, void *);
@@ -203,7 +203,7 @@
        aprint_naive("\n");
 
        /* Attach I2C bus */
-       rw_init(&sc->sc_smb_lock);
+       mutex_init(&sc->sc_smb_mutex, MUTEX_DEFAULT, IPL_NONE);
        sc->sc_smb_tag.ic_cookie = sc;
        sc->sc_smb_tag.ic_acquire_bus = alipm_smb_acquire_bus;
        sc->sc_smb_tag.ic_release_bus = alipm_smb_release_bus;
@@ -224,10 +224,7 @@
 {
        struct alipm_softc *sc = cookie;
 
-       if (flags & I2C_F_POLL)
-               return (0);
-
-       rw_enter(&sc->sc_smb_lock, RW_WRITER);
+       mutex_enter(&sc->sc_smb_mutex);
        return 0;
 }
 
@@ -236,10 +233,7 @@
 {
        struct alipm_softc *sc = cookie;
 
-       if (flags & I2C_F_POLL)
-               return;
-
-       rw_exit(&sc->sc_smb_lock);
+       mutex_exit(&sc->sc_smb_mutex);
 }
 
 int



Home | Main Index | Thread Index | Old Index