Source-Changes-HG archive

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

[src/thorpej-i2c-spi-conf2]: src/sys/dev/ic - Improve some comments.



details:   https://anonhg.NetBSD.org/src/rev/59b28007e410
branches:  thorpej-i2c-spi-conf2
changeset: 985902:59b28007e410
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 12 23:13:02 2021 +0000

description:
- Improve some comments.
- Update pcfiic_i2c_exec() for the channel split (might fix an issue
  spotted by tnn@ in testing).

diffstat:

 sys/arch/sparc64/dev/pcfiic_ebus.c |  12 +++++++++---
 sys/dev/ic/pcf8584.c               |  16 +++++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diffs (79 lines):

diff -r a8cf0d720841 -r 59b28007e410 sys/arch/sparc64/dev/pcfiic_ebus.c
--- a/sys/arch/sparc64/dev/pcfiic_ebus.c        Sun Sep 12 22:02:19 2021 +0000
+++ b/sys/arch/sparc64/dev/pcfiic_ebus.c        Sun Sep 12 23:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcfiic_ebus.c,v 1.7.16.1 2021/08/09 00:30:08 thorpej Exp $     */
+/*     $NetBSD: pcfiic_ebus.c,v 1.7.16.2 2021/09/12 23:13:02 thorpej Exp $     */
 /*     $OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7.16.1 2021/08/09 00:30:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7.16.2 2021/09/12 23:13:02 thorpej Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -167,7 +167,13 @@
 
        nchannels = popcount(busmap);
        if (nchannels == 0) {
-               /* No child devices. */
+               /*
+                * No child devices in the device tree.  This is fine;
+                * the generic code will just assume a single channel
+                * and attach a bus instance, but our MUX will still
+                * get programmed correctly because we've initialized
+                * the acquire/release bus funcitons.
+                */
                return;
        }
 
diff -r a8cf0d720841 -r 59b28007e410 sys/dev/ic/pcf8584.c
--- a/sys/dev/ic/pcf8584.c      Sun Sep 12 22:02:19 2021 +0000
+++ b/sys/dev/ic/pcf8584.c      Sun Sep 12 23:13:02 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcf8584.c,v 1.19.2.1 2021/08/09 01:29:52 thorpej Exp $ */
+/*     $NetBSD: pcf8584.c,v 1.19.2.2 2021/09/12 23:13:02 thorpej Exp $ */
 /*     $OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -120,9 +120,17 @@
 
        printf("\n");
 
+       /*
+        * Sun has a clone of this chip that also has an
+        * associated MUX, which means we treat this as
+        * a multi-channel controller.  If the front-end
+        * did not already allocate channels for us, then
+        * assume we're just a simple single-channel device.
+        */
+
        if (sc->sc_channels == NULL) {
                KASSERT(sc->sc_nchannels == 0);
-               ch = kmem_alloc(sizeof(*sc->sc_channels), KM_SLEEP);
+               ch = kmem_alloc(sizeof(*ch), KM_SLEEP);
                ch->ch_channel = 0;
                ch->ch_devhandle = device_handle(sc->sc_dev);
 
@@ -139,6 +147,7 @@
                ch->ch_sc = sc;
                iic_tag_init(&ch->ch_i2c);
                ch->ch_i2c.ic_cookie = ch;
+               ch->ch_i2c.ic_channel = ch->ch_channel;
                ch->ch_i2c.ic_exec = pcfiic_i2c_exec;
                ch->ch_i2c.ic_acquire_bus = sc->sc_acquire_bus;
                ch->ch_i2c.ic_release_bus = sc->sc_release_bus;
@@ -165,7 +174,8 @@
 pcfiic_i2c_exec(void *arg, i2c_op_t op, i2c_addr_t addr,
     const void *cmdbuf, size_t cmdlen, void *buf, size_t len, int flags)
 {
-       struct pcfiic_softc     *sc = arg;
+       struct pcfiic_channel   *ch = arg;
+       struct pcfiic_softc     *sc = ch->ch_sc;
        int                     ret = 0;
 
 #if 0



Home | Main Index | Thread Index | Old Index