From nobody Tue Feb 10 19:35:45 2026 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 1623880090532774.1189338434515; Wed, 16 Jun 2021 14:48:10 -0700 (PDT) Received: from localhost ([::1]:49728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdOJ-0000nz-S9 for importer2@patchew.org; Wed, 16 Jun 2021 17:48:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJT-0000B0-Pq; Wed, 16 Jun 2021 17:43:07 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:44899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJR-00068z-4N; Wed, 16 Jun 2021 17:43:07 -0400 Received: by mail-wm1-x333.google.com with SMTP id h21-20020a1ccc150000b02901d4d33c5ca0so423602wmb.3; Wed, 16 Jun 2021 14:43:04 -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 g17sm4428892wrh.72.2021.06.16.14.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:02 -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=a6HLvyeOUy+kdQJDm54TvJdrTKORiDn1Vgjl/okbW+FMU0F4ryh79m4t9uM02NYW9D Hw0Ib8djFZ36BUMaEZPK6PR0T++uVa2l01ogpeuNqPrLIrizgVnZh/Vw8CF2OipK6xtk xeFgd0oxFQTnVCLcDx4aNdv0lIx2D9bjK14pRZKmucOltdA7Sp5mqma+QVGxbgG++Vfe 7EXYk0KeQYLZYIStcGY3hloSd7qHoCBoFfQqXf3hG7u6YBzyrXGz6BzQH1za2PnUtfXE ojMNL3/h3wjnKcCm0DBmdEPllRHaeJO9j5rHsByvlt5w2FHcedZCqf12ymhQxfNAogDM zfHw== 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=YGXNY5osw+0uRSNtD+sc7NPnvmKPUIQoykOlAJlOJ50wVXdXWUaO+P8tSZfI+u6mgK UFdJMlPPDTQx2h6ds8Q9D0zJ7dbnR1E4jk1MQi+g+cLAlnN6Ky1zg4u20GsDydq+B/rU 7G6ZEFPjA3/sYp0ZxzG87Rtut8Eq7DVzcjCvg0DFoczOaZYzSx26kK6hDN/s2LJPpGQx saE5qnAr1dVWppMG/9MsMT4bTaG4wSG67iXli5jDMMVeApbVO2R4FYo3SmYrZS41prlk NeQ9K1cl+whqMEK5M46fJ+l+pN9fO4rBofCEvQ0YwHl0TyJ1THKf/wu/RA+II6Krkp8U e0dA== X-Gm-Message-State: AOAM53112sw3MiugclbxGpLPvs2I+YK0b4TWmErJHkR/IRbnwOa2dWuj Oz4APT29Oyafk+/1M7ZrpI7RDw0hdw2Dlg== X-Google-Smtp-Source: ABdhPJxDm1dB+Ts5oJwgx63IQ/f09wKmyQ8DWgjVVYEAgV31pVUY4vyLW7cqfztS27Hx0XK8De4WVw== X-Received: by 2002:a05:600c:4a29:: with SMTP id c41mr1118056wmp.17.1623879782815; Wed, 16 Jun 2021 14:43:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 01/15] hw/input/lm832x: Move lm832x_key_event() declaration to "lm832x.h" Date: Wed, 16 Jun 2021 23:42:40 +0200 Message-Id: <20210616214254.2647796-2-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880248196409.7119287525014; Wed, 16 Jun 2021 14:50:48 -0700 (PDT) Received: from localhost ([::1]:59384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdQt-0007EZ-1q for importer2@patchew.org; Wed, 16 Jun 2021 17:50:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJZ-0000Ku-6E; Wed, 16 Jun 2021 17:43:13 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:38900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJW-0006Ba-JD; Wed, 16 Jun 2021 17:43:12 -0400 Received: by mail-wr1-x42f.google.com with SMTP id c9so4263687wrt.5; Wed, 16 Jun 2021 14:43:09 -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 n42sm5915203wms.29.2021.06.16.14.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:07 -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=MXyh0QJxX4897RGnRCyxdlv7qycF6ckt+c71prZb0zkZuaBofoDZwufM4OcMbzmvc/ +qxJMxNHy4/Y446EGjCXTc7GnXMGA2t4TvyXgFZ856k1CsguNf6mhGCdG6YHBP+luI+t ZinCUZk85pxZ0FCM4Rmgx38ISZUBYxeuqAlDUSU3SdMdPZ7KuceT4Z2Ow+Btxw+jxICt /6Cd7cT1JDx61xqMIpuE+Ez5y2XGp7NZn1/2jm+Zg8UBlxIpn35H4xN/TjKpfSGgA3Ut HHskDbJ1lYjc/c4oEwmNbVN2Ns2tLjk41Uep/UAxAvsBfhob9JmmOm7HqXFvgnvSAXkD DaVQ== 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=WmFrqo3+lSq3luyNqIzkv7AZYtN0eOmO3RnHzsyupk/gCWS4/UFaYJJpRh2zpGYfN0 Yt3h843JsiDT0sp2HtQ79AbZPU+yEF8L8w5xHMvZVj8H3KMlTJgaQh4sjx6d59Uo+nZK 8Wm7rI5Zvrid8s/3Q7cqk/+h6o/579O+JkMzG+66v4F4KUaoDeM5ARuQ54xTwNs3GDnF w3UZoKtkIxjF/cy6i7pR4YNpuCqjrxo02HqQF+aeFkhNof8+9tsexAXSxa8NQb4sbpf8 795ZStZjr6baBKXgWHTMWX0DgbJrXROOqrpikxq3GQCUp71tezNPIlVIidCwmAPUYh0B S9vQ== X-Gm-Message-State: AOAM530Z57MbC77LzcMbCWKVw8tXYju+3Jf2zjg+bDZt/96G2ofxfGcv 1AZuQBV251o0Dg4nZeRnxCQqOqbzisXwXA== X-Google-Smtp-Source: ABdhPJynUDqQJyXLKSbnVFL98/uei8Rv/tGLQkbPls0tPGBMgig48jVQemFb286ZWmXTMHYyK9MBKw== X-Received: by 2002:a5d:59a3:: with SMTP id p3mr1475921wrr.284.1623879788243; Wed, 16 Jun 2021 14:43:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 02/15] hw/input/lm832x: Define TYPE_LM8323 in public header Date: Wed, 16 Jun 2021 23:42:41 +0200 Message-Id: <20210616214254.2647796-3-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623879929604367.1528501593307; Wed, 16 Jun 2021 14:45:29 -0700 (PDT) Received: from localhost ([::1]:41776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdLj-0003ns-Cr for importer2@patchew.org; Wed, 16 Jun 2021 17:45:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJd-0000VX-2k; Wed, 16 Jun 2021 17:43:18 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:35597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJb-0006F6-J9; Wed, 16 Jun 2021 17:43:16 -0400 Received: by mail-wr1-x435.google.com with SMTP id m18so4268417wrv.2; Wed, 16 Jun 2021 14:43:14 -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 l16sm6257864wmj.47.2021.06.16.14.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:12 -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=KW5lTjsputo7N25OpKrD+E7Eo0jAOCluFxXj3IjGob4=; b=tMy4VHt4cCksI+edMUqDzMEwYxEhb9sNwPo6gTSjNBcXCCFuAFHDTD8zWcxZ0ByPPS U4tyU6SnDoT8+reloz2RWfUF+HZWwy4cAQ3flszzzpoJMURWEj5xHRcck2e60wJckVF3 OdHD4aUa3hDsGUwr9Y0CDJWte67UJUzKve2nqoHNKqxQj7pATwo1COD6hxuhXX6EUK6m R476B+f5fAcG76Ckie6Xde5bxk4DpNwnes0TppWsZ/2C2Db7gZ04kH+lkOkEKzt1/Mp+ chgG/dbfl2RKnaJv5Yjafz7H5tUNZKISzCsWMy/98jkHNnSjhnjECeAoXyAhvIawP+5s iNvQ== 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=KW5lTjsputo7N25OpKrD+E7Eo0jAOCluFxXj3IjGob4=; b=X3SGqKoC4jukA6G+0DLM8nlMt25vSBnkYamNSDglN8TR0/c9QqdfZsY+B3ZJQjLo/o pcIMu/Bv+x3aH+tRHpo8EUDCsM2GiQaOWt0PRo+MJ7HEYKanlUxXw+hPQzB4d4f0yT3s vUA4XN73D6SmGExtwDlBIPexF90P+46WR+DRCZ1qqzrCJgsxYdW1E3sFQkuYGBmzSOQS Qv6rVGqQaaZBy2aahCge/RQ7mroH+ua92IoUfwlDHhUyuNo+FKXPB5vyDM3LRmuW3BEm PKi6J61DCPHfbhQsNTncTTPTDtAKX+PNPMYEaEpJ5uGa2Y1bystAJ0poUskw6YER5WAd 05mQ== X-Gm-Message-State: AOAM531dCZWFmmxvKUo4FZdMCC/PmYqVILAdOUHGvWxQ5ZBW7u2bWYHE McMkXr+kavWkt6do6gGOmSHsCNnqxnSpBw== X-Google-Smtp-Source: ABdhPJxk6iAa2/gl5WSyjWxP/h+RLiIYg2I/CkwdOJAz9BukIvRnALISjLvKixQo2zl5muPRD3D2ng== X-Received: by 2002:adf:deca:: with SMTP id i10mr1469987wrn.344.1623879793348; Wed, 16 Jun 2021 14:43:13 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 03/15] hw/display/sm501: Simplify sm501_i2c_write() logic Date: Wed, 16 Jun 2021 23:42:42 +0200 Message-Id: <20210616214254.2647796-4-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::435; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x435.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: BALATON Zoltan --- 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 Tue Feb 10 19:35:45 2026 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 1623880423719244.64717418964335; Wed, 16 Jun 2021 14:53:43 -0700 (PDT) Received: from localhost ([::1]:39774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdTi-0004fM-Ok for importer2@patchew.org; Wed, 16 Jun 2021 17:53:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJk-0000qW-El; Wed, 16 Jun 2021 17:43:24 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:52804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJh-0006I1-0H; Wed, 16 Jun 2021 17:43:24 -0400 Received: by mail-wm1-x333.google.com with SMTP id n23so2069715wms.2; Wed, 16 Jun 2021 14:43: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 g83sm2774930wma.10.2021.06.16.14.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43: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=0yFcNPzCMbJU7ln7mvR4pO20Y4U4Q8SH66r8xtnNF00=; b=FGNPUiL5FbXYqRdvJbWw08nHuEVPkkLQWO3dIKPg4eIrnDIrZ/t2Az9Lb/13ZRhHWW pFI9jrhy/0BG0WNjGFJikNjFZP7eIYbKtlksuzn1Ri6tH20odsEW54BGEPlf3WypPaPy bhH0/8RHQTik1hAOXACc1EV49uqrLzRHhSLUE+jhRUNEPWMgMQaB6RSujRXJZZyCQcv0 gumOjJ6j1z5dfhb/qmJ/KOi0xEKjsVeNIdGZ0w3VeoNtecGzY3LPKQS217DKtDM/hX5u DrVThsjEoLvgKi/KIIwLpXtYVLJlmApk3/O5ng/SceYaJ8jIS9w6hWDgXfgGMJT8IyQe /SdA== 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=j5Ua1c8rTrZrYMiR6svMToluZJex2Y1LXvOcf/flzQIvV0qdpwTE3K0x8ulWMkfsiq XZawSaVjitbVQqMlPkoVytx/qL8f4450fAUL9Ql/PLh/nrZO99bBXDavktk/FlI6QjoU PIrjvkNDhI4Z+gOUcbYGu2dPlBB4G0hki4xDTrsWnqp6RbzvZnF5E9kbJ1jLNPXOyF0X pUN9y9mqzR9vr00zalNGh7yBvXVAkkNV2JeOwQ2i6ygMOI8YtX3sRxGLi7Gq1RG0NYNm 2GtNhlk+zjkdkuWbKUxCddfXCvYGjW3gr01QFSP74G1N8TLKmCO7xbxjgrvxqAEuqvFt Qa/Q== X-Gm-Message-State: AOAM532WaDoYKoch/GJ9Cwo6YpESFKQ+yiI8fx0w709yoigSQOcuRad+ IaeosP1l4SJU8AorzA9RnVhsByvUkKerPA== X-Google-Smtp-Source: ABdhPJxhBMZ3plpWqUCV/ntCJzIaSp8TTk8ea76Lwo8chj0L2B16yWhoMRGrRQ67Sxyjncmff+qbYg== X-Received: by 2002:a05:600c:4f0c:: with SMTP id l12mr1105780wmq.93.1623879798779; Wed, 16 Jun 2021 14:43:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 04/15] hw/display/sm501: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Wed, 16 Jun 2021 23:42:43 +0200 Message-Id: <20210616214254.2647796-5-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 --- 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 Tue Feb 10 19:35:45 2026 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 1623880117788769.6331999899463; Wed, 16 Jun 2021 14:48:37 -0700 (PDT) Received: from localhost ([::1]:51274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdOm-0001pe-Lh for importer2@patchew.org; Wed, 16 Jun 2021 17:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJq-0001Be-GL; Wed, 16 Jun 2021 17:43:30 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:41538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJm-0006MY-Om; Wed, 16 Jun 2021 17:43:30 -0400 Received: by mail-wm1-x32f.google.com with SMTP id y13-20020a1c4b0d0000b02901c20173e165so2489724wma.0; Wed, 16 Jun 2021 14:43:25 -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 p11sm3284037wrx.85.2021.06.16.14.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:23 -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=kGzSERqh+8wBxiJCuZax69b35h3ezUK0XWigjo4qNm3l/5MYGNdOHFhNYAq+qNwNJk 5YcH4FdjrTrP0w4CA5xdInQP3jwZS+ZlMcd5FvN3uAiNwv5G4VNgAFaxLZrmYLfSXfAn +JjYTuUyo8SvVxI8jhKsT/XnfwTEdcBqBlcFCDlt37BdTJipV7fG4NTOCBcGBfSNj9o6 It+Pz2Jhqguz0hggdTIj7M8TFWA9Oig+nFZ6h/qtR09D49wbEJaqxwr2FdOBZfTlkCzX oMsNghWh08w+8GDexu5kYihYcPFckGtX/q8QxfOVWRKyvw/VM27h4BY+kSPoyki6K87r XP4w== 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=TVxB6LIzqGBqbHRY9XcEgqx+997nz2yncrmNjqc9y35WXDiOhTCYR8t/d9GJ/HzZlC DpwxWWM93dfEZCI3UNaWmz3+nU5nrl3xWXEWit1L8TlpQwBdsnyWiMpMDMpIIgcn7CtL SGLbyId04VsLvcH51fubUADSZvMf6Cw0fuqeo6xy6Aw8fZlV6Pz/jvk9eH2SKTVpknAI XlEWq5APnIQYUlmfvHj9IeqLLvHZ+acodnb6H2BLgY4HoNmeICmlG+6ov09Eh5C9Dzue PPoKCYKe94+Up+/5/wYXlAaKTLRjnvdXyZ3LBALedUO/1wjzV77dv4Z3QeP6lnxNDWjw JSFA== X-Gm-Message-State: AOAM531+AQRSFFmTNeIahP4zQ5CBy/FAAwLDSXQB0yZvswhZr4ajfaGd ijIOXIYZ1bw3uxrsnED1NAD3QDY6DRhiLA== X-Google-Smtp-Source: ABdhPJyKCwyfFF7V0tlQyJx7sNkEw2Tvt9Ymyf0BG/IOIggzM/3tTVdeosh3rA30n7fJii+IiyYwrg== X-Received: by 2002:a7b:c10b:: with SMTP id w11mr1117395wmi.186.1623879804348; Wed, 16 Jun 2021 14:43:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 05/15] hw/i2c/ppc4xx_i2c: Add reference to datasheet Date: Wed, 16 Jun 2021 23:42:44 +0200 Message-Id: <20210616214254.2647796-6-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880277653975.6060246565933; Wed, 16 Jun 2021 14:51:17 -0700 (PDT) Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdRK-0008Fj-TU for importer2@patchew.org; Wed, 16 Jun 2021 17:51:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJt-0001ML-Ub; Wed, 16 Jun 2021 17:43:34 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:50908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJs-0006Rr-Bf; Wed, 16 Jun 2021 17:43:33 -0400 Received: by mail-wm1-x32e.google.com with SMTP id k42so179820wms.0; Wed, 16 Jun 2021 14:43:31 -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 m65sm2796646wmm.19.2021.06.16.14.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:29 -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=gSI59bBqHbKcJKwzyvgmBKRH5hvXTSABasX41TFH0De/0Ui4pY4hIG+zBJDeqUbSnC AU9C0rAUllPQMS1RoWs8fBMLcNvLJZ0TpfB6Py1dX3YMzI6Z1P6vYxfOhdqbOwqQtMI0 1jb9RSyzBw+QTY3cbEjP1dWgJm1qFfjjQ33uMbnPvrjFqt8yUmlyDXDx9r6kFglH27AO 67bXjcDjEIcWlX2B3qfEvr+5RAhNehJ06q2u5sCD78bjhGHs5uIp8+5ZhCRz3bBOr15n 8WwoonqxtHQJDib8Lez0oT7RO75UtBh+xQppFshNYBZg/tClz9hWJsJj6o7YGia7pbae jFGQ== 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=WEOAd6PSZgPSb8oGihtimP5u9EpBbxecwqawj/PJXQyrOGjh7iiBxxqStsZ99c4Mtr FD7U0ZHhznOWw/P/QZWCNzuIotgg6jSE+7XS4LTOIDyMdbjBRlhIsNAhJpCv1xj5LB42 sGJVaIRL7SGGRBJ0ryntKN131mLYKyn1DOslRy+F8WDJoIY9udr1I2LcQhMzpKHNTQ7H hY3eHlri9gIy5AjueBJxsi+WS/ws6SYSxyVmuHmLZ2KwRMJjwonNk2TEZ9OCPLhmYIIn ohl71aTXEp0YLu1qXa0Ot1F4/L3Nu/U6tX3Wgokrnnj6QWmFMX82u94lvO/wO5u/3xfZ OCRg== X-Gm-Message-State: AOAM533JRswyYZIdVP/Nnpf0i5Yv9Q8x/SwQAxKEU7S+ekZGNBw36W1i 21oKGPsRXpAbJ2O9AJczTt/SJoT0QV+r+g== X-Google-Smtp-Source: ABdhPJzyOnHL/3rjKttzyhAZVqXsPCbeOclDkPiCFEC4/znyX8cGpgc3MpnVNXBnjimOhHz5PakZ0w== X-Received: by 2002:a05:600c:1ca6:: with SMTP id k38mr1147060wms.49.1623879810085; Wed, 16 Jun 2021 14:43:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 06/15] hw/i2c/ppc4xx_i2c: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Wed, 16 Jun 2021 23:42:45 +0200 Message-Id: <20210616214254.2647796-7-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::32e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32e.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 --- 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 Tue Feb 10 19:35:45 2026 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 1623879997681831.4365690158022; Wed, 16 Jun 2021 14:46:37 -0700 (PDT) Received: from localhost ([::1]:44272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdMq-0005UR-F1 for importer2@patchew.org; Wed, 16 Jun 2021 17:46:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdJz-0001dQ-8k; Wed, 16 Jun 2021 17:43:39 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:34467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdJx-0006VL-ND; Wed, 16 Jun 2021 17:43:39 -0400 Received: by mail-wr1-x431.google.com with SMTP id e22so657364wrc.1; Wed, 16 Jun 2021 14:43:36 -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 j18sm3328687wrw.30.2021.06.16.14.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:34 -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=rW/98W/lMx2v0/s6Cc7n0Sb2bQ3LUk7jsw87TOCYYu5qA4qyo2R+sTfkynbRx/BXfF uodxXLpCCF9Zuzp7PO7vIzTsgYNVO81rdkyt4yROYm3cJhZ9f4/4huMKAHZ7rerAKzX5 N02snHPhvN6M+lFIvP7DMePV6GV8jwXcJQMvkb/2Wm5RTYtONVQIl1VUOYckK12SJHGB pMIKnuV5uhdjB6ty2s5JA6VBOT4XWIxbuLH4w/Yi5zYpsQM3DveDofq9X8OIkFun/ouS s6rb8CWIsRlMcwF5np1/609I+EMiSVJQOF8w7I5Auzf8ryVEYYGzPgOVcOZkiUoSUzA7 nXmg== 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=f/0sflbj7Q9p26Nev2p0OYv45Ce9Hey4vghJQcmfGjA6jJr1Cju0kQn8ntI8GGaL3q ayxiIr1l3rLFv8/3RwJIo/LUGdhSswXQ39Et+WoJ9HnDXfwNTO2R7MTBGGxv7bnLza/M 6olU+M5y7N1xzuWMpe3ReqaTviW1H6/06LUay1KuiG7eJVHi63F5mM1lPAT8zeDxcGp8 4NQAeI4XUW1zGZn44GsYuyE0PQZATFjFxYz4LNanrKtmmxn9mVMlysbClnHl5y8A8lCz sydsj0kCA6ztOrSVfpuH1lKWDApLxua9h3RTMVNOiDklH9Qhm8V2Wiv/5yHCbifVfiOp i8Ig== X-Gm-Message-State: AOAM533gYZlFmML7YP7oW7pNT1zUKhS1Ab9YHECVJPy4Vkx9xgf6HXaN QnyjmFa1QDYt6+sbHTTtPxLNpUnHQj1J5A== X-Google-Smtp-Source: ABdhPJwgGPAVzsgUylUz4UgJOqI99+YbmA31IKk21sxdfAgmdTbXP7ktYNsBjFHQh62R2q9ASYVT8Q== X-Received: by 2002:a5d:4ac5:: with SMTP id y5mr1492329wrs.18.1623879815458; Wed, 16 Jun 2021 14:43:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 07/15] hw/misc/auxbus: Fix MOT/classic I2C mode Date: Wed, 16 Jun 2021 23:42:46 +0200 Message-Id: <20210616214254.2647796-8-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::431; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x431.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880439070352.70226108194174; Wed, 16 Jun 2021 14:53:59 -0700 (PDT) Received: from localhost ([::1]:40062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdTt-0004qk-Qy for importer2@patchew.org; Wed, 16 Jun 2021 17:53:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdK5-0001lc-Qk; Wed, 16 Jun 2021 17:43:45 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:45573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdK3-0006aM-Gb; Wed, 16 Jun 2021 17:43:44 -0400 Received: by mail-wr1-x42f.google.com with SMTP id z8so4230273wrp.12; Wed, 16 Jun 2021 14:43:41 -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 r6sm3327992wrt.21.2021.06.16.14.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43: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=mF7eiAdIfTv9rlxceo15bFIxRiqB6zGPW3KZaJR5WqY=; b=QMUPRVQkv8w+TrL5LUs46LyomAhgxeYc6Iv4T9V/4h98/UT7+h6vnIgZtw+3mYMsDH SHzNobKCtLbSvMkdgLDJrgb5HBnSM+rUgKh2ZCGC81OLcBWZKz0LzaLHBeO+OMwzvgm1 XD0jXJLv2B8pzG6sE5tkkmPKqR0nvHycbgUdVfvfiDmJhttdj9VrImNrjbdnYrlAU1KZ E68/OE+wM+dFM16SkiBh46AsRcVU+JVBYxcyM1H0GIC8ckNpqDbjTvr4EC+xreTJxIaf VhBko9pMmelljYx1m9m6cB4bCHhvVG/BhwhtNcU9Wd8+CGr7csID9MVWqKNDTiLac1Ta Tq/w== 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=tE4oJcKgzkf1QLAOLy5mN6mLgzTJZJS8QGd/k8pBpv7ygVMTJnFlsnTUJonS3OJ7w2 oRYSFUaQQYIj1id5HRvM+rNpKJXESA81+ftGh1l8vh6cbJ/H6O0YtRVdlXBbXeiUEBzp S5juhNgLrUVvVJA01FycaoR0NIPcbvMX7ne40EudVlPYUVqkUAK6XcepjqmWqxcE4KIO rfG+arGqsQFyMu3VgmOZaU3NFpY8SLIaCU1021MS/6MQaZAWx6ZwInSGGKR6ybFvi0+h aT8JgNxQBWyKyYoHzrxRdG935gOyK7JW49Q/U1YbEfxNeO6ROQDLB0dloXRfTPLhzeZI jYsA== X-Gm-Message-State: AOAM53245V/poqbL32K8+sihjnGxTfOex09FmeHOQqq0V6VycOmpJUFA Ic2d2g854wDrQFhh2ndwXBFHp5v4grCURA== X-Google-Smtp-Source: ABdhPJx8MRgUu908mGTfweuziY3ft6u2iJgrTYsp1q5007xKsFYSEQhHOAl/ba99Xzy5MKO2/i9dUQ== X-Received: by 2002:adf:d1cd:: with SMTP id b13mr1364249wrd.317.1623879820737; Wed, 16 Jun 2021 14:43:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 08/15] hw/misc/auxbus: Explode READ_I2C / WRITE_I2C_MOT cases Date: Wed, 16 Jun 2021 23:42:47 +0200 Message-Id: <20210616214254.2647796-9-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880159413180.74543454051172; Wed, 16 Jun 2021 14:49:19 -0700 (PDT) Received: from localhost ([::1]:54074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdPS-0003hf-Bp for importer2@patchew.org; Wed, 16 Jun 2021 17:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKB-0001wA-J1; Wed, 16 Jun 2021 17:43:52 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:43645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdK9-0006dI-UL; Wed, 16 Jun 2021 17:43:51 -0400 Received: by mail-wm1-x334.google.com with SMTP id 3-20020a05600c0243b029019f2f9b2b8aso2460296wmj.2; Wed, 16 Jun 2021 14:43: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 r6sm3328178wrt.21.2021.06.16.14.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43: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=TAZ5Nd2Zr4AEdYczPbEyYCejydYTPBGPwGnfyFJKBD8=; b=UUTClQyfSKiErduQigqFMPUjBXPLR66bqtojXp3+yysOjLTHBaVF/QPmUI5ZPe8XRP /cbFelwOFeMIgo1FGUQKEIQXGP+XIXG6kRUIn/deP5Tei5fm9By4o4smUTl2awbqAd5d tx68XAJ3Vm/T7pDzbUPC8Eh0antKjtqdzPkO8TDu4Y5IB2wcPnX6G6fKux/Ztsy2ctoR T/UF8qudpKUwBBqrCRH+nik4grqwDV2rEHbjTFl0vKJwIgL5LYppTzrBx5YA9WnJv4B5 cLuN1rYxpczJfDXrcSERrkG16RupC570IFRXZkvM42PjpzgjuisxVmh0poRfy6H9cIhj pjmg== 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=fvYQujrZWJpfqcP8eDW2hroUQ/MJrNG/EnCTK91tye7hD2gpaKQ9MSR/NVrkknysZI 1MlducyQTWCDSi2QJ971oIz7p3ROZcMvul6mxWGbHIy27boOrwyxPo3uwwzr/SJt6Dmq yB496FhcdMysiJRolnCqUTu6PuI1g8kZ9NfxDt19TnFMi7F9tVYd+rwemhdeKot4IPP6 qby+QPP+HTTaxsI/09erfLQS8qacm7VfiSIIuPEr+/ClXnGPR0qhsZDDpaMoq5KmcwgH YIMsJkZUO/AkHqlG2l3enBnE62AEo4YQM60A3ZhdVMqr9iX6+1BGVo3j6EBBmLs64/Tg r/Ew== X-Gm-Message-State: AOAM530/VC0oLiY3zy12SQEQCFJaqy1ZqWKFWQjTdPDjbYQUv3zkb2Yl c+TTPmOrxEwwqmyAjHMB8MJFK7UUZ3iC7Q== X-Google-Smtp-Source: ABdhPJx81R37uPFyDFSp0xtO5T1qd8QWSNDdX5nU7bG+rgnJITZQRMyPlt7DxF12szruU/54jQ8/DQ== X-Received: by 2002:a1c:f717:: with SMTP id v23mr1130870wmh.32.1623879825923; Wed, 16 Jun 2021 14:43:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 09/15] hw/misc/auxbus: Replace 'is_write' boolean by its value Date: Wed, 16 Jun 2021 23:42:48 +0200 Message-Id: <20210616214254.2647796-10-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::334; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x334.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880034215985.7716362645265; Wed, 16 Jun 2021 14:47:14 -0700 (PDT) Received: from localhost ([::1]:45786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdNR-0006Zx-02 for importer2@patchew.org; Wed, 16 Jun 2021 17:47:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKE-0001yD-Kf; Wed, 16 Jun 2021 17:43:54 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:40589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKD-0006fV-6W; Wed, 16 Jun 2021 17:43:54 -0400 Received: by mail-wr1-x42e.google.com with SMTP id y7so4231104wrh.7; Wed, 16 Jun 2021 14:43:52 -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 f5sm3882154wrf.22.2021.06.16.14.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43: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=lMrFIFZX4VBJPQraxvDxEyJhOku4B5f9uSq095+uB5I=; b=ROhKU7Wv2GyicVLuhMGoTxFgsEj2O4goVxWO7/ymmFTnyWm6R9IfEF2+GfVWa8Ni97 JTuwnqrkiZWg36fIYxXq2dd37lKX1QIrodDhOz2QSKAdNxCUm7CY8W2ocZu4z4EYCma5 BBIagxNwBNpgWigIuzE7TcjalGQOJgBc2tcbq7LaVROwUVBKxarY3v75RDCMJAnxtqIk PKxlGTKDJd7pYbEBTItjJjKCGGev/YvcG+qSzavGXGrz4AdE8DrivP8+1jTE7VCxnAft avRtnWiOPR5Kok6y2mMYhWOghx1wjpN08lpVEuT6UmwUmCQtOSPrOm8ecR3ZohIzm4f2 SHeg== 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=qnvUucZhr3UvpcW/xWQqhvwJDKsKSL5/c547H0XHiPycDKrIYLwEk3AKidQl/Q5UCA OE8bFmEHNtC32gTqwxJ2yPQco+nV8m+TEquOdnfb9lfsVtl/XHgBRas6oSZsycE8Hi1l paidQ5fxuZNBD/OPCIgqm2YtoU/03eQ8KAU5QTCHenRegWDbOwX3/Okc5meZbMEyvVQo f3dUvUjVAjPmML4CK7VTqIZVFgUEXUHV7vAqUlhIGqgtMAIXogq1yF/D9otfxnfJMmBT drk2XeCPljGhw+NzeCJDMHqEgfBOXZdzQcuXv3NUxDVaNSeBfa4S90Z5G56zrNaFRL9G o9Ag== X-Gm-Message-State: AOAM531lXBh3NeHP+k/LlJTrS3KT5/Ihz02S+u6FGORkwEFdwA5Id3UF GyYPUNHhIJ9JPG0RTRIExPqq7hjRqMxlrQ== X-Google-Smtp-Source: ABdhPJx1sca0UXmy/lGQ9mieLhWuE+h/r4JlJOMlOMsurTYpapJiZGbCP6y+wLOoCg7bdOQxW0ZuoA== X-Received: by 2002:a5d:64c2:: with SMTP id f2mr1418652wri.291.1623879831081; Wed, 16 Jun 2021 14:43:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 10/15] hw/misc/auxbus: Replace i2c_send_recv() by i2c_recv() & i2c_send() Date: Wed, 16 Jun 2021 23:42:49 +0200 Message-Id: <20210616214254.2647796-11-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 162388017603235.45505812815679; Wed, 16 Jun 2021 14:49:36 -0700 (PDT) Received: from localhost ([::1]:55422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdPi-0004ax-TX for importer2@patchew.org; Wed, 16 Jun 2021 17:49:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKK-0002Eg-Co; Wed, 16 Jun 2021 17:44:00 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:44969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKI-0006jL-Ng; Wed, 16 Jun 2021 17:44:00 -0400 Received: by mail-wr1-x431.google.com with SMTP id f2so4230946wri.11; Wed, 16 Jun 2021 14:43:57 -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 f12sm3947441wru.81.2021.06.16.14.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:43:56 -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=b1kEKiK4zGbDqxWxgK1H0qAR4HxX9/cswfC4wJTbHEyLL62akF47X2U/cCX/ic5RFG s4ooq6qdq28WM0hqoN0iVjfyNAb3SPuj5zPEESzHuH1dIL7Dw0uk03o9qT7/i4jREwNG SSCQJ1H7j1HVqrnY1sywr5NlkJMbL3Yu+YX2C41eOv21xNPDDHZKgJidKdTRy4UKXDSQ qoMEmibVGloS0wQz29w6c/KnnAN0Pwolp5SIKUa5ZM3JJpy0COZaY24jmTv44JV8psRl Eo9k6qaLmCdI0oxRIp5n9z9E8Kh2YcBIH65nDsDIKaphOxxAZlPX/K7bYEOYUdgsaK1e NhSw== 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=SNve24Y69K8Ccpd5TXaTvKYrWVgXxMLyUqGf43SLKef2JNNDyXvKAvlZPs/+N/D55h MGOsURqWN+0mt3YUycSQORai4PvGXzi26FfWMdfoH1gdjRmoHtphHvvyrWROcM0/M7Bq Pn6fD3IN6Vij5bmfJTFJYexWgMBo120iYn8k3SO16TPrs8xkcozYweHGq3ieT/rV9Puj skT30wKf4BdOvgrZ6OAEckX7nSoJqoOzwKtMH8gbBpxnBpaJRE/YsG6TlOYnM1AyWMoc KhNABb0cj+OjhnIdHZO7KNOQzD/iuIwwaPkXDRAwi3qhkpeJ4oDf62y3xq6KQYy+MCOr nK/g== X-Gm-Message-State: AOAM530xI1EbMldO1cFB0y4YpU3Smhk4IwcHuyj1icJPGAisAJppsvw5 g9nNeMl8G/TWq5v7Z8+xkLK5/rg+sqwMNg== X-Google-Smtp-Source: ABdhPJxo1CtcK6hh0B6GMM1gy3iCaIw/QjFj5zp+lWaS+xNSNFMrgKuwKcp8kv02gGi4d7zqk4apjQ== X-Received: by 2002:a5d:5986:: with SMTP id n6mr1460631wri.60.1623879836653; Wed, 16 Jun 2021 14:43:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 11/15] hw/i2c: Remove confusing i2c_send_recv() Date: Wed, 16 Jun 2021 23:42:50 +0200 Message-Id: <20210616214254.2647796-12-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::431; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x431.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880720194719.246060598996; Wed, 16 Jun 2021 14:58:40 -0700 (PDT) Received: from localhost ([::1]:48164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdYV-00024E-3c for importer2@patchew.org; Wed, 16 Jun 2021 17:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKQ-0002ZN-Cn; Wed, 16 Jun 2021 17:44:06 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:43648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKO-0006nG-MP; Wed, 16 Jun 2021 17:44:06 -0400 Received: by mail-wr1-x42f.google.com with SMTP id r9so4241276wrz.10; Wed, 16 Jun 2021 14:44:03 -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 z6sm503498wrl.15.2021.06.16.14.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:44:01 -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=qV7V8ajq5SO9Dkmn7fJaakBUZiAJ7MexVY4MKZtdyXMF53pDkpRGEFZ9moMRN4GXXT L7GUmh/CnoP5N18MipnoYVe3MYotZMhcfDzoeWmgWDLHHiy5h3Q/muwK3LoJIXkUoIBX 2BSRyDDlzGQKmcoj7HCemZYsKnEuYsjscw1XA7nRDIU6dv00cuk0TDofVEb74bYOkGGO cqVpDK8I4/5RjkQCxNDXGNPFoRJBkeaw36mYVNMLsSGISyRBYMRt0DW7DWQoKqPiDazn dbOaUzG5nF+y8AL025uYmo+toNdI6bYWofAMxb/pnyjn3dxLECO1Kq49iQ0R6OTBlt3f 6kyg== 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=m/9CxIXKiAA0tOcvht0OPLl3uVgkd9D9T3UANqZxf7/ttzQNAODzePfHDX8FcLClr7 n7EjdMvGmMJYu3bRpfgrRGvf48Tcqk0lXU4JgxF6XYmJT3lgIzYznLaS9CpyTIwZuxEh gC9KpRgxgQi9YwjFFO/KHJWJiDsJbTMkJ4nF/+2gfAmf10tO03pEgrigbmHuRdpUn0jB 40qosvD05lZ+/6BKSSWy4LtCOkBvmRb/LAnjNcORBfY6qFsDr8zVQKYcBSM6cD5cBL8L 8OpZsUZED5kIDlXKINT5YQta/nlogo6zAW0e+vgRDXM7PaH3fmtggDD3wtOfEraI7vtb QnjA== X-Gm-Message-State: AOAM531LV6cHaYYtbQ4AeylSpqzAoHGUtIZJFJpVvMXocNQa9Dqpr+L3 ZyL3GraXrxCz6STDwzcxhful5xTLY7sV5g== X-Google-Smtp-Source: ABdhPJxlqd1oARoHp1skaocwW7kWZzUBf6Jc4VP6k2JZ3tNSxR0pb2AGQBk7ItHUk/Yhn1pavLtq+A== X-Received: by 2002:adf:fa08:: with SMTP id m8mr1360256wrr.319.1623879842361; Wed, 16 Jun 2021 14:44:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 12/15] hw/i2c: Rename i2c_set_slave_address() -> i2c_slave_set_address() Date: Wed, 16 Jun 2021 23:42:51 +0200 Message-Id: <20210616214254.2647796-13-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880816402544.0781168270594; Wed, 16 Jun 2021 15:00:16 -0700 (PDT) Received: from localhost ([::1]:50496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltda3-0003gR-8T for importer2@patchew.org; Wed, 16 Jun 2021 18:00:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKZ-0002mK-CK; Wed, 16 Jun 2021 17:44:15 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:35754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKU-0006pf-0P; Wed, 16 Jun 2021 17:44:15 -0400 Received: by mail-wm1-x32c.google.com with SMTP id o39-20020a05600c5127b02901d23584fd9bso2189111wms.0; Wed, 16 Jun 2021 14:44:08 -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 v8sm3705536wrc.29.2021.06.16.14.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:44:06 -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=LeH+0XzZjrI9Ahy3mFlNXUOSl0AOt8muIB9GjpLaz1jcZ1Lx5MGiVZ6TTGYYY3KoEz q7Ck6+HTjCkse8FD7Z+qXvX74jhenGGtSUjwobtoJ4xUmNK5shKGrrkTI6/rPmwqxggb mufat7s44juoLdwYeN1BrgbKWTEvFevPkYVeoR7fbxuzQxOOaLAbdMomh6L5gE6SIFSx SzB9CpplN9O0j5rXwdMR70sA6YEaEupCTFKV+5NoP1n5wm4A+6G7i8vufsD/ds/ed4/N VZQ3DF0viYuRKlCJLi+jW5PLLG5Gbzc+IVYtUYg+dr++nfA7ZMseDDr7FUWeeUOW61Ug Dqqw== 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=ANuTfxOVtc4UHIOPRMLx7i6P5e8x+1ROtxbw5iuLmwirwi9xr4+af8LGp7Y2F7gFCk tUEhZLtujbWqoe4YNRm58+F3hmQBb8otYRqXQUAIpCU1/N9lACEnh84uM4mGhwol9fI/ tpmzdHaH2VvGwBPqeJ5GTBTJ8XGRikyRTENdaWVKPYI93tVPTUucXRUgvECj+xaF/n5h CR6Y6BuRwcnUtjCrCc399dORUzX09X48O1VJhMzNge6902gcWCXwna5FJxlH431g495v ClX9kMhzTd9N2A1Jvs0sZYxT9CRStMQhc43bZSpjFf48zVTHv0Cl2Z2idD+EYx2+HZo3 nbLg== X-Gm-Message-State: AOAM531UV2XsEI8l7sHvwdldyQ67nQgzKXpnPELVklvP6KfoasTvgM4I liiOHNs/ehgpeFZ4N0FMbeWytAGbF5JbQg== X-Google-Smtp-Source: ABdhPJz9zDUUgR6Ca6FC9g8DjIGwLbBpUFfDEa2MXDzNqPpbSK4oi+pqMwpByDMV4GdEvUNc/LCw2Q== X-Received: by 2002:a1c:b306:: with SMTP id c6mr1097964wmf.37.1623879847485; Wed, 16 Jun 2021 14:44:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 13/15] hw/i2c: Make i2c_start_transfer() direction argument a boolean Date: Wed, 16 Jun 2021 23:42:52 +0200 Message-Id: <20210616214254.2647796-14-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Tue Feb 10 19:35:45 2026 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 1623880988209730.3263609332049; Wed, 16 Jun 2021 15:03:08 -0700 (PDT) Received: from localhost ([::1]:53196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdcp-0005iF-1w for importer2@patchew.org; Wed, 16 Jun 2021 18:03:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKa-0002nI-5b; Wed, 16 Jun 2021 17:44:16 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:33725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKY-0006tY-OB; Wed, 16 Jun 2021 17:44:15 -0400 Received: by mail-wr1-x434.google.com with SMTP id d11so1889390wrm.0; Wed, 16 Jun 2021 14:44:13 -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 p23sm6031712wmi.26.2021.06.16.14.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:44:12 -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=XbaEDOU2JipKG2I/F5MOGMQYq6FK1z0qkr9m5RlbReA=; b=sp4CA67eCjSUDOKltx6UDvI/exh4Fvp7/raabcNUEn0RSQnS9v0ufUDOqw7G7CiGzk VhY/R+1T4/cc2wzrcgT+uLhgfItF10ZsRp2h/3L6awAL4GfIPA4B7YdC0cWyIqWQbLGr yhfxWV4yH7C/MRYooLmTqQa2a55wz1szFM+MqsBnbBPfaGEDmcs7/38Q9PUrOKJ3BjpF QSH/L7/9jEK8YTNFGW0/AoLZtiW6dskKzRWA2IWzXdXr/x1rehh6lAvYmc9Nj7GhpjT0 XUX1OTO3lnXCZ0Ubsas35VUyNKX+ixvcO3b5oDxt+BbCdoMffuxXD7QyQcNzHu8VDF7P rnKA== 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=XbaEDOU2JipKG2I/F5MOGMQYq6FK1z0qkr9m5RlbReA=; b=PAnKq7aloCb4ccuN2O8TB+S4m/oEOT4qqLycBUv8J/5gAno3SzKwazf+4k/Tx8TZQk GDXtUDos1d86b5d+/njJm9x9CAw8DsFv3igGWQ+LHxMWUBWJvMEuJs0PY8H2404oGiD9 p5Is4Ht53gP1+vKv1CCn8qRhCKfAk71xbZ+NKZBnRCuTBGU+KDgRfnS6xDYkHenyW8Cn AQLcS/A4F6jKDvrLm0XESHeT8eTNg9xt1qlNVDVClMAnnQP3ZZRgHhGOjHn7Dek/9nQN 7m6Vn3N6Sr0rsWN0mXUIJavaxQbcuYRHMI9A13JAAtheSSNR0/lNsOhRzdHX3feQ+2Pt fR1A== X-Gm-Message-State: AOAM531j6L4rOOnZZFZN8TXen8GY+0aNWJo3R8QJJv1qu6R0AaQASNrw tDRpeRNt6FgaVmOnnRrP3w6vTHOObG28mw== X-Google-Smtp-Source: ABdhPJx7aZ+RUHW44lXCYZI43uIJqWJpttgakGk45aRYGpvhJ6Fgcp2DCYmjO+rEgaGtlg5Hug/L9g== X-Received: by 2002:a5d:64c3:: with SMTP id f3mr1410886wri.263.1623879852529; Wed, 16 Jun 2021 14:44:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 14/15] hw/i2c: Extract i2c_do_start_transfer() from i2c_start_transfer() Date: Wed, 16 Jun 2021 23:42:53 +0200 Message-Id: <20210616214254.2647796-15-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::434; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x434.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.248, 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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..69df4c0df6b 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -115,12 +115,15 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool = broadcast, * without releasing the bus. If that fails, the bus is still * in a transaction. */ -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; bool bus_scanned =3D false; =20 + assert(event =3D=3D I2C_START_RECV || event =3D=3D I2C_START_SEND); + if (address =3D=3D I2C_BROADCAST) { /* * This is a broadcast, the current_devs will be all the devices o= f the @@ -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 Tue Feb 10 19:35:45 2026 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 1623880422018246.84995581203043; Wed, 16 Jun 2021 14:53:42 -0700 (PDT) Received: from localhost ([::1]:39678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltdTg-0004bU-Ub for importer2@patchew.org; Wed, 16 Jun 2021 17:53:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltdKg-0002zg-Qf; Wed, 16 Jun 2021 17:44:23 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:55825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltdKe-0006xI-GY; Wed, 16 Jun 2021 17:44:22 -0400 Received: by mail-wm1-x335.google.com with SMTP id c84so2047814wme.5; Wed, 16 Jun 2021 14:44: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 62sm3468418wrm.1.2021.06.16.14.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 14:44:17 -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=KhbMgEo2E42ngPoncw0s0RgptDO8KbfdQczk79/g87U=; b=C4EWhVtYX/YfbYWY3L7KeCeib/55K8VlIy20ZOMslUblvUdwdsO/xulzYugN3I1gFe nDRwYIYOD/QboCNfEtV8K9fKOuNgE9+ydYZcdFpnYFc+CdvIRzVTWfg7Bp4HiJLZZeHU IrVM3EjXhsLbmlzkxAH895ed8wr0CshASuHWe7I+gI7ey3qHOpZ8b8A5LxiciN9dl+So Qi6yPPk0Pe7rDjGwZLx11eQzbJueWDDefDOqABuHbgJN5NCcrIKFDYOi+MM2lbivAyF/ nFGtyUXPJnzuiHU+NV/aB8iP5nUFoGDtwEe4S7JEhR6mvh8Uc+/wjThEED7FPvfTIgSw TNdw== 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=KhbMgEo2E42ngPoncw0s0RgptDO8KbfdQczk79/g87U=; b=hkTVhvt/TtW6B6Y3jbttITCrQmPlUo0HGHOjfbGHsvcXTjwCGsbvlUce4QzeniZ6jv E95BfdPLP49rSjSinhh6/dKwciPWBn3ywu73tmhw9vsoQ0A0uV21jLDu9ZXeKwiEQzl8 k59fSVQwS50Z6tJTvJsMLdvTkrvpxp96HxleLR7xa/YuTu2/yP3Ukp3pC7PGKOQqkaKu nobTSZtvp7lyMtOMi+zVkmdPgmH6NS0oHdv1xZxFGlWVmEbcm242E1OQzFRP90tYWpTy TIEOKayG4CB6+luuHmU2qWkeLEO/gzB/6fdTm8tCAEwZQUAtdeYI43oL+tf5vJgUOCMB N8zg== X-Gm-Message-State: AOAM5323aWBrbKJfVO0kmje2KieVhM48dusnHFbpXulhiCJujmDAncQr S4fpLYues/tO8pT5oqGKEto8yyVOB9mPBA== X-Google-Smtp-Source: ABdhPJzMUuua2uxMlDKB+O6nm+Ib/IYgt9ywLGls5MtyGt7NPWTjvnJiis9+T98zJbMDohl+zn3uwg== X-Received: by 2002:a1c:35c2:: with SMTP id c185mr1136561wma.126.1623879858010; Wed, 16 Jun 2021 14:44:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 15/15] hw/i2c: Introduce i2c_start_recv() and i2c_start_send() Date: Wed, 16 Jun 2021 23:42:54 +0200 Message-Id: <20210616214254.2647796-16-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616214254.2647796-1-f4bug@amsat.org> References: <20210616214254.2647796-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::335; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x335.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.248, 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?= , KONRAD Frederic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 69df4c0df6b..7156f55ded7 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