From nobody Tue Feb 10 04:02:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.50 as permitted sender) client-ip=209.85.221.50; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f50.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1623879832; cv=none; d=zohomail.com; s=zohoarc; b=JEzVAFLRDVQgFslHiePZCD0g5fT0QyaWrs9GE1ATqUv3RWrmTPIf/b0v+Hlh2UeljK6yUyFfwHK2KnIieJihQGB8QsmHYMh7eVZqcX20qktNmfvdM0iTZjeIun4WsfAqaSf1EHjxFz+9uvqF33+xZuKTLBGL4Vs2JADqwNVTxuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623879832; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lMrFIFZX4VBJPQraxvDxEyJhOku4B5f9uSq095+uB5I=; b=PYu2eFeRR4pb02Y1CcF+HT9Nw1w2y3fVZYpvo/O8E7ToHdp1XMkUOl3FGTyyCTnmhvhNbox453THf3LND5CUVx/gxP/6WSVWUTc5jU2VVugVO+3RFb8xKvx9G4AwmDwi/g2hJd4ZJMO5CAJFWB1roIdj1G/k6r4tBXzHldGSwuE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.zohomail.com with SMTPS id 1623879832741182.19805979710634; Wed, 16 Jun 2021 14:43:52 -0700 (PDT) Received: by mail-wr1-f50.google.com with SMTP id f2so4230717wri.11 for ; Wed, 16 Jun 2021 14:43:52 -0700 (PDT) Return-Path: Return-Path: 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=YmsgPjOCtoWHqjoI3j0DkjDW3LLXYm6tUXS/viP3pq2izJNfOYePJAUPj6OrCYaD9R KinCD8EHjZ0TjzWbb18pM1M1a7iLSV3WiRaWakizfM6RhTH5lNhMvLlYAFI4uOBxW4It asI7EDv9o1Kol6d7uiS4cfNg0wiWPNjFKui6rrYyI/XGNfuaQfzGac7VDiU3mDlC21M5 xPEojTqYDTuVDjVh34DmE5CUPijzbpCTpdybyn0helvOGR/oFQ3tsFP2/iftOQ3J8+iq T4xB3H8Yq/lzaRZWhWmkslB6fQ0biodf6PmwLkWlvmoELzmQK55+E4aOn31+Q2FVgjvX 45ww== X-Gm-Message-State: AOAM530YHfl6ydea3aVpgDBbOMoLq40RLLZWCklBJ8PPa8wJZPL0mgi2 qz2+VMhtnYOTaekZ51q1jiuN/PPf4/MXYQ== 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) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Corey Minyard , qemu-ppc@nongnu.org, BALATON Zoltan , qemu-arm@nongnu.org, KONRAD Frederic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson 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 X-ZohoMail-DKIM: pass (identity @gmail.com) 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