Index: if_urtwn.c
===================================================================
RCS file: /bracket/repo/src/sys/dev/usb/if_urtwn.c,v
retrieving revision 1.73
diff -u -r1.73 if_urtwn.c
--- if_urtwn.c	10 Oct 2019 23:30:02 -0000	1.73
+++ if_urtwn.c	24 Nov 2019 18:53:09 -0000
@@ -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;
 }
 
@@ -1042,12 +1066,13 @@
 	uint8_t buf[4];
 	uint32_t val;
 
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
 	if (urtwn_read_region_1(sc, addr, buf, 4) != USBD_NORMAL_COMPLETION)
 		return 0xffffffff;
 
 	val = LE_READ_4(&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;
 }
 
@@ -1059,8 +1084,8 @@
 	int fwcur;
 	int ntries;
 
-	DPRINTFN(DBG_REG, ("%s: %s: id=%d, buf=%p, len=%d\n",
-	    device_xname(sc->sc_dev), __func__, id, buf, len));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+	DPRINTFN(DBG_REG, "id=%jd, buf=%#jx, len=%jd", id, (uintptr_t)buf, len, 0);
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1234,7 +1259,7 @@
 	uint8_t off, msk;
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1297,7 +1322,7 @@
 {
 	uint32_t reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if (ISSET(sc->chip, URTWN_CHIP_88E) ||
 	    ISSET(sc->chip, URTWN_CHIP_92EU))
@@ -1414,7 +1439,7 @@
 	struct ieee80211com *ic = &sc->sc_ic;
 	struct r92c_rom *rom = &sc->rom;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	mutex_enter(&sc->sc_write_mtx);
 
@@ -1431,9 +1456,8 @@
 	sc->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY);
 
 	DPRINTFN(DBG_INIT,
-	    ("%s: %s: PA setting=0x%x, board=0x%x, regulatory=%d\n",
-	    device_xname(sc->sc_dev), __func__, sc->pa_setting,
-	    sc->board_type, sc->regulatory));
+	    "PA setting=0x%jx, board=0x%jx, regulatory=%jd",
+	    sc->pa_setting, sc->board_type, sc->regulatory, 0);
 
 	IEEE80211_ADDR_COPY(ic->ic_myaddr, rom->macaddr);
 
@@ -1454,7 +1478,7 @@
 	uint8_t off, msk, tmp;
 	int i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	mutex_enter(&sc->sc_write_mtx);
 
@@ -1521,12 +1545,9 @@
 static int
 urtwn_media_change(struct ifnet *ifp)
 {
-#ifdef URTWN_DEBUG
-	struct urtwn_softc *sc = ifp->if_softc;
-#endif
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if ((error = ieee80211_media_change(ifp)) != ENETRESET)
 		return error;
@@ -1557,7 +1578,7 @@
 	size_t maxrate, maxbasicrate, i, j;
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1593,10 +1614,10 @@
 	} else {
 		mode = R92C_RAID_11BG;
 	}
-	DPRINTFN(DBG_INIT, ("%s: %s: mode=0x%x rates=0x%x, basicrates=0x%x, "
-	    "maxrate=%zx, maxbasicrate=%zx\n",
-	    device_xname(sc->sc_dev), __func__, mode, rates, basicrates,
-	    maxrate, maxbasicrate));
+	DPRINTFN(DBG_INIT, "mode=0x%jx", mode, 0, 0, 0);
+	DPRINTFN(DBG_INIT, "rates=0x%jx, basicrates=0x%jx, "
+	    "maxrate=%jx, maxbasicrate=%jx",
+	    rates, basicrates, maxrate, maxbasicrate);
 
 	if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) {
 		maxbasicrate |= R92C_RATE_SHORTGI;
@@ -1615,8 +1636,7 @@
 		return error;
 	}
 	/* Set initial MRR rate. */
-	DPRINTFN(DBG_INIT, ("%s: %s: maxbasicrate=%zd\n",
-	    device_xname(sc->sc_dev), __func__, maxbasicrate));
+	DPRINTFN(DBG_INIT, "maxbasicrate=%jd", maxbasicrate, 0, 0, 0);
 	urtwn_write_1(sc, R92C_INIDATA_RATE_SEL(RTWN_MACID_BC), maxbasicrate);
 
 	/* Set rates mask for unicast frames. */
@@ -1630,8 +1650,7 @@
 		return error;
 	}
 	/* Set initial MRR rate. */
