Module Name: src Committed By: thorpej Date: Thu Jun 7 05:07:28 UTC 2018
Modified Files: src/sys/arch/arm/broadcom: bcm2835_bsc.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/broadcom/bcm2835_bsc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/broadcom/bcm2835_bsc.c diff -u src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.11 src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.12 --- src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.11 Wed May 9 02:53:00 2018 +++ src/sys/arch/arm/broadcom/bcm2835_bsc.c Thu Jun 7 05:07:28 2018 @@ -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 @@ bsciic_exec(void *v, i2c_op_t op, i2c_ad 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 @@ flood_again: 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 {