Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4600201rwd; Sun, 11 Jun 2023 10:44:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5jo3aTD7FmmDWqM6HwNwwmQZ5T1GspNcJLdfS6Ak8pXXigHLoSgpMQHQTVCZZnJ0WxGgZN X-Received: by 2002:a05:6402:1a27:b0:515:cff3:705c with SMTP id be7-20020a0564021a2700b00515cff3705cmr4130139edb.5.1686505456942; Sun, 11 Jun 2023 10:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686505456; cv=none; d=google.com; s=arc-20160816; b=Z6ywB9Wtvh7Z13whvyWBFtYnHKgTFZq+2oHBcMlNokgZAww1Kt37wttguMNNkx+yad Av3oUNwl/87HnpedHR7PwLp9kyXwBWxZ5q11FWzfLxvOfT4VUkYLbzaFSc4tp8rAcYlE JP/XOa4Sa4q9/iEr/uUHQlswEBt+FH2rtK/kcrDFxlC3n/0b5YZS9gRExc5vPXXBLndp KeBEqSu0kg8Zl+wQ7eufuoVIKp4xHJ8eZ+uVAvbILg7vySYNMzGge3THNj0UIJ2jomO6 iOnt2fkNbe3PWeVh7YwXqrR9DbQWUZOJJTlUGpYP+U8Yc5orGJelu54LDHXZfBwN/0/E U/+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=OFECUJ1shgLQhTBUDB/EGo49nH7RntEO2gKbly8vnE4=; b=UVlLwIiX6F80JmBduGM8TbvyJA2k3+Da+L1OuztMeV8ceFn7a5hjHXP05JlrDvfAqP JA3rEc2CvoCj80mdEZxDfnjby8fOXrwQEeQYUXnPwer6XsfpFeKQRDNT0jdWtx8ZwW8t oSritZbRKwxUQw40paRenAcnmbWhor958ClJUApD3/oxOvQFOUVx6CuS2MzRafr/A2pQ 8cTHpcRkk1URe6Or4AbmY/UjOUUmG6/9Yt4fooqcwc2NDDrNfPMGoHuPWUcUbe/EtRkt vJssyZTiMzHKQLj3/ePY/wGH2s9zZR36Jy4TSiKVjnEaG87LPl0ERxpiAz7C1poGo5fX xykg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p26-20020aa7cc9a000000b005148f8c24d5si4692372edt.382.2023.06.11.10.43.47; Sun, 11 Jun 2023 10:44:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbjFKRU3 (ORCPT + 99 others); Sun, 11 Jun 2023 13:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbjFKRU2 (ORCPT ); Sun, 11 Jun 2023 13:20:28 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EF8F810C4; Sun, 11 Jun 2023 10:20:04 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 53DBD9200C5; Sun, 11 Jun 2023 19:19:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 4D8169200C1; Sun, 11 Jun 2023 18:19:45 +0100 (BST) Date: Sun, 11 Jun 2023 18:19:45 +0100 (BST) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?UTF-8?Q?Pali_Roh=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 08/14] PCI: Use distinct local vars in `pcie_retrain_link' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use separate local variables to hold the respective values retrieved from the Link Control Register and the Link Status Register. Not only it improves readability, but it makes it possible for the compiler to detect actual uninitialised use should this code change in the future. Signed-off-by: Maciej W. Rozycki --- New change in v9. --- drivers/pci/pci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) linux-pcie-retrain-link-lnkctl-lnksta.diff Index: linux-macro/drivers/pci/pci.c =================================================================== --- linux-macro.orig/drivers/pci/pci.c +++ linux-macro/drivers/pci/pci.c @@ -4922,30 +4922,31 @@ bool pcie_wait_for_link(struct pci_dev * bool pcie_retrain_link(struct pci_dev *pdev) { unsigned long end_jiffies; - u16 reg16; + u16 lnkctl; + u16 lnksta; - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, ®16); - reg16 |= PCI_EXP_LNKCTL_RL; - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, reg16); + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnkctl); + lnkctl |= PCI_EXP_LNKCTL_RL; + pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnkctl); if (pdev->clear_retrain_link) { /* * Due to an erratum in some devices the Retrain Link bit * needs to be cleared again manually to allow the link * training to succeed. */ - reg16 &= ~PCI_EXP_LNKCTL_RL; - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, reg16); + lnkctl &= ~PCI_EXP_LNKCTL_RL; + pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnkctl); } /* Wait for link training end. Break out after waiting for timeout. */ end_jiffies = jiffies + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS); do { - pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, ®16); - if (!(reg16 & PCI_EXP_LNKSTA_LT)) + pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnksta); + if (!(lnksta & PCI_EXP_LNKSTA_LT)) break; msleep(1); } while (time_before(jiffies, end_jiffies)); - return !(reg16 & PCI_EXP_LNKSTA_LT); + return !(lnksta & PCI_EXP_LNKSTA_LT); } /*