From nobody Tue Feb 10 20:48:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.47 as permitted sender) client-ip=209.85.128.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1623879800; cv=none; d=zohomail.com; s=zohoarc; b=chm4huvvE32o2uzM4NuD3+Z83sVorfLyy7DPEN2kNbuhxOejo7k8iq7+O0vapIU/s1YTxKC0KUHEO8PP9B2vdpE5jtpjzspbKHDnKP06EMh9xCqUD1jJymT4CBhkGwFBQrO3rzwxa7rduICE67ngFWx1AaJUvAWG/dxjJjmNieo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623879800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0yFcNPzCMbJU7ln7mvR4pO20Y4U4Q8SH66r8xtnNF00=; b=n1AJOikscXtzwKck97J/0rk4AcLtZiBldbvezwbgGFbgbkuABO13vh05yvikNpAUaSsbdcNueuuUXQAH8hhBwt++B9G9AdL06eyzM/x3unbAksHqzmX9GICPAFuaC/GRVKcUkrhld4qnFDGWvAsxcegXqlhM8XfsWQaA9JyDiy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.zohomail.com with SMTPS id 16238798004761009.4081010255063; Wed, 16 Jun 2021 14:43:20 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso3883861wmc.1 for ; Wed, 16 Jun 2021 14:43:19 -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 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=UsfHdzhPYvI3VuoGp2zLs9zdxAhdn+FK8CWrZprNv/lSLnUfLJSkxKepGZFasQc6Eo LRXZD9rWJiDRsx7JbtwgVsZo2fpU5/Y9892Og/Ux2AQ/MsMdYbpY0T3PaSeC6PzcPIHp u4dhTwJYTeKIYvDyRjPfW2vnQZJ3EaCjRaQn8jMYnw4cSWgv+saEimu2bQVl9231q+Qt vle0JMfNujI12ZpnUoB8qTAtd6ZnVJQ1uk09etrfh3yxySoDwJrMqzAIrDCwjVNcNqAq sTyJbHLLu2EudyoCLW0c4rrDcQs93jwtdcKW2RKB1mBgpfFvYesG2NrNL/VXOu5DxvFk zwGQ== X-Gm-Message-State: AOAM532NQgg2ilLQ31nIsFtMyo2FX7oic+RVoJHDxEgdwZLpwBkT1h4e NC0a4t4oWnP6RFdh/KbW46v2FBvfuiQo/g== 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) 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 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 X-ZohoMail-DKIM: pass (identity @gmail.com) 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