Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb convert to USBHIST style debugging.
details: https://anonhg.NetBSD.org/src/rev/9a2109c5fb84
branches: trunk
changeset: 841284:9a2109c5fb84
user: mrg <mrg%NetBSD.org@localhost>
date: Tue May 07 05:17:22 2019 +0000
description:
convert to USBHIST style debugging.
diffstat:
sys/dev/usb/uplcom.c | 143 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 96 insertions(+), 47 deletions(-)
diffs (truncated from 382 to 300 lines):
diff -r 63c02d3dd95a -r 9a2109c5fb84 sys/dev/usb/uplcom.c
--- a/sys/dev/usb/uplcom.c Tue May 07 05:06:42 2019 +0000
+++ b/sys/dev/usb/uplcom.c Tue May 07 05:17:22 2019 +0000
@@ -1,4 +1,5 @@
-/* $NetBSD: uplcom.c,v 1.82 2019/05/05 03:17:54 mrg Exp $ */
+/* $NetBSD: uplcom.c,v 1.83 2019/05/07 05:17:22 mrg Exp $ */
+
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -34,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.82 2019/05/05 03:17:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.83 2019/05/07 05:17:22 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -52,6 +53,7 @@
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/poll.h>
+#include <sys/sysctl.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbcdc.h>
@@ -60,16 +62,51 @@
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
+#include <dev/usb/usbhist.h>
#include <dev/usb/ucomvar.h>
-#ifdef UPLCOM_DEBUG
-#define DPRINTFN(n, x) if (uplcomdebug > (n)) printf x
-int uplcomdebug = 0;
+#ifdef USB_DEBUG
+#ifndef UPLCOM_DEBUG
+#define uplcomdebug 0
#else
-#define DPRINTFN(n, x)
-#endif
-#define DPRINTF(x) DPRINTFN(0, x)
+int uplcomdebug = 0;
+
+SYSCTL_SETUP(sysctl_hw_uplcom_setup, "sysctl hw.uplcom setup")
+{
+ int err;
+ const struct sysctlnode *rnode;
+ const struct sysctlnode *cnode;
+
+ err = sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "uplcom",
+ SYSCTL_DESCR("uplcom global controls"),
+ NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+ if (err)
+ goto fail;
+
+ /* control debugging printfs */
+ err = sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ "debug", SYSCTL_DESCR("Enable debugging output"),
+ NULL, 0, &uplcomdebug, sizeof(uplcomdebug), CTL_CREATE, CTL_EOL);
+ if (err)
+ goto fail;
+
+ return;
+fail:
+ aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* UCOM_DEBUG */
+#endif /* USB_DEBUG */
+
+
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(uplcomdebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(uplcomdebug,N,FMT,A,B,C,D)
+#define UPLCOMHIST_FUNC() USBHIST_FUNC()
+#define UPLCOMHIST_CALLED(name) USBHIST_CALLED(uplcomdebug)
#define UPLCOM_CONFIG_INDEX 0
#define UPLCOM_IFACE_INDEX 0
@@ -232,6 +269,9 @@
int i;
struct ucom_attach_args ucaa;
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("sc=%p", sc, 0, 0, 0);
+
sc->sc_dev = self;
aprint_naive("\n");
@@ -243,8 +283,6 @@
sc->sc_udev = dev;
- DPRINTF(("\n\nuplcom attach: sc=%p\n", sc));
-
/* initialize endpoints */
ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1;
sc->sc_intr_number = -1;
@@ -268,9 +306,9 @@
#ifdef UPLCOM_DEBUG
/* print the chip type */
if (sc->sc_type == UPLCOM_TYPE_HX) {
- DPRINTF(("uplcom_attach: chiptype HX\n"));
+ DPRINTF("chiptype HX", 0, 0, 0, 0);
} else {
- DPRINTF(("uplcom_attach: chiptype 0\n"));
+ DPRINTF("chiptype 0", 0, 0, 0, 0);
}
#endif
@@ -414,8 +452,8 @@
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
- DPRINTF(("uplcom: in=0x%x out=0x%x intr=0x%x\n",
- ucaa.ucaa_bulkin, ucaa.ucaa_bulkout, sc->sc_intr_number ));
+ DPRINTF("in=0x%x out=0x%x intr=0x%x",
+ ucaa.ucaa_bulkin, ucaa.ucaa_bulkout, sc->sc_intr_number, 0);
sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &ucaa,
ucomprint, ucomsubmatch);
@@ -430,17 +468,20 @@
{
struct uplcom_softc *sc = device_private(self);
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+
KASSERT(sc->sc_subdev == child);
sc->sc_subdev = NULL;
}
-
+
int
uplcom_detach(device_t self, int flags)
{
struct uplcom_softc *sc = device_private(self);
int rv = 0;
- DPRINTF(("uplcom_detach: sc=%p flags=%d\n", sc, flags));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("sc=%p flags=%d", sc, flags, 0, 0);
if (sc->sc_intr_pipe != NULL) {
usbd_abort_pipe(sc->sc_intr_pipe);
@@ -599,7 +640,8 @@
uplcom_dtr(struct uplcom_softc *sc, int onoff)
{
- DPRINTF(("uplcom_dtr: onoff=%d\n", onoff));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("onoff=%d", onoff, 0, 0, 0);
if (sc->sc_dtr != -1 && !sc->sc_dtr == !onoff)
return;
@@ -612,7 +654,8 @@
void
uplcom_rts(struct uplcom_softc *sc, int onoff)
{
- DPRINTF(("uplcom_rts: onoff=%d\n", onoff));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("onoff=%d", onoff, 0, 0, 0);
if (sc->sc_rts != -1 && !sc->sc_rts == !onoff)
return;
@@ -627,7 +670,8 @@
{
usb_device_request_t req;
- DPRINTF(("uplcom_break: onoff=%d\n", onoff));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("onoff=%d", onoff, 0, 0, 0);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UCDC_SEND_BREAK;
@@ -644,7 +688,7 @@
usb_device_request_t req;
usbd_status err;
- DPRINTF(("uplcom_set_crtscts: on\n"));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = UPLCOM_SET_REQUEST;
@@ -657,8 +701,7 @@
err = usbd_do_request(sc->sc_udev, &req, 0);
if (err) {
- DPRINTF(("uplcom_set_crtscts: failed, err=%s\n",
- usbd_errstr(err)));
+ DPRINTF("failed, err=%d", err, 0, 0, 0);
return err;
}
@@ -671,12 +714,14 @@
usb_device_request_t req;
usbd_status err;
- DPRINTF(("uplcom_set_line_coding: rate=%d fmt=%d parity=%d bits=%d\n",
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+
+ DPRINTF("rate=%d fmt=%d parity=%d bits=%d",
UGETDW(state->dwDTERate), state->bCharFormat,
- state->bParityType, state->bDataBits));
+ state->bParityType, state->bDataBits);
if (memcmp(state, &sc->sc_line_state, UCDC_LINE_STATE_LENGTH) == 0) {
- DPRINTF(("uplcom_set_line_coding: already set\n"));
+ DPRINTF("already set", 0, 0, 0, 0);
return USBD_NORMAL_COMPLETION;
}
@@ -688,8 +733,7 @@
err = usbd_do_request(sc->sc_udev, &req, state);
if (err) {
- DPRINTF(("uplcom_set_line_coding: failed, err=%s\n",
- usbd_errstr(err)));
+ DPRINTF("failed, err=%u", err, 0, 0, 0);
return err;
}
@@ -705,7 +749,8 @@
usbd_status err;
usb_cdc_line_state_t ls;
- DPRINTF(("uplcom_param: sc=%p\n", sc));
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("sc=%p", sc, 0, 0, 0);
USETDW(ls.dwDTERate, t->c_ospeed);
if (ISSET(t->c_cflag, CSTOPB))
@@ -736,7 +781,7 @@
err = uplcom_set_line_coding(sc, &ls);
if (err) {
- DPRINTF(("uplcom_param: err=%s\n", usbd_errstr(err)));
+ DPRINTF("err=%d", err, 0, 0, 0);
return EIO;
}
@@ -747,20 +792,22 @@
uplcom_set_line_state(sc);
if (err) {
- DPRINTF(("uplcom_param: err=%s\n", usbd_errstr(err)));
+ DPRINTF("err=%d", err, 0, 0, 0);
return EIO;
}
return 0;
}
-Static usbd_status
+usbd_status
uplcom_vendor_control_write(struct usbd_device *dev, uint16_t value,
uint16_t index)
{
usb_device_request_t req;
usbd_status err;
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = UPLCOM_SET_REQUEST;
USETW(req.wValue, value);
@@ -770,8 +817,7 @@
err = usbd_do_request(dev, &req, NULL);
if (err) {
- DPRINTF(("uplcom_open: vendor write failed, err=%s (%d)\n",
- usbd_errstr(err), err));
+ DPRINTF("vendor write failed, err=%d", err, 0, 0, 0);
}
return err;
@@ -782,12 +828,13 @@
{
struct uplcom_softc *sc = addr;
usbd_status err;
+
+ UPLCOMHIST_FUNC(); UPLCOMHIST_CALLED();
+ DPRINTF("sc=%p", sc, 0, 0, 0);
if (sc->sc_dying)
return EIO;
- DPRINTF(("uplcom_open: sc=%p\n", sc));
-
/* Some unknown device frobbing. */
if (sc->sc_type == UPLCOM_TYPE_HX)
uplcom_vendor_control_write(sc->sc_udev, 2, 0x44);
@@ -801,9 +848,8 @@
sc->sc_intr_buf, sc->sc_isize,
uplcom_intr, USBD_DEFAULT_INTERVAL);
Home |
Main Index |
Thread Index |
Old Index