Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom A minimal change to prevent the Raspbe...



details:   https://anonhg.NetBSD.org/src/rev/82db93c3af24
branches:  trunk
changeset: 323287:82db93c3af24
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jun 07 05:07:28 2018 +0000

description:
A minimal change to prevent the Raspberry Pi i2c driver from
looping forever if the command buffer and data buffer are both
NULL.  XXX This driver needs an overhaul.

Also, preemptively return an error if we get a 10-bit address,
because we don't yet handle them correctly.

diffstat:

 sys/arch/arm/broadcom/bcm2835_bsc.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r fb028135f4b7 -r 82db93c3af24 sys/arch/arm/broadcom/bcm2835_bsc.c
--- a/sys/arch/arm/broadcom/bcm2835_bsc.c       Thu Jun 07 00:51:41 2018 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_bsc.c       Thu Jun 07 05:07:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_bsc.c,v 1.11 2018/05/09 02:53:00 thorpej Exp $ */
+/*     $NetBSD: bcm2835_bsc.c,v 1.12 2018/06/07 05:07:28 thorpej Exp $ */
 
 /*
  * Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc.c,v 1.11 2018/05/09 02:53:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc.c,v 1.12 2018/06/07 05:07:28 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_kernhist.h"
@@ -242,8 +242,15 @@
        size_t len;
        size_t pos;
        int error = 0;
+       int whichbuf = 0;
        const bool isread = I2C_OP_READ_P(op);
 
+       /*
+        * XXX We don't do 10-bit addressing correctly yet.
+        */
+       if (addr > 0x7f)
+               return (ENOTSUP);
+
        flags |= I2C_F_POLL;
 
 #if 0
@@ -312,10 +319,13 @@
        KERNHIST_LOG(bsciichist, "flood bot %#jx %ju",
            (uintptr_t)buf, len, 0, 0);
 
-       if (buf == cmdbuf && !isread) {
+       if (whichbuf == 0 && !isread) {
+               KASSERT(buf == cmdbuf);
+               whichbuf++;
                buf = databuf;
                len = datalen;
-               goto flood_again;
+               if (len)
+                       goto flood_again;
        }
 
        do {



Home | Main Index | Thread Index | Old Index