Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp806790pxb; Fri, 22 Apr 2022 11:33:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb/4s5dpFwwqJA3/dJS77iDrqCDChPwG4lEczXUrZy/IXhdecgO8LFvDUtZhauThltqCL3 X-Received: by 2002:a17:902:c2cc:b0:15b:a4e6:f58c with SMTP id c12-20020a170902c2cc00b0015ba4e6f58cmr5612030pla.149.1650652380994; Fri, 22 Apr 2022 11:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650652380; cv=none; d=google.com; s=arc-20160816; b=cWbl9LF4uNdwA0Q+aFeGc9GqfO2WWdm0pxuI9/ENVCqxWStJaeoIM6M5yJKW0TOwXr SWvjk41YYDQHJMRo9XRNCDKgGjUJMolXI9FKpW3E8jp7tdNB3Rl9ktkOSjBSyXYJtCG/ CJXfDUZzPJ2djppAgyIUqwkynoBU8s6U1YkF4wqmhIcvJVpdPuGojiPHY5+2R28FPgZo oZOD5Enm3eRfi/fBkFONQpFqoTYwsGfd7AZQTGtcozUbxYB4TMQidbwrOghQgoj0MhR/ AWoYivIS1A/7KyFp00RTFZeQYJnZulobRI3Pgcwr8VPImjff6ZaH8IzXy3FK+mnKA+db kIqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:date:cc:to :from:subject:message-id:dkim-signature; bh=Zcc0JtPRzC+pKr8++TBAJL5YNRPeYJc/FYOB64+6btE=; b=gRhpt17fMhtwtZc52JTX1pV+05U6pxlhJJlHSS3T2E8QeBMVygNhR23oBGUBEvwTNK Kdf4ILRE2wO4o/OwFbQEWTu3heQbAuhz3oSUL5XEvwCYvJw0QNslxtY5c+rsmdVAAJYS NgSeJhwsCNR395bL9j8kg7Osm6UGpOcoGuYJechxQ1udGITHXNj6qEsp2d8iHxaZV4My IvLtwAM0ZP7QYpo0EGDOroqqIc6I/0pubBLSxIAal2WA97Y4gkzNOEgp7eOOx15NmZ7A IxJWckSW0xBhXzSHm3iMKcpSrBFyUWUX+IeOypTW8mCMVqYHlqF8Q8hY3JzYgzLiWAGk TdUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AmFwLcoI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ip3-20020a17090b314300b001c73b8066e0si8643191pjb.74.2022.04.22.11.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:33:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AmFwLcoI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45920C617D; Fri, 22 Apr 2022 11:01:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1448049AbiDVNiW (ORCPT + 99 others); Fri, 22 Apr 2022 09:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237165AbiDVNiU (ORCPT ); Fri, 22 Apr 2022 09:38:20 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113B44A93F; Fri, 22 Apr 2022 06:35:27 -0700 (PDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23MCmtew008621; Fri, 22 Apr 2022 13:35:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version; s=pp1; bh=Zcc0JtPRzC+pKr8++TBAJL5YNRPeYJc/FYOB64+6btE=; b=AmFwLcoI3tVKKINXxOxlp3AnwyUB1m2zkOvxgDvqYJIqHVGa77iRWtgy5IQRbCGtl052 r/3MTho75Zygv7CEL7isQteaH/2fEQ/zFB1m5c3uGigwL9c8Oh16ytP9CjiN6Az5sN0b p8BPi+0Fx9GYhFSsO/7aRAYoqAhhJrGPxEz19s8IjOwYVneM7lPt6sTbUwu1ZswQIpWR T1apMP1nIj3AQDhBos5N9ZOtSfiH9XNVbPPVgy3N91PeWVj4qQb7zdN9w7hyeJMM3QQI 7iSsXIDM6u8le+rC5g+xam6+3nZMb3LA95IPt70+dJtvQ7f9yttv4KlhqyrQE1ABZSq+ 6g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fjyk5j1sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 13:35:23 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23MDL28n009338; Fri, 22 Apr 2022 13:35:23 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fjyk5j1rf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 13:35:23 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23MDMbop007852; Fri, 22 Apr 2022 13:35:20 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3ffn2j1fce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 13:35:20 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23MDZHXQ47382996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Apr 2022 13:35:17 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FE7C11C04A; Fri, 22 Apr 2022 13:35:17 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0531911C04C; Fri, 22 Apr 2022 13:35:17 +0000 (GMT) Received: from sig-9-145-175-158.de.ibm.com (unknown [9.145.175.158]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Apr 2022 13:35:16 +0000 (GMT) Message-ID: <19ea2a8ff04c24708a6504924f7a91c1045308d0.camel@linux.ibm.com> Subject: Re: [PATCH v4 1/4] PCI: Clean up pci_scan_slot() From: Niklas Schnelle To: Bjorn Helgaas , Jan Kiszka , Matthew Rosato , Pierre Morel Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org Date: Fri, 22 Apr 2022 15:35:07 +0200 In-Reply-To: <20220422132858.1213022-2-schnelle@linux.ibm.com> References: <20220422132858.1213022-1-schnelle@linux.ibm.com> <20220422132858.1213022-2-schnelle@linux.ibm.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-+5TQTceV7kwkEleY1vza" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0WaMBypyLUjSk87yGeJ1ASs6lTTjZ5xt X-Proofpoint-GUID: FVqF75_czQd9DiAeaJToju48fGU_wdNy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-22_03,2022-04-22_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=907 spamscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204220059 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-+5TQTceV7kwkEleY1vza Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2022-04-22 at 15:28 +0200, Niklas Schnelle wrote: > While determining the next PCI function is factored out of > pci_scan_slot() into next_fn() the former still handles the first > function as a special case. This duplicates the code from the scan loop. >=20 > Furthermore the non ARI branch of next_fn() is generally hard to > understand and especially the check for multifunction devices is hidden > in the handling of NULL devices for non-contiguous multifunction. It > also signals that no further functions need to be scanned by returning > 0 via wraparound and this is a valid function number. >=20 > Improve upon this by transforming the conditions in next_fn() to be > easier to understand. >=20 > By changing next_fn() to return -ENODEV instead of 0 when there is no > next function we can then handle the initial function inside the loop > and deduplicate the shared handling. This also makes it more explicit > that only function 0 must exist. >=20 > No functional change is intended. >=20 > Cc: Jan Kiszka > Signed-off-by: Niklas Schnelle > --- > drivers/pci/probe.c | 39 ++++++++++++++++++++------------------- > 1 file changed, 20 insertions(+), 19 deletions(-) >=20 > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 17a969942d37..2000e9858f12 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -2579,8 +2579,7 @@ struct pci_dev *pci_scan_single_device(struct pci_b= us *bus, int devfn) > } > EXPORT_SYMBOL(pci_scan_single_device); > =20 > -static unsigned int next_fn(struct pci_bus *bus, struct pci_dev *dev, > - unsigned int fn) > +static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn) > { > int pos; > u16 cap =3D 0; > @@ -2588,24 +2587,27 @@ static unsigned int next_fn(struct pci_bus *bus, = struct pci_dev *dev, > =20 > if (pci_ari_enabled(bus)) { > if (!dev) > - return 0; > + return -ENODEV; > + >=20 Sorry the whitespace damage was of course not intended, fixed locally. --=-+5TQTceV7kwkEleY1vza Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSiikNOrnCUNbxSj4j7H22hwInkVgUCYmKvCwAKCRD7H22hwInk VuHsAP4kfYFxmlqA+DTbxpABv2slW9y+gv3ZVfhol3ARhACQTAEA7eHZ1cfNp120 EPzOHKOZgvgB4WoqBZ3lks5BKp7bhQg= =esXt -----END PGP SIGNATURE----- --=-+5TQTceV7kwkEleY1vza--