From patchwork Wed Jul 20 05:02:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9238891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A34F660574 for ; Wed, 20 Jul 2016 05:04:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9784026220 for ; Wed, 20 Jul 2016 05:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C17B2756B; Wed, 20 Jul 2016 05:04:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3ED7D26220 for ; Wed, 20 Jul 2016 05:04:06 +0000 (UTC) Received: from localhost ([::1]:60570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjfx-0007yI-3o for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 01:04:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjfH-0007v0-H1 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:03:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPjfG-0004eD-K2 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:03:23 -0400 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:35085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjfG-0004e1-D3; Wed, 20 Jul 2016 01:03:22 -0400 Received: by mail-pa0-x241.google.com with SMTP id cf3so2560112pad.2; Tue, 19 Jul 2016 22:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wdrpkMn5RYUt6mE5m9S7CEEUXhnzN18D2R7qN/IcEx8=; b=GsU9bNTwcLN/NQOY1e4gZNUdSAXkJvHHsQ1bZxU4qwWtLlz8eeVVweHuXIaxa6bsDi s0NnvbTxzogaUys3Dq8NTa2H/01qj7+Mlfx/QZoOFJLf/tzJ1eBSMYHNqJteE/9yCU7f qBrq+VGyiiPxTxmGqrvubAFCuFAPPCwT/OscFTsDyZx7G+VTCATdFFK1onHSkYW02oHA rcRc/f1gb0mh9COSsa2WZcdaYi6bwMmJYrTG20c40ii5RJSi3Wli2MvV79Vo6P8kin55 ChMOIq2rw/IhR/Cn5BZk4dMxmT4mc7Aomtq2XUNKxwL45e9cK9lSyXSMKYlItBvZc387 5waQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wdrpkMn5RYUt6mE5m9S7CEEUXhnzN18D2R7qN/IcEx8=; b=hRApb8+MooHx6r/3mNvHbjqkfEDEIZtrT5bY+qNaCDtVoLU9Q6xljqZ/y/wOIg5cYB xLAa5hyGp6GNH43SogJcv6vIwG5I9fWBCiZSLMgnVlWK/TMFGi9ISfVcAL8cO/Nsz1vm GLDN3/GEZ/zBRy23yuKxDyowQ8kZ0EC3uAMYKzqXkgGmO8Fk05B+sqGjSQm9dyuA0UU9 14+TNzuMOskfI6FNvMt5m7uV+5s2i2fdub8wzcwfvYKD4wjcAm3fnHRq+Ei7szJzY+1o hqqLZgq7IGvqUw259/MZutVgeu9srkA3fbQWj2/itQdEq4mcrQf9ynQ2Fvabi9Z94jMG ohVA== X-Gm-Message-State: ALyK8tI+JWWHl67MzPvYs4WuHQt5nWHJAV69UPvl5zYllBbsETyRo9rKjivT72vkbQc/sQ== X-Received: by 10.66.155.129 with SMTP id vw1mr70947576pab.148.1468991001544; Tue, 19 Jul 2016 22:03:21 -0700 (PDT) Received: from squirtle.localdomain.localdomain (c-73-225-163-254.hsd1.wa.comcast.net. [73.225.163.254]) by smtp.gmail.com with ESMTPSA id c66sm1031757pfd.24.2016.07.19.22.03.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 22:03:21 -0700 (PDT) From: Andrey Smirnov To: qemu-devel@nongnu.org Date: Tue, 19 Jul 2016 22:02:54 -0700 Message-Id: <1468990980-4598-5-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1468990980-4598-1-git-send-email-andrew.smirnov@gmail.com> References: <1468990980-4598-1-git-send-email-andrew.smirnov@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::241 Subject: [Qemu-devel] [PATCH v3 04/10] address_space_write_continue: Distill common code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , kvm@vger.kernel.org, Andrey Smirnov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move call to memory_region_dispatch_write() outside of swtich statement since the only thing that is different about all of those call is "length" argument and that matches value in "l". Reviewed-by: David Gibson Signed-off-by: Andrey Smirnov --- exec.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/exec.c b/exec.c index 44cd424..e2425c5 100644 --- a/exec.c +++ b/exec.c @@ -2567,32 +2567,23 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, potential bugs */ switch (l) { case 8: - /* 64 bit write access */ - val = ldq_p(buf); - result |= memory_region_dispatch_write(mr, addr1, val, 8, - attrs); + val = ldq_p(buf); /* 64 bit write access */ break; case 4: - /* 32 bit write access */ - val = ldl_p(buf); - result |= memory_region_dispatch_write(mr, addr1, val, 4, - attrs); + val = ldl_p(buf); /* 32 bit write access */ break; case 2: - /* 16 bit write access */ - val = lduw_p(buf); - result |= memory_region_dispatch_write(mr, addr1, val, 2, - attrs); + val = lduw_p(buf); /* 16 bit write access */ break; case 1: - /* 8 bit write access */ - val = ldub_p(buf); - result |= memory_region_dispatch_write(mr, addr1, val, 1, - attrs); + val = ldub_p(buf); /* 8 bit write access */ break; default: abort(); } + + result |= memory_region_dispatch_write(mr, addr1, val, l, + attrs); } else { /* RAM case */ ptr = qemu_map_ram_ptr(mr->ram_block, addr1);