From nobody Mon Feb 9 12:37:29 2026 Received: from pv50p00im-ztdg10022001.me.com (pv50p00im-ztdg10022001.me.com [17.58.6.58]) (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 C91D11DA0F5 for ; Wed, 4 Sep 2024 12:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.58 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454649; cv=none; b=dzemU1wY8PGZSMIVXp7MPDHsCeMjJCuVccSiq9Maqy84L1K6Dhfk3D6fYZIxDaDiJ27UkxZnvprSbT02kp5j1w4vJEl1692KrcqTMgrH/kymGs9M0zrD966tgubSUnuWNRhJBeHu5v5I7JIx4o0i+aAfkQ6b1a458g+c2Apv4/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454649; c=relaxed/simple; bh=ZEg2jAnsQ/Fo5b8FKY3/N90ULjhnrmM1sqPGIRzc6P4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c6rTde2rNxEAlsxbw8/JJpUm3X7mf+lqbRHIL8/7tlxBBD77tdEEaDexupKAvNJX6gAzCIvZpNrSTNMlWohELad5Cy5OlJq2bbqrIkCy3mfDa6zeMaQamaR75QnCMis2Ujkxz8Ky/tWlRfGN9wXTbqzuNhihTU0hkTkzBYZ6qkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=toputa6n; arc=none smtp.client-ip=17.58.6.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="toputa6n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725454647; bh=rX8dwEmhgju52/+PCj7lxlcgxu0hlSH5RuwIYsL1waE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=toputa6nimElw1oFag56SBL4AKV76uu+IZeWVYufs2lIwvjYT2T0iiqy8n4Lmp/vz SC6FcYsd3aYiRFaOnRJT/oX7WanC+H2o+xQouLqcjoD1yKSpF6qjFyjMQgrINmG5iF ASe+/006zQ93tQrm2jllKCBBUT6B+DjHV1bJ139Zp9a7tR6uFAi+nVKGSXCHSYhSuO TfkTpt+mUmGHSOHc8UQcNXwQRxZDDie1SmE/rMtj1rQD8JC8zFWueclssW7MXB1QXI wPJOIVxDbZvD55+h9loHBD/SQOqaicSW1hzxMk+VNaeKIcX2msgS/nBccdC/SjjyCi 0rTkqPcfdBTkQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10022001.me.com (Postfix) with ESMTPSA id 8D84B3E1BCE; Wed, 4 Sep 2024 12:57:21 +0000 (UTC) From: Zijun Hu Date: Wed, 04 Sep 2024 20:56:42 +0800 Subject: [PATCH 1/3] driver core: Mark impossible return values of bus_type's match() with unlikely() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240904-bus_match_unlikely-v1-1-122318285261@quicinc.com> References: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> In-Reply-To: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: bpzyUHiC-Subvd0QIw1TE-LCkq-8udJp X-Proofpoint-GUID: bpzyUHiC-Subvd0QIw1TE-LCkq-8udJp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_10,2024-09-04_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409040098 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Bus_type's match() should return bool type compatible integer 0 or 1 ideally since its main operations are lookup and comparison normally actually, this rule is followed by ALL bus_types but @amba_bustype within current v6.10 kernel tree, for @amba_bustype, ONLY extra -EPROBE_DEFER may be returned, so mark those impossible or rare return values with unlikely() to help readers understand device and driver binding logic. Signed-off-by: Zijun Hu --- drivers/base/dd.c | 16 ++++++++++++---- include/linux/device/bus.h | 9 ++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9b745ba54de1..288e19c9854b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -928,7 +928,11 @@ static int __device_attach_driver(struct device_driver= *drv, void *_data) if (ret =3D=3D 0) { /* no match */ return 0; - } else if (ret =3D=3D -EPROBE_DEFER) { + } else if (unlikely(ret =3D=3D -EPROBE_DEFER)) { + /* + * Only match() of @amba_bustype may return this error + * in current v6.10 tree, so also give unlikely() here. + */ dev_dbg(dev, "Device match requests probe deferral\n"); dev->can_match =3D true; driver_deferred_probe_add(dev); @@ -937,7 +941,7 @@ static int __device_attach_driver(struct device_driver = *drv, void *_data) * to match or bind with other drivers on the bus. */ return ret; - } else if (ret < 0) { + } else if (unlikely(ret < 0)) { dev_dbg(dev, "Bus failed to match device: %d\n", ret); return ret; } /* ret > 0 means positive match */ @@ -1172,7 +1176,11 @@ static int __driver_attach(struct device *dev, void = *data) if (ret =3D=3D 0) { /* no match */ return 0; - } else if (ret =3D=3D -EPROBE_DEFER) { + } else if (unlikely(ret =3D=3D -EPROBE_DEFER)) { + /* + * Only match() of @amba_bustype may return this error + * in current v6.10 tree, so also give unlikely() here. + */ dev_dbg(dev, "Device match requests probe deferral\n"); dev->can_match =3D true; driver_deferred_probe_add(dev); @@ -1181,7 +1189,7 @@ static int __driver_attach(struct device *dev, void *= data) * another device on the bus. */ return 0; - } else if (ret < 0) { + } else if (unlikely(ret < 0)) { dev_dbg(dev, "Bus failed to match device: %d\n", ret); /* * Driver could not match with device, but may match with diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h index 807831d6bf0f..1766b555da11 100644 --- a/include/linux/device/bus.h +++ b/include/linux/device/bus.h @@ -29,12 +29,11 @@ struct fwnode_handle; * @bus_groups: Default attributes of the bus. * @dev_groups: Default attributes of the devices on the bus. * @drv_groups: Default attributes of the device drivers on the bus. - * @match: Called, perhaps multiple times, whenever a new device or driver - * is added for this bus. It should return a positive value if the + * @match: Called, perhaps multiple times, whenever a new device or + * driver is added for this bus. It should return one if the * given device can be handled by the given driver and zero - * otherwise. It may also return error code if determining that - * the driver supports the device is not possible. In case of - * -EPROBE_DEFER it will queue the device for deferred probing. + * otherwise. It may also return -EPROBE_DEFER to queue the + * device for deferred probing. * @uevent: Called when a device is added, removed, or a few other things * that generate uevents to add the environment variables. * @probe: Called when a new device or driver add to this bus, and callback --=20 2.34.1 From nobody Mon Feb 9 12:37:29 2026 Received: from pv50p00im-ztdg10022001.me.com (pv50p00im-ztdg10022001.me.com [17.58.6.58]) (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 138201DA10C for ; Wed, 4 Sep 2024 12:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.58 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454655; cv=none; b=WkqcuqpApciXPJojFuNQPDOrqtlFR+FvOip8D9whEauB3sRtNJclx1dGAqB6RL2NdRQVJosYI05036+Eaam5OY/u6wRfa1mF3b1eX15MPuthBr83NzxP2/+XzojH/4MpDU0Fo2AzhyCfcY/tSNBXve2YQ5HNc/N1rO8TQQeXWwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454655; c=relaxed/simple; bh=X0mSMn30a3AM9Vuk9D3MfNP4x92YRiSgqmkv64Gh6VU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JUWiww01FDuatlgxybvkl2wAFYZ/HaigG4Oqel/Dnmvhh25TKFlT9025iV0cTxK/aiXjvkOIAZ211Eao6edRqPDCVyjgyuyzTkJHfA4Z18OwFE+lvcUgJZliC4VcQwEaEJrbdxmX8ld/eGYExPtY2UYwSU2ADpLbPV6YXMh+Ty0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=jQTP63Pp; arc=none smtp.client-ip=17.58.6.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="jQTP63Pp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725454653; bh=eUzdIGebnt7Wgvw4BOsrdf+21i++2ln1njvI6A+j+cM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=jQTP63PpYJajkbwhceGWbWdwEN3IKGl/vzCu5cEDp/tq8E9UHy6OluL0famQl4wil viIqAIXDww3JtedOrfCKadO0W6eQqj9f4q7BmEFsN6Bn0g2CBxx1kyNlB13Z9KX6HY PAWMca40bn0yhQw5wEX5N2bRiX4wmW/pgDYU5DqujLXlgyolfzLI5W9/c8cbOjur9D w/obtbYDlk5ONGvuDPp2A7LmB5J/2xtvSZFdC5M8y+unbHGq47Eynpg5jPX1EHf2OL ow/t54iAGgEIBe1oAQRVR6hq8+t9d7DjLjBa2Ea/z5KhImVfp5Ciam0KgpslfMyupJ Y79KkFs9IT7uQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10022001.me.com (Postfix) with ESMTPSA id 29B183E215E; Wed, 4 Sep 2024 12:57:27 +0000 (UTC) From: Zijun Hu Date: Wed, 04 Sep 2024 20:56:43 +0800 Subject: [PATCH 2/3] driver core: bus: Give error prompt for storing bus attribute drivers_probe failure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240904-bus_match_unlikely-v1-2-122318285261@quicinc.com> References: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> In-Reply-To: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: kjP1pUwr3kXEt5sgKnW6CaTL9I4SwQMA X-Proofpoint-GUID: kjP1pUwr3kXEt5sgKnW6CaTL9I4SwQMA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_10,2024-09-04_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=911 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409040098 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu drivers_probe_store() regards bus_rescan_devices_helper()'s returned value 0 as success when scan drivers for a single device user specify that is wrong since the following 3 failed cases also return 0: (1) the device is dead (2) bus has no driver which match() the device (3) bus fails to probe() the device with any its driver Solved by giving error prompt via dev_err() for above failed cases. Signed-off-by: Zijun Hu --- drivers/base/bus.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index abf090ace833..6b5ea82a44c1 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -40,6 +40,24 @@ static struct kset *bus_kset; struct driver_attribute driver_attr_##_name =3D \ __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) =20 +/* + * Bus scans drivers for a single device, and derives from + * bus_rescan_devices_helper(), but returns scanning result + * as precise as possible. + */ +static int __must_check bus_rescan_single_device(struct device *dev) +{ + int ret; + + if (dev->parent && dev->bus->need_parent_lock) + device_lock(dev->parent); + ret =3D device_attach(dev); + if (dev->parent && dev->bus->need_parent_lock) + device_unlock(dev->parent); + + return ret; +} + static int __must_check bus_rescan_devices_helper(struct device *dev, void *data); =20 @@ -311,12 +329,25 @@ static ssize_t drivers_probe_store(const struct bus_t= ype *bus, { struct device *dev; int err =3D -EINVAL; + int res; =20 dev =3D bus_find_device_by_name(bus, NULL, buf); if (!dev) return -ENODEV; - if (bus_rescan_devices_helper(dev, NULL) =3D=3D 0) + + res =3D bus_rescan_single_device(dev); + if (res < 0) { + /* Propagate error code upwards as precise as possible */ + err =3D res; + } else if (res > 0) { err =3D count; + } else { + /* Which error code to return for this case ? */ + dev_err(dev, "device '%s' fails to attach a driver\n", + dev_name(dev)); + err =3D count; + } + put_device(dev); return err; } --=20 2.34.1 From nobody Mon Feb 9 12:37:29 2026 Received: from pv50p00im-ztdg10022001.me.com (pv50p00im-ztdg10022001.me.com [17.58.6.58]) (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 A9F911D9D99 for ; Wed, 4 Sep 2024 12:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.58 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454661; cv=none; b=pYfkxr/Kzdj2HvGs+NP0hsjh6PCxGsvZQ+eUzzbJBJHJ2GvYSUiQCG73FIBro4U+VyOq8yZRAPQMEVpl5OQFxsyiA/mcWZPWm2J50J3Oc7GGtJ3L9QAd3Di5tNRVgAgfMBVy4UDGALynAkT1hXjCXlr3J62fV6DVvL+ax6ApcRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725454661; c=relaxed/simple; bh=fzj/oclTmnCHB3hbiGEklL8+S9AfRLTq+SRiNp9ZtQI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J7J7QZbaa5X/VgeKSwYcqs28Yj5TMVuWP9uayJgLMMWGpbT3JhN5HRmcfHAI4+jhaVVosYXkOpvYOsJQlb3gNa+cKcUn9WMT1TjwvD8qm4l4gTFkFOrOJIqNmIgsHPKpgBqY9Utjl1kyzJrQJ1tDUHwCAQ30+VAlP+b5gxozyP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=BJH1Gwvd; arc=none smtp.client-ip=17.58.6.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="BJH1Gwvd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1725454659; bh=idcU0ReTbtAFWE8j/+dTR9RAS+21qVyWNpl+uT4Ko4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=BJH1Gwvd0VetAtEkyuSPfMfWvQD4c48kwYIku7uDj4paoJRSEVvUjG3n4YbUEmCAc 4I+OHCa64xGyxdwIX1Kt4XFmxRgwQ8SmSD2SCLr3GN2H1F10xpLrHhtDU0CKptRio9 nBN7FcZ1l0DqanZUZoK/Qgqqsqyr8LBp+ycIbgfV6mf9E/9I4ehkJbg3vA3mb9dAwv y6kqlGZhIe9Y52FJ6CGFMPlJmCJMhmWCYcmuLXiUwaUCMejG9jiEAMYX/FbVRdvyI9 jyBk+Mq9wBVfjUjlM5Qrad+F0G+W87rTuQBgKUnrxw0zYiZHApI5oKy4LsxV2VqAhZ q5qtqGSLX1+bg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10022001.me.com (Postfix) with ESMTPSA id 6C7353E217F; Wed, 4 Sep 2024 12:57:33 +0000 (UTC) From: Zijun Hu Date: Wed, 04 Sep 2024 20:56:44 +0800 Subject: [PATCH 3/3] driver core: bus: Correct API bus_rescan_devices() behavior Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240904-bus_match_unlikely-v1-3-122318285261@quicinc.com> References: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> In-Reply-To: <20240904-bus_match_unlikely-v1-0-122318285261@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Zijun Hu , linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: C6QhOV54FmcYX6wKBFioCQXDjr5uthgS X-Proofpoint-GUID: C6QhOV54FmcYX6wKBFioCQXDjr5uthgS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_10,2024-09-04_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2409040098 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu API bus_rescan_devices() should ideally scan drivers for a bus's devices as many as possible, but it really stops scanning for remaining devices even if a device encounters inconsequential errors such as -EPROBE_DEFER and -ENODEV, fixed by ignoring such inconsequential errors during scanning. By the way, Neither the API's return value nor device_reprobe()'s existing logic are changed. Signed-off-by: Zijun Hu --- drivers/base/bus.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 6b5ea82a44c1..31d9d5d08934 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -58,9 +58,6 @@ static int __must_check bus_rescan_single_device(struct d= evice *dev) return ret; } =20 -static int __must_check bus_rescan_devices_helper(struct device *dev, - void *data); - /** * bus_to_subsys - Turn a struct bus_type into a struct subsys_private * @@ -790,15 +787,18 @@ static int __must_check bus_rescan_devices_helper(str= uct device *dev, void *data) { int ret =3D 0; + int *first_error =3D data; =20 - if (!dev->driver) { - if (dev->parent && dev->bus->need_parent_lock) - device_lock(dev->parent); - ret =3D device_attach(dev); - if (dev->parent && dev->bus->need_parent_lock) - device_unlock(dev->parent); - } - return ret < 0 ? ret : 0; + ret =3D bus_rescan_single_device(dev); + + if (ret >=3D 0) + return 0; + if (!*first_error) + *first_error =3D ret; + /* Ignore these errors to scan drivers for next device */ + if (ret =3D=3D -EPROBE_DEFER || ret =3D=3D -ENODEV) + return 0; + return ret; } =20 /** @@ -811,7 +811,10 @@ static int __must_check bus_rescan_devices_helper(stru= ct device *dev, */ int bus_rescan_devices(const struct bus_type *bus) { - return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); + int err =3D 0; + + bus_for_each_dev(bus, NULL, &err, bus_rescan_devices_helper); + return err; } EXPORT_SYMBOL_GPL(bus_rescan_devices); =20 @@ -826,9 +829,13 @@ EXPORT_SYMBOL_GPL(bus_rescan_devices); */ int device_reprobe(struct device *dev) { + int ret; + if (dev->driver) device_driver_detach(dev); - return bus_rescan_devices_helper(dev, NULL); + + ret =3D bus_rescan_single_device(dev); + return ret < 0 ? ret : 0; } EXPORT_SYMBOL_GPL(device_reprobe); =20 --=20 2.34.1