From c346925bbf5efc2746bea2a637a64a7ec62cf4ed Mon Sep 17 00:00:00 2001 From: imp Date: Mon, 11 Jun 2007 06:14:42 +0000 Subject: Prefer device_printf over printf. --- sys/dev/usb/uark.c | 23 ++++++++++------------ sys/dev/usb/ubsa.c | 56 +++++++++++++++++++++++------------------------------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/sys/dev/usb/uark.c b/sys/dev/usb/uark.c index fb6ea89..6deb557 100644 --- a/sys/dev/usb/uark.c +++ b/sys/dev/usb/uark.c @@ -131,28 +131,27 @@ USB_ATTACH(uark) usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; usbd_status error; - const char *devname; int i; struct ucom_softc *ucom = &sc->sc_ucom; ucom->sc_dev = self; ucom->sc_udev = dev; - devname = device_get_nameunit(ucom->sc_dev); - if (uaa->iface == NULL) { /* Move the device into the configured state. */ error = usbd_set_config_index(dev, UARK_CONFIG_INDEX, 1); if (error) { - printf("\n%s: failed to set configuration, err=%s\n", - devname, usbd_errstr(error)); + device_printf(ucom->sc_dev, + "failed to set configuration, err=%s\n", + usbd_errstr(error)); goto bad; } error = usbd_device2interface_handle(dev, UARK_IFACE_INDEX, &iface); if (error) { - printf("\n%s: failed to get interface, err=%s\n", - devname, usbd_errstr(error)); + device_printf(ucom->sc_dev, + "failed to get interface, err=%s\n", + usbd_errstr(error)); goto bad; } } else @@ -165,8 +164,8 @@ USB_ATTACH(uark) for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); if (ed == NULL) { - printf("%s: could not read endpoint descriptor\n", - devname); + device_printf(ucom->sc_dev, + "could not read endpoint descriptor\n"); goto bad; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && @@ -177,7 +176,7 @@ USB_ATTACH(uark) ucom->sc_bulkout_no = ed->bEndpointAddress; } if (ucom->sc_bulkin_no == -1 || ucom->sc_bulkout_no == -1) { - printf("%s: missing endpoint\n", devname); + device_printf(ucom->sc_dev, "missing endpoint\n"); goto bad; } ucom->sc_parent = sc; @@ -305,9 +304,7 @@ uark_break(void *vsc, int portno, int onoff) #ifdef UARK_DEBUG struct uark_softc *sc = vsc; - printf("%s: break %s!\n", device_get_nameunit(sc->sc_dev), - onoff ? "on" : "off"); - + device_printf(sc->sc_dev, "%s: break %s!\n", onoff ? "on" : "off"); if (onoff) /* break on */ uark_cmd(sc, 4, 0x01); diff --git a/sys/dev/usb/ubsa.c b/sys/dev/usb/ubsa.c index 58be7e4..12c5e8c 100644 --- a/sys/dev/usb/ubsa.c +++ b/sys/dev/usb/ubsa.c @@ -283,7 +283,6 @@ USB_ATTACH(ubsa) usb_config_descriptor_t *cdesc; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; - const char *devname; usbd_status err; int i; @@ -298,12 +297,9 @@ USB_ATTACH(ubsa) sc->sc_rts = -1; ucom->sc_dev = self; - ucom->sc_udev = dev; ucom->sc_iface = uaa->iface; - devname = device_get_nameunit(ucom->sc_dev); - DPRINTF(("ubsa attach: sc = %p\n", sc)); /* initialize endpoints */ @@ -314,8 +310,8 @@ USB_ATTACH(ubsa) /* Move the device into the configured state. */ err = usbd_set_config_index(dev, UBSA_CONFIG_INDEX, 1); if (err) { - printf("%s: failed to set configuration: %s\n", - devname, usbd_errstr(err)); + device_printf(ucom->sc_dev, "failed to set configuration: %s\n", + usbd_errstr(err)); ucom->sc_dying = 1; goto error; } @@ -324,8 +320,8 @@ USB_ATTACH(ubsa) cdesc = usbd_get_config_descriptor(ucom->sc_udev); if (cdesc == NULL) { - printf("%s: failed to get configuration descriptor\n", - device_get_nameunit(ucom->sc_dev)); + device_printf(ucom->sc_dev, + "failed to get configuration descriptor\n"); ucom->sc_dying = 1; goto error; } @@ -334,8 +330,8 @@ USB_ATTACH(ubsa) err = usbd_device2interface_handle(dev, UBSA_IFACE_INDEX, &ucom->sc_iface); if (err) { - printf("%s: failed to get interface: %s\n", - devname, usbd_errstr(err)); + device_printf(ucom->sc_dev, "failed to get interface: %s\n", + usbd_errstr(err)); ucom->sc_dying = 1; goto error; } @@ -348,8 +344,8 @@ USB_ATTACH(ubsa) for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(ucom->sc_iface, i); if (ed == NULL) { - printf("%s: no endpoint descriptor for %d\n", - device_get_nameunit(ucom->sc_dev), i); + device_printf(ucom->sc_dev, + "no endpoint descriptor for %d\n", i); ucom->sc_dying = 1; goto error; } @@ -370,8 +366,7 @@ USB_ATTACH(ubsa) } if (sc->sc_intr_number == -1) { - printf("%s: Could not find interrupt in\n", - device_get_nameunit(ucom->sc_dev)); + device_printf(ucom->sc_dev, "Could not find interrupt in\n"); ucom->sc_dying = 1; goto error; } @@ -380,15 +375,13 @@ USB_ATTACH(ubsa) sc->sc_intr_iface = ucom->sc_iface; if (ucom->sc_bulkin_no == -1) { - printf("%s: Could not find data bulk in\n", - device_get_nameunit(ucom->sc_dev)); + device_printf(ucom->sc_dev, "Could not find data bulk in\n"); ucom->sc_dying = 1; goto error; } if (ucom->sc_bulkout_no == -1) { - printf("%s: Could not find data bulk out\n", - device_get_nameunit(ucom->sc_dev)); + device_printf(ucom->sc_dev, "Could not find data bulk out\n"); ucom->sc_dying = 1; goto error; } @@ -449,8 +442,8 @@ ubsa_request(struct ubsa_softc *sc, u_int8_t request, u_int16_t value) err = usbd_do_request(sc->sc_ucom.sc_udev, &req, 0); if (err) - printf("%s: ubsa_request: %s\n", - device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err)); + device_printf(sc->sc_ucom.sc_dev, "ubsa_request: %s\n", + usbd_errstr(err)); return (err); } @@ -534,9 +527,8 @@ ubsa_baudrate(struct ubsa_softc *sc, speed_t speed) value = B230400 / speed; break; default: - printf("%s: ubsa_param: unsupported baudrate, " - "forcing default of 9600\n", - device_get_nameunit(sc->sc_ucom.sc_dev)); + device_printf(sc->sc_ucom.sc_dev, + "ubsa_param: unsupported baud, forcing default of 9600\n"); value = B230400 / B9600; break; }; @@ -577,9 +569,9 @@ ubsa_databits(struct ubsa_softc *sc, tcflag_t cflag) case CS7: value = 2; break; case CS8: value = 3; break; default: - printf("%s: ubsa_param: unsupported databits requested, " - "forcing default of 8\n", - device_get_nameunit(sc->sc_ucom.sc_dev)); + device_printf(sc->sc_ucom.sc_dev, + "ubsa_param: unsupported databits requested, " + "forcing default of 8\n"); value = 3; } @@ -656,8 +648,8 @@ ubsa_open(void *addr, int portno) ubsa_intr, UBSA_INTR_INTERVAL); if (err) { - printf("%s: cannot open interrupt pipe (addr %d)\n", - device_get_nameunit(sc->sc_ucom.sc_dev), + device_printf(sc->sc_ucom.sc_dev, + "cannot open interrupt pipe (addr %d)\n", sc->sc_intr_number); return (EIO); } @@ -681,13 +673,13 @@ ubsa_close(void *addr, int portno) if (sc->sc_intr_pipe != NULL) { err = usbd_abort_pipe(sc->sc_intr_pipe); if (err) - printf("%s: abort interrupt pipe failed: %s\n", - device_get_nameunit(sc->sc_ucom.sc_dev), + device_printf(sc->sc_ucom.sc_dev, + "abort interrupt pipe failed: %s\n", usbd_errstr(err)); err = usbd_close_pipe(sc->sc_intr_pipe); if (err) - printf("%s: close interrupt pipe failed: %s\n", - device_get_nameunit(sc->sc_ucom.sc_dev), + device_printf(sc->sc_ucom.sc_dev, + "close interrupt pipe failed: %s\n", usbd_errstr(err)); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; -- cgit v1.1