diff options
Diffstat (limited to 'usr.sbin/pccard/pccardc')
-rw-r--r-- | usr.sbin/pccard/pccardc/dumpcis.c | 7 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/enabler.c | 4 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/pccardmem.c | 6 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/rdattr.c | 44 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/rdmap.c | 16 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/rdreg.c | 7 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/wrattr.c | 7 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardc/wrreg.c | 4 |
8 files changed, 50 insertions, 45 deletions
diff --git a/usr.sbin/pccard/pccardc/dumpcis.c b/usr.sbin/pccard/pccardc/dumpcis.c index fb9ec2b..d991f6f 100644 --- a/usr.sbin/pccard/pccardc/dumpcis.c +++ b/usr.sbin/pccard/pccardc/dumpcis.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: dumpcis.c,v 1.9 1997/11/18 21:08:06 nate Exp $"; + "$Id: dumpcis.c,v 1.10 1999/02/05 16:00:15 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -43,7 +43,7 @@ static const char rcsid[] = int nocards; -void +static void scan(slot) int slot; { @@ -57,7 +57,8 @@ scan(slot) if (fd < 0) return; nocards++; - ioctl(fd, PIOCGSTATE, &st); + if (ioctl(fd, PIOCGSTATE, &st)) + err(1, "ioctl (PIOCGSTATE)"); if (st.state == filled) { cp = readcis(fd); if (cp) { diff --git a/usr.sbin/pccard/pccardc/enabler.c b/usr.sbin/pccard/pccardc/enabler.c index 101ed34..ea0779e 100644 --- a/usr.sbin/pccard/pccardc/enabler.c +++ b/usr.sbin/pccard/pccardc/enabler.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: enabler.c,v 1.10 1997/11/18 21:08:06 nate Exp $"; + "$Id: enabler.c,v 1.11 1999/02/05 16:00:15 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -138,7 +138,7 @@ void usage(msg) char *msg; { - warnx("enabler: %s", msg); + fprintf(stderr, "enabler: %s\n", msg); fprintf(stderr, "usage: pccardc enabler slot driver [-m addr size] [-a iobase] [-i irq]\n"); fprintf(stderr, diff --git a/usr.sbin/pccard/pccardc/pccardmem.c b/usr.sbin/pccard/pccardc/pccardmem.c index 8461e0e..240cdd6 100644 --- a/usr.sbin/pccard/pccardc/pccardmem.c +++ b/usr.sbin/pccard/pccardc/pccardmem.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: pccardmem.c,v 1.9 1997/11/18 21:08:06 nate Exp $"; + "$Id: pccardmem.c,v 1.10 1999/02/05 16:00:15 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -64,8 +64,8 @@ pccardmem_main(argc, argv) errx(1, "arg error"); } if (ioctl(fd, PIOCRWMEM, &addr)) - warn("ioctl"); + err(1, "ioctl (PIOCRWMEM)"); else printf("PCCARD Memory address set to 0x%x\n", addr); - exit(0); + return 0; } diff --git a/usr.sbin/pccard/pccardc/rdattr.c b/usr.sbin/pccard/pccardc/rdattr.c index 8d28ed7..1f90c77 100644 --- a/usr.sbin/pccard/pccardc/rdattr.c +++ b/usr.sbin/pccard/pccardc/rdattr.c @@ -24,11 +24,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> + #include <pccard/cardinfo.h> int @@ -42,36 +44,30 @@ rdattr_main(argc, argv) int fd; off_t offs; - if (argc != 4) { - fprintf(stderr, "usage: %s rdattr slot offs length\n", argv[0]); - exit(1); - } + if (argc != 4) + errx(1, "Usage: %s rdattr slot offs length", argv[0]); + sprintf(name, CARD_DEVICE, atoi(argv[1])); fd = open(name, O_RDONLY); - if (fd < 0) { - perror(name); - exit(1); - } + if (fd < 0) + err(1, "%s", name); + reg = MDF_ATTR; - if (ioctl(fd, PIOCRWFLAG, ®)) { - perror("ioctl (PIOCRWFLAG)"); - exit(1); - } + if (ioctl(fd, PIOCRWFLAG, ®)) + err(1, "ioctl (PIOCRWFLAG)"); + if (sscanf(argv[2], "%x", ®) != 1 || - sscanf(argv[3], "%x", &length) != 1) { - fprintf(stderr, "arg error\n"); - exit(1); - } + sscanf(argv[3], "%x", &length) != 1) + errx(1, "arg error"); + offs = reg; - if ((buf = malloc(length)) == 0) { - perror(name); - exit(1); - } + if ((buf = malloc(length)) == 0) + errx(1, "malloc failed"); + lseek(fd, offs, SEEK_SET); - if (read(fd, buf, length) != length) { - perror(name); - exit(1); - } + if (read(fd, buf, length) != length) + err(1, "%s", name); + for (i = 0; i < length; i++) { if (i % 16 == 0) { printf("%04x: ", (int) offs + i); diff --git a/usr.sbin/pccard/pccardc/rdmap.c b/usr.sbin/pccard/pccardc/rdmap.c index 5aba198..41038ae 100644 --- a/usr.sbin/pccard/pccardc/rdmap.c +++ b/usr.sbin/pccard/pccardc/rdmap.c @@ -26,9 +26,10 @@ #ifndef lint static const char rcsid[] = - "$Id: rdmap.c,v 1.9 1997/11/18 21:08:07 nate Exp $"; + "$Id: rdmap.c,v 1.10 1999/02/05 16:00:16 kuriyama Exp $"; #endif /* not lint */ +#include <err.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> @@ -39,7 +40,7 @@ static const char rcsid[] = #include <pccard/cardinfo.h> #include <pccard/cis.h> -void +static void dump_io(fd, nio) int fd, nio; { @@ -48,13 +49,14 @@ dump_io(fd, nio) for (i = 0; i < nio; i++) { io.window = i; - ioctl(fd, PIOCGIO, &io); + if (ioctl(fd, PIOCGIO, &io)) + err(1, "ioctl (PIOCGIO)"); printf("I/O %d: flags 0x%03x port 0x%3x size %d bytes\n", io.window, io.flags, io.start, io.size); } } -void +static void dump_mem(fd, nmem) int fd, nmem; { @@ -63,7 +65,8 @@ dump_mem(fd, nmem) for (i = 0; i < nmem; i++) { mem.window = i; - ioctl(fd, PIOCGMEM, &mem); + if (ioctl(fd, PIOCGMEM, &mem)) + err(1, "ioctl (PIOCGMEM)"); printf("Mem %d: flags 0x%03x host %p card %04lx size %d bytes\n", mem.window, mem.flags, mem.start, mem.card, mem.size); } @@ -81,7 +84,8 @@ scan(slot) fd = open(name, O_RDONLY); if (fd < 0) return; - ioctl(fd, PIOCGSTATE, &st); + if (ioctl(fd, PIOCGSTATE, &st)) + err(1, "ioctl (PIOCGSTATE)"); /* if (st.state == filled) */ diff --git a/usr.sbin/pccard/pccardc/rdreg.c b/usr.sbin/pccard/pccardc/rdreg.c index 0605d5b..da28f52 100644 --- a/usr.sbin/pccard/pccardc/rdreg.c +++ b/usr.sbin/pccard/pccardc/rdreg.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rdreg.c,v 1.9 1997/11/18 21:08:07 nate Exp $"; + "$Id: rdreg.c,v 1.10 1999/02/05 16:00:16 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -38,6 +38,7 @@ static const char rcsid[] = #include <sys/ioctl.h> #include <pccard/cardinfo.h> + void dumpslot(sl) int sl; @@ -47,7 +48,7 @@ dumpslot(sl) struct pcic_reg r; sprintf(name, CARD_DEVICE, sl); - fd = open(name, O_RDWR); + fd = open(name, O_RDONLY); if (fd < 0) { warn("%s", name); return; @@ -55,7 +56,7 @@ dumpslot(sl) printf("Registers for slot %d\n", sl); for (r.reg = 0; r.reg < 0x40; r.reg++) { if (ioctl(fd, PIOCGREG, &r)) { - warn("ioctl"); + err(1, "ioctl (PIOCGREG)"); break; } if ((r.reg % 16) == 0) diff --git a/usr.sbin/pccard/pccardc/wrattr.c b/usr.sbin/pccard/pccardc/wrattr.c index e7857b9..51b57bc 100644 --- a/usr.sbin/pccard/pccardc/wrattr.c +++ b/usr.sbin/pccard/pccardc/wrattr.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: wrattr.c,v 1.10 1997/11/18 21:08:08 nate Exp $"; + "$Id: wrattr.c,v 1.11 1999/02/05 16:00:16 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -62,16 +62,19 @@ wrattr_main(argc, argv) fd = open(name, O_RDWR); if (fd < 0) err(1, "%s", name); + reg = MDF_ATTR; if (ioctl(fd, PIOCRWFLAG, ®)) err(1, "ioctl (PIOCRWFLAG)"); + if (sscanf(argv[2], "%x", ®) != 1 || sscanf(argv[3], "%x", &value) != 1) errx(1, "arg error"); + offs = reg; c = value; lseek(fd, offs, SEEK_SET); if (write(fd, &c, 1) != 1) - warn("%s", name); + err(1, "%s", name); return 0; } diff --git a/usr.sbin/pccard/pccardc/wrreg.c b/usr.sbin/pccard/pccardc/wrreg.c index 39ef42d..b86ee11 100644 --- a/usr.sbin/pccard/pccardc/wrreg.c +++ b/usr.sbin/pccard/pccardc/wrreg.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: wrreg.c,v 1.9 1997/11/18 21:08:08 nate Exp $"; + "$Id: wrreg.c,v 1.10 1999/02/05 16:00:16 kuriyama Exp $"; #endif /* not lint */ #include <err.h> @@ -68,6 +68,6 @@ wrreg_main(argc, argv) r.reg = reg; r.value = value; if (ioctl(fd, PIOCSREG, &r)) - warn("ioctl"); + err(1, "ioctl (PIOCSREG)"); return 0; } |