From patchwork Sat Aug 1 11:24:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696041 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41F6A722 for ; Sat, 1 Aug 2020 12:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2991E2080C for ; Sat, 1 Aug 2020 12:25:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QHi5Tbht" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729259AbgHAMZn (ORCPT ); Sat, 1 Aug 2020 08:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728949AbgHAMY0 (ORCPT ); Sat, 1 Aug 2020 08:24:26 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71499C06174A; Sat, 1 Aug 2020 05:24:26 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id o23so6562719ejr.1; Sat, 01 Aug 2020 05:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BywL0jlhvMnVFDfC0ze8h5LlMNFaT8aAv2rtyExEJSw=; b=QHi5Tbht062uQl2CgFExEPFUSOMEeggyKWMdFMaxe6+Ih4MGawd4RuVAGo9gayKr/D 2yHM3GwaZiead9mkPgX6CmWqtJbVMVrs1ivY/NsgsQYDy259Sl3XZbv/YgzUgCEEqs/l 1wsrUeMhNsz49YAxVBQhfhiIj9RG9ULztEQd4Q8H0R1duiNIIlpXMswb/m7QfOuNR+W7 PzhiKRCjDzvqB1woNt4nMSfQ4i7ZYPwKrKGD1c4qVxpaPGDRJJa1GAWZwDRByPlEFt8o ZwW6DJ21TN+PbO9dKjKlAV0aNVKmWm6tq8l2jd4PPsh2rNZxPgV7qhiiUwBiy6U/4PQq iFbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BywL0jlhvMnVFDfC0ze8h5LlMNFaT8aAv2rtyExEJSw=; b=WwMuk4MJhSn/Z5RPIZ57fVWY8yEB4a8yze6sf0DNdA+h1WurNiHWkzxpXodZrLxxAR yM3UkKhLkjW6kKkqN3ysA8Gi8h0CwZ+rTBUscqSuGsBqewK+tL89k6rf4T88ek+CaNIC HerMYnHx3/hFoMFExtWL0cDfGx8PEMjrSMc/jxra72kDuKNNoNdwUQYXngIGFtMfj8DE hUKW+vwyVHNfN/u9PeibbnYaOi7LkuvA5XO5TLpAiwpUwAcWb6AmANqLL9KIVOHT9JFb 8wcHjuytOOjeIBkS7PnmetfIHwV47/yzNNTXvcKg/dpffrWKCfXG6WMRMCMUfvUvRxPc ihJQ== X-Gm-Message-State: AOAM533cb3gYLjraMelXrRdK3j7o/WQZJoaO68aW2kJI3SRkWyNPxdRR ZGBAf0OJbjNr12dtWn3Sm+E= X-Google-Smtp-Source: ABdhPJz7rYxC2q7EJUBMGW38zssfKtQqC5IyJS7xjTc/otiniFOliqfObCiKTOcL0cPPw/LW53NfQw== X-Received: by 2002:a17:906:1756:: with SMTP id d22mr8343053eje.29.1596284665171; Sat, 01 Aug 2020 05:24:25 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:24 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Jens Axboe Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org Subject: [RFC PATCH 01/17] ata: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:30 +0200 Message-Id: <20200801112446.149549-2-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. drivers/ata/pata_cs5536.c cs5536_read() : None of the callers of cs5536_read() uses the return value. The obtained value can be checked for validity to confirm success. Change the return type of cs5536_read() to void. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/ata/pata_cs5536.c | 6 +++--- drivers/ata/pata_rz1000.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/ata/pata_cs5536.c b/drivers/ata/pata_cs5536.c index 760ac6e65216..c204215e239f 100644 --- a/drivers/ata/pata_cs5536.c +++ b/drivers/ata/pata_cs5536.c @@ -83,16 +83,16 @@ static const struct dmi_system_id udma_quirk_dmi_table[] = { { } }; -static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) +static void cs5536_read(struct pci_dev *pdev, int reg, u32 *val) { if (unlikely(use_msr)) { u32 dummy __maybe_unused; rdmsr(MSR_IDE_CFG + reg, *val, dummy); - return 0; + return; } - return pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); + pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); } static int cs5536_write(struct pci_dev *pdev, int reg, int val) diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 3722a67083fd..e0b3de376357 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c @@ -64,7 +64,8 @@ static int rz1000_fifo_disable(struct pci_dev *pdev) { u16 reg; /* Be exceptionally paranoid as we must be sure to apply the fix */ - if (pci_read_config_word(pdev, 0x40, ®) != 0) + pci_read_config_word(pdev, 0x40, ®); + if (reg == (u16)~0) return -1; reg &= 0xDFFF; if (pci_write_config_word(pdev, 0x40, reg) != 0) From patchwork Sat Aug 1 11:24:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696035 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8898D722 for ; Sat, 1 Aug 2020 12:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AC6E208C7 for ; Sat, 1 Aug 2020 12:25:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B4zX48MK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728985AbgHAMY3 (ORCPT ); Sat, 1 Aug 2020 08:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728505AbgHAMY2 (ORCPT ); Sat, 1 Aug 2020 08:24:28 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09D0C06174A; Sat, 1 Aug 2020 05:24:27 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id c16so13635239ejx.12; Sat, 01 Aug 2020 05:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bG2JE9axjD8+1CxaVpKNmxH/0vdTkJVbn2KxUvFFaz4=; b=B4zX48MKM98OUqRQH2btOaTqQ+4ZBBdc71SUsPcKtP3UNPJeBOiRRZ3umH0Gqic3VR GB0OxXzbXXdW8FGraOn/kPQftWEZ+Uw+UpPMrnJHa7iam+pzis9+Jq2iW78XAXNyFo6s J2pTNBilXsubMUsM9hS8Paz5mGFKJcsoqhinBL3c5owR97ATgzHjM3MwRhll/jbYM7Sr syMquosNWbae4/7CwHFqNsGG1zI9Ik6aRfFVR6cWd64bCM6sO03wq3dpjZDh7zgKDxJZ wkydMXxg54UJ4/tdMtHh6cDckza/LubMIvWbHtLtOT6bkgr2/xaY9+X8SrzDXBeHXKCQ z/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bG2JE9axjD8+1CxaVpKNmxH/0vdTkJVbn2KxUvFFaz4=; b=DpJVltEze/jzY9sdKJPrGUDKUh1fSUO3+nRX24UEHO+5c33ewHMUExY637wET483X3 ABvwsthWjNtLa8pOpdoIiuRDs6g4dj3tNnjTQGrxTGYr0ZWaDnPZsnDi4Z/pjMHKwnVZ a8yDxA/G9JJnu6xj5wmNsG4pZln8HJ6OTSbhADo3zZ0DRcukHI4fxwTn0KRM1K9O20H9 swAr2CrqsFtJ+zSBRTp7jij94J2oMnfCFZ/GwppKbr+uho0ducG2l374/+py3JWiS1Go HeG7DWcLiu9L1xI/L+/RRE1D805h8T2gAqRIRqENjCypgSApo2Y78H4+pbBpdLwJdq08 6kgQ== X-Gm-Message-State: AOAM532fO+q5G2tbNLh8pvl42L4FWFwy+UYeCsI3e8QJPYryli3r2LRB nq7A+lAzOoSwo5sElszVig8= X-Google-Smtp-Source: ABdhPJzLq4qTsUepRwe72zKrmXKw3yVmfhCLVZDkxGgraWLLzl4jYz3H1vxQA8mVW398Mu9CELP63w== X-Received: by 2002:a17:906:1104:: with SMTP id h4mr8389690eja.456.1596284666483; Sat, 01 Aug 2020 05:24:26 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:26 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Chas Williams <3chas3@gmail.com> Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org Subject: [RFC PATCH 02/17] atm: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:31 +0200 Message-Id: <20200801112446.149549-3-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/atm/eni.c | 3 ++- drivers/atm/he.c | 12 +++++++---- drivers/atm/idt77252.c | 9 ++++++--- drivers/atm/iphase.c | 46 +++++++++++++++++++++++------------------- drivers/atm/lanai.c | 4 ++-- drivers/atm/nicstar.c | 3 ++- drivers/atm/zatm.c | 9 +++++---- 7 files changed, 50 insertions(+), 36 deletions(-) diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index 17d47ad03ab7..5beed8a25fa2 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c @@ -1585,7 +1585,8 @@ static char * const media_name[] = { } }) #define GET_SEPROM \ ({ if (!error && !pci_error) { \ - pci_error = pci_read_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,&tonga); \ + pci_read_config_byte(eni_dev->pci_dev, PCI_TONGA_CTRL, &tonga); \ + pci_error = (tonga == (u8)~0) ? -1 : 0; \ udelay(10); /* 10 usecs */ \ } }) diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 8af793f5e811..8727ae7746fb 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c @@ -995,7 +995,8 @@ static int he_start(struct atm_dev *dev) */ /* 4.3 pci bus controller-specific initialization */ - if (pci_read_config_dword(pci_dev, GEN_CNTL_0, &gen_cntl_0) != 0) { + pci_read_config_dword(pci_dev, GEN_CNTL_0, &gen_cntl_0); + if (gen_cntl_0 == (u32)~0) { hprintk("can't read GEN_CNTL_0\n"); return -EINVAL; } @@ -1005,7 +1006,8 @@ static int he_start(struct atm_dev *dev) return -EINVAL; } - if (pci_read_config_word(pci_dev, PCI_COMMAND, &command) != 0) { + pci_read_config_word(pci_dev, PCI_COMMAND, &command); + if (command == (u16)~0) { hprintk("can't read PCI_COMMAND.\n"); return -EINVAL; } @@ -1016,7 +1018,8 @@ static int he_start(struct atm_dev *dev) return -EINVAL; } - if (pci_read_config_byte(pci_dev, PCI_CACHE_LINE_SIZE, &cache_size)) { + pci_read_config_byte(pci_dev, PCI_CACHE_LINE_SIZE, &cache_size); + if (cache_size == (u8)~0) { hprintk("can't read cache line size?\n"); return -EINVAL; } @@ -1027,7 +1030,8 @@ static int he_start(struct atm_dev *dev) hprintk("can't set cache line size to %d\n", cache_size); } - if (pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &timer)) { + pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &timer); + if (timer == (u8)~0) { hprintk("can't read latency timer?\n"); return -EINVAL; } diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c index df51680e8931..f4b0c2ecae62 100644 --- a/drivers/atm/idt77252.c +++ b/drivers/atm/idt77252.c @@ -3271,7 +3271,8 @@ static int init_card(struct atm_dev *dev) /* Set PCI Retry-Timeout and TRDY timeout */ IPRINTK("%s: Checking PCI retries.\n", card->name); - if (pci_read_config_byte(pcidev, 0x40, &pci_byte) != 0) { + pci_read_config_byte(pcidev, 0x40, &pci_byte); + if (pci_byte == (u_char)~0) { printk("%s: can't read PCI retry timeout.\n", card->name); deinit_card(card); return -1; @@ -3287,7 +3288,8 @@ static int init_card(struct atm_dev *dev) } } IPRINTK("%s: Checking PCI TRDY.\n", card->name); - if (pci_read_config_byte(pcidev, 0x41, &pci_byte) != 0) { + pci_read_config_byte(pcidev, 0x41, &pci_byte); + if (pci_byte == (u_char)~0) { printk("%s: can't read PCI TRDY timeout.\n", card->name); deinit_card(card); return -1; @@ -3535,7 +3537,8 @@ static int idt77252_preset(struct idt77252_dev *card) XPRINTK("%s: Enable PCI master and memory access for SAR.\n", card->name); - if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { + pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command); + if (pci_command == (u16)~0) { printk("%s: can't read PCI_COMMAND.\n", card->name); deinit_card(card); return -1; diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index 8c7a996d1f16..d3f2fac3a7d1 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c @@ -2287,25 +2287,29 @@ static int get_esi(struct atm_dev *dev) return 0; } -static int reset_sar(struct atm_dev *dev) -{ - IADEV *iadev; - int i, error = 1; - unsigned int pci[64]; - - iadev = INPH_IA_DEV(dev); - for(i=0; i<64; i++) - if ((error = pci_read_config_dword(iadev->pci, - i*4, &pci[i])) != PCIBIOS_SUCCESSFUL) - return error; - writel(0, iadev->reg+IPHASE5575_EXT_RESET); - for(i=0; i<64; i++) - if ((error = pci_write_config_dword(iadev->pci, - i*4, pci[i])) != PCIBIOS_SUCCESSFUL) - return error; - udelay(5); - return 0; -} +static int reset_sar(struct atm_dev *dev) +{ + IADEV *iadev; + int i, error = 1; + unsigned int pci[64]; + + iadev = INPH_IA_DEV(dev); + for (i = 0; i < 64; i++) { + pci_read_config_dword(iadev->pci, i*4, &pci[i]); + if (pci[i] == (u32)~0) + return error; + } + + writel(0, iadev->reg+IPHASE5575_EXT_RESET); + for (i = 0; i < 64; i++) { + error = pci_write_config_dword(iadev->pci, i*4, pci[i]); + if (error != PCIBIOS_SUCCESSFUL) + return error; + } + + udelay(5); + return 0; +} static int ia_init(struct atm_dev *dev) @@ -2328,8 +2332,8 @@ static int ia_init(struct atm_dev *dev) real_base = pci_resource_start (iadev->pci, 0); iadev->irq = iadev->pci->irq; - error = pci_read_config_word(iadev->pci, PCI_COMMAND, &command); - if (error) { + pci_read_config_word(iadev->pci, PCI_COMMAND, &command); + if (command == (u16)~0) { printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%x\n", dev->number,error); return -EINVAL; diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index 645a6bc1df88..aafe1f934385 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c @@ -1097,8 +1097,8 @@ static void pcistatus_check(struct lanai_dev *lanai, int clearonly) { u16 s; int result; - result = pci_read_config_word(lanai->pci, PCI_STATUS, &s); - if (result != PCIBIOS_SUCCESSFUL) { + pci_read_config_word(lanai->pci, PCI_STATUS, &s); + if (s == (u16)~0) { printk(KERN_ERR DEV_LABEL "(itf %d): can't read PCI_STATUS: " "%d\n", lanai->number, result); return; diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 7af74fb450a0..74f49f54e024 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -399,7 +399,8 @@ static int ns_init_card(int i, struct pci_dev *pcidev) pci_set_master(pcidev); - if (pci_read_config_byte(pcidev, PCI_LATENCY_TIMER, &pci_latency) != 0) { + pci_read_config_byte(pcidev, PCI_LATENCY_TIMER, &pci_latency); + if (pci_latency == (u8)~0) { printk("nicstar%d: can't read PCI latency timer.\n", i); error = 6; ns_init_card_error(card, error); diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 57f97b95a453..8106ee20a94c 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c @@ -1112,11 +1112,11 @@ static void eprom_set(struct zatm_dev *zatm_dev, unsigned long value, static unsigned long eprom_get(struct zatm_dev *zatm_dev, unsigned short cmd) { unsigned int value; - int error; - if ((error = pci_read_config_dword(zatm_dev->pci_dev,cmd,&value))) + pci_read_config_dword(zatm_dev->pci_dev, cmd, &value); + if (value == (u64)~0) printk(KERN_ERR DEV_LABEL ": PCI read failed (0x%02x)\n", - error); + value); return value; } @@ -1197,7 +1197,8 @@ static int zatm_init(struct atm_dev *dev) pci_dev = zatm_dev->pci_dev; zatm_dev->base = pci_resource_start(pci_dev, 0); zatm_dev->irq = pci_dev->irq; - if ((error = pci_read_config_word(pci_dev,PCI_COMMAND,&command))) { + pci_read_config_word(pci_dev, PCI_COMMAND, &command); + if (command == (u16)~0) { printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n", dev->number,error); return -EINVAL; From patchwork Sat Aug 1 11:24:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696027 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F44914DD for ; Sat, 1 Aug 2020 12:25:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 878FD2080C for ; Sat, 1 Aug 2020 12:25:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z1fsyewn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729253AbgHAMZ3 (ORCPT ); Sat, 1 Aug 2020 08:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgHAMY3 (ORCPT ); Sat, 1 Aug 2020 08:24:29 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04FAAC06174A; Sat, 1 Aug 2020 05:24:29 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id o18so34004786eje.7; Sat, 01 Aug 2020 05:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Hm0xl1/zOdRxUCQdh+5jYfhueeXY+Q37DPWRkan6/c=; b=Z1fsyewnXQPs1lEotbQp/siATWa4jPRJDiJOVvbugGAkrgk71MteS23QotXjqzoO6o Djbxi2UnNQBeRQetCyJcsmj7XEkbkjEUsrBRRb6SSdxo55cJ1ZZw3oOBTdeEG+T9gawB kqNWywFCaiN15ibTWf1BBqrYlc4eZxFrmTcx+hCY6rhOR32GwDODZtJzWI8oqbxgWDev ReSpEHfAs2jsheSPy+jkWL96hPBZOWdpyEMcDEoPotp6vo8kMCyYZuAgCYRUcmJsRwj8 4++uigvxKo2XWAIiON6LohksmU20urMe65RhsLkFj4Tv65j0t+uef+LixeYj3ogSaNCl FujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0Hm0xl1/zOdRxUCQdh+5jYfhueeXY+Q37DPWRkan6/c=; b=raCIMhZ2RshNCSiW2hXwT1c/N/uJ8AChSr76HJG3zQn237f1lm/gBytUhCTf+EHK5I 9s1yJiyK/oNtaIzgOIW0oEM63m3DJrd8s1nwheGxlKTSgaTmMoeCjiUKvoQyibFyfsX/ m4AosNrprzH349i7O93RK0srRid+/hroGgeSIiCPZQrAM5782J8KUCg00IUqBfimIO9y 7K3WFtpsQizxsv6gjGgqeqVIiiCSMHLJGCqLap46OuvjfZiqNLnUsOjU5lmVGnC3Ltqg hhXCO+8WokeUIoXzwNnApv+A5S75FAZE4WtO14SSomvvLZ6AtmZkHGWuB4XbqhdjqtNY /g2A== X-Gm-Message-State: AOAM531oCoq6FCnNDI3LvV3qII3tWiNBBBhhcFgFrr2uBUC1QaTOsIzl RXyG6dhrnseL+ndo9ahmPlU= X-Google-Smtp-Source: ABdhPJyuINeMO/fLzFyuKElJkCfpuhowBNnZHWiajwgeM00jZQZtTv2sANzv6LrgYELawrptxq0bLw== X-Received: by 2002:a17:906:7743:: with SMTP id o3mr8213034ejn.224.1596284667784; Sat, 01 Aug 2020 05:24:27 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:27 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [RFC PATCH 03/17] bcma: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:32 +0200 Message-Id: <20200801112446.149549-4-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/bcma/host_pci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c index 69c10a7b7c61..912d5311a444 100644 --- a/drivers/bcma/host_pci.c +++ b/drivers/bcma/host_pci.c @@ -372,9 +372,11 @@ int bcma_host_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core, pdev = bus->host_pci; - err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp); - if (err) + pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp); + if (tmp == (u32)~0) { + err = -ENODEV; goto out; + } coremask = BIT(core->core_index) << 8; if (enable) From patchwork Sat Aug 1 11:24:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696021 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF92E14DD for ; Sat, 1 Aug 2020 12:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5E7E208A9 for ; Sat, 1 Aug 2020 12:25:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W/vkOFTf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729025AbgHAMYg (ORCPT ); Sat, 1 Aug 2020 08:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbgHAMYb (ORCPT ); Sat, 1 Aug 2020 08:24:31 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBAE2C06174A; Sat, 1 Aug 2020 05:24:30 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id df16so7781775edb.9; Sat, 01 Aug 2020 05:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ugiOTcKJH92D5ouhrmd6nUXyIp1jeLijZ9Lgi26pKL8=; b=W/vkOFTfxzqiiqs5PXjZUT+8QIuU0+pxzpIIqEsz/Iah7QiEJd93HPDsKT8TflOP/Z vkokqeDy6Dhfa07r+1amoq4UimqMupmi6vEC/Z2KKJKd/6H6AUQEmduiJ6Zw6DSLqyKa jDLhRax2V6eINcLZ1dLJJvXe2155H77nTZzGKcm96vWk2MiZMNOaCqLXan1u6UVF5zHA Xeo1r1viDJH1NZLzBOqCaLwtu+Q97vwTx3n+mdsV+zBt3JyuxPiiBVO+wC9XKKShnelj 4W8tiRi0URtcz+pixxXLjAWPDnYF8u6tA4L7FyczjlelIPysvj9ACtw2Tuc/Fqe6C5+N akag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ugiOTcKJH92D5ouhrmd6nUXyIp1jeLijZ9Lgi26pKL8=; b=W6fZss5peTu5Ka7TB16RwJ1pastYNTaGVww9EagDu84NrrDBsjtLGAqnVTSl80JP1U P+jx14x7b6BtN1I5r8Y7S5aAAmeGDPF8+lmjwAkgqNJ6H55zZ97pmw3m53MrP94CP0XA qI8uJYai5C1dnYHzSMnbbQs4zgJUjGmrdizbNOeAQNbvtTlJyoUvX7w2KbO/j7Svg7DJ b7IkWQogI83kg+zPIBEL28dO4AQNxVGF3+QkGXcr0mPTDIyy9geDX49w9JfxQCKmoHHC l5ft8/FhqNTX1yJUQq9WhfbrbY7FKoko+2W0aknzIK8Fdwx7VThR9wPpqECMocgIU+DR S1yg== X-Gm-Message-State: AOAM532VbtKejaswcCLG0+poQ2YvgFSDYZrBDwMy9u6VhbiZa79d24bS yzsPiXnbsYmbmf07SANWFtw= X-Google-Smtp-Source: ABdhPJxHTS05lKwaHfmyLAfUgz62XiabbhKbOegL6lSQtaauPJSHYiZ4vVmubnufMFIzKuHLLLAvdg== X-Received: by 2002:a50:cfc6:: with SMTP id i6mr8111480edk.88.1596284669219; Sat, 01 Aug 2020 05:24:29 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:28 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Matt Mackall , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [RFC PATCH 04/17] hwrng: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:33 +0200 Message-Id: <20200801112446.149549-5-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/char/hw_random/amd-rng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c index 9959c762da2f..e7bf17eedaa0 100644 --- a/drivers/char/hw_random/amd-rng.c +++ b/drivers/char/hw_random/amd-rng.c @@ -141,9 +141,9 @@ static int __init mod_init(void) return -ENODEV; found: - err = pci_read_config_dword(pdev, 0x58, &pmbase); - if (err) - return err; + pci_read_config_dword(pdev, 0x58, &pmbase); + if (pmbase == (u32)~0) + return -ENODEV; pmbase &= 0x0000FF00; if (pmbase == 0) From patchwork Sat Aug 1 11:24:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696019 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E553138A for ; Sat, 1 Aug 2020 12:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 668E6208B3 for ; Sat, 1 Aug 2020 12:25:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M6ZCfvut" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729028AbgHAMYg (ORCPT ); Sat, 1 Aug 2020 08:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729007AbgHAMYd (ORCPT ); Sat, 1 Aug 2020 08:24:33 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F2CC061756; Sat, 1 Aug 2020 05:24:31 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id o23so6562832ejr.1; Sat, 01 Aug 2020 05:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4KwHv6QMJMXsH8yaJc8FAm3bwHGuyv+DgGa3tEGDGbc=; b=M6ZCfvutD7TU/pOV2RNFZ9MidUceEEom3Nv3cE806feUIRVqBJG/pIaUprqT1xhcje WdFRwEFWFMhXxFz9OgdZ1Gkc2To7DRldejROIxZU6c5ReUp9u6fMtabD/bp4nvv/xOZ1 gEJrQOJUtdKdJ1QlchgC8PcfGkZLKme+Hi3QCWETI9t5oBQZyeKu/wRZdwIN4fw+6/p2 aP/w5sc4rsYwGAOX8KMKUcMaGtvOVbby2SRPvd52QpVeN1oD1/I8CIBqPGmZsXStVK34 LWU73hZRIlZwQmIZU0I3USachekVwyf51qlBk3yWeO3Owwoptvz+TI+cen849fVsnjFy 6R5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4KwHv6QMJMXsH8yaJc8FAm3bwHGuyv+DgGa3tEGDGbc=; b=YLVC4rbM2SimPmRemE6dbeQ1ES8J8pTZ5TVo9zuqQLNaUp4NChsTrOnOMF8s4ut1Ts f6fuSyp+H8WumrXW+4IhXOH0fWZnEO+EWiTDJBJqqlh6e6Zf5F8p8uCny4YZGOPmdUtB nshFafUTJYAVzlLyQ2lgxosnZVtlXBl14WINvSruWtKCcX4Pxao8hD92LTL8cXVp11bG HQB5al8vjPVxuTE57gXC5o+DEGc/yNWA4Dqy4Rk6VduqvJVYuWo4xsmeiPoSyPqq2xTp /8asu7ee8zsqbj/VJjx5iHaTeyog6zgsqWkzjaEgjD/kwcun/GQ+wC5lkYu0FgNiAujQ MSBA== X-Gm-Message-State: AOAM531PcsKvuwmUhQy5ZuZByzCBlEy0+uiaGY3N8w1qh5fmOQnQWmUA cjs6UIA+YWA8LjiJdBZ288g= X-Google-Smtp-Source: ABdhPJyP/Khv/zO4ruS71OwrBP8neVvwznKuE/Wo/7tG658TgIhiZlq1Bl/1qqyQW8Ic4CfQutik3A== X-Received: by 2002:a17:906:694b:: with SMTP id c11mr8314854ejs.232.1596284670556; Sat, 01 Aug 2020 05:24:30 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:30 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Vinod Koul , Dan Williams Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: [RFC PATCH 05/17] dmaengine: ioat: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:34 +0200 Message-Id: <20200801112446.149549-6-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/dma/ioat/dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index fd782aee02d9..e51418cf93b6 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c @@ -1016,12 +1016,12 @@ int ioat_reset_hw(struct ioatdma_chan *ioat_chan) if (ioat_dma->version < IOAT_VER_3_3) { /* clear any pending errors */ - err = pci_read_config_dword(pdev, + pci_read_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, &chanerr); - if (err) { + if (chanerr == (u32)~0) { dev_err(&pdev->dev, "channel error register unreachable\n"); - return err; + return -ENODEV; } pci_write_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, chanerr); From patchwork Sat Aug 1 11:24:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696013 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6112B722 for ; Sat, 1 Aug 2020 12:25:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44E4A22B3F for ; Sat, 1 Aug 2020 12:25:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MHC8F3xI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729032AbgHAMYh (ORCPT ); Sat, 1 Aug 2020 08:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728505AbgHAMYd (ORCPT ); Sat, 1 Aug 2020 08:24:33 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4580EC061757; Sat, 1 Aug 2020 05:24:33 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id o18so34004885eje.7; Sat, 01 Aug 2020 05:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2peFsovxGVV4gCt0Mx9sMbTzR95trvfBpVMnOvN8Fo4=; b=MHC8F3xInCE2ydGK/EnQ0azhTNezTEawS/NpL5c7th2laUuRZK+3U2vHab/2fuwyUl DNGUnNCuxH7FBodzjNvlXlNt+ZtIWkCAII9T1Mt5ZLClAw59gW8f9j3k3sKDRPXrNIyU 7nCi13fJ2aZ6sc5IsXAiUzbUm8llWjSKhTQi3L3uDX7yIQdR01cgPNzxTshbqkALdUmF hK4lkL8RnounA/F/1zp63gWlI/H1xL9U7jOVI9/kbegdO5cc7JKr1oDJ+VbmW70htio6 CjS1szO3vdyvksMtmWHmNEltLVzsLoea/8tqSWjpK0QYt2sLxAkwzyyHnUOWDZeAcs4s wsgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2peFsovxGVV4gCt0Mx9sMbTzR95trvfBpVMnOvN8Fo4=; b=cnOfZJD6z2My6QzINU+1LB2X4+U6ogOIFkPPs0rQ7ecYVw35bYHA8G1nhe9sbQZc/L pcOHZElTQJ84EhTDOL6nFc+PreXoBM0DqeYhnewsddS0bMIFON+DAQb1pdv60FPgrJtV m+18jMRxkXRBZ7WhZAEryqa/Suk/tveVbZyfemnYOhpJ1syHlPB+BsffLiGbLh//0Jxd gIprOKbiYGWmuM22gOPcZlZbvhT3G4TOTsdnAkq+ebdIrmhAKWNIbvrtuHFQ+sB5BvKx z2qgfDQdqcio+D25chKDxwlYd4yQoVMQcqFurEb7/4BqRU4oW8kPqzPHCeSbB87ZPalo 5Frg== X-Gm-Message-State: AOAM532OQgCj0AUh2dnvfMYvK2DKkwpqVYYKORykn0KHJx00iHCBwJWM dEvZi/h6PtSEQEiPGCM9A2A= X-Google-Smtp-Source: ABdhPJwF5aApjIzhTtBaMsMDyrf3A0H/Q78+5Z43GqAcnXua/uT0af+DGG/DDqkiofeX7NtIiEeB7A== X-Received: by 2002:a17:906:a219:: with SMTP id r25mr8529725ejy.201.1596284671989; Sat, 01 Aug 2020 05:24:31 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:31 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Borislav Petkov , Mauro Carvalho Chehab , Tony Luck Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, James Morse , Robert Richter , linux-edac@vger.kernel.org Subject: [RFC PATCH 06/17] edac: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:35 +0200 Message-Id: <20200801112446.149549-7-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. drivers/edac/amd8111_edac.c edac_pci_read_dword() : None of the callers of edac_pci_read_dword() uses the return value. The obtained value can be checked for validity to confirm success. Change the return type of edac_pci_read_dword() to void. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/edac/amd64_edac.c | 8 +++----- drivers/edac/amd8111_edac.c | 16 +++++----------- drivers/edac/amd8131_edac.c | 6 ++---- drivers/edac/i82443bxgx_edac.c | 3 ++- drivers/edac/sb_edac.c | 12 ++++++++---- drivers/edac/skx_common.c | 18 ++++++++++++------ 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 6262f6370c5d..f798eb17cb23 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -57,14 +57,12 @@ static const struct scrubrate { int __amd64_read_pci_cfg_dword(struct pci_dev *pdev, int offset, u32 *val, const char *func) { - int err = 0; - - err = pci_read_config_dword(pdev, offset, val); - if (err) + pci_read_config_dword(pdev, offset, val); + if (*val == (u32)~0) amd64_warn("%s: error reading F%dx%03x.\n", func, PCI_FUNC(pdev->devfn), offset); - return err; + return -ENODEV; } int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset, diff --git a/drivers/edac/amd8111_edac.c b/drivers/edac/amd8111_edac.c index 7508aa416ddb..ebf6deaf1d3d 100644 --- a/drivers/edac/amd8111_edac.c +++ b/drivers/edac/amd8111_edac.c @@ -34,24 +34,18 @@ enum amd8111_edac_pcis { }; /* Wrapper functions for accessing PCI configuration space */ -static int edac_pci_read_dword(struct pci_dev *dev, int reg, u32 *val32) +static void edac_pci_read_dword(struct pci_dev *dev, int reg, u32 *val32) { - int ret; - - ret = pci_read_config_dword(dev, reg, val32); - if (ret != 0) + pci_read_config_dword(dev, reg, val32); + if (val32 == (u32)~0) printk(KERN_ERR AMD8111_EDAC_MOD_STR " PCI Access Read Error at 0x%x\n", reg); - - return ret; } static void edac_pci_read_byte(struct pci_dev *dev, int reg, u8 *val8) { - int ret; - - ret = pci_read_config_byte(dev, reg, val8); - if (ret != 0) + pci_read_config_byte(dev, reg, val8); + if (val8 == (u8)~0) printk(KERN_ERR AMD8111_EDAC_MOD_STR " PCI Access Read Error at 0x%x\n", reg); } diff --git a/drivers/edac/amd8131_edac.c b/drivers/edac/amd8131_edac.c index 169353710982..6df98c05391d 100644 --- a/drivers/edac/amd8131_edac.c +++ b/drivers/edac/amd8131_edac.c @@ -26,10 +26,8 @@ /* Wrapper functions for accessing PCI configuration space */ static void edac_pci_read_dword(struct pci_dev *dev, int reg, u32 *val32) { - int ret; - - ret = pci_read_config_dword(dev, reg, val32); - if (ret != 0) + pci_read_config_dword(dev, reg, val32); + if (val32 == (u32)~0) printk(KERN_ERR AMD8131_EDAC_MOD_STR " PCI Access Read Error at 0x%x\n", reg); } diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c index a2ca929e2168..d6797ed7ac65 100644 --- a/drivers/edac/i82443bxgx_edac.c +++ b/drivers/edac/i82443bxgx_edac.c @@ -243,7 +243,8 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx) /* Something is really hosed if PCI config space reads from * the MC aren't working. */ - if (pci_read_config_dword(pdev, I82443BXGX_NBXCFG, &nbxcfg)) + pci_read_config_dword(pdev, I82443BXGX_NBXCFG, &nbxcfg); + if (nbxcfg == (u32)~0) return -EIO; layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c index d414698ca324..e56a06d68a4e 100644 --- a/drivers/edac/sb_edac.c +++ b/drivers/edac/sb_edac.c @@ -1697,13 +1697,15 @@ static int get_dimm_config(struct mem_ctl_info *mci) if (knl_get_dimm_capacity(pvt, knl_mc_sizes) != 0) return -1; - if (pci_read_config_dword(pvt->pci_ta, KNL_MCMTR, &pvt->info.mcmtr)) { + pci_read_config_dword(pvt->pci_ta, KNL_MCMTR, &pvt->info.mcmtr); + if (pvt->info.mcmtr == (u32)~0) { edac_dbg(0, "Failed to read KNL_MCMTR register\n"); return -ENODEV; } } else { if (pvt->info.type == HASWELL || pvt->info.type == BROADWELL) { - if (pci_read_config_dword(pvt->pci_ha, HASWELL_HASYSDEFEATURE2, ®)) { + pci_read_config_dword(pvt->pci_ha, HASWELL_HASYSDEFEATURE2, ®); + if (reg == (u32)~0) { edac_dbg(0, "Failed to read HASWELL_HASYSDEFEATURE2 register\n"); return -ENODEV; } @@ -1714,7 +1716,8 @@ static int get_dimm_config(struct mem_ctl_info *mci) goto next; } } - if (pci_read_config_dword(pvt->pci_ras, RASENABLES, ®)) { + pci_read_config_dword(pvt->pci_ras, RASENABLES, ®); + if (reg == (u32)~0) { edac_dbg(0, "Failed to read RASENABLES register\n"); return -ENODEV; } @@ -1727,7 +1730,8 @@ static int get_dimm_config(struct mem_ctl_info *mci) } next: - if (pci_read_config_dword(pvt->pci_ta, MCMTR, &pvt->info.mcmtr)) { + pci_read_config_dword(pvt->pci_ta, MCMTR, &pvt->info.mcmtr); + if (pvt->info.mcmtr == (u32)~0) { edac_dbg(0, "Failed to read MCMTR register\n"); return -ENODEV; } diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c index 6d8d6dc626bf..7956c75c289f 100644 --- a/drivers/edac/skx_common.c +++ b/drivers/edac/skx_common.c @@ -161,7 +161,8 @@ int skx_get_src_id(struct skx_dev *d, int off, u8 *id) { u32 reg; - if (pci_read_config_dword(d->util_all, off, ®)) { + pci_read_config_dword(d->util_all, off, ®); + if (reg == (u32)~0) { skx_printk(KERN_ERR, "Failed to read src id\n"); return -ENODEV; } @@ -174,7 +175,8 @@ int skx_get_node_id(struct skx_dev *d, u8 *id) { u32 reg; - if (pci_read_config_dword(d->util_all, 0xf4, ®)) { + pci_read_config_dword(d->util_all, 0xf4, ®); + if (reg == (u32)~0) { skx_printk(KERN_ERR, "Failed to read node id\n"); return -ENODEV; } @@ -220,7 +222,8 @@ int skx_get_all_bus_mappings(struct res_config *cfg, struct list_head **list) return -ENOMEM; } - if (pci_read_config_dword(pdev, cfg->busno_cfg_offset, ®)) { + pci_read_config_dword(pdev, cfg->busno_cfg_offset, ®); + if (reg == (u32)~0) { kfree(d); pci_dev_put(pdev); skx_printk(KERN_ERR, "Failed to read bus idx\n"); @@ -259,19 +262,22 @@ int skx_get_hi_lo(unsigned int did, int off[], u64 *tolm, u64 *tohm) return -ENODEV; } - if (pci_read_config_dword(pdev, off[0], ®)) { + pci_read_config_dword(pdev, off[0], ®); + if (reg == (u32)~0) { skx_printk(KERN_ERR, "Failed to read tolm\n"); goto fail; } skx_tolm = reg; - if (pci_read_config_dword(pdev, off[1], ®)) { + pci_read_config_dword(pdev, off[1], ®); + if (reg == (u32)~0) { skx_printk(KERN_ERR, "Failed to read lower tohm\n"); goto fail; } skx_tohm = reg; - if (pci_read_config_dword(pdev, off[2], ®)) { + pci_read_config_dword(pdev, off[2], ®); + if (reg == (u32)~0) { skx_printk(KERN_ERR, "Failed to read upper tohm\n"); goto fail; } From patchwork Sat Aug 1 11:24:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696029 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 059DC722 for ; Sat, 1 Aug 2020 12:25:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF1E422CAE for ; Sat, 1 Aug 2020 12:25:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P98yQ73Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbgHAMZ3 (ORCPT ); Sat, 1 Aug 2020 08:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729012AbgHAMYe (ORCPT ); Sat, 1 Aug 2020 08:24:34 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75374C06179E; Sat, 1 Aug 2020 05:24:34 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id l4so33946565ejd.13; Sat, 01 Aug 2020 05:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I8dAqn3oyLTlTqhf29Z52aIjqvD0eEwBI3IdJNmTAKE=; b=P98yQ73QpNAHyJH0DhgL+VteQsL8cJWvez4VBskT+6Zy0ViH186MuBu4nRvGYARUqd PDUMf38OLCl5PvGAT/41B7GiPvDcOBsaM4Y1R+BKMYY18/LuAuqv44mpAEG6r1fYWcfY QMKLZygpMvWntgZg8e/oF7zNlaPq9OSG4dNlG19C7ej6vNjo4PPJFjvpXAMHr399/xBl DpMbGY848f6RaiM4HfSP1a5QFTkzZ4mmVUxFUE7Gz2pAIE0+Lq9sZeuQW4ZeMeTnwEFo 1ZSzd6yuE5ADI8ephhkCQ2Wubpv7kQZm+Cihm/tzF0n0DyDFoVPmGuUYNiBglsxS6GpR f1fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I8dAqn3oyLTlTqhf29Z52aIjqvD0eEwBI3IdJNmTAKE=; b=r7xOiiXnrp1GqNkyZZUCZd041mhMXrTUzS5SRHaX3kS8TLomgPuNYX9/qNTGercbBU DK7ksOUBQjJd4gcFc855O7qi8HAAWXAiGiiwSwTh/yGY9DVa4zM58i7NR1VSPrCx8FVN K3zOf2m0OtEYso9dT5AdNX99y7Pzw2hPf/gVYCZg+J+ub7L/WwO0RLsi8gE8SERgoQlX vo7bx9j7BO15t+dEF9Ry257Kghtvn0aZ1Dc1yhDOvyRmpEhFbcOELeO1La94lXVaaCv5 n6uN1CKTPsW997QrlUO/bXQ0ed+CFqknnwiGh0IwYVPVlaD0GwoXxjX+d4ACIVr50/MZ yUYQ== X-Gm-Message-State: AOAM532ElYbnRbZaFLQcLaL+CKuBEutbB4eGTpn+m0E8g+poqmAnnKMD j63gSkDqLNa6W5wqwm797BM= X-Google-Smtp-Source: ABdhPJyaQUgDgaB0qqpXNRYm/8ED4kbE0a2gf50gNexDXYKCzC2jeZw2r4pLhpg9owqfBDJdG1DmpA== X-Received: by 2002:a17:906:6a5b:: with SMTP id n27mr8123629ejs.221.1596284673233; Sat, 01 Aug 2020 05:24:33 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:32 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Moritz Fischer Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [RFC PATCH 07/17] fpga: altera-cvp: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:36 +0200 Message-Id: <20200801112446.149549-8-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/fpga/altera-cvp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 4e0edb60bfba..99c6e0754f8b 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -96,15 +96,15 @@ struct cvp_priv { static int altera_read_config_byte(struct altera_cvp_conf *conf, int where, u8 *val) { - return pci_read_config_byte(conf->pci_dev, conf->vsec_offset + where, - val); + pci_read_config_byte(conf->pci_dev, conf->vsec_offset + where, val); + return (val == (u8)~0) ? -ENODEV : 0; } static int altera_read_config_dword(struct altera_cvp_conf *conf, int where, u32 *val) { - return pci_read_config_dword(conf->pci_dev, conf->vsec_offset + where, - val); + pci_read_config_dword(conf->pci_dev, conf->vsec_offset + where, val); + return (val == (u32)~0) ? -ENODEV : 0; } static int altera_write_config_dword(struct altera_cvp_conf *conf, From patchwork Sat Aug 1 11:24:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696023 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6CCB722 for ; Sat, 1 Aug 2020 12:25:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D5DE2080C for ; Sat, 1 Aug 2020 12:25:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WMcFJpRf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729233AbgHAMZX (ORCPT ); Sat, 1 Aug 2020 08:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbgHAMYg (ORCPT ); Sat, 1 Aug 2020 08:24:36 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BF5C06174A; Sat, 1 Aug 2020 05:24:35 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id a21so34005317ejj.10; Sat, 01 Aug 2020 05:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=epPKirRj4kip4paapWF+wmIvk6STec5g/eZ1qAPHqnE=; b=WMcFJpRf/lOxCS+UFtLRYapRWoI4RITRNpKoH0WYIEdRtQzRhdoJM2m+oowu10XQVF b5yyHM+bxdKOZwzUyFNMeVE0Y6pD916gDf+ubV+SJLsjKZhZKbMi6/41b1IZQfC0gX4z iHWbsPoAMIAr7CmBfOVmZA3Mm8zN9YJXKSe43HPcEzI+TBnGB3uESwep6+cCCJLvdYQO k3Pq9Rp6gCCZqAq8yzQ1WmyM1fXSxNSUSIlGAg+LcnL+b+VgXM3bpxQijNN2G4f+VA1Y TGPNWlVCuRTIuCWVZ/ljxMkjt8i7dsBo+m9iPBIADCaJcBBBwjV4T7Eult2TR9cZ8wZk Lyaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=epPKirRj4kip4paapWF+wmIvk6STec5g/eZ1qAPHqnE=; b=rVN7kHxIFajJ8FN/MUj4619uJgY90wtbZrnjIlwc12Xt1dWZ90r+RaumgAMqhmwBjC qzBX84h2LS4BJpPNVnXehzHi/qgugPhUTZ7WpOusVOVcIQ0zOLJukxMbPQl38RobjOau RL167NCXI/PwiSo5DY30VZ4qTsjOtmu2v+nm/PAE0Bz9g8QuGoF5rB0s6oWZCPG002Go vQwzfEblyUhrfglHsyWbnw3kwKXosOGIVj94CkpLQYcvq/Y7HL9YBduC7e3hBKsMDACm J7v+QhyHQir6Ei4Gi9L5JM54tw4qMwaJUEaGta3mv/bdLlMr4fojQ9Dg8KkdCd+oS3Fi RbjQ== X-Gm-Message-State: AOAM533BRfOutsSwl7R8tIjRTpaOGZF19729hEOQtxc1HJ+xMow75WvF SSo2zO8VZVj0HBG0pXsIgmV7cbgXDxNM1g== X-Google-Smtp-Source: ABdhPJwuExwGM+Muatp1WuT205GPGAkYdwooFfx/4UjM/AxNCA9IZ5/VWUebqtI+PF1sFL/q0k+PDA== X-Received: by 2002:a17:906:7f0b:: with SMTP id d11mr8932095ejr.116.1596284674567; Sat, 01 Aug 2020 05:24:34 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:34 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Bartosz Golaszewski , Linus Walleij Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [RFC PATCH 08/17] gpio: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:37 +0200 Message-Id: <20200801112446.149549-9-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/gpio/gpio-amd8111.c | 7 +++++-- drivers/gpio/gpio-rdc321x.c | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index fdcebe59510d..7b9882380cbc 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c @@ -198,9 +198,12 @@ static int __init amd_gpio_init(void) goto out; found: - err = pci_read_config_dword(pdev, 0x58, &gp.pmbase); - if (err) + pci_read_config_dword(pdev, 0x58, &gp.pmbase); + if (gp.pmbase == (u32)~0) { + err = -ENODEV; goto out; + } + err = -EIO; gp.pmbase &= 0x0000FF00; if (gp.pmbase == 0) diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c index 01ed2517e9fd..03f1ff07b844 100644 --- a/drivers/gpio/gpio-rdc321x.c +++ b/drivers/gpio/gpio-rdc321x.c @@ -85,10 +85,13 @@ static int rdc_gpio_config(struct gpio_chip *chip, gpch = gpiochip_get_data(chip); spin_lock(&gpch->lock); - err = pci_read_config_dword(gpch->sb_pdev, gpio < 32 ? - gpch->reg1_ctrl_base : gpch->reg2_ctrl_base, ®); - if (err) + pci_read_config_dword(gpch->sb_pdev, + (gpio < 32) ? gpch->reg1_ctrl_base + : gpch->reg2_ctrl_base, ®); + if (reg == (u32)~0) { + err = -ENODEV; goto unlock; + } reg |= 1 << (gpio & 0x1f); @@ -166,17 +169,17 @@ static int rdc321x_gpio_probe(struct platform_device *pdev) /* This might not be, what others (BIOS, bootloader, etc.) wrote to these registers before, but it's a good guess. Still better than just using 0xffffffff. */ - err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev, + pci_read_config_dword(rdc321x_gpio_dev->sb_pdev, rdc321x_gpio_dev->reg1_data_base, &rdc321x_gpio_dev->data_reg[0]); - if (err) - return err; + if (rdc321x_gpio_dev->data_reg[0] == (u32)~0) + return -ENODEV; - err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev, + pci_read_config_dword(rdc321x_gpio_dev->sb_pdev, rdc321x_gpio_dev->reg2_data_base, &rdc321x_gpio_dev->data_reg[1]); - if (err) - return err; + if (rdc321x_gpio_dev->data_reg[1] == (u32)~0) + return -ENODEV; dev_info(&pdev->dev, "registering %d GPIOs\n", rdc321x_gpio_dev->chip.ngpio); From patchwork Sat Aug 1 11:24:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696015 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7910B722 for ; Sat, 1 Aug 2020 12:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 609862080C for ; Sat, 1 Aug 2020 12:25:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MxXS7aXG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729043AbgHAMZS (ORCPT ); Sat, 1 Aug 2020 08:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbgHAMYh (ORCPT ); Sat, 1 Aug 2020 08:24:37 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3826BC06174A; Sat, 1 Aug 2020 05:24:37 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id bs17so5368392edb.1; Sat, 01 Aug 2020 05:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mTab8JNvsgo4CL+J2E65GCxL4zVDcvJICP1+e2MGiww=; b=MxXS7aXGg49OI8aq1o2JxQSacx3GEkx7XRc4h3ldURK6zBJgpz5BCs4TCQi9vzW8bw 6N5rmJ/Bc2EsNZmNEy95m4VrSdD6S36XHIE0bXDvbmHdvv8Ihd/DN3YqOot8+XNsBn4K uH6Ip0XLj/CLkS7OQbIMeU5cG1JmDbAF6R4dkjrmVllWjiJc6lq/K7WJN3y20CFnB+Zq Veh4WXw6cFj5wfDJzSErjSaJ/GQ1p/YmseYNttpG96RLDnixkmg9o75N4xiBxD0qqPsJ 1iL8Qj7buxqLPP29VEWOUOsDSz4OPW5lGkFWyKdBy9bfKl3Yd4OWQ3uoiFlz2n2kpCGD NGZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mTab8JNvsgo4CL+J2E65GCxL4zVDcvJICP1+e2MGiww=; b=pa8PyqiRXCleEs8MJbgKvUwLyhtbQQKu/3LxyfJE9G9tvCw/rM1DitlyNwNeLnHt/q mmjTUBnfiX5t3aWU6JVhZ03SdIITbjognEdB0rCuU/FsMt+ICDIx71iz2SLMKwYgTzqG kij8iQ4YfXDa7vKTxTANaUB1UrcdFtKuqPtFPIQ3NuBCRWj9mMVLS9NXH7+V7WFQQ0i8 mRFm5ViuF3ydIDiD5m9asVBX4TwZdqLLg90Eo+2Cbb3PuaffIRRkK7RYiWy1JAZa5iPP ZZOdBvCHUMCzn7YVxpsH5iedrviT+WwT5cPQvNqM8BpVM9C7twVKJN6ndStIcxdddgi7 kYdA== X-Gm-Message-State: AOAM533934lHCn1H2Qf5XdkoTyeyge9gkiIKcjj5cb0YC18dmILmUg9y oTOQh/LUlPLi37H6hXaYj8Q= X-Google-Smtp-Source: ABdhPJyNuqCc/8r6/A/7Q7T/LnVDBWUQ9SzPEt/TNIqjoVA3EMIMDnSI53A+QOmplMa8tW5cITLjzA== X-Received: by 2002:aa7:d5d0:: with SMTP id d16mr7805559eds.212.1596284675988; Sat, 01 Aug 2020 05:24:35 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:35 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, David Airlie , Daniel Vetter Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [RFC PATCH 09/17] drm/i915/vga: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:38 +0200 Message-Id: <20200801112446.149549-10-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/gpu/drm/i915/display/intel_vga.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c index be333699c515..6f9406699c9d 100644 --- a/drivers/gpu/drm/i915/display/intel_vga.c +++ b/drivers/gpu/drm/i915/display/intel_vga.c @@ -99,7 +99,8 @@ intel_vga_set_state(struct drm_i915_private *i915, bool enable_decode) unsigned int reg = INTEL_GEN(i915) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL; u16 gmch_ctrl; - if (pci_read_config_word(i915->bridge_dev, reg, &gmch_ctrl)) { + pci_read_config_word(i915->bridge_dev, reg, &gmch_ctrl); + if (gmch_ctrl == (u16)~0) { drm_err(&i915->drm, "failed to read control word\n"); return -EIO; } From patchwork Sat Aug 1 11:24:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696011 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B795F14DD for ; Sat, 1 Aug 2020 12:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A007721744 for ; Sat, 1 Aug 2020 12:25:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iYcYgSrZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728505AbgHAMZO (ORCPT ); Sat, 1 Aug 2020 08:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729043AbgHAMYi (ORCPT ); Sat, 1 Aug 2020 08:24:38 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 865C7C06174A; Sat, 1 Aug 2020 05:24:38 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id c2so18272473edx.8; Sat, 01 Aug 2020 05:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bdwFdqR8uTJkBxeLE6+6M0ZT6V7Ev5F6Fk3j55l8Z9k=; b=iYcYgSrZmWlo3R6AUjHZkTUqWlOCuvWQfp9o/jYHquATEwsySoI7qb/5R298C4XuP6 41LiSJR2F+wAaeJbMOPDCVFPHsL0+Fo4vxG7q9em4PQJboP6PNqu/EZa36fMsM/zZbBz JCHW/o6zUF9a2HzOkDNo+9vZ2c5PCBRDQeUpdDN2BOT+MMhqCt4g8i2V0lS4IiBQw05V he5n2kloQO33fgxJyOaPrLYN0f7EOtJSixf210mNPyBCU5yXE9oEPpuWtwkow02lziQ5 AygMJ24A5io1qUJTTJ+itzp+4YiuCii7XbUXLOjJXwTJ52oP7dmycNBHJfJeLprStDPf kBJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bdwFdqR8uTJkBxeLE6+6M0ZT6V7Ev5F6Fk3j55l8Z9k=; b=KrafF9SmbGjuxxq3QxgHGbOCL5EmkaHdjHj6jgJnrzUm2qRWpBoAiM6RBohiT+4VLS WL+diT2bZyw0e98zwMy+5pAOaizCtRJyo23fKLMGVtsC/HagT/re9IRZbA4m/24REg7R zcH8vBY6kFfFK5rdnMG2HEwALs/nl4wPozQVrkwQpOlzCrA+m+qCu8JBIg3clQfLxvfG UPvHDeZ5lKanJhYVBz164790R0oMabsObbouCL142l0pO3WTncUMRSJwNccySZNrdUay j56fbf6QqrkKOjuUQFXc5nA6ZravwdLN4ee9R3x1jeNK40Ub/5jExVXFqY0iyjaQFSL9 f8Bg== X-Gm-Message-State: AOAM531ql9NwKa4bBaCWZA6N05ppjS7ovsKDTCStcaje6mF1+kTmdMaX Yg+n+fk6oLoedpxQUx8NlvJCcsMW4VmPrQ== X-Google-Smtp-Source: ABdhPJwD7rV3Z2sHm2Urux9ibnAQJLnjp5J8GSKRJQtu26ivkTzM9jU1IBe5MLhlZErz7vNjd6oCBw== X-Received: by 2002:aa7:da0e:: with SMTP id r14mr8200605eds.236.1596284677325; Sat, 01 Aug 2020 05:24:37 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:36 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Jean Delvare , Guenter Roeck Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org Subject: [RFC PATCH 10/17] hwmon: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:39 +0200 Message-Id: <20200801112446.149549-11-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/hwmon/i5k_amb.c | 12 ++++++++---- drivers/hwmon/vt8231.c | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index eeac4b04df27..b7497510323c 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c @@ -427,11 +427,13 @@ static int i5k_find_amb_registers(struct i5k_amb_data *data, if (!pcidev) return -ENODEV; - if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32)) + pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32); + if (val32 == (u32)~0) goto out; data->amb_base = val32; - if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32)) + pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32); + if (val32 == (u32)~0) goto out; data->amb_len = val32; @@ -458,11 +460,13 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id) if (!pcidev) return -ENODEV; - if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16)) + pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16); + if (val16 == (u16)~0) goto out; amb_present[0] = val16; - if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16)) + pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16); + if (val16 == (u16)~0) goto out; amb_present[1] = val16; diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 2335d440f72d..6603727e15a0 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -992,8 +992,8 @@ static int vt8231_pci_probe(struct pci_dev *dev, return -ENODEV; } - if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_BASE_REG, - &val)) + pci_read_config_word(dev, VT8231_BASE_REG, &val); + if (val == (u16)~0) return -ENODEV; address = val & ~(VT8231_EXTENT - 1); @@ -1002,8 +1002,8 @@ static int vt8231_pci_probe(struct pci_dev *dev, return -ENODEV; } - if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_ENABLE_REG, - &val)) + pci_read_config_word(dev, VT8231_ENABLE_REG, &val); + if (val == (u16)~0) return -ENODEV; if (!(val & 0x0001)) { From patchwork Sat Aug 1 11:24:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11695993 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A63EE14DD for ; Sat, 1 Aug 2020 12:24:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D13F2076A for ; Sat, 1 Aug 2020 12:24:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tE/fjtx1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729089AbgHAMYo (ORCPT ); Sat, 1 Aug 2020 08:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbgHAMYk (ORCPT ); Sat, 1 Aug 2020 08:24:40 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7550C06174A; Sat, 1 Aug 2020 05:24:39 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id w9so33998813ejc.8; Sat, 01 Aug 2020 05:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Ef8IUcnocHoCROk98NuQIVshhmZka7ZCelapJAaYyI=; b=tE/fjtx1OYaqRRakblDmsU7Cnv83ftTXHcpBU2sObAMVsHdeeD511d9uE4CQXW/ML4 9ou6kcbOTCYlmoJ0BO9fpP7W3JJjmWv949Gl3o20KOci/t0eNHJAqYZ2Gxk5TopcRyvh XLrXHaTzRgX1modYGbrCQebf06ionlzqNcQDrvnR7iTys9rnsAiAjUDK29lVQ0B44zV/ xLk1t7R97tRvTLpCRVbiLlyZiSK49nLlimS8r/LHu8RKfg7euo0rzECAOimgYpZk2+B7 QVbgypX/3v6luzZE15+a7OoNY9AhGTRacKHp3DnL+ZdWO2O7gG/HZVrRUPIAMzfjSFbQ 0qyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3Ef8IUcnocHoCROk98NuQIVshhmZka7ZCelapJAaYyI=; b=KYLkXIOW9XRGxhlotqORzUbqGxgbpsvzNo/nkZTsHzCSRYScNE6xFdp1yD1CsuhVYT TC7Kq2ZDyq5hftR0lXejs7VMXwV2qfBGscTMsoSFrt4rKOIUNSl+adM6ozOJmLNINnEm YmEm09NkV7mwJEWTcPBgMT6mtcv0AnnWC86SqpR2chHMhwMpbA4DcLHrzAnHmUX4ByMw b1fPi6poq3vJDG8013ogK2/JwYj09b2ww3x4s7dCv1DVgxmZKn3juXi9cFffICRIFCfr Mqy0OSpz9Sma+p8eN/GLxfnvox2WzRYOsh0ymW7tNZHm3Syws8f2M8sm56IXz9/jwd4Q cKig== X-Gm-Message-State: AOAM532tnMT0jGUI8VgZN1sBl4PM0gnaeCZjKX6nos9GuPMG4DwuF8hH s8FB3OimGL/zfGM6Too1W1U= X-Google-Smtp-Source: ABdhPJz01/oRMdN4kVKWwAkYQUYeZyQfsFmTxzv+VPQbHpGFpIXoIwXAq4Azmv82DQf/ASMIkfxYUw== X-Received: by 2002:a17:906:eb90:: with SMTP id mh16mr8170598ejb.10.1596284678498; Sat, 01 Aug 2020 05:24:38 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:38 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Alexander Shishkin Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 11/17] intel_th: pci: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:40 +0200 Message-Id: <20200801112446.149549-12-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/hwtracing/intel_th/pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c index 21fdf0b93516..176c9088038e 100644 --- a/drivers/hwtracing/intel_th/pci.c +++ b/drivers/hwtracing/intel_th/pci.c @@ -32,13 +32,13 @@ static int intel_th_pci_activate(struct intel_th *th) { struct pci_dev *pdev = to_pci_dev(th->dev); u32 npkdsc; - int err; + int err = -ENODEV; if (!INTEL_TH_CAP(th, tscu_enable)) return 0; - err = pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); - if (!err) { + pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); + if (npkdsc != (u32)~0) { npkdsc |= NPKDSC_TSACT; err = pci_write_config_dword(pdev, PCI_REG_NPKDSC, npkdsc); } @@ -53,13 +53,13 @@ static void intel_th_pci_deactivate(struct intel_th *th) { struct pci_dev *pdev = to_pci_dev(th->dev); u32 npkdsc; - int err; + int err = -ENODEV; if (!INTEL_TH_CAP(th, tscu_enable)) return; - err = pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); - if (!err) { + pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); + if (npkdsc != (u32)~0) { npkdsc |= NPKDSC_TSACT; err = pci_write_config_dword(pdev, PCI_REG_NPKDSC, npkdsc); } From patchwork Sat Aug 1 11:24:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11695991 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85949138A for ; Sat, 1 Aug 2020 12:24:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67B7F2076A for ; Sat, 1 Aug 2020 12:24:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lxoAru1R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729095AbgHAMYp (ORCPT ); Sat, 1 Aug 2020 08:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729079AbgHAMYl (ORCPT ); Sat, 1 Aug 2020 08:24:41 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED97C061756; Sat, 1 Aug 2020 05:24:41 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id o18so34005098eje.7; Sat, 01 Aug 2020 05:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UPMKmQkw5j2Bh/Rizmhe2Km1hW9ddbiX+OSz6ICfDL0=; b=lxoAru1R5QoARIY5Zj8IRtaCQjydTdcDfATP28B1jbs7FRLq31y9L/U2SR0zijpXrz bwjdGdwpBCY+OL8xy3+j8KOYTQ4iuc9pQ7t1ryeXThG/akFvuU5yTDz4bKRppe3UTI6S mVk1U19Sq1sZ5/BFGKbeETK7mgjUoVVrEja3FLOzJB39cha7M1+zv2654sn/ZVjvDKjF 4pB4sPSLkEAGsjJ7lx/0i9X+FEoPJHHs30BL/XHuibQBDEMQsaMLSnn6J0s4EQ/nuUuK JbxLd+JXACbythRSYj8Fo862E0AsZbbp92RxcFiBidmKNrCL1IdKeKAKnnBLqOIqjvx8 HRCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UPMKmQkw5j2Bh/Rizmhe2Km1hW9ddbiX+OSz6ICfDL0=; b=N9qcFM7oNv9apn3wRRO/t6e2dz+XudRblBdBfkn8OV83RzEiIuZYbcr9NooGHzDpL1 Av7uZZocpW6D8H9LURX/HjPJGSs7w8mCcrM4Y4a5l8lh7p5NXCd9XGX7ts58ubhvctGz USS+VR7CrjtUu/MpjBE1lrLaspSNhKL2V2DnFqBA35Jj3JEYbrDUdn57s2ZZAMVD4OAj 1Qdwb3brbtbbquWmpx3KrTZs9sQ9JsXIdvL1263Xe9hyF+q6x0xc5oHFcdE8OV1AP/Ch OlXU7hZeS2qyyGq3yAOUXnBJdC2gDdAqXqImt0yyIhz6R3uNMJ+fH21epEAKuSUGLELk l6RQ== X-Gm-Message-State: AOAM533TO+vaJVBbTmTJY1YE882WUJMd8ssZg1DFVnffFrBCELIhASnP Rn1KG3FzKQ1ApzmsemXWXLT75nW7/vN+tQ== X-Google-Smtp-Source: ABdhPJyCxIUjb+mwT7ePMCbvB9sb/Y2iHevdo/OKsCbDfX1QEQPPASWDc4dVgABKN92MfYabQCbrqA== X-Received: by 2002:a17:906:bce9:: with SMTP id op9mr8659385ejb.462.1596284679790; Sat, 01 Aug 2020 05:24:39 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:39 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Wolfram Sang Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH 12/17] i2c: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:41 +0200 Message-Id: <20200801112446.149549-13-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/i2c/busses/i2c-ali15x3.c | 6 ++++-- drivers/i2c/busses/i2c-elektor.c | 3 ++- drivers/i2c/busses/i2c-nforce2.c | 4 ++-- drivers/i2c/busses/i2c-sis5595.c | 17 +++++++++++------ drivers/i2c/busses/i2c-sis630.c | 7 ++++--- drivers/i2c/busses/i2c-viapro.c | 11 ++++++----- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 02185a1cfa77..fa103131746d 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -171,9 +171,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev) SMBBA, ali15x3_smba)) goto error; - if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev, - SMBBA, &a)) + + pci_read_config_word(ALI15X3_dev, SMBBA, &a); + if (a == (u16)~0) goto error; + if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { /* make sure it works */ dev_err(&ALI15X3_dev->dev, diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 140426db28df..82c8d6d55561 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c @@ -207,7 +207,8 @@ static int elektor_match(struct device *dev, unsigned int id) if (cy693_dev) { unsigned char config; /* yeap, we've found cypress, let's check config */ - if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { + pci_read_config_byte(cy693_dev, 0x47, &config); + if (config != (u8)~0) { dev_dbg(dev, "found cy82c693, config " "register 0x47 = 0x%02x\n", config); diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 777278386f58..dc5d032c5a1d 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -327,8 +327,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg, /* Older incarnations of the device used non-standard BARs */ u16 iobase; - if (pci_read_config_word(dev, alt_reg, &iobase) - != PCIBIOS_SUCCESSFUL) { + pci_read_config_word(dev, alt_reg, &iobase); + if (iobase == (u16)~0) { dev_err(&dev->dev, "Error reading PCI config for %s\n", name); return -EIO; diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index c793a5c14cda..9b3fbde9cd9c 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c @@ -178,9 +178,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) if (pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base) != PCIBIOS_SUCCESSFUL) goto error; - if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a) - != PCIBIOS_SUCCESSFUL) + + pci_read_config_word(SIS5595_dev, ACPI_BASE, &a); + if (a == (u16)~0) goto error; + if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) { /* doesn't work for some chips! */ dev_err(&SIS5595_dev->dev, "force address failed - not supported?\n"); @@ -188,17 +190,20 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) } } - if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val) - != PCIBIOS_SUCCESSFUL) + pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val); + if (val == (u8)~0) goto error; + if ((val & 0x80) == 0) { dev_info(&SIS5595_dev->dev, "enabling ACPI\n"); if (pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80) != PCIBIOS_SUCCESSFUL) goto error; - if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val) - != PCIBIOS_SUCCESSFUL) + + pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val); + if (val == (u8)~0) goto error; + if ((val & 0x80) == 0) { /* doesn't work for some chips? */ dev_err(&SIS5595_dev->dev, "ACPI enable failed - not supported?\n"); diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index cfb8e04a2a83..73b17436f964 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c @@ -430,7 +430,8 @@ static int sis630_setup(struct pci_dev *sis630_dev) Enable ACPI first , so we can accsess reg 74-75 in acpi io space and read acpi base addr */ - if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, &b)) { + pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, &b); + if (b == (u8)~0) { dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n"); retval = -ENODEV; goto exit; @@ -444,8 +445,8 @@ static int sis630_setup(struct pci_dev *sis630_dev) } /* Determine the ACPI base address */ - if (pci_read_config_word(sis630_dev, - SIS630_ACPI_BASE_REG, &acpi_base)) { + pci_read_config_word(sis630_dev, SIS630_ACPI_BASE_REG, &acpi_base); + if (acpi_base == (u16)~0) { dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n"); retval = -ENODEV; diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 4abc7771af06..14bfa5401845 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -321,12 +321,13 @@ static int vt596_probe(struct pci_dev *pdev, goto found; } - if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || - !(vt596_smba & 0x0001)) { + pci_read_config_word(pdev, id->driver_data, &vt596_smba); + if ((vt596_smba == (u16)~0) || !(vt596_smba & 0x0001)) { /* try 2nd address and config reg. for 596 */ - if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && - !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && - (vt596_smba & 0x0001)) { + pci_read_config_word(pdev, SMBBA2, &vt596_smba); + if ((id->device == PCI_DEVICE_ID_VIA_82C596_3) && + (vt596_smba != (u16)~0) && + (vt596_smba & 0x0001)) { SMBHSTCFG = 0x84; } else { /* no matches at all */ From patchwork Sat Aug 1 11:24:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696001 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D61C138A for ; Sat, 1 Aug 2020 12:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 507152245C for ; Sat, 1 Aug 2020 12:25:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ncnCAE+5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729099AbgHAMYp (ORCPT ); Sat, 1 Aug 2020 08:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbgHAMYm (ORCPT ); Sat, 1 Aug 2020 08:24:42 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75837C061757; Sat, 1 Aug 2020 05:24:42 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id bo3so11390591ejb.11; Sat, 01 Aug 2020 05:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f7EHkSWbrjhplB2d+YIJIh5vLQH5GmykUiEqLTIStB4=; b=ncnCAE+5L7BB5/YjIaWKdov1rz6HP5TvXA9nZA3PXndUUW1xK5+ufbrRdCYCwHcqHm t1EMuhi4tuEBdBJ5YsN9BB5sxWFTI0+q//E8z9o5Ck0ZyU+V5BrrZ5nZXdtol4sWPkxZ b9MIFjQEbPFh3ySpTdLCOFWSkzspCjS2kD4irjY0YxXuW38z5ndkVpebr288Yek4HTE7 +2vr3ZHRUJaZVRsq+jCq8P6pvvPOtSBdlH0LEq1DjZSQP5YlhLmDT7iewerLkZWaqc/g VR8PYab69Ni5ovDIAYK7FvMde3VGmx+R28fsxL9Zyq9QmFLaLLeo+1pPbnbJL/G3y8oR c/IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f7EHkSWbrjhplB2d+YIJIh5vLQH5GmykUiEqLTIStB4=; b=Bhcu03CrvCaJhpZJX2C9eo2m2HsoOPftZ8cNgV+Fpwzv9tOYt2Lzi0CQJbhEnNsJWB mQn+d4uy3gJpjwI3gnqRiCkvH4Sxd1F86PvRUy9PtXUtxlYXMMWic9/ovyNXAXfAFoA+ zneJIJCCt3/iT6OL4RBFM43GL9CLgFQ7BzHBAQVS0Q8fH62lVCpofXQQJI/ZNirhZu3G uhKsLjuz5cGZ3NfarXidsdCrI9oWLnSdfjgk3VoytxVYGBGIUiB+HI3FD/YrjkwDgqRz Upa+A1kCJS28fXBakfA1n3HjwICaA6S4UEQcfvTV2cDSmwvZV3nCjn1YuwRjWenOG0jW QYbA== X-Gm-Message-State: AOAM531PtDbv4Hr3UCV4hSRBN4RQ1xhyaKmBGXFdg76c0H+8JBoFaP6u GJK+ARPilP/Ut1874jMXHaI= X-Google-Smtp-Source: ABdhPJxK6QsCLubg/13FQ7axRtOuPxj8lfRiykbHYiquSlkMilSMcUUDzaC4VkaClUghhqDZwK4BZw== X-Received: by 2002:a17:906:c002:: with SMTP id e2mr8812396ejz.244.1596284681233; Sat, 01 Aug 2020 05:24:41 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:40 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, "David S. Miller" Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org Subject: [RFC PATCH 13/17] ide: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:42 +0200 Message-Id: <20200801112446.149549-14-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. drivers/ide/cs5536.c cs5536_read() : None of the callers of cs5536_read() uses the return value. The obtained value can be checked for validity to confirm success. Change the return type of cs5536_read() to void. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/ide/cs5536.c | 6 +++--- drivers/ide/rz1000.c | 3 ++- drivers/ide/setup-pci.c | 26 ++++++++++++++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c index 8b5ca145191b..58d1cf37c013 100644 --- a/drivers/ide/cs5536.c +++ b/drivers/ide/cs5536.c @@ -55,16 +55,16 @@ enum { static int use_msr; -static int cs5536_read(struct pci_dev *pdev, int reg, u32 *val) +static void cs5536_read(struct pci_dev *pdev, int reg, u32 *val) { if (unlikely(use_msr)) { u32 dummy; rdmsr(MSR_IDE_CFG + reg, *val, dummy); - return 0; + return; } - return pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); + pci_read_config_dword(pdev, PCI_IDE_CFG + reg * 4, val); } static int cs5536_write(struct pci_dev *pdev, int reg, int val) diff --git a/drivers/ide/rz1000.c b/drivers/ide/rz1000.c index fce2b7de5a19..19ac4328e707 100644 --- a/drivers/ide/rz1000.c +++ b/drivers/ide/rz1000.c @@ -27,7 +27,8 @@ static int rz1000_disable_readahead(struct pci_dev *dev) { u16 reg; - if (!pci_read_config_word (dev, 0x40, ®) && + pci_read_config_word(dev, 0x40, ®); + if ((reg != (u16)~0) && !pci_write_config_word(dev, 0x40, reg & 0xdfff)) { printk(KERN_INFO "%s: disabled chipset read-ahead " "(buggy RZ1000/RZ1001)\n", pci_name(dev)); diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index fdc8e813170c..a7b93ccd55d1 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -37,7 +37,8 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name) /* * Place both IDE interfaces into PCI "native" mode: */ - if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || + pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); + if ((progif == (u8)~0) || (progif & 5) != 5) { if ((progif & 0xa) != 0xa) { printk(KERN_INFO "%s %s: device not capable of full " @@ -47,7 +48,8 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name) printk(KERN_INFO "%s %s: placing both ports into native PCI " "mode\n", name, pci_name(dev)); (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); - if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || + pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); + if ((progif == (u8)~0) || (progif & 5) != 5) { printk(KERN_ERR "%s %s: rewrite of PROGIF failed, " "wanted 0x%04x, got 0x%04x\n", @@ -251,7 +253,8 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) d->name, pci_name(dev)); return -ENODEV; } - if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { + pci_read_config_word(dev, PCI_COMMAND, &pcicmd); + if (pcicmd == (u16)~0) { printk(KERN_ERR "%s %s: error accessing PCI regs\n", d->name, pci_name(dev)); return -EIO; @@ -415,8 +418,8 @@ static int ide_setup_pci_controller(struct pci_dev *dev, int bars, if (ret < 0) goto out; - ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd); - if (ret < 0) { + pci_read_config_word(dev, PCI_COMMAND, &pcicmd); + if (pcicmd == (u16)~0) { printk(KERN_ERR "%s %s: error accessing PCI regs\n", d->name, pci_name(dev)); goto out_free_bars; @@ -466,11 +469,14 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, for (port = 0; port < channels; ++port) { const struct ide_pci_enablebit *e = &d->enablebits[port]; - if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || - (tmp & e->mask) != e->val)) { - printk(KERN_INFO "%s %s: IDE port disabled\n", - d->name, pci_name(dev)); - continue; /* port not enabled */ + if (e->reg) { + pci_read_config_byte(dev, e->reg, &tmp); + + if ((tmp == (u8)~0) || ((tmp & e->mask) != e->val)) { + printk(KERN_INFO "%s %s: IDE port disabled\n", + d->name, pci_name(dev)); + continue; /* port not enabled */ + } } if (ide_hw_configure(dev, d, port, hw + port)) From patchwork Sat Aug 1 11:24:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696005 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FB15138A for ; Sat, 1 Aug 2020 12:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E531E21744 for ; Sat, 1 Aug 2020 12:25:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TPXE0MeF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbgHAMZJ (ORCPT ); Sat, 1 Aug 2020 08:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728505AbgHAMYo (ORCPT ); Sat, 1 Aug 2020 08:24:44 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA247C06179E; Sat, 1 Aug 2020 05:24:43 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id c16so13635623ejx.12; Sat, 01 Aug 2020 05:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SrhDN2Qf8+lE/P1EU/TJXEXFld12zPt7dPQFf412LUk=; b=TPXE0MeFmNEeYfTarS0h6lEu6T0txCu1b9KgvIqoPjxSgbUjX4ba/CalHwh+XNV9EE zlXi4oKFUnZZ5zVHu3WsUdEEvPp6L05on/HWX3VkVM77SKuj2FlpD86dH5NZ0QEzjtTg K6Nhr9ENw+lKNFgRQijLjk+mW5c0pk5ZeQxpTHze7A4BQdrPzxltjjv/Vjb6Z0Aox8Ed VEDJwMbimBqhxR0PWwCryl7i42bAF/Lj23OoFongQc7qaNfxcZ19cdJVnPclf3scGhyn SuPxs1q4uD+8x4GNtXQxh8OWpVwFNMLSH/5l5QbhWZdIK8bLxs9GcQ3rDUmnwv4+7V1h dxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SrhDN2Qf8+lE/P1EU/TJXEXFld12zPt7dPQFf412LUk=; b=B568GJ76mBI7AaPi6AiwVC4s176YHNnwnHUjQD6HvaBRnTpC3wTJK7/c7hkD2WOecy mbEDrGEnW5grXQuMAEpA0Plwsymfi0+bRE+Poc9ggYyqf26N0sXAjJcJtiIvgmBEILl/ gaFxOWLK9kIpPzrMEU7FeC14bSGpdxkH5oPb4S3sz8sJuxgo860UfhUSFuGJLxf3FDbM 5YBUPkiqY2nrNCsryhFJioiPCOlkdkRvnkH76GiUTAnQ9bwVpbJoAwTD/yX1z4eBLv7b 9EMJFQ+UrGJTPe0zqR5S2Zl4bNqerwlHq3TetrT6+p2tWCtVUtE7QllIHF6lr1pIm/wz 24jA== X-Gm-Message-State: AOAM530fqa3GVkqrzmmwwox6mX9wVLxjdLtv1VDC2rZTvhMct9/CVDyI 8frxfd8F9BM8vmszEUdH/Pk= X-Google-Smtp-Source: ABdhPJwCqcTSSFI7x9YZQM/IwvnR14OpHVv8jfwf8XU/U7ZA+HW+nlMkfVJ1UJTfn+AVXi9rMi5gOw== X-Received: by 2002:a17:906:3616:: with SMTP id q22mr8872560ejb.79.1596284682629; Sat, 01 Aug 2020 05:24:42 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:42 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Jason Gunthorpe Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [RFC PATCH 14/17] IB: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:43 +0200 Message-Id: <20200801112446.149549-15-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/infiniband/hw/hfi1/pcie.c | 38 +++++++++++------------ drivers/infiniband/hw/mthca/mthca_reset.c | 19 ++++++------ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 1a6268d61977..11cf7dde873d 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -392,24 +392,24 @@ int restore_pci_variables(struct hfi1_devdata *dd) /* Save BARs and command to rewrite after device reset */ int save_pci_variables(struct hfi1_devdata *dd) { - int ret = 0; + int ret = -ENODEV; - ret = pci_read_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0, + pci_read_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0, &dd->pcibar0); - if (ret) + if (dd->pcibar0 == (u32)~0) goto error; - ret = pci_read_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1, + pci_read_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1, &dd->pcibar1); - if (ret) + if (dd->pcibar1 == (u32)~0) goto error; - ret = pci_read_config_dword(dd->pcidev, PCI_ROM_ADDRESS, &dd->pci_rom); - if (ret) + pci_read_config_dword(dd->pcidev, PCI_ROM_ADDRESS, &dd->pci_rom); + if (dd->pci_rom == (u32)~0) goto error; - ret = pci_read_config_word(dd->pcidev, PCI_COMMAND, &dd->pci_command); - if (ret) + pci_read_config_word(dd->pcidev, PCI_COMMAND, &dd->pci_command); + if (dd->pci_command == (u16)~0) goto error; ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, @@ -427,14 +427,14 @@ int save_pci_variables(struct hfi1_devdata *dd) if (ret) goto error; - ret = pci_read_config_dword(dd->pcidev, PCI_CFG_MSIX0, &dd->pci_msix0); - if (ret) + pci_read_config_dword(dd->pcidev, PCI_CFG_MSIX0, &dd->pci_msix0); + if (dd->pci_command == (u32)~0) goto error; if (pci_find_ext_capability(dd->pcidev, PCI_EXT_CAP_ID_TPH)) { - ret = pci_read_config_dword(dd->pcidev, PCIE_CFG_TPH2, + pci_read_config_dword(dd->pcidev, PCIE_CFG_TPH2, &dd->pci_tph2); - if (ret) + if (dd->pci_tph2 == (u32)~0) goto error; } return 0; @@ -783,9 +783,9 @@ static int load_eq_table(struct hfi1_devdata *dd, const u8 eq[11][3], u8 fs, pci_write_config_dword(pdev, PCIE_CFG_REG_PL102, eq_value(c_minus1, c0, c_plus1)); /* check if these coefficients violate EQ rules */ - ret = pci_read_config_dword(dd->pcidev, + pci_read_config_dword(dd->pcidev, PCIE_CFG_REG_PL105, &violation); - if (ret) { + if (violation == (32)~0) { dd_dev_err(dd, "Unable to read from PCI config\n"); hit_error = 1; break; @@ -1322,8 +1322,8 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd) /* step 10: decide what to do next */ /* check if we can read PCI space */ - ret = pci_read_config_word(dd->pcidev, PCI_VENDOR_ID, &vendor); - if (ret) { + pci_read_config_word(dd->pcidev, PCI_VENDOR_ID, &vendor); + if (vendor == (u16)~0) { dd_dev_info(dd, "%s: read of VendorID failed after SBR, err %d\n", __func__, ret); @@ -1376,8 +1376,8 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd) setextled(dd, 0); /* check for any per-lane errors */ - ret = pci_read_config_dword(dd->pcidev, PCIE_CFG_SPCIE2, ®32); - if (ret) { + pci_read_config_dword(dd->pcidev, PCIE_CFG_SPCIE2, ®32); + if (reg32 == (u32)~0) { dd_dev_err(dd, "Unable to read from PCI config\n"); return_error = 1; goto done; diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c index 2a6979e4ae1c..5f09d5312472 100644 --- a/drivers/infiniband/hw/mthca/mthca_reset.c +++ b/drivers/infiniband/hw/mthca/mthca_reset.c @@ -102,7 +102,10 @@ int mthca_reset(struct mthca_dev *mdev) for (i = 0; i < 64; ++i) { if (i == 22 || i == 23) continue; - if (pci_read_config_dword(mdev->pdev, i * 4, hca_header + i)) { + + pci_read_config_dword(mdev->pdev, i * 4, + hca_header + i); + if (*(hca_header + i) == (u32)~0) { err = -ENODEV; mthca_err(mdev, "Couldn't save HCA " "PCI header, aborting.\n"); @@ -123,7 +126,10 @@ int mthca_reset(struct mthca_dev *mdev) for (i = 0; i < 64; ++i) { if (i == 22 || i == 23) continue; - if (pci_read_config_dword(bridge, i * 4, bridge_header + i)) { + + pci_read_config_dword(bridge, i * 4, + bridge_header + i); + if (*(bridge_header + i) == (u32)~0) { err = -ENODEV; mthca_err(mdev, "Couldn't save HCA bridge " "PCI header, aborting.\n"); @@ -164,13 +170,8 @@ int mthca_reset(struct mthca_dev *mdev) int c = 0; for (c = 0; c < 100; ++c) { - if (pci_read_config_dword(bridge ? bridge : mdev->pdev, 0, &v)) { - err = -ENODEV; - mthca_err(mdev, "Couldn't access HCA after reset, " - "aborting.\n"); - goto free_bh; - } - + pci_read_config_dword(bridge ? bridge : mdev->pdev, 0, + &v); if (v != 0xffffffff) goto good; From patchwork Sat Aug 1 11:24:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11696003 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68BCB722 for ; Sat, 1 Aug 2020 12:25:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EED22080C for ; Sat, 1 Aug 2020 12:25:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vc2zKFpS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbgHAMZE (ORCPT ); Sat, 1 Aug 2020 08:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbgHAMYq (ORCPT ); Sat, 1 Aug 2020 08:24:46 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A878DC061756; Sat, 1 Aug 2020 05:24:45 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id c2so18272607edx.8; Sat, 01 Aug 2020 05:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9SS/6geyX0ClI4ij6hB9TxwrDh/zKm7zopv5L3r5c8s=; b=Vc2zKFpSPflxIgkXb2/9foXDeDygDY7Eh7RBpe+OBhcwG9txlHhUTADSY0zl+WxwY9 Kfb8ubabl5bXf5t+me8h6LOdOVgNx3RWTh3l9nvD62Hj4C+HVNM0yzL81CZDIgWKuQsM 1RFCX6qT0RpcjIQnrRuZ+3NoxXgbeGY86tdkUxocr8VnSr4sDLHBSzv4ELIsnoN3tr0L hOwCWxwXz+8O/GBTJW2I4CAR3b25+gDsusQFJbca/CnQOa+THu4aXP6LLU9OXqdAxiiZ M7CVKh2dwCjyd35SrdHeY97TUAPQMrUxfslEBfgVTDcSjqpTy0I/VAdWHS1thQpVA/Af dnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9SS/6geyX0ClI4ij6hB9TxwrDh/zKm7zopv5L3r5c8s=; b=XBhArnWH5AF3yNbu0WuT/3pOe46831+VqF6UF86/5wzD0YBA1wD37Ke6LLTtArDJpE 6z+6lzsMkDdjlRUkbKnJbzCbhg9fiSsAUldnLP1HrLlZ7X/hoAzr25IVjrj0cVpvxtkd eWCKqq0ZsNEtjGgBT/se4wTRQy81RHmD7AA3YpnsZ+jT5zG3heqNG9cbOJiI7JbfR41f Vrzn8XMtojXuEuvbc0dT6nTQJdeG8z/8lCM55RP2N+8uBhyS1H15l8wkgfq6aZUb9Qi9 JdMUSFVa0h/ii+rgsXFTzJrg9sbr1vN28Zp+UQa4UN2FZY71DMY9jBvPWkNF4sOXu2qz Y/tQ== X-Gm-Message-State: AOAM530rPVEhrGoY8H1OLAfJ+21Faj8pklyawPVWcafbH0/4BoXCK/E8 4dklc6OCPcqyzoSceQSDi5k= X-Google-Smtp-Source: ABdhPJxCb6w1gVLD3rEZyWpaLmof4X4XsjraNm+7kSy1/q7MbTUqjWvl5aU3W4jrAAp2UMmQx6JGjA== X-Received: by 2002:a50:d80c:: with SMTP id o12mr8165291edj.265.1596284684386; Sat, 01 Aug 2020 05:24:44 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:43 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Joerg Roedel Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, David Woodhouse , Lu Baolu , iommu@lists.linux-foundation.org Subject: [RFC PATCH 15/17] iommu/vt-d: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:44 +0200 Message-Id: <20200801112446.149549-16-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/iommu/intel/iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index d759e7234e98..aad3c065e4a0 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -6165,7 +6165,8 @@ static void quirk_calpella_no_shadow_gtt(struct pci_dev *dev) if (risky_device(dev)) return; - if (pci_read_config_word(dev, GGC, &ggc)) + pci_read_config_word(dev, GGC, &ggc); + if (ggc == (u16)~0) return; if (!(ggc & GGC_MEMORY_VT_ENABLED)) { @@ -6218,7 +6219,8 @@ static void __init check_tylersburg_isoch(void) return; } - if (pci_read_config_dword(pdev, 0x188, &vtisochctrl)) { + pci_read_config_dword(pdev, 0x188, &vtisochctrl); + if (vtisochctrl == (uint32_t)~0) { pci_dev_put(pdev); return; } From patchwork Sat Aug 1 11:24:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11695995 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31F4E722 for ; Sat, 1 Aug 2020 12:24:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18B652080C for ; Sat, 1 Aug 2020 12:24:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hgKqoCrs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgHAMYs (ORCPT ); Sat, 1 Aug 2020 08:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbgHAMYr (ORCPT ); Sat, 1 Aug 2020 08:24:47 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9EFC06174A; Sat, 1 Aug 2020 05:24:47 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id o10so14440173edh.6; Sat, 01 Aug 2020 05:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y/Cb7GKK5mO5miGjoqukiO9DrcaVbTzBZ/XAaAsprek=; b=hgKqoCrsgEvqzZxuemcdmAGc7l+erLtC0MIMuinBU6Z7xRXXMH08QxW5iaYUUehX4a N2jhjFbh6KSNqPO6rdIXcBDOVF+TC3NA3OpVybZTUL2FZnmU5fe1xan0Ku0OsTsKgJBT 2Bl+4Fm9qSzXFiD2qF5WRx67/ES4EZypV3beloZaZm672olY421KHi08EwsFRo3ualou ugM9j06fc7F2D6U3a6xTJCuLmhn+UiqI0N3tIwyBhgTUcLrRz0fNiyAjWlAKP6mHkIdm eTJXEvhx4KUsgrDhJUp31wqdm0zs7H8VlSv9shvME6ij/bBn32Wm2j3Nlw+fMdhGApwy SPMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y/Cb7GKK5mO5miGjoqukiO9DrcaVbTzBZ/XAaAsprek=; b=YbJLGTo6YxT6L8bmdIauPy8HPPIuCImmPNMesgZ7TRwExace8oX/uQ0/WIua2FfWyy HmygaErDT1JrcKrflGFUgYeap9EtYT0rPKUEHiOURRZYT0zgqnLcsZAB6oU4Y4IXNAjA RXj9J139nNLxQpYQXxHeb1ejFGzWFyqHlRPGDStbsqgQbL9lGCeAF3DCqwpJ5yUA3k8I Uhaw6EcInVQy5ZbQWKYaov+xk5LEsQWkqjwPHpHmSTwmTOsN+R+yBM60nL696h7W2lwG TmcB/cwD9QuouqCu7kA2XFmz0aCJ0GYw5BPyjYDjKocACzGSfhC27vwAzEghJIPxF5+z Skog== X-Gm-Message-State: AOAM530hhXu0epEh8X7/SgBGv8BwNslPvQPAERp5mXRnr7yStj0J872A r91U9PPIySUZ5/k7svlZ6CU= X-Google-Smtp-Source: ABdhPJygCFTQRnLVaNC5h4/9yQOO7Dg3dB0ySHxdfO6WpfJvbhq/7rd7jFfxV5f6I7rAPQsprZz5+A== X-Received: by 2002:a05:6402:13c4:: with SMTP id a4mr8165000edx.108.1596284686131; Sat, 01 Aug 2020 05:24:46 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:45 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [RFC PATCH 16/17] mtd: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:45 +0200 Message-Id: <20200801112446.149549-17-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/mtd/maps/ichxrom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c index fda72c5fd8f9..04728d902e49 100644 --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c @@ -61,8 +61,8 @@ static void ichxrom_cleanup(struct ichxrom_window *window) int ret; /* Disable writes through the rom window */ - ret = pci_read_config_word(window->pdev, BIOS_CNTL, &word); - if (!ret) + pci_read_config_word(window->pdev, BIOS_CNTL, &word); + if (word != (u16)~0) pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); pci_dev_put(window->pdev); From patchwork Sat Aug 1 11:24:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Saheed O. Bolarinwa" X-Patchwork-Id: 11695997 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 206C5722 for ; Sat, 1 Aug 2020 12:24:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 000A02087C for ; Sat, 1 Aug 2020 12:24:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="puciVruZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729135AbgHAMYu (ORCPT ); Sat, 1 Aug 2020 08:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729126AbgHAMYt (ORCPT ); Sat, 1 Aug 2020 08:24:49 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080F3C06174A; Sat, 1 Aug 2020 05:24:49 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id a26so8221192ejc.2; Sat, 01 Aug 2020 05:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WuEfbc6tXTSPxgYhc8GBlrhIgPKHPNIokCc6jcbGrnA=; b=puciVruZjSj58crrBaPOvKOFovdmwjton2ViDkAJyXSDsbH8S5wJxOHfMtUqv0lnvK UbzqzW8Sw74URsHUOZuVVnmeJFtusJ7sP7gVy9SKne9ZoWNsdiwXkBj0ECAq1CHwPmIO reMg2wCxUhVWSbkj6jSC/fzluoGV8fnAM3wy2+eCMIqhlGsCAE/zYXiseP7GDtf2rwpQ sH54wyQ/QX+TE/5jtzRPmS9EmeJKWowCukWlbSl9s0QLXogmlXZn3RyX7zqzgbPaZuiB z3bPxmwfp+pWZo+EkqHlCyJeSpotz1fGxShfzxiB7Q1gEumoOUdz4bp7+Rm73oNtinsu ImfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WuEfbc6tXTSPxgYhc8GBlrhIgPKHPNIokCc6jcbGrnA=; b=hYQvpLmDlcSSVvCG+Kg7WG7IEJkBYHiIb/v4O9MWWHYJFFWZMWLODODieLUR9nyiv+ xWbEfDIxIM5xYrnENyu+t+RWVlp4cHUOhEZaUVFlKisvagz2mYYqJ6QGw1jNpllWZItc kSwOA4LtWP+NFVL9qArSCTowIkCzD9TZXB6G4Rc93/rF8TGayJJEtEKAxRlnHFrxlf6e KoxCf6ogViKZOj0GFDVOQalm9SMBtfDoGuifmqbmWEp7GZoYKErRtoS/YuShp36QI2Qj b3fTDZbrl0iXgf9N1yw+N4cGaTUW6g6Fn0wyL5HIOgN12QeP7ulYsa1kGmzb36BfbsNm CWYA== X-Gm-Message-State: AOAM530CbqqZV8La6XpLBrMyCJj8JO/aMf2kHeESu7GdjQox04fWa/PK gn/Ee/LsqZa5L56lpp7jmgQ= X-Google-Smtp-Source: ABdhPJwWT9TZbxDhqkMVpM+iCmur7AgDN5wt9JmA4+V0x7td71JPi8yIMDJT1uKV5t2/nsl3f9ZyYw== X-Received: by 2002:a17:906:9356:: with SMTP id p22mr8260889ejw.119.1596284687686; Sat, 01 Aug 2020 05:24:47 -0700 (PDT) Received: from net.saheed (95C84E0A.dsl.pool.telekom.hu. [149.200.78.10]) by smtp.gmail.com with ESMTPSA id a101sm12083131edf.76.2020.08.01.05.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 05:24:47 -0700 (PDT) From: "Saheed O. Bolarinwa" To: helgaas@kernel.org, "David S. Miller" , Kalle Valo , Jakub Kicinski , Wolfgang Grandegger , Marc Kleine-Budde Cc: "Saheed O. Bolarinwa" , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 17/17] net: Drop uses of pci_read_config_*() return value Date: Sat, 1 Aug 2020 13:24:46 +0200 Message-Id: <20200801112446.149549-18-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200801112446.149549-1-refactormyself@gmail.com> References: <20200801112446.149549-1-refactormyself@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas Signed-off-by: Saheed O. Bolarinwa --- drivers/net/can/peak_canfd/peak_pciefd_main.c | 6 ++++-- drivers/net/can/sja1000/peak_pci.c | 6 ++++-- drivers/net/ethernet/agere/et131x.c | 11 +++++++---- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 5 +++-- .../ethernet/cavium/liquidio/cn23xx_pf_device.c | 4 ++-- drivers/net/ethernet/marvell/sky2.c | 5 +++-- drivers/net/ethernet/mellanox/mlx4/catas.c | 7 +------ drivers/net/ethernet/mellanox/mlx4/reset.c | 10 ++++++---- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 4 ++-- drivers/net/wan/farsync.c | 5 +++-- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++-- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 15 ++++++++++----- 12 files changed, 47 insertions(+), 35 deletions(-) diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c index 6ad83a881039..484a214fc1f1 100644 --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c @@ -730,9 +730,11 @@ static int peak_pciefd_probe(struct pci_dev *pdev, goto err_disable_pci; /* the number of channels depends on sub-system id */ - err = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &sub_sys_id); - if (err) + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &sub_sys_id); + if (sub_sys_id == (u16)~0) { + err = -ENODEV; goto err_release_regions; + } dev_dbg(&pdev->dev, "probing device %04x:%04x:%04x\n", pdev->vendor, pdev->device, sub_sys_id); diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c index 8c0244f51059..d25a99ad08da 100644 --- a/drivers/net/can/sja1000/peak_pci.c +++ b/drivers/net/can/sja1000/peak_pci.c @@ -560,9 +560,11 @@ static int peak_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) goto failure_disable_pci; - err = pci_read_config_word(pdev, 0x2e, &sub_sys_id); - if (err) + pci_read_config_word(pdev, 0x2e, &sub_sys_id); + if (sub_sys_id == (u16)~0) { + err = -ENODEV; goto failure_release_regions; + } dev_dbg(&pdev->dev, "probing device %04x:%04x:%04x\n", pdev->vendor, pdev->device, sub_sys_id); diff --git a/drivers/net/ethernet/agere/et131x.c b/drivers/net/ethernet/agere/et131x.c index 865892c1f23f..6b0e5f193e73 100644 --- a/drivers/net/ethernet/agere/et131x.c +++ b/drivers/net/ethernet/agere/et131x.c @@ -505,7 +505,8 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status) * to 1 prior to starting a single byte read/write */ for (i = 0; i < MAX_NUM_REGISTER_POLLS; i++) { - if (pci_read_config_dword(pdev, LBCIF_DWORD1_GROUP, ®)) + pci_read_config_dword(pdev, LBCIF_DWORD1_GROUP, ®); + if (reg == (u32)~0) return -EIO; /* I2C idle and Phy Queue Avail both true */ @@ -679,7 +680,8 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter) * function, because I thought there could be some time conditions * but it didn't work. Call the whole function twice also work. */ - if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) { + pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus); + if (eestatus == (u8)~0) { dev_err(&pdev->dev, "Could not read PCI config space for EEPROM Status\n"); return -EIO; @@ -3059,8 +3061,9 @@ static int et131x_pci_init(struct et131x_adapter *adapter, } for (i = 0; i < ETH_ALEN; i++) { - if (pci_read_config_byte(pdev, ET1310_PCI_MAC_ADDRESS + i, - adapter->rom_addr + i)) { + pci_read_config_byte(pdev, ET1310_PCI_MAC_ADDRESS + i, + adapter->rom_addr + i); + if (*(adapter->rom_addr + i) == (u8)~0) { dev_err(&pdev->dev, "Could not read PCI config space for MAC address\n"); goto err_out; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 7cea33803f7f..5962a1d2dffc 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1463,14 +1463,15 @@ static int bnx2x_nvram_read32(struct bnx2x *bp, u32 offset, u32 *buf, static bool bnx2x_is_nvm_accessible(struct bnx2x *bp) { - int rc = 1; + bool rc = true; u16 pm = 0; struct net_device *dev = pci_get_drvdata(bp->pdev); if (bp->pdev->pm_cap) - rc = pci_read_config_word(bp->pdev, + pci_read_config_word(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL, &pm); + rc = (pm == (u16)~0); if ((rc && !netif_running(dev)) || (!rc && ((pm & PCI_PM_CTRL_STATE_MASK) != (__force u16)PCI_D0))) return false; diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c index 43d11c38b38a..cf52d6cc2a46 100644 --- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c +++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c @@ -1162,8 +1162,8 @@ static int cn23xx_get_pf_num(struct octeon_device *oct) ret = 0; /** Read Function Dependency Link reg to get the function number */ - if (pci_read_config_dword(oct->pci_dev, CN23XX_PCIE_SRIOV_FDL, - &fdl_bit) == 0) { + pci_read_config_dword(oct->pci_dev, CN23XX_PCIE_SRIOV_FDL, &fdl_bit); + if (fdl_bit != (u32)~0) { oct->pf_num = ((fdl_bit >> CN23XX_PCIE_SRIOV_FDL_BIT_POS) & CN23XX_PCIE_SRIOV_FDL_MASK); } else { diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index fe54764caea9..1042bfd0ff70 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -4964,8 +4964,9 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * other PCI access through shared memory for speed and to * avoid MMCONFIG problems. */ - err = pci_read_config_dword(pdev, PCI_DEV_REG2, ®); - if (err) { + pci_read_config_dword(pdev, PCI_DEV_REG2, ®); + if (reg == (u32)~0) { + err = -ENODEV; dev_err(&pdev->dev, "PCI read config failed\n"); goto err_out_disable; } diff --git a/drivers/net/ethernet/mellanox/mlx4/catas.c b/drivers/net/ethernet/mellanox/mlx4/catas.c index 5b11557f1ae4..1e774a181133 100644 --- a/drivers/net/ethernet/mellanox/mlx4/catas.c +++ b/drivers/net/ethernet/mellanox/mlx4/catas.c @@ -52,12 +52,7 @@ static int read_vendor_id(struct mlx4_dev *dev) u16 vendor_id = 0; int ret; - ret = pci_read_config_word(dev->persist->pdev, 0, &vendor_id); - if (ret) { - mlx4_err(dev, "Failed to read vendor ID, ret=%d\n", ret); - return ret; - } - + pci_read_config_word(dev->persist->pdev, 0, &vendor_id); if (vendor_id == 0xffff) { mlx4_err(dev, "PCI can't be accessed to read vendor id\n"); return -EINVAL; diff --git a/drivers/net/ethernet/mellanox/mlx4/reset.c b/drivers/net/ethernet/mellanox/mlx4/reset.c index 0076d88587ca..f0b9af99aa26 100644 --- a/drivers/net/ethernet/mellanox/mlx4/reset.c +++ b/drivers/net/ethernet/mellanox/mlx4/reset.c @@ -81,8 +81,9 @@ int mlx4_reset(struct mlx4_dev *dev) for (i = 0; i < 64; ++i) { if (i == 22 || i == 23) continue; - if (pci_read_config_dword(dev->persist->pdev, i * 4, - hca_header + i)) { + pci_read_config_dword(dev->persist->pdev, i * 4, + hca_header + i); + if (*(hca_header + i) == (u32)~0) { err = -ENODEV; mlx4_err(dev, "Couldn't save HCA PCI header, aborting\n"); goto out; @@ -124,8 +125,9 @@ int mlx4_reset(struct mlx4_dev *dev) end = jiffies + MLX4_RESET_TIMEOUT_JIFFIES; do { - if (!pci_read_config_word(dev->persist->pdev, PCI_VENDOR_ID, - &vendor) && vendor != 0xffff) + pci_read_config_word(dev->persist->pdev, PCI_VENDOR_ID, + &vendor); + if (vendor != 0xffff) break; msleep(1); diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c index e1e1f4e3639e..b1b055f8ac47 100644 --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c @@ -3090,8 +3090,8 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) if (!cap) return; - ret = pci_read_config_dword(bridge, cap + PCI_ERR_CAP, &err_cap); - if (ret) { + pci_read_config_dword(bridge, cap + PCI_ERR_CAP, &err_cap); + if (err_cap == (u32)~0) { dev_err(dev, "failed reading ext-conf-space of %s\n", pci_name(bridge)); dev_err(dev, "\t pci=nommconf in use? " diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 7916efce7188..8981334d9f82 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -678,8 +678,9 @@ fst_cpureset(struct fst_card_info *card) unsigned int regval; if (card->family == FST_FAMILY_TXU) { - if (pci_read_config_byte - (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) { + pci_read_config_byte + (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register); + if (interrupt_line_register == (u8)~0) { dbg(DBG_ASS, "Error in reading interrupt line register\n"); } diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 39381cbde89e..f501b4759630 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -544,8 +544,8 @@ brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid) if (core) { bar0_win = core->base; pci_write_config_dword(pdev, BRCMF_PCIE_BAR0_WINDOW, bar0_win); - if (pci_read_config_dword(pdev, BRCMF_PCIE_BAR0_WINDOW, - &bar0_win) == 0) { + pci_read_config_dword(pdev, BRCMF_PCIE_BAR0_WINDOW, &bar0_win); + if (bar0_win != (u32)~0) { if (bar0_win != core->base) { bar0_win = core->base; pci_write_config_dword(pdev, diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index e5160d620868..caafad424aa7 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -122,7 +122,8 @@ void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) sprintf(prefix, "iwlwifi %s: ", pci_name(pdev)); IWL_ERR(trans, "iwlwifi device config registers:\n"); for (i = 0, ptr = buf; i < PCI_DUMP_SIZE; i += 4, ptr++) - if (pci_read_config_dword(pdev, i, ptr)) + pci_read_config_dword(pdev, i, ptr); + if (*ptr == (u32)~0) goto err_read; print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); @@ -135,7 +136,8 @@ void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) if (pos) { IWL_ERR(trans, "iwlwifi device AER capability structure:\n"); for (i = 0, ptr = buf; i < PCI_ERR_ROOT_COMMAND; i += 4, ptr++) - if (pci_read_config_dword(pdev, pos + i, ptr)) + pci_read_config_dword(pdev, pos + i, ptr); + if (*ptr == (u32)~0) goto err_read; print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); @@ -151,7 +153,8 @@ void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) IWL_ERR(trans, "iwlwifi parent port (%s) config registers:\n", pci_name(pdev)); for (i = 0, ptr = buf; i < PCI_PARENT_DUMP_SIZE; i += 4, ptr++) - if (pci_read_config_dword(pdev, i, ptr)) + pci_read_config_dword(pdev, i, ptr); + if (*ptr == (u32)~0) goto err_read; print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); @@ -165,7 +168,8 @@ void iwl_trans_pcie_dump_regs(struct iwl_trans *trans) pci_name(pdev)); sprintf(prefix, "iwlwifi %s: ", pci_name(pdev)); for (i = 0, ptr = buf; i <= PCI_ERR_ROOT_ERR_SRC; i += 4, ptr++) - if (pci_read_config_dword(pdev, pos + i, ptr)) + pci_read_config_dword(pdev, pos + i, ptr); + if (*ptr == (u32)~0) goto err_read; print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 32, 4, buf, i, 0); @@ -2191,8 +2195,9 @@ static int iwl_trans_pcie_write_mem(struct iwl_trans *trans, u32 addr, static int iwl_trans_pcie_read_config32(struct iwl_trans *trans, u32 ofs, u32 *val) { - return pci_read_config_dword(IWL_TRANS_GET_PCIE_TRANS(trans)->pci_dev, + pci_read_config_dword(IWL_TRANS_GET_PCIE_TRANS(trans)->pci_dev, ofs, val); + return (*val == (u32)~0) ? -ENODEV : 0; } static void iwl_trans_pcie_freeze_txq_timer(struct iwl_trans *trans,