From patchwork Fri Jan 19 11:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 763925 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a08:0:b0:337:62d3:c6d5 with SMTP id m8csp399311wrq; Fri, 19 Jan 2024 03:42:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7M7ANQGn5M68xgqDBnq01fNLbnKUMSRr8DuepFYjLpQYzoW2Ulx8qEwyuQ3/UUogRLS8x X-Received: by 2002:ac8:7c44:0:b0:42a:4e8:e2cf with SMTP id o4-20020ac87c44000000b0042a04e8e2cfmr2990600qtv.45.1705664572156; Fri, 19 Jan 2024 03:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705664572; cv=none; d=google.com; s=arc-20160816; b=WbwhtZ5ao0N1jv3ktn8nOJMxwI4x7mLuIk+XV+Tx4823AsXOTVIZV5a6QqHk3OGkqj 0qFekvl8kqMuGktVo4eNpsqrllvKHGgXC8o62FZlASDpbF+KzUPhY7SopfMz06mrfbPm oR9xG+qyF1tLAsuFz0w/QCjqHsywD1kVs8X7LeTaTcLMaF697FgUCLm6D0gQoQssb/Ta 16xH+0GSD8OYhatAeRpJ7N2DyfsdtrRgpIadhDegUYEMzhIrNOJ7lGcmHx83UNW/xePJ 3b0yTicxNiejlh+EvGZHtR6yf3+8LLHBXXT1zQEO4cYu5WrUcnYonzzqiNqh/vLTciBP akBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ti8d6bE+nqA1U4OtHFV3Ptf3sJVQ6hdYw2WwbY+h+tg=; fh=H3gzWMxIGcYpnCV3e2JUJoIjDrs6lUKJhouF472DiR4=; b=f4JwjoctRTgkU/KAhgM7uHGw/fsjoO56166PWw/0p9TcF9QbJm7FwxD9QlvB3FfuUq iD5sAmWnD4quoR1LUWDypbGvkVYuMBJjxvh+vAXz45JEt9pjyWfYoFFRO5MQIXqjvrUP q+zJ7TNY4PrTJj3gMJwVyjS7DrJXS5m6u4kiWHdmF4DWN/pt23BJXpl+25sZypesd7Qw bkOxaeUDuZ9432kHAjlHryghoUCPpvGltLRIPeE6wLhO2uJYoiAmp7wpcCU3qmVqnzgP HCbktN+bi6qPb5FQm1smnmKJb9agaaWgN3lW8Se4wdlAu8y8lWbceIKugNRWQJ2iZ5xk BY0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jtC4+k3X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j21-20020ac85c55000000b0042a0e68c831si5615266qtj.120.2024.01.19.03.42.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2024 03:42:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jtC4+k3X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQnAp-0003Sl-KQ; Fri, 19 Jan 2024 06:36:35 -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 1rQnAo-0003Qd-9X for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:36:34 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQnAl-0002nX-IB for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:36:33 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-337be1326e3so588392f8f.2 for ; Fri, 19 Jan 2024 03:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705664190; x=1706268990; 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=Ti8d6bE+nqA1U4OtHFV3Ptf3sJVQ6hdYw2WwbY+h+tg=; b=jtC4+k3XnelZv7GJiyBwnfVasVVy5r5+TDjQe89E0a2/rwO7pYHCnFpS8O6yVo1vPw l3on6WFWfPNxPHxLmjLhjbRxy/Cc24kSrNFSzKg3NKceUmPecRUbgdW8/nyS9T/LgWX8 rOKN3/zdsQV1yP/VqTKtzdx2ecOb9LXVxzeUIfHs9AzL7dyJiPGqLJWEkVQSIXiluzYa fwq92QjNLIdySWx5tbmGhdiddeUdUoTOM42udllBwgPCBQVxSuRza2YG1AoBx0gbXd34 K+RrqA0TyTbcBw5RFBHVMZHgRYmW8cd5OrEHCa399iIySnMa4zSQLj2T9Y6fQ7eipg6M 3ghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705664190; x=1706268990; 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=Ti8d6bE+nqA1U4OtHFV3Ptf3sJVQ6hdYw2WwbY+h+tg=; b=cU7kC7uvlYrlvPHla5wlNLh89yGA4q2A2o9HScfHi8n/2WdvPkmJaP5fqFQn0oD8a0 WHGwQb+8g0mKgCYpdzhUBMee3rYDmV5BgrsCbpt9saNqCAagyWiaqeHjhIep8O5440mh uXl386G9IQ9CCmfxm+9nPfIKqSHehlwzElkf5Q3YT2M7CkvVUsognjJrbOD7HNefqKSe TBk+Wb+I5lnmn5mu/1//pDhjr2yrczV20DOzeeStD6GD8rfMNrENcfOKrvBCNWD4xJLc AX+E36gXeFVx91Bm9MvMrt4Pq6xyDA8FQt8mqNdRujqbPw3ktVL4UrAdXTLcFSAzoTxl TZMA== X-Gm-Message-State: AOJu0Yz9uCahGUZNhcX4GnsFxJmvBu670rFA4gPp1p82iSNv3HUjIoSM 49Mpdq0gJG26UBAXdXAxNIZ2f8jCvENAaRskDXjhzRYYBmupexwc1asTmN/2JoHhjmp/asjnr3X q6/Y+EA== X-Received: by 2002:adf:a1d1:0:b0:337:c872:7146 with SMTP id v17-20020adfa1d1000000b00337c8727146mr1312014wrv.13.1705664190046; Fri, 19 Jan 2024 03:36:30 -0800 (PST) Received: from localhost.localdomain (91-163-26-170.subs.proxad.net. [91.163.26.170]) by smtp.gmail.com with ESMTPSA id i7-20020a5d6307000000b00337d71bb3c0sm2533871wru.46.2024.01.19.03.36.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jan 2024 03:36:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-block@nongnu.org, qemu-arm@nongnu.org, Gerd Hoffmann , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz Subject: [PULL 18/36] hw/pflash: refactor pflash_data_write() Date: Fri, 19 Jan 2024 12:34:47 +0100 Message-ID: <20240119113507.31951-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240119113507.31951-1-philmd@linaro.org> References: <20240119113507.31951-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gerd Hoffmann Move the offset calculation, do it once at the start of the function and let the 'p' variable point directly to the memory location which should be updated. This makes it simpler to update other buffers than pfl->storage in an upcoming patch. No functional change. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240108160900.104835-2-kraxel@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi01.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 3e2dc08bd7..67f1c9773a 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -403,33 +403,35 @@ static void pflash_update(PFlashCFI01 *pfl, int offset, static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset, uint32_t value, int width, int be) { - uint8_t *p = pfl->storage; + uint8_t *p; trace_pflash_data_write(pfl->name, offset, width, value, pfl->counter); + p = pfl->storage + offset; + switch (width) { case 1: - p[offset] = value; + p[0] = value; break; case 2: if (be) { - p[offset] = value >> 8; - p[offset + 1] = value; + p[0] = value >> 8; + p[1] = value; } else { - p[offset] = value; - p[offset + 1] = value >> 8; + p[0] = value; + p[1] = value >> 8; } break; case 4: if (be) { - p[offset] = value >> 24; - p[offset + 1] = value >> 16; - p[offset + 2] = value >> 8; - p[offset + 3] = value; + p[0] = value >> 24; + p[1] = value >> 16; + p[2] = value >> 8; + p[3] = value; } else { - p[offset] = value; - p[offset + 1] = value >> 8; - p[offset + 2] = value >> 16; - p[offset + 3] = value >> 24; + p[0] = value; + p[1] = value >> 8; + p[2] = value >> 16; + p[3] = value >> 24; } break; }