Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c The i2c code handles the 'cold' dance with I2C_F...
details: https://anonhg.NetBSD.org/src/rev/360668ab174a
branches: trunk
changeset: 962577:360668ab174a
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Jul 25 04:25:40 2019 +0000
description:
The i2c code handles the 'cold' dance with I2C_F_POLL now; no need to
do it here.
diffstat:
sys/dev/i2c/tsl256x.c | 45 ++++++++++++++++++---------------------------
1 files changed, 18 insertions(+), 27 deletions(-)
diffs (160 lines):
diff -r fd9618ecb408 -r 360668ab174a sys/dev/i2c/tsl256x.c
--- a/sys/dev/i2c/tsl256x.c Thu Jul 25 04:24:44 2019 +0000
+++ b/sys/dev/i2c/tsl256x.c Thu Jul 25 04:25:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tsl256x.c,v 1.6 2018/06/26 06:03:57 thorpej Exp $ */
+/* $NetBSD: tsl256x.c,v 1.7 2019/07/25 04:25:40 thorpej Exp $ */
/*-
* Copyright (c) 2018 Jason R. Thorpe
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.6 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.7 2019/07/25 04:25:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,7 +49,6 @@
device_t sc_dev;
i2c_tag_t sc_i2c;
i2c_addr_t sc_addr;
- int sc_i2c_flags;
uint32_t sc_poweron;
@@ -125,11 +124,11 @@
return (0);
}
- if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0)
+ if (iic_acquire_bus(ia->ia_tag, 0) != 0)
return (0);
error = iic_smbus_read_byte(ia->ia_tag, ia->ia_addr,
- TSL256x_REG_ID | COMMAND_CMD, &id_reg, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ TSL256x_REG_ID | COMMAND_CMD, &id_reg, 0);
+ iic_release_bus(ia->ia_tag, 0);
if (error)
return (0);
@@ -154,14 +153,12 @@
sc->sc_dev = self;
sc->sc_i2c = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
- sc->sc_i2c_flags = I2C_F_POLL;
if (self->dv_cfdata != NULL &&
self->dv_cfdata->cf_flags & TSLLUX_F_CS_PACKAGE)
sc->sc_cs_package = true;
- if (iic_acquire_bus(ia->ia_tag, I2C_F_POLL) != 0) {
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ if (iic_acquire_bus(ia->ia_tag, 0) != 0) {
return;
}
@@ -195,7 +192,7 @@
tsllux_poweroff(sc);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, 0);
have_i2c = false;
tsllux_sysctl_attach(sc);
@@ -217,10 +214,8 @@
if (have_i2c) {
if (sc->sc_poweron)
tsllux_poweroff(sc);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ iic_release_bus(ia->ia_tag, 0);
}
-
- sc->sc_i2c_flags = 0;
}
static int
@@ -327,13 +322,13 @@
return (EINVAL);
}
- if ((error = iic_acquire_bus(sc->sc_i2c, sc->sc_i2c_flags)) != 0) {
+ if ((error = iic_acquire_bus(sc->sc_i2c, 0)) != 0) {
mutex_exit(&sc->sc_lock);
return (error);
}
error = tsllux_set_gain(sc, new_gain);
- iic_release_bus(sc->sc_i2c, sc->sc_i2c_flags);
+ iic_release_bus(sc->sc_i2c, 0);
mutex_exit(&sc->sc_lock);
return (error);
@@ -393,13 +388,13 @@
return (EINVAL);
}
- if ((error = iic_acquire_bus(sc->sc_i2c, sc->sc_i2c_flags)) != 0) {
+ if ((error = iic_acquire_bus(sc->sc_i2c, 0)) != 0) {
mutex_exit(&sc->sc_lock);
return (error);
}
error = tsllux_set_integration_time(sc, new_itime);
- iic_release_bus(sc->sc_i2c, sc->sc_i2c_flags);
+ iic_release_bus(sc->sc_i2c, 0);
mutex_exit(&sc->sc_lock);
return (error);
@@ -465,9 +460,9 @@
mutex_enter(&sc->sc_lock);
- if ((error = iic_acquire_bus(sc->sc_i2c, sc->sc_i2c_flags)) == 0) {
+ if ((error = iic_acquire_bus(sc->sc_i2c, 0)) == 0) {
error = tsllux_get_lux(sc, &lux, NULL, NULL);
- iic_release_bus(sc->sc_i2c, sc->sc_i2c_flags);
+ iic_release_bus(sc->sc_i2c, 0);
}
if (error) {
@@ -489,24 +484,21 @@
tsllux_read1(struct tsllux_softc *sc, uint8_t reg, uint8_t *valp)
{
reg = (reg & REGMASK) | COMMAND_CMD;
- return (iic_smbus_read_byte(sc->sc_i2c, sc->sc_addr, reg, valp,
- sc->sc_i2c_flags));
+ return (iic_smbus_read_byte(sc->sc_i2c, sc->sc_addr, reg, valp, 0));
}
static int
tsllux_read2(struct tsllux_softc *sc, uint8_t reg, uint16_t *valp)
{
reg = (reg & REGMASK) | COMMAND_CMD | COMMAND_WORD;
- return (iic_smbus_read_word(sc->sc_i2c, sc->sc_addr, reg, valp,
- sc->sc_i2c_flags));
+ return (iic_smbus_read_word(sc->sc_i2c, sc->sc_addr, reg, valp, 0));
}
static int
tsllux_write1(struct tsllux_softc *sc, uint8_t reg, uint8_t val)
{
reg = (reg & REGMASK) | COMMAND_CMD;
- return (iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr, reg, val,
- sc->sc_i2c_flags));
+ return (iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr, reg, val, 0));
}
#if 0
@@ -514,8 +506,7 @@
tsllux_write2(struct tsllux_softc *sc, uint8_t reg, uint16_t val)
{
reg = (reg & REGMASK) | COMMAND_CMD | COMMAND_WORD;
- return (iic_smbus_write_word(sc->sc_i2c, sc->sc_addr, reg, val,
- sc->sc_i2c_flags));
+ return (iic_smbus_write_word(sc->sc_i2c, sc->sc_addr, reg, val, 0));
}
#endif
Home |
Main Index |
Thread Index |
Old Index