Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp762718pxa; Sat, 1 Aug 2020 05:27:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdWEJlupMBGYb8GgpPmwd7Pc9RYHvgtwtG69rFPA6+H8xP7gKtx7jetBbCsDFpO/ZwNfgn X-Received: by 2002:a50:8a62:: with SMTP id i89mr8067724edi.324.1596284820830; Sat, 01 Aug 2020 05:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596284820; cv=none; d=google.com; s=arc-20160816; b=DhiPppUSQtxH/E/looMvrNwpYPctcx9T30LuyBQafInI8kzpFXDUWf8qtFIq6dwL5K QnQ3+HdkazcM79e9zrGbmOjKFNuip4r1HJzqP2ADAOFKGpMN6CX+LjSQhnWdzaTdE6Q/ PH0C6SIE6tYUHFWnJJ9dVLhQTcIlSgmYFEPqX8zqM7bgGhGXYjqL7o27d9te8JdnV5KS wfZr1KmfzN9SmHnmZbqJOkwANombv4TXc4vd6/fVx3bW91bTO/5IX0ZuCmWPLXGN8D7l t350XLBOgr6NZkaS59jz1ieSadl5Fs7HmgmaIQfgvlh2gttrkNU1kA3Vzd+qSVqJMEkh o+zw== 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=I8dAqn3oyLTlTqhf29Z52aIjqvD0eEwBI3IdJNmTAKE=; b=vdlcKUSF78l6AUGNlXPLhH9XxQjkbfJyBHJa55TqIMwpNE77fcah3SRqusAbkJU5oe d5tHDrLie/ATT475390WIEkL7RV0S8CdfLl+GwcT0+DW7IZ3wb/7wtLBZKeV6C0L2hdd sVF3fLE+TlQ+xYNCSJBTTSukiljq7mnWH75uZnI885hA9ihcjNha49ZvQkqprTvZyJKN wJd/PSbwkq1i1CZNzTZmNXPYxPnjkMjENGhXVo0PvKiAm26/rO4qU0dT1FdsJKhJO/JH xVDW1pZRKDL5qj3zV8QmyBu8mnA+jZZfo9l/jKYhNAvrkgVxXPXRFIeCvoPzndAimq3j 491A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P98yQ73Q; 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 f21si8649347ejl.329.2020.08.01.05.26.39; Sat, 01 Aug 2020 05:27:00 -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=P98yQ73Q; 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 S1729281AbgHAMZd (ORCPT + 99 others); Sat, 1 Aug 2020 08:25:33 -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-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-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. 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, -- 2.18.4