Received: from eggs.gnu.org ([2001:4830:134:3::10]:47670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9dUt-0005HS-Vb for qemu-devel@nongnu.org; Wed, 23 Nov 2016 14:46:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9dUr-0002qK-9o for qemu-devel@nongnu.org; Wed, 23 Nov 2016 14:46:24 -0500 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:32987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9dUr-0002q2-5U for qemu-devel@nongnu.org; Wed, 23 Nov 2016 14:46:21 -0500 Received: by mail-qt0-x22a.google.com with SMTP id p16so21544700qta.0 for ; Wed, 23 Nov 2016 11:46:21 -0800 (PST) Received: from localhost.localdomain (mikiko.cesar.org.br. [200.199.23.104]) by smtp.googlemail.com with ESMTPSA id h47sm17102355qtc.27.2016.11.23.11.46.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 23 Nov 2016 11:46:20 -0800 (PST) From: Fabio Urquiza Date: Wed, 23 Nov 2016 16:46:04 -0300 Message-Id: <20161123194605.94717-2-flus@cesar.org.br> In-Reply-To: <20161123194605.94717-1-flus@cesar.org.br> References: <20161123194605.94717-1-flus@cesar.org.br> Subject: [Qemu-devel] [PATCH 1/2] i2c: Add flag to NACK I2C transfers when busy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Add a busy flag on the I2CSlave struct which the device could set to NACK I2C transfer requests during the execution of the event handling function. If the busy flag is set, i2c_start_transfer() shall return 1. Signed-off-by: Fabio Urquiza --- hw/i2c/core.c | 3 +++ include/hw/i2c/i2c.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hw/i2c/core.c b/hw/i2c/core.c index abd4c4c..438233c 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -142,6 +142,9 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) start condition. */ if (sc->event) { sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND); + if (node->elt->busy) { + return -1; + } } } return 0; diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index c4085aa..9c6b1ce 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -48,6 +48,7 @@ struct I2CSlave /* Remaining fields for internal use by the I2C code. */ uint8_t address; + uint8_t busy; }; I2CBus *i2c_init_bus(DeviceState *parent, const char *name); -- 2.9.3 (Apple Git-75)