Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Actually, the local mutex is unnecesary; the i2c...
details: https://anonhg.NetBSD.org/src/rev/7b164c3f6ad2
branches: trunk
changeset: 967840:7b164c3f6ad2
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Dec 23 19:20:18 2019 +0000
description:
Actually, the local mutex is unnecesary; the i2c bus lock is held
across all register r/m/w cycles, so we can just piggy back on that.
(I misread the code previously.)
diffstat:
sys/dev/i2c/max77620.c | 20 ++------------------
1 files changed, 2 insertions(+), 18 deletions(-)
diffs (89 lines):
diff -r 8a29ce7878cc -r 7b164c3f6ad2 sys/dev/i2c/max77620.c
--- a/sys/dev/i2c/max77620.c Mon Dec 23 19:12:22 2019 +0000
+++ b/sys/dev/i2c/max77620.c Mon Dec 23 19:20:18 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $ */
+/* $NetBSD: max77620.c,v 1.8 2019/12/23 19:20:18 thorpej Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.7 2019/12/23 18:49:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: max77620.c,v 1.8 2019/12/23 19:20:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,13 +58,6 @@
i2c_tag_t sc_i2c;
i2c_addr_t sc_addr;
int sc_phandle;
-
- /*
- * Locking order:
- *
- * max77620 -> i2c
- */
- kmutex_t sc_lock;
};
struct max77620_pin {
@@ -115,7 +108,6 @@
uint32_t gpio;
KASSERT(pin >= 0 && pin < MAX_GPIO_COUNT);
- KASSERT(mutex_owned(&sc->sc_lock));
gpio = I2C_READ(sc, MAX_GPIO_REG(pin));
@@ -170,11 +162,9 @@
if (pin >= MAX_GPIO_COUNT)
return NULL;
- mutex_enter(&sc->sc_lock);
I2C_LOCK(sc);
error = max77620_gpio_config(sc, pin, flags);
I2C_UNLOCK(sc);
- mutex_exit(&sc->sc_lock);
if (error != 0) {
device_printf(dev, "bad pin %d config %#x\n", pin, flags);
@@ -196,11 +186,9 @@
struct max77620_softc * const sc = device_private(dev);
struct max77620_pin *gpin = priv;
- mutex_enter(&sc->sc_lock);
I2C_LOCK(sc);
max77620_gpio_config(sc, gpin->pin_num, GPIO_PIN_INPUT|GPIO_PIN_OPENDRAIN);
I2C_UNLOCK(sc);
- mutex_exit(&sc->sc_lock);
kmem_free(gpin, sizeof(*gpin));
}
@@ -245,7 +233,6 @@
if (!raw && gpin->pin_actlo)
val = !val;
- mutex_enter(&sc->sc_lock);
I2C_LOCK(sc);
gpio = I2C_READ(sc, MAX_GPIO_REG(gpin->pin_num));
gpio &= ~MAX_GPIO_OUTPUT_VAL;
@@ -257,7 +244,6 @@
#endif
I2C_WRITE(sc, MAX_GPIO_REG(gpin->pin_num), gpio);
I2C_UNLOCK(sc);
- mutex_exit(&sc->sc_lock);
}
static struct fdtbus_gpio_controller_func max77620_gpio_funcs = {
@@ -297,8 +283,6 @@
sc->sc_addr = ia->ia_addr;
sc->sc_phandle = ia->ia_cookie;
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
-
aprint_naive("\n");
aprint_normal(": MAX77620 Power Management IC\n");
Home |
Main Index |
Thread Index |
Old Index