From nobody Thu Jun 23 18:16:05 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AFC1A876904; Thu, 23 Jun 2022 18:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LTT2t21XHz3PNM; Thu, 23 Jun 2022 18:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656008166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9PyaZtBB0z/MiY0jp/039Y6kMVJ0Sbj3qZpRmgoUD9Y=; b=i7tKqIMJ0VOGWCuZeyXqbYUYpmMYFiD6Kpm95PqymP+n7ikf6HmB1AKSjvvJ2inhitQT/L oN8PBuILQv+jKIkHSR2gJWWKuIPENIfjMXeqLN2uzrdz9khk02CW1GTBhwH95BqpuVTu9O a9tWtB3N9N+1UxTcgQj7U2eWPajpGTtSGyBsCPJmdt66TFzcil4wWwGYATkn195H9a9EOq /RnZRs92/XiL33VQh5Y48FN2QCq44C2yiQfkcBwSksLOZoYfxPIdyTrOY4CBBtFSbtoQIo i9DhatPpdFzcSgyGu6RyVHU37d9SGD35VkJ19Do20D0UsPSTPPcQgSk2x9grNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B38AB200C4; Thu, 23 Jun 2022 18:16:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25NIG5IH014879; Thu, 23 Jun 2022 18:16:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25NIG5aL014878; Thu, 23 Jun 2022 18:16:05 GMT (envelope-from git) Date: Thu, 23 Jun 2022 18:16:05 GMT Message-Id: <202206231816.25NIG5aL014878@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 36a8572ee8f5 - main - bus_if: provide a default null rescan method List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36a8572ee8f5db7ecb64bedc5738a363ec7cad36 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656008166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9PyaZtBB0z/MiY0jp/039Y6kMVJ0Sbj3qZpRmgoUD9Y=; b=DbzkJDVT1WnxDZRc0eP9QxT78CMBazTjK3OZIVCnbYrM51gJUAGrQJMdUe4cg/aw+sb0AJ U5wUhL3a5Y3NYGJ2Uko4GRIMY9BRAa3/JyuS/Ad6YhCm74tdwWIKwbWNFwmCiAs7cXkllq vsx0VRxSgNOqNWp+2aQlcxoaMCMG/tDc/N3a+tBMu+ZditUBsJeEMPyOtJc14yExaUBN7p dpQVKVUa1fucjVYiZ3PwAvhmrKeFhwGkjXF71YrG2RgHKT6hd1yG9HAeBePOf8MXEW51+2 l6tuBnUIO/whCe2NH4KyHBrz0OUpuKWMhkfJGrdSObFgS8YXGbiOX0BWaSJizA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656008166; a=rsa-sha256; cv=none; b=W3se77+4kXv+Jk6c09MEq/V41N8EqFUzbn2TqB6kFFMJiqdCaR5/Swq7chXRlnwrX8xv4Z clc3l/w+yM8Hjoqd+O3MvAojypJGTiCuQv5YTk43PnryIcEp3n+6DWi2Jm7pvS914yrxdg IWiSAIvAfS/CoPO9258HzcnFhn8npZkIBnUyZOf7NOk/8weDoTI3EWXs8dFqQc5Cry6DsC 2/EWq+9KIj2BJ4c8PnC0S94H0S74kMYXnyLIomEPzPPf/CMMux9maqoci2EOd8kg8LLmyM zry709KfWAO1oEMVv3/nxXp3bagSeKo8410C5jWDuy14emTMJiNSArAu32Z2Yg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=36a8572ee8f5db7ecb64bedc5738a363ec7cad36 commit 36a8572ee8f5db7ecb64bedc5738a363ec7cad36 Author: Mitchell Horne AuthorDate: 2022-06-21 13:29:53 +0000 Commit: Mitchell Horne CommitDate: 2022-06-23 18:15:10 +0000 bus_if: provide a default null rescan method There is an existing helper method in subr_bus.c, but almost no drivers know to use it. It also returns the same error as an empty method, making it not very useful. Move this to bus_if.m and return a more sensible error code. This gives a slightly more meaningful error message when attempting 'devctl rescan' on buses and devices alike: "Device not configured" --> "Operation not supported by device" Reviewed by: imp MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35501 --- sys/dev/cardbus/cardbus.c | 1 - sys/kern/bus_if.m | 13 ++++++++++--- sys/kern/subr_bus.c | 13 ------------- sys/powerpc/ofw/ofw_pcibus.c | 1 - sys/sys/bus.h | 1 - 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index c28b1558f28e..d0661e0473be 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -351,7 +351,6 @@ static device_method_t cardbus_methods[] = { DEVMETHOD(bus_get_dma_tag, bus_generic_get_dma_tag), DEVMETHOD(bus_read_ivar, cardbus_read_ivar), DEVMETHOD(bus_driver_added, cardbus_driver_added), - DEVMETHOD(bus_rescan, bus_null_rescan), /* Card Interface */ DEVMETHOD(card_attach_card, cardbus_attach_card), diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 1e4102e52d29..9862f87aac64 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -67,16 +67,23 @@ CODE { panic("bus_add_child is not implemented"); } - static int null_reset_post(device_t bus, device_t dev) + static int + null_reset_post(device_t bus, device_t dev) { return (0); } - static int null_reset_prepare(device_t bus, device_t dev) + static int + null_reset_prepare(device_t bus, device_t dev) { return (0); } + static int + null_rescan(device_t dev) + { + return (ENODEV); + } }; /** @@ -253,7 +260,7 @@ METHOD device_t add_child { */ METHOD int rescan { device_t _dev; -} +} DEFAULT null_rescan; /** * @brief Allocate a system resource diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 3be468fd7c43..eeecd4b189a2 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -4708,19 +4708,6 @@ bus_generic_get_device_path(device_t bus, device_t child, const char *locator, return (0); } - -/** - * @brief Helper function for implementing BUS_RESCAN(). - * - * This null implementation of BUS_RESCAN() always fails to indicate - * the bus does not support rescanning. - */ -int -bus_null_rescan(device_t dev) -{ - return (ENXIO); -} - /* * Some convenience functions to make it easier for drivers to use the * resource-management functions. All these really do is hide the diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c index c0e99817888b..202adf11d53b 100644 --- a/sys/powerpc/ofw/ofw_pcibus.c +++ b/sys/powerpc/ofw/ofw_pcibus.c @@ -81,7 +81,6 @@ static device_method_t ofw_pcibus_methods[] = { /* Bus interface */ DEVMETHOD(bus_child_deleted, ofw_pcibus_child_deleted), DEVMETHOD(bus_child_pnpinfo, ofw_pcibus_child_pnpinfo_method), - DEVMETHOD(bus_rescan, bus_null_rescan), DEVMETHOD(bus_get_cpus, ofw_pcibus_get_cpus), DEVMETHOD(bus_get_domain, ofw_pcibus_get_domain), diff --git a/sys/sys/bus.h b/sys/sys/bus.h index a1d11138a1cc..adb6a0ac57d4 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -513,7 +513,6 @@ int bus_generic_get_device_path(device_t bus, device_t child, const char *locato struct sbuf *sb); int bus_helper_reset_post(device_t dev, int flags); int bus_helper_reset_prepare(device_t dev, int flags); -int bus_null_rescan(device_t dev); /* * Wrapper functions for the BUS_*_RESOURCE methods to make client code