-	DPRINTFN(DBG_INIT, ("%s: %s: maxrate=%zd\n", device_xname(sc->sc_dev),
-	    __func__, maxrate));
+	DPRINTFN(DBG_INIT, "maxrate=%jd", maxrate, 0, 0, 0);
 	urtwn_write_1(sc, R92C_INIDATA_RATE_SEL(RTWN_MACID_BSS), maxrate);
 
 	rrsr_rate = ic->ic_fixed_rate;
@@ -1653,7 +1672,7 @@
 	struct ieee80211com *ic = &sc->sc_ic;
 	int type;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	switch (ic->ic_opmode) {
 	case IEEE80211_M_STA:
@@ -1677,8 +1696,8 @@
 {
 	uint8_t	reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s: type=%d\n", device_xname(sc->sc_dev),
-	    __func__, type));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("type=%jd", type, 0, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1692,7 +1711,7 @@
 	struct ieee80211_node *ni = sc->sc_ic.ic_bss;
 	uint64_t tsf;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1721,8 +1740,8 @@
 {
 	uint8_t reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s: led=%d, on=%d\n", device_xname(sc->sc_dev),
-	    __func__, led, on));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("led=%jd, on=%jd", led, on, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -1764,7 +1783,7 @@
 {
 	struct urtwn_softc *sc = arg;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if (sc->sc_dying)
 		return;
@@ -1780,7 +1799,7 @@
 	struct r92c_fw_cmd_rssi cmd;
 	struct r92e_fw_cmd_rssi cmde;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if (sc->sc_ic.ic_state != IEEE80211_S_RUN)
 		goto restart_timer;
@@ -1794,8 +1813,8 @@
 		cmde.macid = 0;	/* BSS. */
 		cmd.pwdb = sc->avg_pwdb;
 		cmde.pwdb = sc->avg_pwdb;
-		DPRINTFN(DBG_RF, ("%s: %s: sending RSSI command avg=%d\n",
-		    device_xname(sc->sc_dev), __func__, sc->avg_pwdb));
+		DPRINTFN(DBG_RF, "sending RSSI command avg=%jd",
+		    sc->avg_pwdb, 0, 0, 0);
 		if (!ISSET(sc->chip, URTWN_CHIP_92EU)) {
 			urtwn_fw_cmd(sc, R92C_CMD_RSSI_SETTING, &cmd,
 			    sizeof(cmd));
@@ -1822,7 +1841,7 @@
 	struct urtwn_softc *sc = arg;
 	int s;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if (sc->sc_dying)
 		return;
@@ -1836,8 +1855,15 @@
 static void
 urtwn_newassoc(struct ieee80211_node *ni, int isnew)
 {
-	DPRINTFN(DBG_FN, ("%s: new node %s\n", __func__,
-	    ether_sprintf(ni->ni_macaddr)));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("new node %06jx%06jx",
+	    ni->ni_macaddr[0] << 2 |
+	    ni->ni_macaddr[1] << 1 |
+	    ni->ni_macaddr[2],
+	    ni->ni_macaddr[3] << 2 |
+	    ni->ni_macaddr[4] << 1 |
+	    ni->ni_macaddr[5],
+	    0, 0);
 	/* start with lowest Tx rate */
 	ni->ni_txrate = 0;
 }
@@ -1848,9 +1874,8 @@
 	struct urtwn_softc *sc = ic->ic_ifp->if_softc;
 	struct urtwn_cmd_newstate cmd;
 
-	DPRINTFN(DBG_FN, ("%s: %s: nstate=%s(%d), arg=%d\n",
-	    device_xname(sc->sc_dev), __func__,
-	    ieee80211_state_name[nstate], nstate, arg));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("nstate=%jd, arg=%jd", nstate, arg, 0, 0);
 
 	callout_stop(&sc->sc_scan_to);
 	callout_stop(&sc->sc_calib_to);
@@ -1874,10 +1899,8 @@
 	uint8_t sifs_time, msr;
 	int s;
 
-	DPRINTFN(DBG_FN|DBG_STM, ("%s: %s: %s(%d)->%s(%d)\n",
-	    device_xname(sc->sc_dev), __func__,
-	    ieee80211_state_name[ostate], ostate,
-	    ieee80211_state_name[nstate], nstate));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+	DPRINTFN(DBG_STM, "%jd->%jd", ostate, nstate, 0, 0);
 
 	s = splnet();
 	mutex_enter(&sc->sc_write_mtx);
@@ -2163,7 +2186,7 @@
 {
 	struct urtwn_softc *sc = ic->ic_ifp->if_softc;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	/* don't override default WME values if WME is not actually enabled */
 	if (!(ic->ic_flags & IEEE80211_F_WME))
@@ -2188,8 +2211,8 @@
 	int ac, aifs, slottime;
 	int s;
 
-	DPRINTFN(DBG_FN|DBG_STM, ("%s: %s\n", device_xname(sc->sc_dev),
-	    __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+	DPRINTFN(DBG_STM, "called", 0, 0, 0, 0);
 
 	s = splnet();
 	mutex_enter(&sc->sc_write_mtx);
@@ -2213,8 +2236,8 @@
 {
 	int pwdb;
 
-	DPRINTFN(DBG_FN, ("%s: %s: rate=%d, rsst=%d\n",
-	    device_xname(sc->sc_dev), __func__, rate, rssi));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("rate=%jd, rsst=%jd", rate, rssi, 0, 0);
 
 	/* Convert antenna signal to percentage. */
 	if (rssi <= -100 || rssi >= 20)
@@ -2246,9 +2269,8 @@
 	else
 		sc->avg_pwdb = ((sc->avg_pwdb * 19 + pwdb) / 20);
 
-	DPRINTFN(DBG_RF, ("%s: %s: rate=%d rssi=%d PWDB=%d EMA=%d\n",
-		     device_xname(sc->sc_dev), __func__,
-		     rate, rssi, pwdb, sc->avg_pwdb));
+	DPRINTFN(DBG_RF, "rate=%jd rssi=%jd PWDB=%jd EMA=%jd",
+	    rate, rssi, pwdb, sc->avg_pwdb);
 }
 
 static int8_t
@@ -2260,8 +2282,8 @@
 	uint8_t rpt;
 	int8_t rssi;
 
-	DPRINTFN(DBG_FN, ("%s: %s: rate=%d\n", device_xname(sc->sc_dev),
-	    __func__, rate));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("rate=%jd", rate, 0, 0, 0);
 
 	if (rate <= 3) {
 		cck = (struct r92c_rx_cck *)physt;
@@ -2288,8 +2310,8 @@
 	uint8_t cck_agc_rpt, lna_idx, vga_idx;
 	int8_t rssi;
 
-	DPRINTFN(DBG_FN, ("%s: %s: rate=%d\n", device_xname(sc->sc_dev),
-	    __func__, rate));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("rate=%jd", rate, 0, 0, 0);
 
 	rssi = 0;
 	if (rate <= 3) {
@@ -2348,8 +2370,8 @@
 	int8_t rssi = 0;
 	int s, infosz;
 
-	DPRINTFN(DBG_FN, ("%s: %s: buf=%p, pktlen=%d\n",
-	    device_xname(sc->sc_dev), __func__, buf, pktlen));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("buf=%jp, pktlen=%#jd", (uintptr_t)buf, pktlen, 0, 0);
 
 	stat = (struct r92c_rx_desc_usb *)buf;
 	rxdw0 = le32toh(stat->rxdw0);
@@ -2360,8 +2382,7 @@
 		 * This should not happen since we setup our Rx filter
 		 * to not receive these frames.
 		 */
-		DPRINTFN(DBG_RX, ("%s: %s: CRC error\n",
-		    device_xname(sc->sc_dev), __func__));
+		DPRINTFN(DBG_RX, "CRC error", 0, 0, 0, 0);
 		ifp->if_ierrors++;
 		return;
 	}
@@ -2371,15 +2392,13 @@
 	 */
 //	if (__predict_false(pktlen < (int)sizeof(*wh))) {
 	if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) {
-		DPRINTFN(DBG_RX, ("%s: %s: packet too short %d\n",
-		    device_xname(sc->sc_dev), __func__, pktlen));
+		DPRINTFN(DBG_RX, "packet too short %jd", pktlen, 0, 0, 0);
 		ic->ic_stats.is_rx_tooshort++;
 		ifp->if_ierrors++;
 		return;
 	}
 	if (__predict_false(pktlen > MCLBYTES)) {
-		DPRINTFN(DBG_RX, ("%s: %s: packet too big %d\n",
-		    device_xname(sc->sc_dev), __func__, pktlen));
+		DPRINTFN(DBG_RX, "packet too big %jd", pktlen, 0, 0, 0);
 		ifp->if_ierrors++;
 		return;
 	}
@@ -2397,8 +2416,8 @@
 		urtwn_update_avgrssi(sc, rate, rssi);
 	}
 
-	DPRINTFN(DBG_RX, ("%s: %s: Rx frame len=%d rate=%d infosz=%d rssi=%d\n",
-	    device_xname(sc->sc_dev), __func__, pktlen, rate, infosz, rssi));
+	DPRINTFN(DBG_RX, "Rx frame len=%jd rate=%jd infosz=%jd rssi=%jd",
+	    pktlen, rate, infosz, rssi);
 
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (__predict_false(m == NULL)) {
@@ -2480,8 +2499,8 @@
 	uint8_t *buf;
 	int len, totlen, pktlen, infosz, npkts;
 
-	DPRINTFN(DBG_FN|DBG_RX, ("%s: %s: status=%d\n",
-	    device_xname(sc->sc_dev), __func__, status));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+	DPRINTFN(DBG_RX, "status=%jd", status, 0, 0, 0);
 
 	mutex_enter(&sc->sc_rx_mtx);
 	TAILQ_REMOVE(&sc->rx_free_list[pidx], data, next);
@@ -2499,8 +2518,7 @@
 	usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
 
 	if (__predict_false(len < (int)sizeof(*stat))) {
-		DPRINTFN(DBG_RX, ("%s: %s: xfer too short %d\n",
-		    device_xname(sc->sc_dev), __func__, len));
+		DPRINTFN(DBG_RX, "xfer too short %jd", len, 0, 0, 0);
 		goto resubmit;
 	}
 	buf = data->buf;
@@ -2508,8 +2526,7 @@
 	/* Get the number of encapsulated frames. */
 	stat = (struct r92c_rx_desc_usb *)buf;
 	npkts = MS(le32toh(stat->rxdw2), R92C_RXDW2_PKTCNT);
-	DPRINTFN(DBG_RX, ("%s: %s: Rx %d frames in one chunk\n",
-	    device_xname(sc->sc_dev), __func__, npkts));
+	DPRINTFN(DBG_RX, "Rx %jd frames in one chunk", npkts, 0, 0, 0);
 
 	if (npkts != 0)
 		rnd_add_uint32(&sc->rnd_source, npkts);
@@ -2517,9 +2534,8 @@
 	/* Process all of them. */
 	while (npkts-- > 0) {
 		if (__predict_false(len < (int)sizeof(*stat))) {
-			DPRINTFN(DBG_RX,
-			    ("%s: %s: len(%d) is short than header\n",
-			    device_xname(sc->sc_dev), __func__, len));
+			DPRINTFN(DBG_RX, "len(%jd) is short than header",
+			    len, 0, 0, 0);
 			break;
 		}
 		stat = (struct r92c_rx_desc_usb *)buf;
@@ -2527,8 +2543,7 @@
 
 		pktlen = MS(rxdw0, R92C_RXDW0_PKTLEN);
 		if (__predict_false(pktlen == 0)) {
-			DPRINTFN(DBG_RX, ("%s: %s: pktlen is 0 byte\n",
-			    device_xname(sc->sc_dev), __func__));
+			DPRINTFN(DBG_RX, "pktlen is 0 byte", 0, 0, 0, 0);
 			break;
 		}
 
@@ -2537,9 +2552,8 @@
 		/* Make sure everything fits in xfer. */
 		totlen = sizeof(*stat) + infosz + pktlen;
 		if (__predict_false(totlen > len)) {
-			DPRINTFN(DBG_RX, ("%s: %s: pktlen %d(%d+%d+%d) > %d\n",
-			    device_xname(sc->sc_dev), __func__, totlen,
-			    (int)sizeof(*stat), infosz, pktlen, len));
+			DPRINTFN(DBG_RX, "pktlen (%jd+%jd+%jd) > %jd",
+			    (int)sizeof(*stat), infosz, pktlen, len);
 			break;
 		}
 
@@ -2568,8 +2582,8 @@
 	size_t pidx = data->pidx;
 	int s;
 
-	DPRINTFN(DBG_FN|DBG_TX, ("%s: %s: status=%d\n",
-	    device_xname(sc->sc_dev), __func__, status));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
+	DPRINTFN(DBG_TX, "status=%jd", status, 0, 0, 0);
 
 	mutex_enter(&sc->sc_tx_mtx);
 	/* Put this Tx buffer back to our free list. */
@@ -2612,7 +2626,7 @@
 	uint8_t raid, type, tid;
 	int s, hasqos, error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	wh = mtod(m, struct ieee80211_frame *);
 	type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
@@ -2679,8 +2693,7 @@
 
 	/* fix pad field */
 	if (padsize > 0) {
-		DPRINTFN(DBG_TX, ("%s: %s: padding: size=%zd\n",
-		    device_xname(sc->sc_dev), __func__, padsize));
+		DPRINTFN(DBG_TX, "padding: size=%jd", padsize, 0, 0, 0);
 		txd->txdw1 |= htole32(SM(R92C_TXDW1_PKTOFF, (padsize / 8)));
 	}
 
@@ -2690,9 +2703,8 @@
 			raid = R92C_RAID_11B;
 		else
 			raid = R92C_RAID_11BG;
-		DPRINTFN(DBG_TX,
-		    ("%s: %s: data packet: tid=%d, raid=%d\n",
-		    device_xname(sc->sc_dev), __func__, tid, raid));
+		DPRINTFN(DBG_TX, "data packet: tid=%jd, raid=%jd",
+		    tid, raid, 0, 0);
 
 		if (!ISSET(sc->chip, URTWN_CHIP_92C)) {
 			txd->txdw1 |= htole32(
@@ -2735,8 +2747,7 @@
 		else
 			txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11));
 	} else if (type == IEEE80211_FC0_TYPE_MGT) {
-		DPRINTFN(DBG_TX, ("%s: %s: mgmt packet\n",
-		    device_xname(sc->sc_dev), __func__));
+		DPRINTFN(DBG_TX, "mgmt packet", 0, 0, 0, 0);
 		txd->txdw1 |= htole32(
 		    SM(R92C_TXDW1_MACID, RTWN_MACID_BSS) |
 		    SM(R92C_TXDW1_QSEL, R92C_TXDW1_QSEL_MGNT) |
@@ -2748,8 +2759,7 @@
 		txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 0));
 	} else {
 		/* broadcast or multicast packets */
-		DPRINTFN(DBG_TX, ("%s: %s: bc or mc packet\n",
-		    device_xname(sc->sc_dev), __func__));
+		DPRINTFN(DBG_TX, "bc or mc packet", 0, 0, 0, 0);
 		txd->txdw1 |= htole32(
 		    SM(R92C_TXDW1_MACID, RTWN_MACID_BC) |
 		    SM(R92C_TXDW1_RAID, R92C_RAID_11B));
@@ -2796,8 +2806,7 @@
 	if (__predict_false(error != USBD_NORMAL_COMPLETION &&
 	    error != USBD_IN_PROGRESS)) {
 		splx(s);
-		DPRINTFN(DBG_TX, ("%s: %s: transfer failed %d\n",
-		    device_xname(sc->sc_dev), __func__, error));
+		DPRINTFN(DBG_TX, "transfer failed %jd", error, 0, 0, 0);
 		return error;
 	}
 	splx(s);
@@ -2829,7 +2838,7 @@
 	struct ieee80211_node *ni;
 	struct mbuf *m;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
 		return;
@@ -2845,8 +2854,8 @@
 
 			if (data == NULL) {
 				ifp->if_flags |= IFF_OACTIVE;
-				DPRINTFN(DBG_TX, ("%s: empty tx_free_list\n",
-					    device_xname(sc->sc_dev)));
+				DPRINTFN(DBG_TX, "empty tx_free_list",
+				    0, 0, 0, 0);
 				return;
 			}
 			IF_DEQUEUE(&ic->ic_mgtq, m);
@@ -2877,8 +2886,7 @@
 
 		if (data == NULL) {
 			ifp->if_flags |= IFF_OACTIVE;
-			DPRINTFN(DBG_TX, ("%s: empty tx_free_list\n",
-				    device_xname(sc->sc_dev)));
+			DPRINTFN(DBG_TX, "empty tx_free_list", 0, 0, 0, 0);
 			return;
 		}
 		IFQ_DEQUEUE(&ifp->if_snd, m);
@@ -2928,7 +2936,7 @@
 {
 	struct urtwn_softc *sc = ifp->if_softc;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	ifp->if_timer = 0;
 
@@ -2952,8 +2960,9 @@
 	struct ieee80211com *ic = &sc->sc_ic;
 	int s, error = 0;
 
-	DPRINTFN(DBG_FN, ("%s: %s: cmd=0x%08lx, data=%p\n",
-	    device_xname(sc->sc_dev), __func__, cmd, data));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("cmd=0x%08jx, data=%#jx", cmd, (uintptr_t)data,
+	    0, 0);
 
 	s = splnet();
 
@@ -3029,7 +3038,7 @@
 	uint32_t reg;
 	int ntries;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3122,7 +3131,7 @@
 	uint32_t val;
 	int ntries;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3202,7 +3211,7 @@
 	uint8_t val;
 	int ntries;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3262,7 +3271,7 @@
 	uint32_t val;
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3316,7 +3325,7 @@
 	uint16_t reg;
 	int ntries;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3340,7 +3349,7 @@
 {
 	uint16_t reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3371,8 +3380,9 @@
 	uint32_t reg;
 	int off, mlen, error = 0;
 
-	DPRINTFN(DBG_FN, ("%s: %s: page=%d, buf=%p, len=%d\n",
-	    device_xname(sc->sc_dev), __func__, page, buf, len));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("page=%jd, buf=%#jx, len=%jd",
+	    page, (uintptr_t)buf, len, 0);
 
 	reg = urtwn_read_4(sc, R92C_MCUFWDL);
 	reg = RW(reg, R92C_MCUFWDL_PAGE, page);
@@ -3407,7 +3417,7 @@
 	uint32_t reg;
 	int mlen, ntries, page, error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3452,10 +3462,10 @@
 	    (le16toh(hdr->signature) >> 4) == 0x88e ||
 	    (le16toh(hdr->signature) >> 4) == 0x92e ||
 	    (le16toh(hdr->signature) >> 4) == 0x92c) {
-		DPRINTFN(DBG_INIT, ("%s: %s: FW V%d.%d %02d-%02d %02d:%02d\n",
-		    device_xname(sc->sc_dev), __func__,
-		    le16toh(hdr->version), le16toh(hdr->subversion),
-		    hdr->month, hdr->date, hdr->hour, hdr->minute));
+		DPRINTFN(DBG_INIT, "FW V%jd.%jd",
+		    le16toh(hdr->version), le16toh(hdr->subversion), 0, 0);
+		DPRINTFN(DBG_INIT, "%02jd-%02jd %02jd:%02jd",
+		    hdr->month, hdr->date, hdr->hour, hdr->minute);
 		ptr += sizeof(*hdr);
 		len -= sizeof(*hdr);
 	}
@@ -3553,7 +3563,7 @@
 	uint32_t reg;
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3565,8 +3575,7 @@
 	/* Get Tx queues to USB endpoints mapping. */
 	hashq = hasnq = haslq = 0;
 	reg = urtwn_read_2(sc, R92C_USB_EP + 1);
-	DPRINTFN(DBG_INIT, ("%s: %s: USB endpoints mapping 0x%x\n",
-	    device_xname(sc->sc_dev), __func__, reg));
+	DPRINTFN(DBG_INIT, "USB endpoints mapping 0x%jx", reg, 0, 0, 0);
 	if (MS(reg, R92C_USB_EP_HQ) != 0)
 		hashq = 1;
 	if (MS(reg, R92C_USB_EP_NQ) != 0)
@@ -3642,7 +3651,7 @@
 	int nqueues;
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3694,7 +3703,7 @@
 {
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3722,7 +3731,7 @@
 	uint8_t crystalcap;
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -3885,7 +3894,7 @@
 	uint32_t reg, mask, saved;
 	size_t i, j, idx;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	/* Select RF programming based on board type. */
 	if (ISSET(sc->chip, URTWN_CHIP_88E))
@@ -3971,7 +3980,7 @@
 	uint8_t idx;
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 	if (ISSET(sc->chip, URTWN_CHIP_92EU))
@@ -4020,7 +4029,7 @@
 	uint8_t reg;
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4044,7 +4053,7 @@
 urtwn_rxfilter_init(struct urtwn_softc *sc)
 {
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4069,7 +4078,7 @@
 urtwn_edca_init(struct urtwn_softc *sc)
 {
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4094,8 +4103,8 @@
 {
 	uint32_t reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s: chain=%d\n", device_xname(sc->sc_dev),
-	    __func__, chain));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("chain=%jd", chain, 0, 0, 0);
 
 	/* Write per-CCK rate Tx power. */
 	if (chain == 0) {
@@ -4162,8 +4171,8 @@
 	const struct rtwn_txpwr *base;
 	int ridx, group;
 
-	DPRINTFN(DBG_FN, ("%s: %s: chain=%zd, chan=%d\n",
-	    device_xname(sc->sc_dev), __func__, chain, chan));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("chain=%jd, chan=%jd", chain, chan, 0, 0);
 
 	/* Determine channel group. */
 	if (chan <= 3) {
@@ -4275,8 +4284,8 @@
 	const struct rtwn_r88e_txpwr *base;
 	int ridx, group;
 
-	DPRINTFN(DBG_FN, ("%s: %s: chain=%zd, chan=%d\n",
-	    device_xname(sc->sc_dev), __func__, chain, chan));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("chain=%jd, chan=%jd", chain, chan, 0, 0);
 
 	/* Determine channel group. */
 	if (chan <= 2)
@@ -4342,7 +4351,7 @@
 	uint16_t power[URTWN_RIDX_COUNT];
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	for (i = 0; i < sc->ntxchains; i++) {
 		/* Compute per-rate Tx power values. */
@@ -4365,8 +4374,8 @@
 
 	chan = ieee80211_chan2ieee(ic, c);	/* XXX center freq! */
 
-	DPRINTFN(DBG_FN, ("%s: %s: chan=%d\n", device_xname(sc->sc_dev),
-	    __func__, chan));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("chan=%jd", chan, 0, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4450,8 +4459,8 @@
 urtwn_iq_calib(struct urtwn_softc *sc, bool inited)
 {
 
-	DPRINTFN(DBG_FN, ("%s: %s: inited=%d\n", device_xname(sc->sc_dev),
-	    __func__, inited));
+	URTWNHIST_FUNC();
+	URTWNHIST_CALLARGS("inited=%jd", inited, 0, 0, 0);
 
 	uint32_t addaBackup[16], iqkBackup[4], piMode;
 
@@ -4601,7 +4610,7 @@
 	uint8_t txmode;
 	size_t i;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4647,7 +4656,7 @@
 {
 	int temp, t_meter_reg;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	KASSERT(mutex_owned(&sc->sc_write_mtx));
 
@@ -4658,8 +4667,7 @@
 
 	if (sc->thcal_state == 0) {
 		/* Start measuring temperature. */
-		DPRINTFN(DBG_RF, ("%s: %s: start measuring temperature\n",
-		    device_xname(sc->sc_dev), __func__));
+		DPRINTFN(DBG_RF, "start measuring temperature", 0, 0, 0, 0);
 		urtwn_rf_write(sc, 0, t_meter_reg, 0x60);
 		sc->thcal_state = 1;
 		return;
@@ -4668,8 +4676,7 @@
 
 	/* Read measured temperature. */
 	temp = urtwn_rf_read(sc, 0, R92C_RF_T_METER) & 0x1f;
-	DPRINTFN(DBG_RF, ("%s: %s: temperature=%d\n", device_xname(sc->sc_dev),
-	    __func__, temp));
+	DPRINTFN(DBG_RF, "temperature=%jd", temp, 0, 0, 0);
 	if (temp == 0)		/* Read failed, skip. */
 		return;
 
@@ -4681,10 +4688,8 @@
 		/* First LC calibration is performed in urtwn_init(). */
 		sc->thcal_lctemp = temp;
 	} else if (abs(temp - sc->thcal_lctemp) > 1) {
-		DPRINTFN(DBG_RF,
-		    ("%s: %s: LC calib triggered by temp: %d -> %d\n",
-		    device_xname(sc->sc_dev), __func__, sc->thcal_lctemp,
-		    temp));
+		DPRINTFN(DBG_RF, "LC calib triggered by temp: %jd -> %jd",
+		    sc->thcal_lctemp, temp, 0, 0);
 		urtwn_lc_calib(sc);
 		/* Record temperature of last LC calibration. */
 		sc->thcal_lctemp = temp;
@@ -4701,7 +4706,7 @@
 	size_t i;
 	int error;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	urtwn_stop(ifp, 0);
 
@@ -4969,7 +4974,7 @@
 	size_t i;
 	int s;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	s = splusb();
 	ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
@@ -5024,7 +5029,7 @@
 	uint32_t reg;
 	bool disabled = true;
 
-	DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+	URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
 	if (ISSET(sc->chip, URTWN_CHIP_88E) ||
 	    ISSET(sc->chip, URTWN_CHIP_92EU))
