Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp762798pxa; Sat, 1 Aug 2020 05:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe2HNRuRwe9Nik4zfByFWoa/CMpoUIPSD5kSkM66y8u9QAP32yGNVa6Lkj1zE8ev5Q53+0 X-Received: by 2002:a05:6402:743:: with SMTP id p3mr5351756edy.19.1596284832884; Sat, 01 Aug 2020 05:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596284832; cv=none; d=google.com; s=arc-20160816; b=gZ96y7NaR6P3VvtgwPwjtv9UUNQazZmSaE7lgBueXIwmN7weD6VXZrVMXILOPL5oIX fbc3HK6Mr5oUwYR/iMX5ILLhPcnCAEwIJUKDSr2hjJcT2DRSdf9uzQynb2gUIwAL8vrf Qe1jeZaa7y8tlwmlRBpPg/sCrR9FMmrPA51JIUoSRKFq+yTEahd96fcQqtf82LSaGBcN Z1Dq/m04HQhUw6s2pmoLlOdiF+ojG07NAxCga80nUng5JyuLbrPMu8NlaxbJaRK/98+n X0vxlZA5bXPo/TqsMq2jdCbqcPF11kkIuQZA1tH0E1mrEObwaC0tWbSYHpGXnCFDPdxQ ayCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=BywL0jlhvMnVFDfC0ze8h5LlMNFaT8aAv2rtyExEJSw=; b=cwPF4vGPRVP9vHHQgqYxQAMwcUWtyX8YqEeRlURLQgzoDpNg+ktqJCjQbvm8fLU9UD qmHi+pkIKqP8ab0ZvD/9kYSkR23NLrtnsOpC9gKQdjdGs1zCNEwereiYkgroVqQWihc6 jYkOGUqLNzr1ONijv5WG/fOkdOakyjahet/OcOYOMrlD5ReC5/SVbfRTRr4ySIm2OqQA V7MJxvRlHlWjopd0Fzsi/xi5wKfNS/9E/vZXaMZOpd71e070zHncv6UWP8epwv6M2vEN yQRrGzOckka36gvVzcQEGVrJBGVfLyrJzNKB4q4rlxBXP/qYEXKqrqKW0o622/0FIG86 TGAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QHi5Tbht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si2137846ejr.184.2020.08.01.05.26.51; Sat, 01 Aug 2020 05:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QHi5Tbht; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729295AbgHAMZo (ORCPT + 99 others); Sat, 1 Aug 2020 08:25:44 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) -- 2.18.4