The branch main has been updated by mhorne:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=29afffb942b159511ad7d5ea5d086851f65ef4a0

commit 29afffb942b159511ad7d5ea5d086851f65ef4a0
Author:     Mitchell Horne <mho...@freebsd.org>
AuthorDate: 2022-06-23 18:44:28 +0000
Commit:     Mitchell Horne <mho...@freebsd.org>
CommitDate: 2022-06-23 19:07:00 +0000

    subr_bus: restore bus_null_rescan()
    
    Partially revert the previous change; we need to keep this method as a
    specific override for pci_driver subclasses which should not use
    pci_rescan_method() -- cardbus and ofw_pcibus. However, change the return
    value to ENODEV for the same reasoning given in the original commit, and
    use this as the default rescan method in bus_if.m.
    
    Reported by:    jhb
    Fixes:          36a8572ee8f5 ("bus_if: provide a default null rescan 
method")
    MFC with:       36a8572ee8f5
---
 sys/dev/cardbus/cardbus.c    |  1 +
 sys/kern/bus_if.m            |  8 +-------
 sys/kern/subr_bus.c          | 13 +++++++++++++
 sys/powerpc/ofw/ofw_pcibus.c |  1 +
 sys/sys/bus.h                |  1 +
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index d0661e0473be..c28b1558f28e 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -351,6 +351,7 @@ 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 9862f87aac64..6fc73a5732de 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -78,12 +78,6 @@ CODE {
        {
                return (0);
        }
-
-       static int
-       null_rescan(device_t dev)
-       {
-               return (ENODEV);
-       }
 };
 
 /**
@@ -260,7 +254,7 @@ METHOD device_t add_child {
  */
 METHOD int rescan {
        device_t _dev;
-} DEFAULT null_rescan;
+} DEFAULT bus_null_rescan;
 
 /**
  * @brief Allocate a system resource
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index eeecd4b189a2..78faa3a542eb 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -4708,6 +4708,19 @@ 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 (ENODEV);
+}
+
 /*
  * 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 202adf11d53b..c0e99817888b 100644
--- a/sys/powerpc/ofw/ofw_pcibus.c
+++ b/sys/powerpc/ofw/ofw_pcibus.c
@@ -81,6 +81,7 @@ 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 adb6a0ac57d4..a1d11138a1cc 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -513,6 +513,7 @@ 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

Reply via email to