diff --git a/tools/tools/ath/athregs/Makefile b/tools/tools/ath/athregs/Makefile index 6b61b32ceb51..20e248910b52 100644 --- a/tools/tools/ath/athregs/Makefile +++ b/tools/tools/ath/athregs/Makefile @@ -2,9 +2,12 @@ PROG= athregs +CFLAGS+= -I${.CURDIR}/../common/ + .PATH.c: ${.CURDIR}/../common SRCS= dumpregs.c +SRCS+= ctrl.c SRCS+= dumpregs_5210.c SRCS+= dumpregs_5211.c SRCS+= dumpregs_5212.c diff --git a/tools/tools/ath/athregs/dumpregs.c b/tools/tools/ath/athregs/dumpregs.c index 472df052c489..a5f510af165f 100644 --- a/tools/tools/ath/athregs/dumpregs.c +++ b/tools/tools/ath/athregs/dumpregs.c @@ -43,6 +43,8 @@ #include #include +#include "ctrl.h" + typedef struct { HAL_REVS revs; u_int32_t regdata[0xffff / sizeof(u_int32_t)]; @@ -93,11 +95,11 @@ main(int argc, char *argv[]) const char *ifname; u_int32_t *data; u_int32_t *dp, *ep; - int what, c, s, i; + int what, c, i; + struct ath_driver_req req; + + ath_driver_req_init(&req); - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) - err(1, "socket"); ifname = getenv("ATH"); if (!ifname) ifname = ATH_DEFAULT; @@ -144,6 +146,16 @@ main(int argc, char *argv[]) usage(); /*NOTREACHED*/ } + + /* Initialise the driver interface */ + if (ath_driver_req_open(&req, ifname) < 0) { + exit(127); + } + + /* + * Whilst we're doing the ath_diag pieces, we have to set this + * ourselves. + */ strncpy(atd.ad_name, ifname, sizeof (atd.ad_name)); argc -= optind; @@ -154,7 +166,8 @@ main(int argc, char *argv[]) atd.ad_id = HAL_DIAG_REVS; atd.ad_out_data = (caddr_t) &state.revs; atd.ad_out_size = sizeof(state.revs); - if (ioctl(s, SIOCGATHDIAG, &atd) < 0) + + if (ath_driver_req_fetch_diag(&req, SIOCGATHDIAG, &atd) < 0) err(1, "%s", atd.ad_name); if (ath_hal_setupregs(&atd, what) == 0) @@ -172,7 +185,8 @@ main(int argc, char *argv[]) exit(-1); } atd.ad_id = HAL_DIAG_REGS | ATH_DIAG_IN | ATH_DIAG_DYN; - if (ioctl(s, SIOCGATHDIAG, &atd) < 0) + + if (ath_driver_req_fetch_diag(&req, SIOCGATHDIAG, &atd) < 0) err(1, "%s", atd.ad_name); /* @@ -238,6 +252,7 @@ main(int argc, char *argv[]) fprintf(stdout, "\n"); ath_hal_dumpbb(stdout, what); } + ath_driver_req_close(&req); return 0; }