From patchwork Thu Oct 17 14:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 13840115 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 848C25680; Thu, 17 Oct 2024 14:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729175513; cv=none; b=lTOTDOb5n/NG+9JQ3VG3WI5P2v+9MQW0XfiShZiMU3uT8eLGhZ7AkGIs2Y1Ky13uiPBOod0lLdqKE9BDyF0k9+MR+t+5tTt1D+e1iB1Bnw1r2aMeJ13wS5AwJ+w9p+Yfqrw4VAnByrGW9Djv1JV02zsYnh9wov3GX5V0ZoMHTm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729175513; c=relaxed/simple; bh=SKDmrC6wxkBh0QMo8rcm+HsLNB4sdnUMvZwopu+gpCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=u7efiAyEepQ4tUHu0jQ158dy89fLA6xCz++f4CQquGgA9Ub7ZH4w+syWrjOZECclvsnujn/G3K4ojQ34zW+sG6oBVynGjA9U+MiAxjh1EWv9zsaaWMcftjmN2JwjH6A1G/1Lksf1LeqWi1CdgyWppbHpgwV9eHqYU9CN9TEpURc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SlY91ZtE; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SlY91ZtE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729175508; x=1760711508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SKDmrC6wxkBh0QMo8rcm+HsLNB4sdnUMvZwopu+gpCw=; b=SlY91ZtEciJ+FbKwai2N8Ydj4WAOlOfVkxkzrTclfaHkLloQDQ+5aMQA Neqltmue6g32XvF4P/K8xVqCt2EsD5MJ8GViHZmCAr7Sxfg+sWpjajtzl 8b+KzUIhWlp1y1z4V5GMYSY8nJb2FY/eK21AvqKUfIAhBBhHFwczHpS4l NLXgvl5u1VDHZ3Ccf37ddM+F/UiuezrUf4se0FsvzhAywu+W45vOKwD8z MnhqanUiK8TcYdJK0JivH+RUoR40K0GXnXDeZiBlTKq7CJOT06hUCeKgx AT/rOBYFvFrEVsou5qQs0UbVWOHFStGFjF64NkDXp1AUZPK1Mdspj5Dzu Q==; X-CSE-ConnectionGUID: N+JJgMidQleuQoauBYqLEQ== X-CSE-MsgGUID: 94fZau+pQh2qFxiUupJU0g== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="16281365" X-IronPort-AV: E=Sophos;i="6.11,211,1725346800"; d="scan'208";a="16281365" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 07:31:47 -0700 X-CSE-ConnectionGUID: Wv8vvAAHR4q9jO27alDQGA== X-CSE-MsgGUID: PrUnzNQoTJKU4lXcRi46sg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="83394687" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.91]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 07:31:46 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 1/4] PCI: cpqphp: Fix PCIBIOS_* return value confusions Date: Thu, 17 Oct 2024 17:31:28 +0300 Message-Id: <20241017143131.46163-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241017143131.46163-1-ilpo.jarvinen@linux.intel.com> References: <20241017143131.46163-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Code in and related to PCI_RefinedAccessConfig() has 3 types of return type confusion: - PCI_RefinedAccessConfig() tests pci_bus_read_config_dword() return value against -1. - PCI_RefinedAccessConfig() returns both -1 and PCIBIOS_* return codes. - Callers of PCI_RefinedAccessConfig() only test for -1. Make PCI_RefinedAccessConfig() return PCIBIOS_* codes consistently and adapt callers accordingly. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Ilpo Järvinen --- drivers/pci/hotplug/cpqphp_pci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 718bc6cf12cb..974c7db3265b 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -135,11 +135,13 @@ int cpqhp_unconfigure_device(struct pci_func *func) static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value) { u32 vendID = 0; + int ret; - if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) == -1) - return -1; + ret = pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID); + if (ret != PCIBIOS_SUCCESSFUL) + return PCIBIOS_DEVICE_NOT_FOUND; if (PCI_POSSIBLE_ERROR(vendID)) - return -1; + return PCIBIOS_DEVICE_NOT_FOUND; return pci_bus_read_config_dword(bus, devfn, offset, value); } @@ -202,13 +204,15 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_ { u16 tdevice; u32 work; + int ret; u8 tbus; ctrl->pci_bus->number = bus_num; for (tdevice = 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1) + ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (ret) continue; dbg("Looking for nonbridge bus_num %d dev_num %d\n", bus_num, tdevice); /* Yep we got one. Not a bridge ? */ @@ -220,7 +224,8 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_ } for (tdevice = 0; tdevice < 0xFF; tdevice++) { /* Scan for access first */ - if (PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work) == -1) + ret = PCI_RefinedAccessConfig(ctrl->pci_bus, tdevice, 0x08, &work); + if (ret) continue; dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); /* Yep we got one. bridge ? */