Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1018088ybt; Fri, 19 Jun 2020 21:46:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi7LUBsLFWGEEsYBxRMLg+yJsEghxm6ucOvnmEh9wo7Gi8V9fspi5o7NoICI5vfs8ETQtD X-Received: by 2002:a17:906:b292:: with SMTP id q18mr2443286ejz.253.1592628388534; Fri, 19 Jun 2020 21:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592628388; cv=none; d=google.com; s=arc-20160816; b=X0y/PAa+8poztFVzK++aZMhR4OSNUkQQU5f3Oxx7HdXOTTfFHnjthbQBVwdXddHj4C R3XYI5tBOBo0+uH7zGfhirqA/qC1M9q5dNjv5Bz88Ylwyuk8ONIqp89qA7B9OQnICd4L 3Wh9vxWZe247Y0/L9wHVqnWSvO+YIoJhPxZrIDSWoR0Ze9idfTy93K4F9XCHIAX3XiI4 fYPkB7XFNsRNoHy2UfyZnUcGpwAazTLpKS4W9DckNZ4X8lWoKIyJHjCtnTG7sC2w6ulJ Vm1t2cVAUFrLXQDOKYRQH1kn/CnKIgEonKUkfKSA6npK77XbUvxfNVS+3rbB6vmkRKcH YmCw== 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=KMBNaqmBbj9htNDag97z0bn7cN5DmjB31K/2q35ybKs=; b=Ryd7Bz92S8aAEKvqvDk614oaC80PXHaKG0XvGeP2VSKm2y9Agjqp0/ta48EMQ+cd4p G5EJdYo9RRR/bE8Cis0Fu3aZQ4J+DYlGJcvASj1PaHMrkAw1X4l6Hi1tQ15XvO4rOaky GRHadkTZnYyZELRYgjWboGlGCsv1mVo+8O2ZAb5phCGz8kHiqUUUm4Ub2NLVvJd+BO/r QJahLUb5FhsuckyOMfp1J6VQ5tvaZm7lhgKfOY7pqLMLmqz563qIwRC9KEda9ztL7RKD zlsF0UgWZjxjq+T8trQxECRCAU3VUnVGwOK68fD4cbbJAUfh/n8sBR1TiBBKfNThzcnE SSHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xt+ERAcz; 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 ly19si4938751ejb.394.2020.06.19.21.46.06; Fri, 19 Jun 2020 21:46:28 -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=Xt+ERAcz; 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 S2392368AbgFSVMQ (ORCPT + 99 others); Fri, 19 Jun 2020 17:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392091AbgFSVMJ (ORCPT ); Fri, 19 Jun 2020 17:12:09 -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 B483FC06174E; Fri, 19 Jun 2020 14:12:07 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id gl26so11616376ejb.11; Fri, 19 Jun 2020 14:12:07 -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=KMBNaqmBbj9htNDag97z0bn7cN5DmjB31K/2q35ybKs=; b=Xt+ERAczMjZ5VwzchOiLz2WSckbRaMvRMHmHlkReP29Uod92e0e1ioG8V+RkzSEgWJ V3GXll6AHBebYlNtGn8Y7vr3xKZgY+Q15a5kdw3I0KGzFfUevDuvQbLf0/A8tbew17H7 HAhJENkAawKNsnVCqTrA2Ky5TRisZXzzcF9UcGhSrVTuVBN2DgQQZJQVp4mkR5cP7MQO O4MUeE8X1kUgc9lz8/iwEeoKEyOt+8vQd3HIJoAqYvjdPJkqf40Uo7WIqiE7F5YaZBvV NNEo7fNmqIZY0ABGTXXp+Q60EGeLbeJobHd5NMY4nyfJlKGd0vdpImuh//P+baFQ+vk6 oXsg== 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=KMBNaqmBbj9htNDag97z0bn7cN5DmjB31K/2q35ybKs=; b=D3flwsY1TN6cx+xyZqdJeADpt1IG1yIpVE17HR/U3Iq04ofxtXSTFip+cM2z3Yssf0 gelo5OpA35YmYf0KR5rNXm29TAB4FFL0andEc2h7g/WOyBQ8BPlNeUJpJ3JGxrQNrtT1 GcSn/wFmnvBrPS4S5XfFk3bQRxEsTelHKZMhl2KP0mx2vkaj5SF8KjSor7kL+l0npLzy NNq28jl8IP3w18GndjO+375e9+XjNY8FyHZb7I+ZKSeEvKUFvX0f/FrLxiDMa2uqwuIi 38aTTdGRh+yV5XRLmQzs6BvSz493Uktprch0VGUy9K6N8YWEZK6ue2s/1Lyr62XzQT22 2Jzg== X-Gm-Message-State: AOAM532TbEYewY6BBzd4wN0HTqxNDeSdodiEPHy82uTyaiJuX0bg82hj uYZV4j4emkyssqHC1sFtkc0= X-Received: by 2002:a17:907:7294:: with SMTP id dt20mr5300331ejc.355.1592601126447; Fri, 19 Jun 2020 14:12:06 -0700 (PDT) Received: from net.saheed (54001B7F.dsl.pool.telekom.hu. [84.0.27.127]) by smtp.gmail.com with ESMTPSA id kt10sm5485833ejb.54.2020.06.19.14.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 14:12:05 -0700 (PDT) From: refactormyself@gmail.com To: helgaas@kernel.org Cc: Bolarinwa Olayemi Saheed , bjorn@helgaas.com, linux-pci@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PCI: pciehp: Fix wrong failure check on pcie_capability_read_*() Date: Fri, 19 Jun 2020 22:12:19 +0200 Message-Id: <20200619201219.32126-3-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200619201219.32126-1-refactormyself@gmail.com> References: <20200619201219.32126-1-refactormyself@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bolarinwa Olayemi Saheed On failure, pcie_capabiility_read_*() will set the status value, its last parameter to 0 and not ~0. This bug fix checks for the proper value. Signed-off-by: Bolarinwa Olayemi Saheed --- drivers/pci/hotplug/pciehp_hpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 53433b37e181..c1a67054948a 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -89,7 +89,7 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout) do { pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (slot_status == (u16) ~0) { + if (slot_status == (u16)0) { ctrl_info(ctrl, "%s: no response from device\n", __func__); return 0; @@ -165,7 +165,7 @@ static void pcie_do_write_cmd(struct controller *ctrl, u16 cmd, pcie_wait_cmd(ctrl); pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); - if (slot_ctrl == (u16) ~0) { + if (slot_ctrl == (u16)0) { ctrl_info(ctrl, "%s: no response from device\n", __func__); goto out; } @@ -236,7 +236,7 @@ int pciehp_check_link_active(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)0) return -ENODEV; ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); @@ -440,7 +440,7 @@ int pciehp_card_present(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || slot_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || slot_status == (u16)0) return -ENODEV; return !!(slot_status & PCI_EXP_SLTSTA_PDS); @@ -592,7 +592,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) read_status: pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status); - if (status == (u16) ~0) { + if (status == (u16)0) { ctrl_info(ctrl, "%s: no response from device\n", __func__); if (parent) pm_runtime_put(parent); -- 2.18.2