diff options
author | adrian <adrian@FreeBSD.org> | 2016-02-28 06:30:39 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2016-02-28 06:30:39 +0000 |
commit | 52c3e879a6b72f8bce408ea56c21b419d90c827c (patch) | |
tree | c17e20c92beeb6684faba64d2fb1161db9076a90 | |
parent | 48d73dc7387196163174f4b853ee95a5ac5fe166 (diff) | |
download | FreeBSD-src-52c3e879a6b72f8bce408ea56c21b419d90c827c.zip FreeBSD-src-52c3e879a6b72f8bce408ea56c21b419d90c827c.tar.gz |
Migrate athregs over to use the new stats API.
-rw-r--r-- | tools/tools/ath/athregs/Makefile | 3 | ||||
-rw-r--r-- | tools/tools/ath/athregs/dumpregs.c | 27 |
2 files changed, 24 insertions, 6 deletions
diff --git a/tools/tools/ath/athregs/Makefile b/tools/tools/ath/athregs/Makefile index 6b61b32..20e2489 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 472df05..a5f510a 100644 --- a/tools/tools/ath/athregs/dumpregs.c +++ b/tools/tools/ath/athregs/dumpregs.c @@ -43,6 +43,8 @@ #include <ctype.h> #include <err.h> +#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; } |