Commit 36a8572e authored by Mitchell Horne's avatar Mitchell Horne
Browse files

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
parent 8757d0fc
......@@ -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),
......
......@@ -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
......
......@@ -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
......
......@@ -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),
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment