From nobody Sun Feb 8 05:41:18 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CBBFC04E69 for ; Tue, 8 Aug 2023 22:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbjHHWel (ORCPT ); Tue, 8 Aug 2023 18:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjHHWeg (ORCPT ); Tue, 8 Aug 2023 18:34:36 -0400 Received: from out-106.mta1.migadu.com (out-106.mta1.migadu.com [IPv6:2001:41d0:203:375::6a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5FA137 for ; Tue, 8 Aug 2023 15:34:34 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691534073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQgYw5lX3SkYq1STywg88ED6q5FjX9omCE5FKYEvLx8=; b=V2b/yZWh7iqOPKRM+woaS0Pcn2y/ZwlopGA/To5CR6hBItv7RHn++t0bdatVP+jBdJY3WF XEy5JoecUt0pwfcntmWSCZuzjtsjWYXbh4aYIVQPplR1enGjSuBkUvCm7NtvjmK/1e2a/q t2IOEGUJZhKpiH+y+nQ3gBn4OCPe5HA= From: Sui Jingfeng To: Bjorn Helgaas Cc: Dave Airlie , Daniel Vetter , linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v2 05/11] PCI/VGA: Move the new_state assignment out of the loop Date: Wed, 9 Aug 2023 06:34:06 +0800 Message-Id: <20230808223412.1743176-6-sui.jingfeng@linux.dev> In-Reply-To: <20230808223412.1743176-1-sui.jingfeng@linux.dev> References: <20230808223412.1743176-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sui Jingfeng In the vga_arbiter_notify_clients() function, the value of the 'new_state' variable will be 'false' on systems that have more than one VGA device. The value will be 'true' if there is only one VGA device or no VGA device at all. Hence, its value is not relevant to the iteration of the loop. So move the assignment clause out of the loop. For a system with multiple video cards, this patch saves unnecessary assignment. Signed-off-by: Sui Jingfeng --- drivers/pci/vgaarb.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index dc10a262fb5e..6883067a802a 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -1468,22 +1468,20 @@ static void vga_arbiter_notify_clients(void) { struct vga_device *vgadev; unsigned long flags; - uint32_t new_decodes; - bool new_state; + bool state; =20 if (!vga_arbiter_used) return; =20 + state =3D (vga_count > 1) ? false : true; + spin_lock_irqsave(&vga_lock, flags); list_for_each_entry(vgadev, &vga_list, list) { - if (vga_count > 1) - new_state =3D false; - else - new_state =3D true; if (vgadev->set_decode) { - new_decodes =3D vgadev->set_decode(vgadev->pdev, - new_state); - vga_update_device_decodes(vgadev, new_decodes); + unsigned int decodes; + + decodes =3D vgadev->set_decode(vgadev->pdev, state); + vga_update_device_decodes(vgadev, decodes); } } spin_unlock_irqrestore(&vga_lock, flags); --=20 2.34.1