Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Don't read from the chip when matching, fail the...
details: https://anonhg.NetBSD.org/src/rev/921cde0b2a79
branches: trunk
changeset: 957646:921cde0b2a79
user: jdc <jdc%NetBSD.org@localhost>
date: Sun Dec 06 10:09:36 2020 +0000
description:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill). Reverts previous.
diffstat:
sys/dev/i2c/pcf8574.c | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
diffs (55 lines):
diff -r c1f4ee0bfb17 -r 921cde0b2a79 sys/dev/i2c/pcf8574.c
--- a/sys/dev/i2c/pcf8574.c Sun Dec 06 10:06:15 2020 +0000
+++ b/sys/dev/i2c/pcf8574.c Sun Dec 06 10:09:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $ */
+/* $NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -108,21 +108,10 @@
pcf8574_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
- struct pcf8574_softc sc;
int match_result;
- if (!iic_use_direct_match(ia, cf, compat_data, &match_result))
- return 0;
-
- /* Try a read so that we don't match on optional components */
- if (match_result) {
- sc.sc_tag = ia->ia_tag;
- sc.sc_addr = ia->ia_addr;
- if (pcf8574_read(&sc, &sc.sc_state))
- return 0;
- else
- return match_result;
- }
+ if (iic_use_direct_match(ia, cf, compat_data, &match_result))
+ return match_result;
/* We don't support indirect matches */
return 0;
@@ -153,7 +142,11 @@
*/
sc->sc_mask = 0xff;
- pcf8574_read(sc, &sc->sc_state);
+ /* Try a read, and fail if this component isn't present */
+ if (pcf8574_read(sc, &sc->sc_state)) {
+ aprint_normal(": read failed\n");
+ return;
+ }
#ifdef PCF8574_DEBUG
aprint_normal(": GPIO: state = 0x%02x\n", sc->sc_state);
Home |
Main Index |
Thread Index |
Old Index