From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623930929059100.53972954547919; Thu, 17 Jun 2021 04:55:29 -0700 (PDT) Received: from localhost ([::1]:35084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqcI-0008Np-Uh for importer2@patchew.org; Thu, 17 Jun 2021 07:55:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqae-0005sZ-QA for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:44 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:39579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqad-00059J-4H for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:44 -0400 Received: by mail-wm1-x32c.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso6182003wmh.4 for ; Thu, 17 Jun 2021 04:53:42 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id g23sm8399630wmk.3.2021.06.17.04.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZVPBTnPyrwKkWmxUGbbjqq6/7nF/87IireIxXO+4BKk=; b=LjKqJr/Gn5U2aG2W28+I61UPkbkCxsSmxsOiA4ZmJd2xigzbRTp+cjiB2k9yAkMng/ wwLaeFioIlkKA2iq9JWBQYBraHPpSErKhnol3cISq3511jgeyOwHcyl/t9kAR5vl6FzY 2O3MmDTYHu5DoyW2IIvrJTWOqQAyqikbUtOPCIi8m1mXe6y4Uizwl2vaI2UK/WJPNARS Es3DQQO+YIfYYwa33XmrtoVZ2pOa3ECRILwo+cp/ODBIEMGvWyRIE66zTuii5PtJTBKE DT7iygSekm7rxrM1EpCdTU9TC8gJEhtTH0LJ2umbWW6JslEn4/aWVLKjrn030f9whrPM GXqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZVPBTnPyrwKkWmxUGbbjqq6/7nF/87IireIxXO+4BKk=; b=bmEq24S95m5crjClBY67H6j2/s3fjzysJU0gugIHtHH17xwpPYbcKKjp2BItYsZI2e zRTrXITewVMNJ5kO7aXDHZG45ZnhQALb5jPK/PENIdcq1M+BnGmSS4tAjqDwCp2EfSA3 3oTtyA3SaWG2HUEnF7GNxQhx2rpC9cWlhTy4dTtfQU+mF4Gs/lxU1an6Ot5AWXOz2ct8 rjuYgUwcHDYt048u0mrp7FErzV35Yc+/IYuoYBv1z7DmAEsXUcouZRWykD427gvp5YJi 8sMTeRHm3/twfbwzPDact/2YRHZnW13QLO4biPBmyCYv2G5S9xhWeSMQ9GnjwIkSPNZQ /zMw== X-Gm-Message-State: AOAM531YzkZi026PvLNAI6HuE1up9wsCBtOepUK21XIqOcPy1S4eAoQl mHlke3Yxzsn+o/3Cp6VmbNTBrlAHJYgI4g== X-Google-Smtp-Source: ABdhPJwuPDAlf026IfCYpQKja/6oGbeY7MkU8rKOl/GRLB73dTT1z91F1TkatkBsJxaFsTaRRmqM2Q== X-Received: by 2002:a1c:2142:: with SMTP id h63mr4686584wmh.84.1623930821248; Thu, 17 Jun 2021 04:53:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 01/15] hw/input/lm832x: Move lm832x_key_event() declaration to "lm832x.h" Date: Thu, 17 Jun 2021 13:53:20 +0200 Message-Id: <20210617115334.2761573-2-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) lm832x_key_event() is specific go LM832x devices, not to the I2C bus API. Move it out of "i2c.h" to a new header. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 3 --- include/hw/input/lm832x.h | 26 ++++++++++++++++++++++++++ hw/arm/nseries.c | 1 + hw/input/lm832x.c | 1 + MAINTAINERS | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 include/hw/input/lm832x.h diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index ff4129ea704..850815e707c 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -142,9 +142,6 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const ch= ar *name, uint8_t addr); */ bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp); =20 -/* lm832x.c */ -void lm832x_key_event(DeviceState *dev, int key, int state); - extern const VMStateDescription vmstate_i2c_slave; =20 #define VMSTATE_I2C_SLAVE(_field, _state) { \ diff --git a/include/hw/input/lm832x.h b/include/hw/input/lm832x.h new file mode 100644 index 00000000000..f47e579ff90 --- /dev/null +++ b/include/hw/input/lm832x.h @@ -0,0 +1,26 @@ +/* + * National Semiconductor LM8322/8323 GPIO keyboard & PWM chips. + * + * Copyright (C) 2008 Nokia Corporation + * Written by Andrzej Zaborowski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef HW_INPUT_LM832X +#define HW_INPUT_LM832X + +void lm832x_key_event(DeviceState *dev, int key, int state); + +#endif diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 0aefa5d0f3e..7b82b8682e8 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -34,6 +34,7 @@ #include "hw/boards.h" #include "hw/i2c/i2c.h" #include "hw/display/blizzard.h" +#include "hw/input/lm832x.h" #include "hw/input/tsc2xxx.h" #include "hw/misc/cbus.h" #include "hw/misc/tmp105.h" diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c index 4cb1e9de01f..d2b92b457e3 100644 --- a/hw/input/lm832x.c +++ b/hw/input/lm832x.c @@ -19,6 +19,7 @@ */ =20 #include "qemu/osdep.h" +#include "hw/input/lm832x.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "migration/vmstate.h" diff --git a/MAINTAINERS b/MAINTAINERS index 636bf2f5365..c56bc112ccf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -792,6 +792,7 @@ F: hw/input/tsc2005.c F: hw/misc/cbus.c F: hw/rtc/twl92230.c F: include/hw/display/blizzard.h +F: include/hw/input/lm832x.h F: include/hw/input/tsc2xxx.h F: include/hw/misc/cbus.h F: tests/acceptance/machine_arm_n8x0.py --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162393093710191.21338024749627; Thu, 17 Jun 2021 04:55:37 -0700 (PDT) Received: from localhost ([::1]:35626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqcS-0000JQ-0x for importer2@patchew.org; Thu, 17 Jun 2021 07:55:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqaj-00061y-1h for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:49 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:54058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqah-0005BU-GQ for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:48 -0400 Received: by mail-wm1-x329.google.com with SMTP id j18so3079176wms.3 for ; Thu, 17 Jun 2021 04:53:47 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id p187sm4339944wmp.28.2021.06.17.04.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7tkCcGMeSxkeYuEayXQwDf2U36P/eV7M7g2ybGL9KI=; b=PHe/VNuEZjHarNlEl0zV5SK1U2ew9APLI9N1IMT49Y/TM0G2Cgk5ilRvuv6j+wwkRW Hjx2k2SJ2jvxLoHqL+mYI1swMZi1FKLnBGNTuFNsOAwQdvFZZ5nOIRhODj6Y79+uhLCz xBb/EHXEFVAiTP1bzjJDMEGq1VQ7Rra3F09Sxs2jhHCBbCs8wZc8EVdw3Z9MbhN6gsl9 dkvDv9G1GhJMB/9SRkhKSQfYu1+fwfOagXP5ul9XnrPbPL20DoIDBxdjwmG4kPx5e08G scrkwDFIbhrJJxl5aNgaQmiUkrp4GJGKNur1kej7xtURm4M2D+XiMEAKk21/kx+k4LXz M8Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=g7tkCcGMeSxkeYuEayXQwDf2U36P/eV7M7g2ybGL9KI=; b=VLXdWxTyeh0p7ESq9P/uVv50na31HfWPREfe2U+KLPW7DicmVU4jQB9MuGQdCEK0VW Qb0jBhfNWppM/x+hsa1PWaxEpxP8M0002qPIiFidKiGC4IPtR6yfN3Sx/zbiuVHrOljk 4tgnevvMBRCAwWlKXGJQL2ADsgKGoWhIMe8JzS0S7iIka/PhXsoKrNiPY9rod5VCa2XG z+fJO9a7yWY09xRVgfLN5ZdG7VHvoubbGKbOutffXNq1iDLYepbIt4NTgsEgZHrw10Gu CnKpu3VKwVPIXNnmyb/kNTZ4icdq9NXAxLcVlQZ2wR0II6Ro+phSTvPkY1jF0d0CtgYE iGSA== X-Gm-Message-State: AOAM530YVhVPWYlFdj05B7D5ZoQ+XMOW8U5KWEVc42R3VQMvaIwLcZ+r +9PW0VzJtYsCGjrLPiNxbDL+5ZnF13NUjg== X-Google-Smtp-Source: ABdhPJxX8o5tssdyMdEwzOEvB9miVkmjnGy5NDAfe/RoVnCdXeiwbwQcPh8dt1gqYCGWz3CU6FLC9g== X-Received: by 2002:a1c:e246:: with SMTP id z67mr3294845wmg.119.1623930826042; Thu, 17 Jun 2021 04:53:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 02/15] hw/input/lm832x: Define TYPE_LM8323 in public header Date: Thu, 17 Jun 2021 13:53:21 +0200 Message-Id: <20210617115334.2761573-3-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Define TYPE_LM8323 in the public "hw/input/lm832x.h" header and use it in hw/arm/nseries.c. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/input/lm832x.h | 2 ++ hw/arm/nseries.c | 2 +- hw/input/lm832x.c | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/hw/input/lm832x.h b/include/hw/input/lm832x.h index f47e579ff90..2a58ccf8916 100644 --- a/include/hw/input/lm832x.h +++ b/include/hw/input/lm832x.h @@ -21,6 +21,8 @@ #ifndef HW_INPUT_LM832X #define HW_INPUT_LM832X =20 +#define TYPE_LM8323 "lm8323" + void lm832x_key_event(DeviceState *dev, int key, int state); =20 #endif diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 7b82b8682e8..3a51264e3cf 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -417,7 +417,7 @@ static void n810_kbd_setup(struct n800_s *s) /* Attach the LM8322 keyboard to the I2C bus, * should happen in n8x0_i2c_setup and s->kbd be initialised here. */ s->kbd =3D DEVICE(i2c_slave_create_simple(omap_i2c_bus(s->mpu->i2c[0]), - "lm8323", N810_LM8323_ADDR)); + TYPE_LM8323, N810_LM8323_ADDR)= ); qdev_connect_gpio_out(s->kbd, 0, kbd_irq); } =20 diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c index d2b92b457e3..19a646d9bb4 100644 --- a/hw/input/lm832x.c +++ b/hw/input/lm832x.c @@ -28,7 +28,6 @@ #include "ui/console.h" #include "qom/object.h" =20 -#define TYPE_LM8323 "lm8323" OBJECT_DECLARE_SIMPLE_TYPE(LM823KbdState, LM8323) =20 struct LM823KbdState { --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162393094495978.07532396296972; Thu, 17 Jun 2021 04:55:44 -0700 (PDT) Received: from localhost ([::1]:36130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqcZ-0000eo-Vv for importer2@patchew.org; Thu, 17 Jun 2021 07:55:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqao-0006IB-65 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:54 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:37455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqam-0005Dz-BH for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:53 -0400 Received: by mail-wm1-x333.google.com with SMTP id f16-20020a05600c1550b02901b00c1be4abso6197579wmg.2 for ; Thu, 17 Jun 2021 04:53:51 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id w23sm8327291wmi.0.2021.06.17.04.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PLm+CAmE6exi2+6ozO8dDlwl9EePwAhLr88hp6FkarA=; b=l+gBpnNlmzIsLpjXsAuhDyV3cq1HN+KfsoUrZDhR12BdxXEM0XGEtXBjDh3T2wxPt/ 8SqbkLCpuwqUaIzrgI/3cXCHFuYm2B1cMcdqQ+UtRGmLFpkzoxkBGqqKAhsnc3hmr7sM c+eF6uVxpXhwCrvevcXAv4DRiGcokr5bzHNP+Lk2pRsV3jXzB8j7ArrdX2SqVgJ+GvnJ DH/pmwmgihkjtpYxp+ablnd1Bv3LOTbmX7tGFw5PyOW78GdNlJPhaDu9ERMV7gNjPgdF modpvAvHQqjYi1ube8PAE8gVt5mqEpsBlKK1akA9gofyyGxVa3+YOqqF3BeEzjp+pVuX Y2Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PLm+CAmE6exi2+6ozO8dDlwl9EePwAhLr88hp6FkarA=; b=dTTjlYOA/fxZWSZGv0otEIw4Gl6kHjQymPPhjNeUoAau772998AokKIda60FKSr0V3 j3rr3S4so72PJAL9Gd+uBOa86Ic5PGNrs8qLJUnUfvY+oPwvduWcI5R6gD3cvLpDDklI waTxGUJcAVSJmRUUt/MBoJbFqdwVL5gD41EzIHPruFGXgeVnLEheOU7VBH0He0QRUXTo m/2SO5C4OeRo2Fg1xvxwh+dZzHZGqvjLk39sW88/Iy8mGlZR4m/wTbHCoPY7/dUqrsnh qMeUvWeqEtZCCbWgFk/UtcVVcLZafS0b0jA672VZfnu7PK6ffC55PFA3mkpY9dHbcFSs lxZg== X-Gm-Message-State: AOAM531zQFfjKqNT8IoKWOa5kLdWAJ670ciCuxs/LDfKF4AbrS2Lj8il SCKj5DA0/VLoEO4larNcl8fK0vDp98M6oA== X-Google-Smtp-Source: ABdhPJzXqa9Qfx2Bx1vEZJUy5ivkHoF4M4CDVTC9Z2dLTUqcQpfF2woEM6t6zxZlcCLY9ABe0Ss8Rw== X-Received: by 2002:a05:600c:2d45:: with SMTP id a5mr806266wmg.161.1623930830756; Thu, 17 Jun 2021 04:53:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 03/15] hw/display/sm501: Simplify sm501_i2c_write() logic Date: Thu, 17 Jun 2021 13:53:22 +0200 Message-Id: <20210617115334.2761573-4-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Richard Henderson Acked-by: Corey Minyard Reviewed-by: BALATON Zoltan Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/sm501.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 8789722ef27..f276276f7f1 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1036,8 +1036,9 @@ static void sm501_i2c_write(void *opaque, hwaddr addr= , uint64_t value, int res =3D i2c_start_transfer(s->i2c_bus, s->i2c_addr >> 1, s->i2c_addr & 1); - s->i2c_status |=3D (res ? SM501_I2C_STATUS_ERROR : 0); - if (!res) { + if (res) { + s->i2c_status |=3D SM501_I2C_STATUS_ERROR; + } else { int i; for (i =3D 0; i <=3D s->i2c_byte_count; i++) { res =3D i2c_send_recv(s->i2c_bus, &s->i2c_data[i], --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931064027444.34639278927943; Thu, 17 Jun 2021 04:57:44 -0700 (PDT) Received: from localhost ([::1]:43440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqeV-0005jP-0k for importer2@patchew.org; Thu, 17 Jun 2021 07:57:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqas-0006ZR-B4 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:58 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:42598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqaq-0005Gq-QG for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:53:58 -0400 Received: by mail-wm1-x32c.google.com with SMTP id l7-20020a05600c1d07b02901b0e2ebd6deso3525690wms.1 for ; Thu, 17 Jun 2021 04:53:56 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id t9sm4646788wmq.14.2021.06.17.04.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0yFcNPzCMbJU7ln7mvR4pO20Y4U4Q8SH66r8xtnNF00=; b=OTbM4gF9kYBNFJEShrnJTZDm64kaTsMoodOYgY4nwWVH7YgfDSELHcCWWOjh51oO9j cTcpKAP46KqxI0/P2OgDHCb4ibi2VBCXAOiIP63ZVgnJENdTSL1k/DVFDTCKOWdHHgYh O2UUbiNz4teaqjhEZLqqMbWVTnlKNm8iNDo9g7MpAxL6SgfHCSqW/8KFQ4p0UNzVoem6 0/MgU0gICpGLWK/SR4OJh4Ahn5s14xPinjyFv/SCsCx7u/D7JPg+CVAIXR2EZ6UnYZGU LWV7jjhEGAFCfGv46DP8MfFCSmpsVMu/zCmRNTGx2coG4UHtNsLC/SBCK8TvlpfxnWfq 54Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0yFcNPzCMbJU7ln7mvR4pO20Y4U4Q8SH66r8xtnNF00=; b=IWVA5IZdXBnwVwNHPDAu/Wf46xyepAP0O4EIohO7ZvpiBPyzoLY6Me8GmsNwxH94As cWNfMRUT/hxe15ozFcUXoF8E1Z7tjJTu4gYnprd1mPwG71xAlQ9nl5WNSsvogqiI/3/q lrjWhpElK07fEBSpYCFTzZVNC6AH+47Mf/Pu5Of26Y2MvjEmpKdxJ5H5qDPqFjDcatKE OyeHyCDGpNf5s5Fd0bC3dDoC0XOoBSjHi7AQ8O1KLNStt1atM7gIWk419qgizGcD70Vc JdbGtFuMt2NoBhIWzseGyQrqMxRrQdLnTNyrTAg0RLVFHqtFyx7n3EhuvZyW9ycL8XRq rkRA== X-Gm-Message-State: AOAM532eDLu9KGx4O3Ii/XlapAHOthrqaVk1pfGamcFVLe+Qbh+69/DX qB69Qrlw/XfGWuwcLScYJbYD4lei4XbqtQ== X-Google-Smtp-Source: ABdhPJxPGzt/pgjWg+3ZlKo53AlbVd3EhL/8zVBjFE4oKFRHCNk2Y0iUj5YSeuDCefgGNJUmki0U5g== X-Received: by 2002:a1c:4954:: with SMTP id w81mr4636156wma.182.1623930835312; Thu, 17 Jun 2021 04:53:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 04/15] hw/display/sm501: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Thu, 17 Jun 2021 13:53:23 +0200 Message-Id: <20210617115334.2761573-5-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of using the confuse i2c_send_recv(), rewrite to directly call i2c_recv() & i2c_send(), resulting in code easier to review. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: BALATON Zoltan --- hw/display/sm501.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index f276276f7f1..569661a0746 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1033,17 +1033,18 @@ static void sm501_i2c_write(void *opaque, hwaddr ad= dr, uint64_t value, case SM501_I2C_CONTROL: if (value & SM501_I2C_CONTROL_ENABLE) { if (value & SM501_I2C_CONTROL_START) { + bool is_recv =3D s->i2c_addr & 1; int res =3D i2c_start_transfer(s->i2c_bus, s->i2c_addr >> 1, - s->i2c_addr & 1); + is_recv); if (res) { s->i2c_status |=3D SM501_I2C_STATUS_ERROR; } else { int i; for (i =3D 0; i <=3D s->i2c_byte_count; i++) { - res =3D i2c_send_recv(s->i2c_bus, &s->i2c_data[i], - !(s->i2c_addr & 1)); - if (res) { + if (is_recv) { + s->i2c_data[i] =3D i2c_recv(s->i2c_bus); + } else if (i2c_send(s->i2c_bus, s->i2c_data[i]) < = 0) { s->i2c_status |=3D SM501_I2C_STATUS_ERROR; return; } --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931077813850.394177658412; Thu, 17 Jun 2021 04:57:57 -0700 (PDT) Received: from localhost ([::1]:44502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqei-0006QR-KT for importer2@patchew.org; Thu, 17 Jun 2021 07:57:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqax-0006sU-2O for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:03 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:34486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqav-0005Iv-Kd for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:02 -0400 Received: by mail-wr1-x42a.google.com with SMTP id e22so2861297wrc.1 for ; Thu, 17 Jun 2021 04:54:01 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id t9sm4646977wmq.14.2021.06.17.04.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+jgVQlH2ZLclahkepwe/jy0S2FD3dNErrT3z+1Ksb0M=; b=Iwd60xuZjpJGwG+LwZyaNmfItJOD/FJ2+T93IOBnxXDHNhzaNSphuSSBCgdcDORg5b QfI1i/JKSH63W20qI/eV56RRdknMuOkefb9AuzNU9ENEK99zb1RvAPGeMCT0Y/iPBpQX 1FHtH7c3TrJ49O9kSLQ7kXWjjHHVEi0gMYsLaR48gdpWvVEBNfQpzQOdh+nAo8eiyX9d k0yQuXnYqLgiJFixd+vEqmKzeutJLf5HyIuhwjvffpEEhtSvc76SeIPvvq5VWdiIt3s2 r9S+gM79r713P4MnyJMehzXB0RvS9TMkmtzBSQtz7dOjChZTQ2QAoUTKIeOECASZgxEo 5viw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+jgVQlH2ZLclahkepwe/jy0S2FD3dNErrT3z+1Ksb0M=; b=iIILDffhUs8kerATi69zc3fiOE0edGm2Agl7TtnMwUJgZMZPLodPxGqtBBiwaVt1yb B3ApV3wx2JwR+HWA2zGdpHGFkpB8ZPqTlHYPmnHmXnGclWQ01cOC6uF9VUFagmL/H0VR tTMzSHBr3PtDlZDxkUXAx02jkhjOCcXh+sTH7TM7XwzR9ULA0FnCkWVJBRMwL8e72iWo YlMutAFuk+KatYHHp8ZQsZdh5UxQ9f6PZSQrrfZOv2IXfMgCwn865wCjSFsl91vi+Ihy nC9PJRqvOSpc+sh/wnKa19x7frwn6KhDVGaNXXZmnga2Vim14JYsQKglA3DHwTyaWDej UqwA== X-Gm-Message-State: AOAM531ia2txfOwIGP089OfCyauKIF+ju6tk3U1phRmFNMcg55xngJEM ueucNhwnrSGSYaxBXfZ5Jo8IMayXWjB2jg== X-Google-Smtp-Source: ABdhPJxlMaX6LbeJQo3w9yS2feZHWLGxEY3MUsI+tIk2OM/1mSFaqoERiQEGTP8gYN6DvYvQ+fcwlw== X-Received: by 2002:a5d:51c3:: with SMTP id n3mr5171928wrv.322.1623930840006; Thu, 17 Jun 2021 04:54:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 05/15] hw/i2c/ppc4xx_i2c: Add reference to datasheet Date: Thu, 17 Jun 2021 13:53:24 +0200 Message-Id: <20210617115334.2761573-6-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It took me a while to find this model datasheet, since it is an OCR scan. Add a reference to save other developers time. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i2c/ppc4xx_i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c index c0a8e045670..f4c5bc12d36 100644 --- a/hw/i2c/ppc4xx_i2c.c +++ b/hw/i2c/ppc4xx_i2c.c @@ -1,6 +1,8 @@ /* * PPC4xx I2C controller emulation * + * Documentation: PPC405GP User's Manual, Chapter 22. IIC Bus Interface + * * Copyright (c) 2007 Jocelyn Mayer * Copyright (c) 2012 Fran=C3=A7ois Revol * Copyright (c) 2016-2018 BALATON Zoltan --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931245164100.19838663003907; Thu, 17 Jun 2021 05:00:45 -0700 (PDT) Received: from localhost ([::1]:51834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqhP-00030G-Cf for importer2@patchew.org; Thu, 17 Jun 2021 08:00:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqb1-0007AX-LH for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:07 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:34490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqb0-0005Kx-0l for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:07 -0400 Received: by mail-wr1-x42d.google.com with SMTP id e22so2861560wrc.1 for ; Thu, 17 Jun 2021 04:54:05 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id a24sm4183461wmj.30.2021.06.17.04.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WmyHaJHcvUKLEVm6aSpmTart9qZchQ/2Um+oWz7mMdA=; b=X9jMfQFSYaokIrJZgLTlIh90r++RmcxwxZ9RzZwSiOFjtN3CHjZqt/amS5e3CZaXPQ 6f117Et2G/F1m1yoGa240WMr/6u+VLdxuEe0JC01KMueSKYfMwV4iUYtSWbjL1u8xtmz n6ohTuFv9bDnbEewUQjZhs7823y44hj5SWML9N0DY/mTfluO/KpXdnHo5smOAHAit434 sQ48EN9bigAF/P01ilMsTsANZcPTNtzld/MW1zLw3/YSrdW2yF5DBpW+drayPbnPQne4 mYeLuDqQyMf15dSaD8acsnDfYTtlICtIlkaAeQdEbpwPmqUU8HiOAlwHTCNAtwky2fyl 22EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=WmyHaJHcvUKLEVm6aSpmTart9qZchQ/2Um+oWz7mMdA=; b=n66uFYRGeALIVPhUKEXIK0fKRRfz+otg8wsMQij0vDuphwEVTHe1Ct3//f8dsPJfgQ H6+g7f8h/3kgsWMQFVhsFpjJFrQVJ4Kp34pDmGEyyCg7JJk+bdFyfrAwPxmP5cuz93B4 jdWFxmCqk8YeQEggSsvxh5Bh07SXuriWI1d35r7ABl3D5eF0cbirpUMq48SinvrKVkW6 JnMnDXXgoaVGZlAa5RhHsTj7WmwTh218QrYNt33VgBeKTariTvrlfY3ImDRsyngPubvb PzPCdWjlfpn27auwaBelzORsbYvA9WKJ7/ktOaWtdp45RERsWhUo5fSaWEdwIsBGHAi7 9anQ== X-Gm-Message-State: AOAM530uK82vjhRa4OdmzY11oP9s4PAgqJsIE2/EuwwR5c2H+vOEFoVa 8jMM+yMV7svmB2R7LdltZv9QVtHyL9LzJA== X-Google-Smtp-Source: ABdhPJw0RrTLORTJPfvp+O+0sFRcg5OSgR/BCQ7u2LfBXQH+C9Im4wFEiIReX7F7PFPd471SjQLp2w== X-Received: by 2002:a05:6000:18a8:: with SMTP id b8mr5088922wri.208.1623930844525; Thu, 17 Jun 2021 04:54:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 06/15] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Thu, 17 Jun 2021 13:53:25 +0200 Message-Id: <20210617115334.2761573-7-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of using the confuse i2c_send_recv(), rewrite to directly call i2c_recv() & i2c_send(), resulting in code easier to review. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: BALATON Zoltan --- hw/i2c/ppc4xx_i2c.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c index f4c5bc12d36..75d50f15158 100644 --- a/hw/i2c/ppc4xx_i2c.c +++ b/hw/i2c/ppc4xx_i2c.c @@ -240,11 +240,14 @@ static void ppc4xx_i2c_writeb(void *opaque, hwaddr ad= dr, uint64_t value, i2c->sts &=3D ~IIC_STS_ERR; } } - if (!(i2c->sts & IIC_STS_ERR) && - i2c_send_recv(i2c->bus, &i2c->mdata[i], !recv)) { - i2c->sts |=3D IIC_STS_ERR; - i2c->extsts |=3D IIC_EXTSTS_XFRA; - break; + if (!(i2c->sts & IIC_STS_ERR)) { + if (recv) { + i2c->mdata[i] =3D i2c_recv(i2c->bus); + } else if (i2c_send(i2c->bus, i2c->mdata[i]) < 0) { + i2c->sts |=3D IIC_STS_ERR; + i2c->extsts |=3D IIC_EXTSTS_XFRA; + break; + } } if (value & IIC_CNTL_RPST || !(value & IIC_CNTL_CHT)) { i2c_end_transfer(i2c->bus); --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162393105462919.241619573084904; Thu, 17 Jun 2021 04:57:34 -0700 (PDT) Received: from localhost ([::1]:42704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqeL-0005D1-JK for importer2@patchew.org; Thu, 17 Jun 2021 07:57:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqb6-0007U5-KD for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:14 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:34494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqb5-0005Mp-2q for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:12 -0400 Received: by mail-wr1-x430.google.com with SMTP id e22so2861829wrc.1 for ; Thu, 17 Jun 2021 04:54:10 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id t16sm5340426wmi.2.2021.06.17.04.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ePgJDFFOw4rGg/va2x01kE3ubJf7MZ1h52aSuruLrco=; b=HnNmlRALfMLH2OE+ckY37Pm42oO7kVbaezU//2KLKTCN1Sv4SBCZ8MLb2qXOylccdX 3axcG7n9mHxmzJJi6rvWaz0Cf/ZSygugBKywmAPdZNQzEF6MbZqW1paXCceiaVyQbhEs yk5pHXgAdZtpXOXw2O1cgQ5PtGM2mZoEv0Kk923tf2777S7uySiGgaFoDa+/k5XPcml8 BjHbThrXV6LYdx6OzBb7LkrdqOMVgCzVULxHkI20WlPQHiQBpJrDPXaHrCGbpQxv0dpZ B1vVsMAhrc04GD4KoBqECRGMIU64zVnSaV7YIkQIcMnB7a/REGpEY0HYeYtoxxs6nEzu NJTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ePgJDFFOw4rGg/va2x01kE3ubJf7MZ1h52aSuruLrco=; b=IwFw3bTxjeYIti5eBl7Jav9WM4HrM402/Smg+BQrg1CCJj5MJUabrWPXo0IGip22rd XivqKGFPan0hvUqgKMaDVnP4+DZVZC2JSdLfb9svDnVIY/JYQWree4U7tCaU63JbM1LQ Sq9LRMz4reniS6Yu8XTl2+NPXgZkJa3E+Ey4+9wIcD+VkKNvNEO7vAQKQ23KPJ+mSJWO /Hw/cpjcUaiQyVHqbiKyJQqwVmsq/8hLVeKvrqmQZqFOwM0QUruyJE5a1XHmWweMcLOn pNhs3NdKYyuXqjFmi+djYO+dUozvu6NkOCgEVslCAFGNxSbdzHgaKp59gETua5Dj0ieE Et3A== X-Gm-Message-State: AOAM531+07ePBnC7I0qeX/7zhN7v+mLQHfaOp0ygeMzomDI9/Wn+vmjO b976WJFBdmKeI536TjlXf4oH8+j4Pm/jzQ== X-Google-Smtp-Source: ABdhPJzo3GW4MCp+ya2yUhB9nqqkgHhkW4zzJmMBoU+eZC81lsQJ4Z7tNOPrzcpZRWwq7Jvjs6Y+Bw== X-Received: by 2002:a5d:5903:: with SMTP id v3mr5164227wrd.285.1623930849399; Thu, 17 Jun 2021 04:54:09 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 07/15] hw/misc/auxbus: Fix MOT/classic I2C mode Date: Thu, 17 Jun 2021 13:53:26 +0200 Message-Id: <20210617115334.2761573-8-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since its introduction in commit 6fc7f77fd2 i2c_start_transfer() uses incorrectly the direction of the transfer (the last argument is called 'is_recv'). Fix by inverting the argument, we now have is_recv =3D !is_write. Fixes: 6fc7f77fd2 ("introduce aux-bus") Reported-by: BALATON Zoltan Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/auxbus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 6c099ae2a2d..148b070ce4a 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -139,7 +139,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, i2c_end_transfer(i2c_bus); } =20 - if (i2c_start_transfer(i2c_bus, address, is_write)) { + if (i2c_start_transfer(i2c_bus, address, !is_write)) { ret =3D AUX_I2C_NACK; break; } @@ -170,7 +170,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, /* * No transactions started.. */ - if (i2c_start_transfer(i2c_bus, address, is_write)) { + if (i2c_start_transfer(i2c_bus, address, !is_write)) { break; } } else if ((address !=3D bus->last_i2c_address) || @@ -179,7 +179,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, * Transaction started but we need to restart.. */ i2c_end_transfer(i2c_bus); - if (i2c_start_transfer(i2c_bus, address, is_write)) { + if (i2c_start_transfer(i2c_bus, address, !is_write)) { break; } } --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931284287273.9091795679145; Thu, 17 Jun 2021 05:01:24 -0700 (PDT) Received: from localhost ([::1]:52806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqi3-0003em-4z for importer2@patchew.org; Thu, 17 Jun 2021 08:01:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbB-0007gT-0T for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:17 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:39458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqb9-0005OT-He for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:16 -0400 Received: by mail-wr1-x436.google.com with SMTP id v9so6462869wrx.6 for ; Thu, 17 Jun 2021 04:54:15 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id q3sm5353360wrz.71.2021.06.17.04.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mF7eiAdIfTv9rlxceo15bFIxRiqB6zGPW3KZaJR5WqY=; b=JPiiubiExRrQKBsdszp7UUvTYYhP0JJkS8zd/Voextvc83gla6v7bKo/p9EuBXcTHK kK6LtQeWATZc8kBPBsAoV6UpFkPVlfDe0MH7/+C6LwAcvJwny6UdrKjniGQEADe2Ebf6 w3pSKIQ0wIAxctL2tj30eKV5yPO7gl5RpeQjNqRYOd8cO2yQeKlDpgxHgdoQLkQRfp5c Q2gp2C6hXQXfRHpBxN3tFgqzfUJ5JXtxJTudZYt5OibUyQc+rTrFaxfahfwumD3NAhCP E2O2UH+O/77PYxgOFxbUAB4nvWZmdHA4Uk+fW93aHDP62WvLDnkfbynccnZy3PRxIOov LEHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mF7eiAdIfTv9rlxceo15bFIxRiqB6zGPW3KZaJR5WqY=; b=X0tEtx8a5g/KciSv47VRcwqYRS/N8oyFKxr1AY+FX1hOkjzwYaELiRtj50fq9eRCQN T+D75Xj7/I3hoWrp8Nh87wBGBJc9oscwYBe5GcsGJCx3DR3teubnzZvfXVWPIjpAyFWJ nnKBRX20RH6inxcISMC4kocrWAUKQthvV6aDWkpJCzLeqzRwT4+d3MIDuLoSRNoxj7GZ cjkbGjmCl2M6ysII3R0A0WrjpJ+rLVrDceZMGFwR8IxyArpgDI00UfHsXlVuUtQtvu3o EWCLClm0EqpIpQqyRDCs9p2BcDTtu922TLcNJ3d50o6Qi7KCdTNGo4CFB3iY3igbRCTZ j/eA== X-Gm-Message-State: AOAM532kebthDgqKy+gE8Zzmj/zs5CDcaQp5x/oiJqg5+hTkTfxr5UWa 7UWiEpONkfXH0WS2Fme3PGg5XkS91eifCw== X-Google-Smtp-Source: ABdhPJy7L9o0KzEjyXX1qK62ulMKIaKv2GZAJCvx2gqqCFd3u/qYax0aNC2uDu0Z8yii393mGwUAdg== X-Received: by 2002:adf:a1c1:: with SMTP id v1mr5230119wrv.234.1623930854005; Thu, 17 Jun 2021 04:54:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 08/15] hw/misc/auxbus: Explode READ_I2C / WRITE_I2C_MOT cases Date: Thu, 17 Jun 2021 13:53:27 +0200 Message-Id: <20210617115334.2761573-9-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) To allow further simplifications in the following commits, start copying WRITE_I2C code to the READ_I2C, and READ_I2C_MOT to WRITE_I2C_MOT. No logical change. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/auxbus.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 148b070ce4a..9cc9cf3be32 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -133,6 +133,26 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint= 32_t address, * Classic I2C transactions.. */ case READ_I2C: + is_write =3D cmd =3D=3D READ_I2C ? false : true; + if (i2c_bus_busy(i2c_bus)) { + i2c_end_transfer(i2c_bus); + } + + if (i2c_start_transfer(i2c_bus, address, !is_write)) { + ret =3D AUX_I2C_NACK; + break; + } + + ret =3D AUX_I2C_ACK; + while (len > 0) { + if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + ret =3D AUX_I2C_NACK; + break; + } + len--; + } + i2c_end_transfer(i2c_bus); + break; case WRITE_I2C: is_write =3D cmd =3D=3D READ_I2C ? false : true; if (i2c_bus_busy(i2c_bus)) { @@ -163,6 +183,39 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint= 32_t address, * - We changed the address. */ case WRITE_I2C_MOT: + is_write =3D cmd =3D=3D READ_I2C_MOT ? false : true; + ret =3D AUX_I2C_NACK; + if (!i2c_bus_busy(i2c_bus)) { + /* + * No transactions started.. + */ + if (i2c_start_transfer(i2c_bus, address, !is_write)) { + break; + } + } else if ((address !=3D bus->last_i2c_address) || + (bus->last_transaction !=3D cmd)) { + /* + * Transaction started but we need to restart.. + */ + i2c_end_transfer(i2c_bus); + if (i2c_start_transfer(i2c_bus, address, !is_write)) { + break; + } + } + + bus->last_transaction =3D cmd; + bus->last_i2c_address =3D address; + while (len > 0) { + if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + i2c_end_transfer(i2c_bus); + break; + } + len--; + } + if (len =3D=3D 0) { + ret =3D AUX_I2C_ACK; + } + break; case READ_I2C_MOT: is_write =3D cmd =3D=3D READ_I2C_MOT ? false : true; ret =3D AUX_I2C_NACK; --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931451570438.94815292708574; Thu, 17 Jun 2021 05:04:11 -0700 (PDT) Received: from localhost ([::1]:60206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqkj-0000eK-RA for importer2@patchew.org; Thu, 17 Jun 2021 08:04:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbH-000871-DX for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:23 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbE-0005RR-70 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:23 -0400 Received: by mail-wr1-x432.google.com with SMTP id c9so6463768wrt.5 for ; Thu, 17 Jun 2021 04:54:19 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id t19sm1450841wmh.20.2021.06.17.04.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TAZ5Nd2Zr4AEdYczPbEyYCejydYTPBGPwGnfyFJKBD8=; b=CwTjhLWsQZYAVq13+e3HDpBuLgpQwdDkTcKDY3pMYtxj/PYPV4rLubz30QEJ7zFdgH 4epbLJTm9YI3zqnYkAs11TTdL0x9dghf0/KHHVAxc45BVxxWazsna1w5AYkAGQm09GCB wbEiTo47rULP8x1Hdh14dXRBcO8n8MbpPoCaSLBwcYF7uy667E2MVj0ZCT1y/qU2IQal nrzsWHHpgLgJiZn6DJ4iN99zpMiWtzCdv/GW3vutocDXeUpFJwSWR7RintG+1Kdz/ghz LVlu9iNxsoMBVksaI0XIBMqwGdFj5DrvgkgxCKGTXR6TPiwtfm0HQNVOOjY2e+uvotQN YYLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=TAZ5Nd2Zr4AEdYczPbEyYCejydYTPBGPwGnfyFJKBD8=; b=E+LfejdrCl+LkphHgaBxAcfCLYTVPmR+QUM4AnRB8JuQ4ucD/ldiWvwjpWZMY0I7Fe yoFKBAVzKceEe/IuaFdx1cE4W1i96lNuqqFsT84PfESCmwzU+Fn7rrEcACmjw3RDzgtX IZJrf6u9AJSc9V7q3aeXU72KS2tCKgipyY7VXIIjaUxg1EyxRyd1o3cJiejpHMtV7HKs ABBt74BlOXv92q7mVNOivCFodzBk1Ea2iuoRTGomAkcP54q8WXtwnY16K+XrQ3A40ISg cDYuXXTX8L49yg0LaFlJZthqLSPDL/bR0Ooc6Ai+LA0gIP3/9UUhaCSe9X6RgOueaFkt Hz6w== X-Gm-Message-State: AOAM531/VJuYpUxXH1rzUkx8WoCmvDq0qI0iYh1BTQBrSPcudY8Ztb94 oZ3bxammHQI6Z/upMytIIMPLnyLbGwfIZA== X-Google-Smtp-Source: ABdhPJxH1I0glMxCfk3dHYTGBCn/ILGSaLP2IV0PLb7Hh7tBLUtkTKcKQqTzKT3+uBcqoNdQ8EzlzQ== X-Received: by 2002:adf:bd88:: with SMTP id l8mr5204015wrh.90.1623930858568; Thu, 17 Jun 2021 04:54:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 09/15] hw/misc/auxbus: Replace 'is_write' boolean by its value Date: Thu, 17 Jun 2021 13:53:28 +0200 Message-Id: <20210617115334.2761573-10-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove the 'is_write' boolean by directly using its value in place. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/auxbus.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 9cc9cf3be32..d96219aef88 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -106,7 +106,6 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, AUXReply ret =3D AUX_NACK; I2CBus *i2c_bus =3D aux_get_i2c_bus(bus); size_t i; - bool is_write =3D false; =20 DPRINTF("request at address 0x%" PRIX32 ", command %u, len %u\n", addr= ess, cmd, len); @@ -117,11 +116,10 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, */ case WRITE_AUX: case READ_AUX: - is_write =3D cmd =3D=3D READ_AUX ? false : true; for (i =3D 0; i < len; i++) { if (!address_space_rw(&bus->aux_addr_space, address++, MEMTXATTRS_UNSPECIFIED, data++, 1, - is_write)) { + cmd =3D=3D WRITE_AUX)) { ret =3D AUX_I2C_ACK; } else { ret =3D AUX_NACK; @@ -133,19 +131,18 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, * Classic I2C transactions.. */ case READ_I2C: - is_write =3D cmd =3D=3D READ_I2C ? false : true; if (i2c_bus_busy(i2c_bus)) { i2c_end_transfer(i2c_bus); } =20 - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, true)) { ret =3D AUX_I2C_NACK; break; } =20 ret =3D AUX_I2C_ACK; while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + if (i2c_send_recv(i2c_bus, data++, false) < 0) { ret =3D AUX_I2C_NACK; break; } @@ -154,19 +151,18 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, i2c_end_transfer(i2c_bus); break; case WRITE_I2C: - is_write =3D cmd =3D=3D READ_I2C ? false : true; if (i2c_bus_busy(i2c_bus)) { i2c_end_transfer(i2c_bus); } =20 - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, false)) { ret =3D AUX_I2C_NACK; break; } =20 ret =3D AUX_I2C_ACK; while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + if (i2c_send_recv(i2c_bus, data++, true) < 0) { ret =3D AUX_I2C_NACK; break; } @@ -183,13 +179,12 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, * - We changed the address. */ case WRITE_I2C_MOT: - is_write =3D cmd =3D=3D READ_I2C_MOT ? false : true; ret =3D AUX_I2C_NACK; if (!i2c_bus_busy(i2c_bus)) { /* * No transactions started.. */ - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, false)) { break; } } else if ((address !=3D bus->last_i2c_address) || @@ -198,7 +193,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, * Transaction started but we need to restart.. */ i2c_end_transfer(i2c_bus); - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, false)) { break; } } @@ -206,7 +201,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, bus->last_transaction =3D cmd; bus->last_i2c_address =3D address; while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + if (i2c_send_recv(i2c_bus, data++, true) < 0) { i2c_end_transfer(i2c_bus); break; } @@ -217,13 +212,12 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, } break; case READ_I2C_MOT: - is_write =3D cmd =3D=3D READ_I2C_MOT ? false : true; ret =3D AUX_I2C_NACK; if (!i2c_bus_busy(i2c_bus)) { /* * No transactions started.. */ - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, true)) { break; } } else if ((address !=3D bus->last_i2c_address) || @@ -232,7 +226,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, * Transaction started but we need to restart.. */ i2c_end_transfer(i2c_bus); - if (i2c_start_transfer(i2c_bus, address, !is_write)) { + if (i2c_start_transfer(i2c_bus, address, true)) { break; } } @@ -240,7 +234,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, bus->last_transaction =3D cmd; bus->last_i2c_address =3D address; while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { + if (i2c_send_recv(i2c_bus, data++, false) < 0) { i2c_end_transfer(i2c_bus); break; } --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162393161203026.250438443641997; Thu, 17 Jun 2021 05:06:52 -0700 (PDT) Received: from localhost ([::1]:38874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqnK-0005NL-QG for importer2@patchew.org; Thu, 17 Jun 2021 08:06:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbK-0008Ip-AX for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:26 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:37453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbI-0005T7-MR for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:26 -0400 Received: by mail-wm1-x32c.google.com with SMTP id f16-20020a05600c1550b02901b00c1be4abso6198818wmg.2 for ; Thu, 17 Jun 2021 04:54:24 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id f5sm6126634wrf.22.2021.06.17.04.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lMrFIFZX4VBJPQraxvDxEyJhOku4B5f9uSq095+uB5I=; b=qDhkZeLjhAHgduWQ7jztCxzxHL24Z+ru7vAtjKudTNlRv52tbfcGv7KpE6tTzsKe0l 0n53pU6lwGIJyTrIJZKK2rK5QRLytDN2ZK2cXtEPtv+5wPWCC9RT6Hdopvt5bV1LSpn3 SN988XpJEPnCrnUkk+x4y64gVp9gCq3rZUZ4nOshWl7IJ+eNuRjqYnF6SqB4OarkUjx8 l+Hc8QxZs6MWDy6c3k5ezT5N53ctGnyXwEqrRZjRDUFeNKvxmMcWvvhAT62clTcMVnvp J492lVWJOFvnkOovE3WX3i3E3AnWBCR1WSkCw/96jfTQUr7TAAKD9rUClCH9At81k56U 6r9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=lMrFIFZX4VBJPQraxvDxEyJhOku4B5f9uSq095+uB5I=; b=J5yTYh092SGJp/gnMIsas3KKLxZ0P5F4PE5Pc4wHu7TfgD4DD6GdDcCi4R67tLWjUc 7I1dJuK08mdGCUWh0fnSdvThn6z+Jr4fthvZl9o2rqo/ZqyL3GYUh6tQlhx0zXzRJaSK dYR/Sa0HK9ud8Ugw+USrEj6+LGYP5/f4fPbKF+CHFOV1NvD5OWFuh2T0v6St+JpJ6xw8 qgE0yEBOdVyEP9NbPeHPSVXyndDN25LW+aIKupleXzAJ7OLml90KN6imXkltNPabVmiI 4Le+7uGeoMtRYf/xZC8LRBlIQBrFmDxuThkp1++ygAtepkcmqMz0wqE50J+BZF1SKXkS vUxA== X-Gm-Message-State: AOAM533LbCHP3pO9974CbHcoIK77mNHCKH41AqSP/m45lvlo0t+K/fA7 G3YGfV579yD+ZOScXBVZJak06EgIafMYXw== X-Google-Smtp-Source: ABdhPJzkiMMvmGOa4BIUg/B0FMPUlbQoJs617pqwZgs3ZPMcDAUWnlahc/CMFF+7SbzWq2RQRuONkg== X-Received: by 2002:a05:600c:190f:: with SMTP id j15mr4742749wmq.4.1623930863189; Thu, 17 Jun 2021 04:54:23 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 10/15] hw/misc/auxbus: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Thu, 17 Jun 2021 13:53:29 +0200 Message-Id: <20210617115334.2761573-11-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of using the confuse i2c_send_recv(), replace i2c_send_recv(send =3D true) by i2c_send() and i2c_send_recv(send =3D false) by i2c_recv(). During the replacement we also change a while() statement by for(). The resulting code is easier to review. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/auxbus.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index d96219aef88..44aa9730bc9 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -141,12 +141,8 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint= 32_t address, } =20 ret =3D AUX_I2C_ACK; - while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, false) < 0) { - ret =3D AUX_I2C_NACK; - break; - } - len--; + for (i =3D 0; i < len; i++) { + data[i] =3D i2c_recv(i2c_bus); } i2c_end_transfer(i2c_bus); break; @@ -161,12 +157,11 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, } =20 ret =3D AUX_I2C_ACK; - while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, true) < 0) { + for (i =3D 0; i < len; i++) { + if (i2c_send(i2c_bus, data[i]) < 0) { ret =3D AUX_I2C_NACK; break; } - len--; } i2c_end_transfer(i2c_bus); break; @@ -200,15 +195,13 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, =20 bus->last_transaction =3D cmd; bus->last_i2c_address =3D address; - while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, true) < 0) { + ret =3D AUX_I2C_ACK; + for (i =3D 0; i < len; i++) { + if (i2c_send(i2c_bus, data[i]) < 0) { i2c_end_transfer(i2c_bus); + ret =3D AUX_I2C_NACK; break; } - len--; - } - if (len =3D=3D 0) { - ret =3D AUX_I2C_ACK; } break; case READ_I2C_MOT: @@ -233,16 +226,10 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uin= t32_t address, =20 bus->last_transaction =3D cmd; bus->last_i2c_address =3D address; - while (len > 0) { - if (i2c_send_recv(i2c_bus, data++, false) < 0) { - i2c_end_transfer(i2c_bus); - break; - } - len--; - } - if (len =3D=3D 0) { - ret =3D AUX_I2C_ACK; + for (i =3D 0; i < len; i++) { + data[i] =3D i2c_recv(i2c_bus); } + ret =3D AUX_I2C_ACK; break; default: qemu_log_mask(LOG_UNIMP, "AUX cmd=3D%u not implemented\n", cmd); --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931459232350.58327760837653; Thu, 17 Jun 2021 05:04:19 -0700 (PDT) Received: from localhost ([::1]:32810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqks-0001EG-6l for importer2@patchew.org; Thu, 17 Jun 2021 08:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbO-0008Sk-TC for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:31 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:40626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbN-0005VL-93 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:30 -0400 Received: by mail-wr1-x42c.google.com with SMTP id y7so6421061wrh.7 for ; Thu, 17 Jun 2021 04:54:28 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id k16sm4406285wmr.42.2021.06.17.04.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xaw3RJNkpGriYz8vt+BCpgugibw18q+MPp6XakrxTs4=; b=MIV75LH5f3NzD9QkwVgh2t2wUpIGQ9SnLzse2hAGKUb7Scd/uk9pJ4PP97zet6JrG5 IU6ApWm7fZae/jHaiLTfCf4ke8LpiHr4YI3VM3yYgkZ/Vj7OI2t5W5mbP0591J2g2efm ibBfnYuDPG9qxSPNd3ni++t1fjOQ/kYZeSFa7aCJt9qpeFD7tZCtamoXJyX4lKgpsZr/ LOc3FxIYZogzs6zBOYCCfNXoH3PfQkL0NtKY7HOMoDwoanbnFB6lYpSHDVPLkNLPhpSG XYZmLFs2av/00x5cZIHkiBLPlOgJdExl8NZfyLTCbKvjqMhD1jouJDg5P9lHVK/uKZmZ tixg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Xaw3RJNkpGriYz8vt+BCpgugibw18q+MPp6XakrxTs4=; b=lTU8BR2s57aKY0b6onzXP6OAnJoJCMfP+H1beMTLsWKuUmVKMCQZ4EfTL6The0eFVS DQhiHWI0pee/3afKqElqNJ/jlXYA1X5QsafGjGkLvSSOtiGK3LgYuO9NPSP15SRu1gxe sFH3pLqqfIEVAV3olYWgwGD5paYk/V+Ee/+u2EfHUFcXYMaLOmI5+p0SHMIhyZKBJy/F uy09P2DYRrGd8SGe0RCXvzfanVbPq3A+GCLCDfbhFcjcAKhu5VnXVVpHmT2spOw0WIBz WN3lDHfYF7Az5Uamq0XhFqtnhWE0FiTCUP8y8xRqkecux+X7WqEgqQRG7145xjNceQ8o BuPQ== X-Gm-Message-State: AOAM530AG3WEbgSi/UFFcY/2Qv7fMjV4fHRJi2FFsbhVLfHfD9FlicJs 6/IKlRSyV819y3Bl3rKA2IXNfNhWCVd/og== X-Google-Smtp-Source: ABdhPJw+wqDEWyK7GRV70ApBcSBu5RPp1cJsduLZNqq0b6wrsAcHfa1FEzh/4YWT2vp5EfV6X9QH0A== X-Received: by 2002:adf:bb54:: with SMTP id x20mr3997548wrg.19.1623930867781; Thu, 17 Jun 2021 04:54:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 11/15] hw/i2c: Remove confusing i2c_send_recv() Date: Thu, 17 Jun 2021 13:53:30 +0200 Message-Id: <20210617115334.2761573-12-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We replaced all the i2c_send_recv() calls by the clearer i2c_recv() and i2c_send(), so we can remove this confusing API. Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 1 - hw/i2c/core.c | 50 +++++++++++++++++++------------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 850815e707c..99635b837a5 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -84,7 +84,6 @@ int i2c_bus_busy(I2CBus *bus); int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv); void i2c_end_transfer(I2CBus *bus); void i2c_nack(I2CBus *bus); -int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send); int i2c_send(I2CBus *bus, uint8_t data); uint8_t i2c_recv(I2CBus *bus); bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool broadcast, diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 3a7bae311df..27a66df7f34 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -188,50 +188,42 @@ void i2c_end_transfer(I2CBus *bus) bus->broadcast =3D false; } =20 -int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send) +int i2c_send(I2CBus *bus, uint8_t data) { I2CSlaveClass *sc; I2CSlave *s; I2CNode *node; int ret =3D 0; =20 - if (send) { - QLIST_FOREACH(node, &bus->current_devs, next) { - s =3D node->elt; - sc =3D I2C_SLAVE_GET_CLASS(s); - if (sc->send) { - trace_i2c_send(s->address, *data); - ret =3D ret || sc->send(s, *data); - } else { - ret =3D -1; - } + QLIST_FOREACH(node, &bus->current_devs, next) { + s =3D node->elt; + sc =3D I2C_SLAVE_GET_CLASS(s); + if (sc->send) { + trace_i2c_send(s->address, data); + ret =3D ret || sc->send(s, data); + } else { + ret =3D -1; } - return ret ? -1 : 0; - } else { - ret =3D 0xff; - if (!QLIST_EMPTY(&bus->current_devs) && !bus->broadcast) { - sc =3D I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->el= t); - if (sc->recv) { - s =3D QLIST_FIRST(&bus->current_devs)->elt; - ret =3D sc->recv(s); - trace_i2c_recv(s->address, ret); - } - } - *data =3D ret; - return 0; } -} =20 -int i2c_send(I2CBus *bus, uint8_t data) -{ - return i2c_send_recv(bus, &data, true); + return ret ? -1 : 0; } =20 uint8_t i2c_recv(I2CBus *bus) { uint8_t data =3D 0xff; + I2CSlaveClass *sc; + I2CSlave *s; + + if (!QLIST_EMPTY(&bus->current_devs) && !bus->broadcast) { + sc =3D I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt); + if (sc->recv) { + s =3D QLIST_FIRST(&bus->current_devs)->elt; + data =3D sc->recv(s); + trace_i2c_recv(s->address, data); + } + } =20 - i2c_send_recv(bus, &data, false); return data; } =20 --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931073793375.20006359072215; Thu, 17 Jun 2021 04:57:53 -0700 (PDT) Received: from localhost ([::1]:44044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqee-00068D-Ld for importer2@patchew.org; Thu, 17 Jun 2021 07:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbT-00007t-M2 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:36 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:45007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbR-0005X0-W6 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:35 -0400 Received: by mail-wr1-x42f.google.com with SMTP id f2so6424487wri.11 for ; Thu, 17 Jun 2021 04:54:33 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id k67sm2500562wma.14.2021.06.17.04.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eoP4CL94JaZlg7eqmYc7iZiTJ8FoF/Caiy1Z28ZBDWs=; b=G858hUL8y+gTNB0JQ+0W+kMiCs2mS7ppF05b4PCshZcyPxCoSMyDPl4KvfjVycpMql jM5O9Y2RmsF44b/GvgTOb4uR2frtFvKinnAx4aatiri4swBQfI1fmXe/c13krpttmRBT lVC1IpemzEjr4I47nmpTlDJVaZBT1LdvByGy01vzwHWZ9VInJtS2qpJsOcCg6I2rk9aN cSC/W6niuXxSP24DxaQOK8w2BkoVadI4+Jgq/CJHnYICXTxbYMjCUdyZ5HRrBDO8GAef wTbtudiu7vT+p0llH1+3dMKDuKsEDGlIqH55HrBFNky1yp2VhCrUhSaviclm0Yn8PCiP DoYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=eoP4CL94JaZlg7eqmYc7iZiTJ8FoF/Caiy1Z28ZBDWs=; b=VFlKdHi8zg6yvF6A0LGDjDzQ0vXuw0aFYLxCPr8bqIPEpDGq0fhJFQkgWe6ZFkxwM2 VdRLZsyq9Bud+C4DVffxhH1Nq/Pk0cmcIuSoJ25GtWl2yospTHqeAJVPOeiNkNIPTTkH j+QCeLGMeDNEpQje46FSA5A4E+wS3SKg9d164GXqe2CKzAeA/gqr00aatv0reuvrLg/x j97wbtQ1TSGr0gGuhPZR1wMWQNTX2pllTXn1B8CgdR2meobpJaIqa/q8/RK9t3E2EkYC nfUIbknEJvkwyVXr9RUVH8l+7lH2L9GT+1Fk1zzoCUqgBUGThH+5FPHPFU8D6o/zeOH8 USqw== X-Gm-Message-State: AOAM532BSaQBcEcizV93w2L1ZkKjF8yRr+50JHjoiLolnX/Musc5AYwd qNzTko3GXQYDcwEuZpjC73u8v7LJKUnNJA== X-Google-Smtp-Source: ABdhPJyvmMl4ZymDWUVIAC8xDMf3w9HvnjUuvFr1alvSkvyE+znMf1NKp6HrkTxPmMTyhzLc+D1tfg== X-Received: by 2002:a5d:4d09:: with SMTP id z9mr5270010wrt.5.1623930872435; Thu, 17 Jun 2021 04:54:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 12/15] hw/i2c: Rename i2c_set_slave_address() -> i2c_slave_set_address() Date: Thu, 17 Jun 2021 13:53:31 +0200 Message-Id: <20210617115334.2761573-13-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Other functions from I2C slave API are named "i2c_slave_XXX()". Follow that pattern with set_address(). Add docstring along. No logical change. Patch created mechanically using: $ sed -i s/i2c_set_slave_address/i2c_slave_set_address/ \ $(git grep -l i2c_set_slave_address) Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 8 +++++++- hw/arm/pxa2xx.c | 2 +- hw/arm/spitz.c | 4 ++-- hw/display/ati.c | 2 +- hw/display/sm501.c | 2 +- hw/display/xlnx_dp.c | 2 +- hw/i2c/core.c | 2 +- hw/i2c/imx_i2c.c | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 99635b837a5..2adf521b271 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -79,7 +79,6 @@ struct I2CBus { }; =20 I2CBus *i2c_init_bus(DeviceState *parent, const char *name); -void i2c_set_slave_address(I2CSlave *dev, uint8_t address); int i2c_bus_busy(I2CBus *bus); int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv); void i2c_end_transfer(I2CBus *bus); @@ -141,6 +140,13 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const c= har *name, uint8_t addr); */ bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp); =20 +/** + * Set the I2C bus address of a slave device + * @dev: I2C slave device + * @address: I2C address of the slave when put on a bus + */ +void i2c_slave_set_address(I2CSlave *dev, uint8_t address); + extern const VMStateDescription vmstate_i2c_slave; =20 #define VMSTATE_I2C_SLAVE(_field, _state) { \ diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index fdc4955e95b..15a247efae2 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -1437,7 +1437,7 @@ static void pxa2xx_i2c_write(void *opaque, hwaddr add= r, break; =20 case ISAR: - i2c_set_slave_address(I2C_SLAVE(s->slave), value & 0x7f); + i2c_slave_set_address(I2C_SLAVE(s->slave), value & 0x7f); break; =20 case IDBR: diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index b45a929cbd9..c0f0f8193f4 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -769,9 +769,9 @@ static void spitz_wm8750_addr(void *opaque, int line, i= nt level) { I2CSlave *wm =3D (I2CSlave *) opaque; if (level) - i2c_set_slave_address(wm, SPITZ_WM_ADDRH); + i2c_slave_set_address(wm, SPITZ_WM_ADDRH); else - i2c_set_slave_address(wm, SPITZ_WM_ADDRL); + i2c_slave_set_address(wm, SPITZ_WM_ADDRL); } =20 static void spitz_i2c_setup(PXA2xxState *cpu) diff --git a/hw/display/ati.c b/hw/display/ati.c index 4c3ad8f47b0..31f22754dce 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -968,7 +968,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **err= p) I2CBus *i2cbus =3D i2c_init_bus(DEVICE(s), "ati-vga.ddc"); bitbang_i2c_init(&s->bbi2c, i2cbus); I2CSlave *i2cddc =3D I2C_SLAVE(qdev_new(TYPE_I2CDDC)); - i2c_set_slave_address(i2cddc, 0x50); + i2c_slave_set_address(i2cddc, 0x50); qdev_realize_and_unref(DEVICE(i2cddc), BUS(i2cbus), &error_abort); =20 /* mmio register space */ diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 569661a0746..663c37e7f28 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1828,7 +1828,7 @@ static void sm501_init(SM501State *s, DeviceState *de= v, s->i2c_bus =3D i2c_init_bus(dev, "sm501.i2c"); /* ddc */ I2CDDCState *ddc =3D I2CDDC(qdev_new(TYPE_I2CDDC)); - i2c_set_slave_address(I2C_SLAVE(ddc), 0x50); + i2c_slave_set_address(I2C_SLAVE(ddc), 0x50); qdev_realize_and_unref(DEVICE(ddc), BUS(s->i2c_bus), &error_abort); =20 /* mmio */ diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 4fd6aeb18b5..2bb7a5441ad 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1253,7 +1253,7 @@ static void xlnx_dp_init(Object *obj) object_property_add_child(OBJECT(s), "dpcd", OBJECT(s->dpcd)); =20 s->edid =3D I2CDDC(qdev_new("i2c-ddc")); - i2c_set_slave_address(I2C_SLAVE(s->edid), 0x50); + i2c_slave_set_address(I2C_SLAVE(s->edid), 0x50); object_property_add_child(OBJECT(s), "edid", OBJECT(s->edid)); =20 fifo8_create(&s->rx_fifo, 16); diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 27a66df7f34..6af24c9e797 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -66,7 +66,7 @@ I2CBus *i2c_init_bus(DeviceState *parent, const char *nam= e) return bus; } =20 -void i2c_set_slave_address(I2CSlave *dev, uint8_t address) +void i2c_slave_set_address(I2CSlave *dev, uint8_t address) { dev->address =3D address; } diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c index 2e02e1c4faa..9792583fea7 100644 --- a/hw/i2c/imx_i2c.c +++ b/hw/i2c/imx_i2c.c @@ -171,7 +171,7 @@ static void imx_i2c_write(void *opaque, hwaddr offset, switch (offset) { case IADR_ADDR: s->iadr =3D value & IADR_MASK; - /* i2c_set_slave_address(s->bus, (uint8_t)s->iadr); */ + /* i2c_slave_set_address(s->bus, (uint8_t)s->iadr); */ break; case IFDR_ADDR: s->ifdr =3D value & IFDR_MASK; --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931278995957.6762083828556; Thu, 17 Jun 2021 05:01:18 -0700 (PDT) Received: from localhost ([::1]:52410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqhx-0003Oi-DQ for importer2@patchew.org; Thu, 17 Jun 2021 08:01:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbX-0000OS-Qt for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:39 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:42766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbW-0005Z2-Aa for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:39 -0400 Received: by mail-wr1-x42f.google.com with SMTP id c5so6439371wrq.9 for ; Thu, 17 Jun 2021 04:54:37 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id w13sm4302321wmi.48.2021.06.17.04.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DtENdvfDn6VhzVLT/89Jq/1ZlyaMFR9nNkP3jZQYETo=; b=sD3Nh+DpYARiEPwFRlpCqNmf1bec5ZvkJmyDTmr6ww98byox06r6/rT+qlfn46NIlS Ri2jSVFSiSUv2Bj6vyYcxufbUOH46pejVU9tKKWohTxT5gk2xbDYBrWMiUkxB6W9Ifdv 2fig2fH8e9NKvH4sIM8uDMJBcQZoZi6D9mnnSCke21yKkmwbsGygX1mDTdyJcX+wwiM1 Kb1/Yi8RP7xkFMOwlrQog+zc3oDgpjCDpeLGAFXWXniTxfR5QdQPzn7UdQeP/AmXOIms SWCgbaAj0/1aOJHrDcbXSzcO2Pk0RzWax59sdUvkqi7Grrh2dQ+hmDY4KX8X6b6EIY5Z bpAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DtENdvfDn6VhzVLT/89Jq/1ZlyaMFR9nNkP3jZQYETo=; b=S85XK9EH0a4qQP2ONgFGkz2jfjMUNspT3kWzOubB7zHuLSKybEzjkmVU1yEicwXGPU ueG7GtPGZa30WmfV60fG5HjQ3KGkD8auGZDyeCg0+WHcRma725J62k6E9PSDEeVG85+c Qx6Mz1eE+BM5b5r017mHufJV+3/pYfSzJB7fYf8eF5Xd/eZb4GFBfr4uhmPRn3IN+oxy HTY/iw3KdVNdGCfJLNucmYoN+hbyZEa0jrBXhCkocrnSPho/uN8WP6mTrkIjUNpWq1FO 92TOiF7ZvwZFw+XerIHbZ8bDwJgFh/1VU+67ZQIdB5hWqnKI8nzTW3f8pCYXiwOwJi3F lTAg== X-Gm-Message-State: AOAM530xQDq6eBXD6++dJS3xQyjw32hVX4YIdebxWjLRAVfFvAK8RGJS P//IxcnKzgBx3aA7HaDZUQojNVOTOo5k6Q== X-Google-Smtp-Source: ABdhPJygNMgafvbdZ+odBNFakAc30A8R3rW22k1rXCM/6V1msHnfzfalsIxEuDo6tA/+ZsP1zs2J7Q== X-Received: by 2002:a5d:64ee:: with SMTP id g14mr5442881wri.66.1623930876941; Thu, 17 Jun 2021 04:54:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 13/15] hw/i2c: Make i2c_start_transfer() direction argument a boolean Date: Thu, 17 Jun 2021 13:53:32 +0200 Message-Id: <20210617115334.2761573-14-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: BALATON Zoltan Make the argument representing the direction of the transfer a boolean type. Rename the boolean argument as 'is_recv' to match i2c_recv_send(). Document the function prototype. Signed-off-by: BALATON Zoltan Message-Id: <20200621145235.9E241745712@zero.eik.bme.hu> [PMD: Split patch, added docstring] Reviewed-by: Richard Henderson Acked-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 12 +++++++++++- hw/i2c/core.c | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 2adf521b271..21f2dba1bf7 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -80,7 +80,17 @@ struct I2CBus { =20 I2CBus *i2c_init_bus(DeviceState *parent, const char *name); int i2c_bus_busy(I2CBus *bus); -int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv); + +/** + * i2c_start_transfer: start a transfer on an I2C bus. + * + * @bus: #I2CBus to be used + * @address: address of the slave + * @is_recv: indicates the transfer direction + * + * Returns: 0 on success, -1 on error + */ +int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv); void i2c_end_transfer(I2CBus *bus); void i2c_nack(I2CBus *bus); int i2c_send(I2CBus *bus, uint8_t data); diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 6af24c9e797..6639ca8c2e0 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -115,7 +115,7 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool br= oadcast, * without releasing the bus. If that fails, the bus is still * in a transaction. */ -int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) +int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv) { I2CSlaveClass *sc; I2CNode *node; @@ -157,7 +157,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, in= t recv) =20 if (sc->event) { trace_i2c_event("start", s->address); - rv =3D sc->event(s, recv ? I2C_START_RECV : I2C_START_SEND); + rv =3D sc->event(s, is_recv ? I2C_START_RECV : I2C_START_SEND); if (rv && !bus->broadcast) { if (bus_scanned) { /* First call, terminate the transfer. */ --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162393172917815.653725076288197; Thu, 17 Jun 2021 05:08:49 -0700 (PDT) Received: from localhost ([::1]:45070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqpE-0001XG-56 for importer2@patchew.org; Thu, 17 Jun 2021 08:08:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbc-0000hi-PQ for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:44 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:38495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbb-0005bO-7x for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:44 -0400 Received: by mail-wr1-x42e.google.com with SMTP id c9so6465151wrt.5 for ; Thu, 17 Jun 2021 04:54:42 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id p11sm5131344wrx.85.2021.06.17.04.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xZIk02rN/B58vn5urmzzUKpoCipYBcMsvK06nQVHHKc=; b=Eod+vIGg0cefzbDAOmaG80IrmsQew7M/iFFJFdmySSzwXU1bWnVriMOQI3QCzHjzCp sumFcLDTAYycWJgr2DMzEVusqSwefYJkhl1+Lsz8337tfy8Jazr2e2Rqv4pTq/Zrx1+H kHmR8Cr+CPASulG7v1izv3dyYZUKrXqzEpUg820lpG+ONIDCY+27lsYueb31OelN9cSs 0vHJJXeSVv6twpZLDXc2CzOLLqSxCeQl3xXoOZSQ2c+YwXEiWOP/p+S1cwpczedMJEVP oPJCoi3zutESkYnN4zQvurI8lwiacEsH2aVzehVMT/tYVFIqBDF+Pu1CEDyGV/h5YNyS ZeEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xZIk02rN/B58vn5urmzzUKpoCipYBcMsvK06nQVHHKc=; b=Lvcfc4cygdY3o66UHkYxQAWWjdvnlsHaZUtzNuvd+/RlJRX0G7GwGaBE2dxKKcP8Y9 ZwBghIhOiWpz2kxcyrsVNFXYlpNpSv0wzyFzLWTofXdMJxcqj5HXUHe/k6KVXYM6f0ap YwGJTGaiFcpG2hk2DG6/mB9PsROQYrixQBGcJ2XwFdGp13BKy8RLYGfTYl9xxL4XIZSf M9NYBMwNQWHFm/iZhD2iPNw6ngcmrvTQyEmkoN8ZJ0LMKVkKB8pc1PqyMtBIBuhOlDNn gXbQAArLyoUa/q3QDtNE5HXodSPkhBbuci7T7n+msRD/bkVpcat/vw+Zn6aVuK52N7la F/xg== X-Gm-Message-State: AOAM532T3B76bgiklLP864yW6JlWKzXVOXGmrT3v7wzxAvk/uOK8L+mZ dxGrANNsg4gqxihQiUoe+gtsl58fWoP0/g== X-Google-Smtp-Source: ABdhPJzHz030wgO5q/NyLw7VsKK26ZNlHoQRcL27P0GVkSrHAzBdFThYw3FX6sMmf7awBhiqePwbiw== X-Received: by 2002:a5d:460e:: with SMTP id t14mr5287910wrq.149.1623930881572; Thu, 17 Jun 2021 04:54:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 14/15] hw/i2c: Extract i2c_do_start_transfer() from i2c_start_transfer() Date: Thu, 17 Jun 2021 13:53:33 +0200 Message-Id: <20210617115334.2761573-15-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) To allow further simplications, extract i2c_do_start_transfer() from i2c_start_transfer(). This is mostly the same function, but the former is static and takes an enum argument. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/i2c/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 6639ca8c2e0..5483bf95a3e 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -114,8 +114,11 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool b= roadcast, * protocol uses a start transfer to switch from write to read mode * without releasing the bus. If that fails, the bus is still * in a transaction. + * + * @event must be I2C_START_RECV or I2C_START_SEND. */ -int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv) +static int i2c_do_start_transfer(I2CBus *bus, uint8_t address, + enum i2c_event event) { I2CSlaveClass *sc; I2CNode *node; @@ -157,7 +160,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, bo= ol is_recv) =20 if (sc->event) { trace_i2c_event("start", s->address); - rv =3D sc->event(s, is_recv ? I2C_START_RECV : I2C_START_SEND); + rv =3D sc->event(s, event); if (rv && !bus->broadcast) { if (bus_scanned) { /* First call, terminate the transfer. */ @@ -170,6 +173,13 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, b= ool is_recv) return 0; } =20 +int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv) +{ + return i2c_do_start_transfer(bus, address, is_recv + ? I2C_START_RECV + : I2C_START_SEND); +} + void i2c_end_transfer(I2CBus *bus) { I2CSlaveClass *sc; --=20 2.31.1 From nobody Fri May 17 01:54:00 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623931619802148.4700779225576; Thu, 17 Jun 2021 05:06:59 -0700 (PDT) Received: from localhost ([::1]:39464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltqnS-0005t2-P7 for importer2@patchew.org; Thu, 17 Jun 2021 08:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltqbj-0000xk-27 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:51 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:34417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltqbf-0005dQ-R2 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 07:54:50 -0400 Received: by mail-wm1-x32f.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso4761300wmc.1 for ; Thu, 17 Jun 2021 04:54:47 -0700 (PDT) Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id j1sm4415717wmi.44.2021.06.17.04.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 04:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cTmXbAZuVSJ/iAUXGS3uU1Sg/xrnfGmybw7wWkCyin8=; b=n5mOzI+QEg/h8yQEy2G7Yx79vFljUN7KfsGw5Tvirhh5YwQtSXCnyBCh5Au4JdnoQL 2djrqIc8ZUi5zryKsjF7RzLZfjGM8kM4iaGhiDGf4d2rz6dsTtMul/42sJPripR9xxQY XBnVZBXNGo4rP6GRz8tVO4IB+vjty1PKHHDO2d7yNZxqfL2QpqcoxGlbgPsqPoEE1ZMT 1V3btKBRJTN2DFoZrxdFGvHJGGExxJDGb9iMNYPNuGDYC+tTsH/eaME71E5A/itpir+j Vs1R+bEmej850VIfmuuvJRPo3BQ7qm49t5lx/y1Shj5TJzCZZuyoxH9Wh+AqyxbQeN0f 6LKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cTmXbAZuVSJ/iAUXGS3uU1Sg/xrnfGmybw7wWkCyin8=; b=sdAzUG+X7c9Er8KpIxVpJ4egA4cr8HmszaLbIy+6lLqkPVFVvVELGTDmDWLSSmuvM9 rfR724P6tXfLYf8n8rSZYCy2XKwtGDa+WJ/CNXAFsLvRz95zFj+uFT+YdF/imwfjvaJs 4unx76B/g8B243BHwg6Ml0FPkohhv0ChTGj+OJ3FW4TuRzchop7WE3HOCsXwMjk0OGgF Lx3F/0iq0J7oPZcdxil7fW/y9NghksNfzVNiqqeH8fEmY20gTBOF9714dkE47E/Wskib 71q0bzWH+HnqVbpd84jGt8yi0qMTSHLFYf3jsr+SczEITrRwzWkveXyVUZdgK+ltJlFG P7tQ== X-Gm-Message-State: AOAM532364i+YF7iV1eyad9B6dou2R64wD/7YSq+468ij6WsSqX3s8qB WqMD+gxhWGQwiJmskiv6Pm13jHAfTIq8Bg== X-Google-Smtp-Source: ABdhPJwwVeom4mbpOdacLMHniBDEf1Nw94Zd+2Qdz7LwchYqJZMcafxa8FAPgPfNmXxz0c5FweCbHQ== X-Received: by 2002:a05:600c:22cf:: with SMTP id 15mr4704358wmg.144.1623930886202; Thu, 17 Jun 2021 04:54:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 15/15] hw/i2c: Introduce i2c_start_recv() and i2c_start_send() Date: Thu, 17 Jun 2021 13:53:34 +0200 Message-Id: <20210617115334.2761573-16-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617115334.2761573-1-f4bug@amsat.org> References: <20210617115334.2761573-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) To ease reviewing code using the I2C bus API, introduce the i2c_start_recv() and i2c_start_send() helpers which don't take the confusing 'is_recv' boolean argument. Use these new helpers in the SMBus / AUX bus models. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 24 ++++++++++++++++++++++++ hw/i2c/core.c | 10 ++++++++++ hw/i2c/pm_smbus.c | 4 ++-- hw/i2c/smbus_master.c | 22 +++++++++++----------- hw/misc/auxbus.c | 12 ++++++------ 5 files changed, 53 insertions(+), 19 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 21f2dba1bf7..5ca3b708c0b 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -88,9 +88,33 @@ int i2c_bus_busy(I2CBus *bus); * @address: address of the slave * @is_recv: indicates the transfer direction * + * When @is_recv is a known boolean constant, use the + * i2c_start_recv() or i2c_start_send() helper instead. + * * Returns: 0 on success, -1 on error */ int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv); + +/** + * i2c_start_recv: start a 'receive' transfer on an I2C bus. + * + * @bus: #I2CBus to be used + * @address: address of the slave + * + * Returns: 0 on success, -1 on error + */ +int i2c_start_recv(I2CBus *bus, uint8_t address); + +/** + * i2c_start_send: start a 'send' transfer on an I2C bus. + * + * @bus: #I2CBus to be used + * @address: address of the slave + * + * Returns: 0 on success, -1 on error + */ +int i2c_start_send(I2CBus *bus, uint8_t address); + void i2c_end_transfer(I2CBus *bus); void i2c_nack(I2CBus *bus); int i2c_send(I2CBus *bus, uint8_t data); diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 5483bf95a3e..416372ad00c 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -180,6 +180,16 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, b= ool is_recv) : I2C_START_SEND); } =20 +int i2c_start_recv(I2CBus *bus, uint8_t address) +{ + return i2c_do_start_transfer(bus, address, I2C_START_RECV); +} + +int i2c_start_send(I2CBus *bus, uint8_t address) +{ + return i2c_do_start_transfer(bus, address, I2C_START_SEND); +} + void i2c_end_transfer(I2CBus *bus) { I2CSlaveClass *sc; diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 06e1e5321b9..d7eae548cbc 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -128,14 +128,14 @@ static void smb_transaction(PMSMBus *s) * So at least Linux may or may not set the read bit here. * So just ignore the read bit for this command. */ - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { goto error; } ret =3D i2c_send(bus, s->smb_data1); if (ret) { goto error; } - if (i2c_start_transfer(bus, addr, 1)) { + if (i2c_start_recv(bus, addr)) { goto error; } s->in_i2c_block_read =3D true; diff --git a/hw/i2c/smbus_master.c b/hw/i2c/smbus_master.c index dc43b8637d1..6a53c34e70b 100644 --- a/hw/i2c/smbus_master.c +++ b/hw/i2c/smbus_master.c @@ -29,7 +29,7 @@ int smbus_receive_byte(I2CBus *bus, uint8_t addr) { uint8_t data; =20 - if (i2c_start_transfer(bus, addr, 1)) { + if (i2c_start_recv(bus, addr)) { return -1; } data =3D i2c_recv(bus); @@ -40,7 +40,7 @@ int smbus_receive_byte(I2CBus *bus, uint8_t addr) =20 int smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data) { - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, data); @@ -51,11 +51,11 @@ int smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t = data) int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command) { uint8_t data; - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); - if (i2c_start_transfer(bus, addr, 1)) { + if (i2c_start_recv(bus, addr)) { i2c_end_transfer(bus); return -1; } @@ -67,7 +67,7 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t co= mmand) =20 int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t d= ata) { - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); @@ -79,11 +79,11 @@ int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t= command, uint8_t data) int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command) { uint16_t data; - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); - if (i2c_start_transfer(bus, addr, 1)) { + if (i2c_start_recv(bus, addr)) { i2c_end_transfer(bus); return -1; } @@ -96,7 +96,7 @@ int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t co= mmand) =20 int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t = data) { - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); @@ -113,12 +113,12 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8= _t command, uint8_t *data, int i; =20 if (send_cmd) { - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); } - if (i2c_start_transfer(bus, addr, 1)) { + if (i2c_start_recv(bus, addr)) { if (send_cmd) { i2c_end_transfer(bus); } @@ -149,7 +149,7 @@ int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_= t command, uint8_t *data, len =3D 32; } =20 - if (i2c_start_transfer(bus, addr, 0)) { + if (i2c_start_send(bus, addr)) { return -1; } i2c_send(bus, command); diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 44aa9730bc9..434ff8d910d 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -135,7 +135,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, i2c_end_transfer(i2c_bus); } =20 - if (i2c_start_transfer(i2c_bus, address, true)) { + if (i2c_start_recv(i2c_bus, address)) { ret =3D AUX_I2C_NACK; break; } @@ -151,7 +151,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, i2c_end_transfer(i2c_bus); } =20 - if (i2c_start_transfer(i2c_bus, address, false)) { + if (i2c_start_send(i2c_bus, address)) { ret =3D AUX_I2C_NACK; break; } @@ -179,7 +179,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, /* * No transactions started.. */ - if (i2c_start_transfer(i2c_bus, address, false)) { + if (i2c_start_send(i2c_bus, address)) { break; } } else if ((address !=3D bus->last_i2c_address) || @@ -188,7 +188,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, * Transaction started but we need to restart.. */ i2c_end_transfer(i2c_bus); - if (i2c_start_transfer(i2c_bus, address, false)) { + if (i2c_start_send(i2c_bus, address)) { break; } } @@ -210,7 +210,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, /* * No transactions started.. */ - if (i2c_start_transfer(i2c_bus, address, true)) { + if (i2c_start_recv(i2c_bus, address)) { break; } } else if ((address !=3D bus->last_i2c_address) || @@ -219,7 +219,7 @@ AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint3= 2_t address, * Transaction started but we need to restart.. */ i2c_end_transfer(i2c_bus); - if (i2c_start_transfer(i2c_bus, address, true)) { + if (i2c_start_recv(i2c_bus, address)) { break; } } --=20 2.31.1