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/dev/iicbus | |
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/dev/iicbus')
-rw-r--r-- | sys/dev/iicbus/iicbb.c | 19 | ||||
-rw-r--r-- | sys/dev/iicbus/iicbus.c | 20 | ||||
-rw-r--r-- | sys/dev/iicbus/iicsmb.c | 13 |
3 files changed, 23 insertions, 29 deletions
diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index 1502ca4..df46c1a 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iicbb.c,v 1.3 1999/01/28 15:50:24 roger Exp $ + * $Id: iicbb.c,v 1.4 1999/05/08 21:59:04 dfr Exp $ * */ @@ -70,7 +70,7 @@ struct iicbb_softc { static int iicbb_probe(device_t); static int iicbb_attach(device_t); -static void iicbb_print_child(device_t, device_t); +static int iicbb_print_child(device_t, device_t); static int iicbb_callback(device_t, int, caddr_t); static int iicbb_start(device_t, u_char, int); @@ -119,27 +119,28 @@ static int iicbb_attach(device_t dev) return (0); } -static void +static int iicbb_print_child(device_t bus, device_t dev) { int error; + int retval = 0; u_char oldaddr; + retval += bus_print_child_header(bus, dev); /* retrieve the interface I2C address */ error = IICBB_RESET(device_get_parent(bus), IIC_FASTEST, 0, &oldaddr); if (error == IIC_ENOADDR) { - printf(" on %s%d master-only", device_get_name(bus), - device_get_unit(bus)); - + retval += printf(" on %s master-only\n", + device_get_nameunit(bus)); } else { /* restore the address */ IICBB_RESET(device_get_parent(bus), IIC_FASTEST, oldaddr, NULL); - printf(" on %s%d addr 0x%x", device_get_name(bus), - device_get_unit(bus), oldaddr & 0xff); + retval += printf(" on %s addr 0x%x\n", + device_get_nameunit(bus), oldaddr & 0xff); } - return; + return (retval); } #define I2C_SET(dev,ctrl,data) \ diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c index 50e1dd1..e97cbfb 100644 --- a/sys/dev/iicbus/iicbus.c +++ b/sys/dev/iicbus/iicbus.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iicbus.c,v 1.8 1999/04/11 02:55:52 eivind Exp $ + * $Id: iicbus.c,v 1.9 1999/05/08 21:59:04 dfr Exp $ * */ @@ -92,7 +92,7 @@ static devclass_t iicbus_devclass; */ static int iicbus_probe(device_t); static int iicbus_attach(device_t); -static void iicbus_print_child(device_t, device_t); +static int iicbus_print_child(device_t, device_t); static int iicbus_read_ivar(device_t , device_t, int, u_long *); static int iicbus_write_ivar(device_t , device_t, int, u_long); @@ -231,27 +231,29 @@ iicbus_null_repeated_start(device_t dev, u_char addr) return (IIC_ENOTSUPP); } -static void +static int iicbus_print_child(device_t bus, device_t dev) { struct iicbus_device* iicdev = DEVTOIICBUS(dev); + int retval = 0; + + retval += bus_print_child_header(bus, dev); switch (iicdev->iicd_class) { case IICBUS_DEVICE_CLASS: - printf(" on %s%d addr 0x%x", device_get_name(bus), - device_get_unit(bus), iicdev->iicd_addr); + retval += printf(" on %s addr 0x%x\n", + device_get_nameunit(bus), iicdev->iicd_addr); break; case IICBUS_DRIVER_CLASS: - printf(" on %s%d", device_get_name(bus), - device_get_unit(bus)); + retval += bus_print_child_footer(bus, dev); break; default: - panic("%s: unknown class!", __FUNCTION__); + panic("%s: unknown class!\n", __FUNCTION__); } - return; + return (retval); } static int diff --git a/sys/dev/iicbus/iicsmb.c b/sys/dev/iicbus/iicsmb.c index 4319ca0..4cea0b5 100644 --- a/sys/dev/iicbus/iicsmb.c +++ b/sys/dev/iicbus/iicsmb.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iicsmb.c,v 1.2 1998/10/31 11:31:07 nsouch Exp $ + * $Id: iicsmb.c,v 1.3 1999/05/08 21:59:05 dfr Exp $ * */ @@ -83,7 +83,6 @@ struct iicsmb_softc { static int iicsmb_probe(device_t); static int iicsmb_attach(device_t); -static void iicsmb_print_child(device_t, device_t); static void iicsmb_intr(device_t dev, int event, char *buf); static int iicsmb_callback(device_t dev, int index, caddr_t data); @@ -106,7 +105,7 @@ static device_method_t iicsmb_methods[] = { DEVMETHOD(device_attach, iicsmb_attach), /* bus interface */ - DEVMETHOD(bus_print_child, iicsmb_print_child), + DEVMETHOD(bus_print_child, bus_generic_print_child), /* iicbus interface */ DEVMETHOD(iicbus_intr, iicsmb_intr), @@ -157,14 +156,6 @@ iicsmb_attach(device_t dev) return (0); } -static void -iicsmb_print_child(device_t bus, device_t dev) -{ - printf(" on %s%d", device_get_name(bus), device_get_unit(bus)); - - return; -} - /* * iicsmb_intr() * |