From patchwork Wed Nov 23 19:46:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Urquiza X-Patchwork-Id: 698510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tPCYC6S5Kz9ryn for ; Thu, 24 Nov 2016 06:47:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=cesar-org-br.20150623.gappssmtp.com header.i=@cesar-org-br.20150623.gappssmtp.com header.b="nAETYZki"; dkim-atps=neutral Received: from localhost ([::1]:35990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9dW6-0006AF-TK for incoming@patchwork.ozlabs.org; Wed, 23 Nov 2016 14:47:38 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesar-org-br.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=MjwdDiXIvXQAF+635O5Mk39OH/8PKW5IIm9/WPvkfEw=; b=nAETYZkiWZQeOG97n2at7KAJe7JlSXpaOdZuHBPLz6A21vA8xynXORuthxyCLvoxuf 0E34maQwGJ96mAQeGCdaLwuTM0kfIxLYBZ9hpdzkxxGy2Gph9UX0vQI7vfe2HqVwuEom gNDky1gGvEfTagaPyavvnbkZejfIkpzarJpC+T9WC0ADNEySbFxwlIXq72tOWZ7nrv2U L4FtglHpWxwfwVGZbQXKLcMuzA1kcrdRY2gfrSRtUzvFt3AEC2TSZGBd3iWQrIkWtWKk fezvlZ+372xP7FDRf33XWMM5MZcaV3riQtWqrZGadhycqcWaAg0A+LqxJocs7EE0yhpz 7bGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=MjwdDiXIvXQAF+635O5Mk39OH/8PKW5IIm9/WPvkfEw=; b=E7EwpVEcE4OWjlYs9IY1O+6jXniBoFuVMWrNzapIwJN1920YUN8Ud8bmscLjrMrIQc +1SgXS27rv6EFkaMHTDqFLJjAp6VLZLrY7PeZjCKyuZ4oz3Z46PrfEeEH7DzPmuXzXyc eS3e8tEFnwlAG0jDmFayxyyfWycznTZrJOXErtBxQsDHmdF+N+3/Ab0Tw6/1usjvPOmo ZxSCJ0ZkpzleDfjM3pZxBD+/ytMbIzRFVgk1Xce/iT9N79x1diBH9coF/Mgdi5KQDKNQ IY1W3gvykFz3hlM4mfRLBMgPWZXAKUoeRXBkGnmj7YkTztGPa1LayiXRc5b0uQB42kHf wXHw== X-Gm-Message-State: AKaTC02Ia1tgr/rbs+EpVS1jojeihakUPTbEccZ6zIX7cL7y3AD2qVcYt9LcSVjt+6+tFQIz X-Received: by 10.200.53.53 with SMTP id y50mr4757774qtb.127.1479930380492; Wed, 23 Nov 2016 11:46:20 -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 To: qemu-devel@nongnu.org Date: Wed, 23 Nov 2016 16:46:04 -0300 Message-Id: <20161123194605.94717-2-flus@cesar.org.br> X-Mailer: git-send-email 2.9.3 (Apple Git-75) In-Reply-To: <20161123194605.94717-1-flus@cesar.org.br> References: <20161123194605.94717-1-flus@cesar.org.br> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::22a Subject: [Qemu-devel] [PATCH 1/2] i2c: Add flag to NACK I2C transfers when busy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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);