Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c No need to do the poll-during-autoconfiguration ...
details: https://anonhg.NetBSD.org/src/rev/fe97f1c9b26c
branches: trunk
changeset: 466471:fe97f1c9b26c
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Dec 23 02:25:28 2019 +0000
description:
No need to do the poll-during-autoconfiguration dance; the i2c code
does the right thing for us.
diffstat:
sys/dev/i2c/adm1026.c | 20 +++++++-------------
sys/dev/i2c/as3722.c | 24 ++++++++++++------------
2 files changed, 19 insertions(+), 25 deletions(-)
diffs (163 lines):
diff -r 6796ac6e9322 -r fe97f1c9b26c sys/dev/i2c/adm1026.c
--- a/sys/dev/i2c/adm1026.c Mon Dec 23 02:16:43 2019 +0000
+++ b/sys/dev/i2c/adm1026.c Mon Dec 23 02:25:28 2019 +0000
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.6 2019/12/11 21:00:11 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.7 2019/12/23 02:25:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -87,7 +87,6 @@
device_t sc_dev;
i2c_tag_t sc_tag;
int sc_address;
- int sc_iic_flags;
bool sc_multi_read;
uint8_t sc_rev, sc_cfg[2];
@@ -136,7 +135,6 @@
sc.sc_tag = ia->ia_tag;
sc.sc_address = ia->ia_addr;
- sc.sc_iic_flags = 0;
if (iic_use_direct_match(ia, cf, compat_data, &match_result))
return match_result;
@@ -183,7 +181,6 @@
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
sc->sc_dev = self;
- sc->sc_iic_flags = I2C_F_POLL; /* Use polling during autoconf */
sc->sc_multi_read = false;
prop_dictionary_get_bool(props, "multi_read", &sc->sc_multi_read);
@@ -239,8 +236,6 @@
if (!pmf_device_register(self, adm1026_pmf_suspend, adm1026_pmf_resume))
aprint_error_dev(self, "couldn't establish power handler\n");
- sc->sc_iic_flags = 0; /* Drop polling flag */
-
return;
}
@@ -493,7 +488,7 @@
int i, j, err = 0;
uint8_t creg, cval, tmp[ADM1026_READ_RETRIES + 1];
- if ((err = iic_acquire_bus(sc->sc_tag, sc->sc_iic_flags)) != 0)
+ if ((err = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return err;
/* Standard ADM1026 */
if (sc->sc_multi_read == false) {
@@ -512,7 +507,7 @@
creg = ADM1026_CONF1;
if ((err = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
sc->sc_address, ®, 1, &tmp[0], 1, 0)) != 0) {
- iic_release_bus(sc->sc_tag, sc->sc_iic_flags);
+ iic_release_bus(sc->sc_tag, 0);
return err;
}
for (i = 1; i <= ADM1026_READ_RETRIES; i++) {
@@ -522,8 +517,7 @@
for (j = 0; j < i; j++)
if (abs(tmp[j] - tmp[i]) < 3) {
*val = tmp[i];
- iic_release_bus(sc->sc_tag,
- sc->sc_iic_flags);
+ iic_release_bus(sc->sc_tag, 0);
return 0;
}
if ((err = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
@@ -532,7 +526,7 @@
err = -1; /* Return error if we don't match. */
}
}
- iic_release_bus(sc->sc_tag, sc->sc_iic_flags);
+ iic_release_bus(sc->sc_tag, 0);
return err;
}
@@ -541,10 +535,10 @@
{
int err = 0;
- if ((err = iic_acquire_bus(sc->sc_tag, sc->sc_iic_flags)) != 0)
+ if ((err = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return err;
err = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_address,
®, 1, &val, 1, 0);
- iic_release_bus(sc->sc_tag, sc->sc_iic_flags);
+ iic_release_bus(sc->sc_tag, 0);
return err;
}
diff -r 6796ac6e9322 -r fe97f1c9b26c sys/dev/i2c/as3722.c
--- a/sys/dev/i2c/as3722.c Mon Dec 23 02:16:43 2019 +0000
+++ b/sys/dev/i2c/as3722.c Mon Dec 23 02:25:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.16 2019/07/27 16:02:27 thorpej Exp $ */
+/* $NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.16 2019/07/27 16:02:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -240,11 +240,11 @@
if (ia->ia_addr != AS3722_I2C_ADDR)
return 0;
- iic_acquire_bus(ia->ia_tag, I2C_F_POLL);
+ iic_acquire_bus(ia->ia_tag, 0);
reg = AS3722_ASIC_ID1_REG;
error = iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- ®, 1, &id1, 1, I2C_F_POLL);
- iic_release_bus(ia->ia_tag, I2C_F_POLL);
+ ®, 1, &id1, 1, 0);
+ iic_release_bus(ia->ia_tag, 0);
if (error == 0 && id1 == 0x0c)
return I2C_MATCH_ADDRESS_AND_PROBE;
@@ -281,16 +281,16 @@
{
int error;
- iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+ iic_acquire_bus(sc->sc_i2c, 0);
error = as3722_write(sc, AS3722_GPIO0_CTRL_REG,
__SHIFTIN(AS3722_GPIO0_CTRL_IOSF_GPIO,
AS3722_GPIO0_CTRL_IOSF) |
__SHIFTIN(AS3722_GPIO0_CTRL_MODE_PULLDOWN,
AS3722_GPIO0_CTRL_MODE),
- I2C_F_POLL);
+ 0);
error += as3722_set_clear(sc, AS3722_WATCHDOG_CTRL_REG,
- __SHIFTIN(1, AS3722_WATCHDOG_CTRL_MODE), 0, I2C_F_POLL);
- iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+ __SHIFTIN(1, AS3722_WATCHDOG_CTRL_MODE), 0, 0);
+ iic_release_bus(sc->sc_i2c, 0);
if (error) {
aprint_error_dev(sc->sc_dev, "couldn't setup watchdog\n");
@@ -315,10 +315,10 @@
{
int error;
- iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+ iic_acquire_bus(sc->sc_i2c, 0);
error = as3722_set_clear(sc, AS3722_RTC_CONTROL_REG,
- AS3722_RTC_CONTROL_RTC_ON, 0, I2C_F_POLL);
- iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+ AS3722_RTC_CONTROL_RTC_ON, 0, 0);
+ iic_release_bus(sc->sc_i2c, 0);
if (error) {
aprint_error_dev(sc->sc_dev, "couldn't setup RTC\n");
Home |
Main Index |
Thread Index |
Old Index