From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A975C3DA6E for ; Fri, 5 Jan 2024 14:09:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLksM-0002bX-Uf; Fri, 05 Jan 2024 09:08:42 -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 1rLksL-0002b8-1W for qemu-devel@nongnu.org; Fri, 05 Jan 2024 09:08:41 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rLksJ-00030O-6i for qemu-devel@nongnu.org; Fri, 05 Jan 2024 09:08:40 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40d60c49ee7so16390045e9.0 for ; Fri, 05 Jan 2024 06:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704463717; x=1705068517; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hKciBo3VLeB1ivg2FYiPgY0sifTOvsA6mJmXTFqHC+0=; b=qxEJErUv/Jd3oFPJzUTcl8f7ikCA7MITVHxovFiQn1S4rbDzmm5an6LR4DUgZoD58b 4Iz6zpGdoxggDRh9CKV41zaywA6Nc24QVvCO+KZmATCzaAOvCYCvgioPdBaAt9sT3lpH QHEb/ZPafiSH54D5+Mkf6mgIZgITPSQOoYzHftSHkHfXGKZjInW5sCyWYZJ8QuCIrzyl v76AMDQJzzfA3VFq1jEOb3NCG77JpUc4L04x60d3cHEavJPzbO+yzhwZ20zNMrjti9bv d1ZgMjTtaLQA37SGT2GtfZHGJR9lR8wtoP2fo1NjpjkJhTplvHlL0mBYjWBwbNHXmOel dxJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704463717; x=1705068517; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hKciBo3VLeB1ivg2FYiPgY0sifTOvsA6mJmXTFqHC+0=; b=KOJhvDAI/XjEvPz7iRflk3fpOFTtE8LHHvaV7QSmE7hDQb5zrx8Hxla70GZXuYsw2t a0GBJcScjIxzmN5JbzJ1Q6bJV6WZL93WP7q1XzmmByS8p3vr656wTv1XtMkpXyqkj3ZI brJ5ARw7Ly9I5a+kvXBXh/pUS7rR6fycXAhSsNVMIM0EWW9YD6usX5GfdY46CTscKf5p XzyT6yS5202m73ETC9GB124X5J8MWgon8xVfAJBtKTbUepwdPK8IBlwfQJVVjWDIPZnf /LTztZogElw8OkHkki2sc3Rtwm/cUNvKr56bK3BsjBy70mzN98z88tmRoh11To1+ZRfh 6XdA== X-Gm-Message-State: AOJu0YwmYMVxIi+iN8zFEI1IL2MYEmdoqe9iagO9hKbOK5kbGA+zy7d+ /vktxAXyzGVTQsyr/rPmztiT4/nxcM0P2g== X-Google-Smtp-Source: AGHT+IHRCURP0aJ+kSrc6cNEtOuTZX2Vv1H7ZdVzIWFLRb4XBoIRt4hJn43YWFbuHzCPrh3E9+w8Xw== X-Received: by 2002:a05:600c:3ca3:b0:40d:5597:c7e9 with SMTP id bg35-20020a05600c3ca300b0040d5597c7e9mr1210263wmb.95.1704463716864; Fri, 05 Jan 2024 06:08:36 -0800 (PST) Received: from [192.168.69.100] (juv34-h02-176-184-26-1.dsl.sta.abo.bbox.fr. [176.184.26.1]) by smtp.gmail.com with ESMTPSA id k3-20020a5d5243000000b0033668b27f8fsm1477995wrc.4.2024.01.05.06.08.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Jan 2024 06:08:36 -0800 (PST) Message-ID: Date: Fri, 5 Jan 2024 15:08:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] hw/pflash: refactor pflash_data_write() Content-Language: en-US To: Gerd Hoffmann , qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org References: <20240105135855.268064-1-kraxel@redhat.com> <20240105135855.268064-2-kraxel@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= In-Reply-To: <20240105135855.268064-2-kraxel@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 5/1/24 14:58, Gerd Hoffmann wrote: > 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 > --- > 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 3e2dc08bd78f..67f1c9773ab3 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; > } Close to commit c3d25271b2 ("hw/block/pflash_cfi02: Use the ldst API in pflash_write()"): if (be) { stn_be_p(p, width, value); } else { stn_le_p(p, width, value); }