From nobody Tue Feb 10 06:08:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1699558183; cv=none; d=zohomail.com; s=zohoarc; b=frAqPHOUdNIIUYLYl93sWozL6PMIPbHFONEJXd7HiSevo+UFWd+hKpLyFdf5PcweEpQ59Lj4KpolySJ8ZM1B61gM9WK6xjLip/sNBooQJ4u3s0ERGG8vdEJGQjL/jMNGapBaV3cQ0vGKZVWNjy0QVLT0/Yk/+XzBin+MQSQuyqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699558183; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=B9ZxoEwDSHdTDDF4xe3FaT39yQk5FrQXJ9Sn5dzqm6m1kyLb/RrtNUZRAgNPCBWX7FqMfe1IYWZdbs2k3qJuP1vgS7LZ6kCRMwN9qr7ce0XfMvEZ7YpP7ldOFkcaZcnGTT9Ll2iL9HNttmfp6C3YgVKUGXyRyet/UZM6ripiqgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699558183219116.47875092547588; Thu, 9 Nov 2023 11:29:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1AiL-0005l9-Uo; Thu, 09 Nov 2023 14:29:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1Ahw-0005Hf-7R for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:57 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1Ahs-0005Hs-N0 for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:51 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9c53e8b7cf4so211265866b.1 for ; Thu, 09 Nov 2023 11:28:48 -0800 (PST) Received: from m1x-phil.lan ([176.187.199.161]) by smtp.gmail.com with ESMTPSA id qx11-20020a170906fccb00b009b2f2451381sm2930998ejb.182.2023.11.09.11.28.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Nov 2023 11:28:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699558127; x=1700162927; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=IF0YNX5h+jeFnwz/GDjs7O7/0TnAwwqWMVtRuFm+oxr74QPr2tw1DvFQoNPk7IikKD +GtO0/yFn9XZLMnak2KqH84pgIs28uCQTIydjRvVoKw18luZoqqcx+FLeDyAAhVxLTJ2 7kmE4BHG6/y/AM89G/PnzA9nWIw6X983rzRvknc8VyLssgUDe5iP6Lj9IZCu8x2qIihp B82uKDAPqNhRypiKJesmFuqLIdxQhlPNK6iEB6XZBVeq3dWLzMKuXWulbYIxZ9M/69vN Ufgp6fslRTQzZNy/yHz4AMMf7H04UuiAeXbboebDsOUFCBUa6q+6PziHK1VXIVYTG/Eo s4aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699558127; x=1700162927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=rD7GhHDMmD4cGnAZxhrPHYtcsBLieYtVSLAIZunYwTc9wDQVLmNU1f/8UQnX9aj1Gw YKf9HRW5vSD94koj5+wwfWpyL7pU43ABhY07LATG91CAoUbn2z+WfVQ+kzP0uK/EqVEV jNxAIMtHhoWd86B0HrC08ez+yXduIW/eixMqyGYA+/FIo6jJvslxCm/aeKgPUkftJ1x6 TLH4jtqk5bkoTbwM3z34ftiHa7699l7C3K8h58FKp0LNS6nFV+YUWl/C0Dipe5hJkEDg N1SKijk5atun2HBcGwP94Yd2k2Tw2vZ7zwC2uyliir9PrjQvlgspfxaICXMWWCdIdKpC EAgw== X-Gm-Message-State: AOJu0YyVJRyIpU074O/MGdOPqASkEndDe2ObuzTsLcTr93zcp/I61Wf6 UEsKVJYIQpfrUR3E6T2GP93gPw4N9uv4mUrppkeGgg== X-Google-Smtp-Source: AGHT+IG1mIB1epOkXgJaPMduGKGeTPr6W+PS0WSWibBTbSNphDMXSkK+WfnOF/yBf0DY9R9lsFpDqg== X-Received: by 2002:a17:907:26c9:b0:9d2:ab03:a22d with SMTP id bp9-20020a17090726c900b009d2ab03a22dmr4450766ejc.73.1699558126739; Thu, 09 Nov 2023 11:28:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gavin Shan , Paolo Bonzini , Mark Cave-Ayland , Peter Maydell , Evgeny Iakovlev , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH-for-8.2 v4 05/10] hw/char/pl011: Extract pl011_read_rxdata() from pl011_read() Date: Thu, 9 Nov 2023 20:28:09 +0100 Message-ID: <20231109192814.95977-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109192814.95977-1-philmd@linaro.org> References: <20231109192814.95977-1-philmd@linaro.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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1699558186379100013 To keep MemoryRegionOps read/write handlers with similar logic, factor pl011_read_txdata() out of pl011_read(), similar to what the previous commit did to pl011_write(). No functional change intended. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/pl011.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 1cb9015ea2..30309337b1 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -160,31 +160,38 @@ static void pl011_write_txdata(PL011State *s, uint8_t= data) pl011_update(s); } =20 +static uint32_t pl011_read_rxdata(PL011State *s) +{ + uint32_t c; + + s->flags &=3D ~PL011_FLAG_RXFF; + c =3D s->read_fifo[s->read_pos]; + if (s->read_count > 0) { + s->read_count--; + s->read_pos =3D (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); + } + if (s->read_count =3D=3D 0) { + s->flags |=3D PL011_FLAG_RXFE; + } + if (s->read_count =3D=3D s->read_trigger - 1) { + s->int_level &=3D ~ INT_RX; + } + trace_pl011_read_fifo(s->read_count); + s->rsr =3D c >> 8; + pl011_update(s); + qemu_chr_fe_accept_input(&s->chr); + return c; +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { PL011State *s =3D (PL011State *)opaque; - uint32_t c; uint64_t r; =20 switch (offset >> 2) { case 0: /* UARTDR */ - s->flags &=3D ~PL011_FLAG_RXFF; - c =3D s->read_fifo[s->read_pos]; - if (s->read_count > 0) { - s->read_count--; - s->read_pos =3D (s->read_pos + 1) & (pl011_get_fifo_depth(s) -= 1); - } - if (s->read_count =3D=3D 0) { - s->flags |=3D PL011_FLAG_RXFE; - } - if (s->read_count =3D=3D s->read_trigger - 1) - s->int_level &=3D ~ INT_RX; - trace_pl011_read_fifo(s->read_count); - s->rsr =3D c >> 8; - pl011_update(s); - qemu_chr_fe_accept_input(&s->chr); - r =3D c; + r =3D pl011_read_rxdata(s); break; case 1: /* UARTRSR */ r =3D s->rsr; --=20 2.41.0