Received: from eggs.gnu.org ([2001:4830:134:3::10]:52736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBo7e-0005Pl-2A for qemu-devel@nongnu.org; Tue, 29 Nov 2016 14:31:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBo7d-0001Ag-2d for qemu-devel@nongnu.org; Tue, 29 Nov 2016 14:31:22 -0500 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]:35104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBo7c-0001AO-S4 for qemu-devel@nongnu.org; Tue, 29 Nov 2016 14:31:20 -0500 Received: by mail-qk0-x22f.google.com with SMTP id n204so185838575qke.2 for ; Tue, 29 Nov 2016 11:31:20 -0800 (PST) Received: from localhost.localdomain ([2804:7f7:d787:c9ce:d40d:5523:4fe6:c287]) by smtp.googlemail.com with ESMTPSA id y22sm31590256qtb.26.2016.11.29.11.31.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 11:31:19 -0800 (PST) From: Fabio Urquiza Date: Tue, 29 Nov 2016 16:30:51 -0300 Message-Id: <20161129193052.11736-2-flus@cesar.org.br> In-Reply-To: <20161129193052.11736-1-flus@cesar.org.br> References: <20161123194605.94717-1-flus@cesar.org.br> <20161129193052.11736-1-flus@cesar.org.br> Subject: [Qemu-devel] [PATCH v1 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..f36020f 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.8.3