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 debug printfs to usbhist.
details: https://anonhg.NetBSD.org/src/rev/d7fde94cbbd8
branches: trunk
changeset: 967005:d7fde94cbbd8
user: gson <gson%NetBSD.org@localhost>
date: Tue Nov 26 10:24:17 2019 +0000
description:
Convert debug printfs to usbhist.
diffstat:
sys/dev/usb/if_urtwn.c | 399 ++++++++++++++++++++++++------------------------
1 files changed, 198 insertions(+), 201 deletions(-)
diffs (truncated from 1216 to 300 lines):
diff -r eeeda478567b -r d7fde94cbbd8 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Tue Nov 26 08:38:19 2019 +0000
+++ b/sys/dev/usb/if_urtwn.c Tue Nov 26 10:24:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $ */
+/* $NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $ */
/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */
/*-
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.73 2019/10/10 23:30:02 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.74 2019/11/26 10:24:17 gson Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -73,6 +73,7 @@
#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdevs.h>
+#include <dev/usb/usbhist.h>
#include <dev/ic/rtwnreg.h>
#include <dev/ic/rtwn_data.h>
@@ -95,10 +96,27 @@
#define DBG_REG __BIT(6)
#define DBG_ALL 0xffffffffU
u_int urtwn_debug = 0;
-#define DPRINTFN(n, s) \
- do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
+#define DPRINTFN(n, fmt, a, b, c, d) do { \
+ if (urtwn_debug & (n)) { \
+ KERNHIST_LOG(usbhist, fmt, a, b, c, d); \
+ } \
+} while (/*CONSTCOND*/0)
+#define URTWNHIST_FUNC() USBHIST_FUNC()
+#define URTWNHIST_CALLED() do { \
+ if (urtwn_debug & DBG_FN) { \
+ KERNHIST_CALLED(usbhist); \
+ } \
+} while(/*CONSTCOND*/0)
+#define URTWNHIST_CALLARGS(fmt, a, b, c, d) do { \
+ if (urtwn_debug & DBG_FN) { \
+ KERNHIST_CALLARGS(usbhist, fmt, a, b, c, d); \
+ } \
+} while(/*CONSTCOND*/0)
#else
-#define DPRINTFN(n, s)
+#define DPRINTFN(n, fmt, a, b, c, d)
+#define URTWNHIST_FUNC()
+#define URTWNHIST_CALLED()
+#define URTWNHIST_CALLARGS(fmt, a, b, c, d)
#endif
#define URTWN_DEV(v,p) { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, 0 }
@@ -350,6 +368,8 @@
size_t i;
int error;
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
sc->sc_dev = self;
sc->sc_udev = uaa->uaa_device;
@@ -363,8 +383,6 @@
aprint_naive("\n");
aprint_normal("\n");
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
-
devinfop = usbd_devinfo_alloc(sc->sc_udev, 0);
aprint_normal_dev(self, "%s\n", devinfop);
usbd_devinfo_free(devinfop);
@@ -539,7 +557,7 @@
struct ifnet *ifp = &sc->sc_if;
int s;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
pmf_device_deregister(self);
@@ -589,7 +607,7 @@
{
struct urtwn_softc *sc = device_private(self);
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
switch (act) {
case DVACT_DEACTIVATE:
@@ -611,7 +629,7 @@
size_t i, ntx = 0, nrx = 0;
int error;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* Determine the number of bulk-out pipes. */
id = usbd_get_interface_descriptor(sc->sc_iface);
@@ -641,8 +659,8 @@
"%zd: invalid number of Tx bulk pipes\n", ntx);
return EIO;
}
- DPRINTFN(DBG_INIT, ("%s: %s: found %zd/%zd bulk-in/out pipes\n",
- device_xname(sc->sc_dev), __func__, nrx, ntx));
+ DPRINTFN(DBG_INIT, "found %jd/%jd bulk-in/out pipes",
+ nrx, ntx, 0, 0);
sc->rx_npipe = nrx;
sc->tx_npipe = ntx;
@@ -688,7 +706,7 @@
struct usbd_pipe *pipe;
size_t i;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* Close Rx pipes. */
CTASSERT(sizeof(pipe) == sizeof(void *));
@@ -715,7 +733,7 @@
size_t i;
int error = 0;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
for (size_t j = 0; j < sc->rx_npipe; j++) {
TAILQ_INIT(&sc->rx_free_list[j]);
@@ -747,7 +765,7 @@
struct usbd_xfer *xfer;
size_t i;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* NB: Caller must abort pipe first. */
for (size_t j = 0; j < sc->rx_npipe; j++) {
@@ -767,7 +785,7 @@
size_t i;
int error = 0;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
mutex_enter(&sc->sc_tx_mtx);
for (size_t j = 0; j < sc->tx_npipe; j++) {
@@ -808,7 +826,7 @@
struct usbd_xfer *xfer;
size_t i;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* NB: Caller must abort pipe first. */
for (size_t j = 0; j < sc->tx_npipe; j++) {
@@ -839,7 +857,7 @@
struct urtwn_host_cmd *cmd;
int s;
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
if (ic->ic_state == IEEE80211_S_RUN &&
(ic->ic_opmode == IEEE80211_M_HOSTAP ||
ic->ic_opmode == IEEE80211_M_IBSS)) {
@@ -887,8 +905,9 @@
struct urtwn_host_cmd *cmd;
int s;
- DPRINTFN(DBG_FN, ("%s: %s: cb=%p, arg=%p, len=%d\n",
- device_xname(sc->sc_dev), __func__, cb, arg, len));
+ URTWNHIST_FUNC();
+ URTWNHIST_CALLARGS("cb=%#jx, arg=%#jx, len=%jd",
+ (uintptr_t)cb, (uintptr_t)arg, len, 0);
s = splusb();
mutex_spin_enter(&sc->sc_task_mtx);
@@ -911,7 +930,7 @@
urtwn_wait_async(struct urtwn_softc *sc)
{
- DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* Wait for all queued asynchronous commands to complete. */
while (sc->cmdq.queued > 0)
@@ -925,6 +944,7 @@
usb_device_request_t req;
usbd_status error;
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
KASSERT(mutex_owned(&sc->sc_write_mtx));
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
@@ -934,8 +954,8 @@
USETW(req.wLength, len);
error = usbd_do_request(sc->sc_udev, &req, buf);
if (error != USBD_NORMAL_COMPLETION) {
- DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=0x%x, len=%d\n",
- device_xname(sc->sc_dev), __func__, error, addr, len));
+ DPRINTFN(DBG_REG, "error=%jd: addr=0x%jx, len=%jd",
+ error, addr, len, 0);
}
return error;
}
@@ -944,8 +964,8 @@
urtwn_write_1(struct urtwn_softc *sc, uint16_t addr, uint8_t val)
{
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, val=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, val));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+ DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0);
urtwn_write_region_1(sc, addr, &val, 1);
}
@@ -955,8 +975,8 @@
{
uint8_t buf[2];
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, val=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, val));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+ DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0);
buf[0] = (uint8_t)val;
buf[1] = (uint8_t)(val >> 8);
@@ -968,8 +988,8 @@
{
uint8_t buf[4];
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, val=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, val));
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+ DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0);
buf[0] = (uint8_t)val;
buf[1] = (uint8_t)(val >> 8);
@@ -982,8 +1002,8 @@
urtwn_write_region(struct urtwn_softc *sc, uint16_t addr, uint8_t *buf, int len)
{
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, len=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, len));
+ URTWNHIST_FUNC();
+ URTWNHIST_CALLARGS("addr=0x%jx, len=0x%jx", addr, len, 0, 0);
return urtwn_write_region_1(sc, addr, buf, len);
}
@@ -995,6 +1015,8 @@
usb_device_request_t req;
usbd_status error;
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
req.bmRequestType = UT_READ_VENDOR_DEVICE;
req.bRequest = R92C_REQ_REGS;
USETW(req.wValue, addr);
@@ -1002,8 +1024,8 @@
USETW(req.wLength, len);
error = usbd_do_request(sc->sc_udev, &req, buf);
if (error != USBD_NORMAL_COMPLETION) {
- DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=0x%x, len=%d\n",
- device_xname(sc->sc_dev), __func__, error, addr, len));
+ DPRINTFN(DBG_REG, "error=%jd: addr=0x%jx, len=%jd",
+ error, addr, len, 0);
}
return error;
}
@@ -1013,11 +1035,12 @@
{
uint8_t val;
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
if (urtwn_read_region_1(sc, addr, &val, 1) != USBD_NORMAL_COMPLETION)
return 0xff;
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, val=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, val));
+ DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0);
return val;
}
@@ -1027,12 +1050,13 @@
uint8_t buf[2];
uint16_t val;
+ URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
if (urtwn_read_region_1(sc, addr, buf, 2) != USBD_NORMAL_COMPLETION)
return 0xffff;
val = LE_READ_2(&buf[0]);
- DPRINTFN(DBG_REG, ("%s: %s: addr=0x%x, val=0x%x\n",
- device_xname(sc->sc_dev), __func__, addr, val));
+ DPRINTFN(DBG_REG, "addr=0x%jx, val=0x%jx", addr, val, 0, 0);
return val;
Home |
Main Index |
Thread Index |
Old Index