diff options
author | mdodd <mdodd@FreeBSD.org> | 1999-07-29 01:03:04 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 1999-07-29 01:03:04 +0000 |
commit | 1b3328c30076a4872fb76549719ee41c4f633e6a (patch) | |
tree | 08fbd565ea1bf201e2bfcfcd2a4119c82ef665a7 /sys/kern/subr_bus.c | |
parent | 0d84c8efb0a2e4b063d0c818f89eb17ee4bc6e47 (diff) | |
download | FreeBSD-src-1b3328c30076a4872fb76549719ee41c4f633e6a.zip FreeBSD-src-1b3328c30076a4872fb76549719ee41c4f633e6a.tar.gz |
Alter the behavior of sys/kern/subr_bus.c:device_print_child()
- device_print_child() either lets the BUS_PRINT_CHILD
method produce the entire device announcement message or
it prints "foo0: not found\n"
Alter sys/kern/subr_bus.c:bus_generic_print_child() to take on
the previous behavior of device_print_child() (printing the
"foo0: <FooDevice 1.1>" bit of the announce message.)
Provide bus_print_child_header() and bus_print_child_footer()
to actually print the output for bus_generic_print_child().
These functions should be used whenever possible (unless you can
just use bus_generic_print_child())
The BUS_PRINT_CHILD method now returns int instead of void.
Modify everything else that defines or uses a BUS_PRINT_CHILD
method to comply with the above changes.
- Devices are 'on' a bus, not 'at' it.
- If a custom BUS_PRINT_CHILD method does the same thing
as bus_generic_print_child(), use bus_generic_print_child()
- Use device_get_nameunit() instead of both
device_get_name() and device_get_unit()
- All BUS_PRINT_CHILD methods return the number of
characters output.
Reviewed by: dfr, peter
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 526b402..3ddb950 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: subr_bus.c,v 1.30 1999/07/11 13:42:37 dfr Exp $ + * $Id: subr_bus.c,v 1.31 1999/07/24 09:34:12 dfr Exp $ */ #include <sys/param.h> @@ -625,17 +625,17 @@ make_device(device_t parent, const char *name, return dev; } -static void +static int device_print_child(device_t dev, device_t child) { - printf("%s%d", device_get_name(child), device_get_unit(child)); + int retval = 0; + if (device_is_alive(child)) { - if (device_get_desc(child)) - printf(": <%s>", device_get_desc(child)); - BUS_PRINT_CHILD(dev, child); + retval += BUS_PRINT_CHILD(dev, child); } else - printf(" not found"); - printf("\n"); + retval += device_printf(child, " not found\n"); + + return (retval); } device_t @@ -1857,10 +1857,36 @@ bus_generic_resume(device_t dev) return 0; } -void +int +bus_print_child_header (device_t dev, device_t child) +{ + int retval = 0; + + if (device_get_desc(child)) { + retval += device_printf(child, "<%s>", + device_get_desc(child)); + } else { + retval += printf("%s", device_get_nameunit(child)) + } + + return (retval); +} + +int +bus_print_child_footer (device_t dev, device_t child) +{ + return(printf(" on %s\n", device_get_nameunit(dev))); +} + +int bus_generic_print_child(device_t dev, device_t child) { - printf(" on %s%d", device_get_name(dev), device_get_unit(dev)); + int retval = 0; + + retval += bus_print_child_header(dev, child); + retval += bus_print_child_footer(dev, child); + + return (retval); } int @@ -2020,9 +2046,10 @@ bus_teardown_intr(device_t dev, struct resource *r, void *cookie) return (BUS_TEARDOWN_INTR(dev->parent, dev, r, cookie)); } -static void +static int root_print_child(device_t dev, device_t child) { + return (0); } static int |