Date: Wed, 14 Jul 1999 00:36:41 -0600 From: Warner Losh <imp@village.org> To: mobile@freebsd.org Subject: pccardd patches for review Message-ID: <199907140636.AAA53085@harmony.village.org>
next in thread | raw e-mail | index | archive | help
I've spent some time hacking pccardd to not have that frustrating delay in it, as well as to have some better error reporting. All the patches aren't perfect, but I thought I'd post them here for review and testing. I've introduced a new #define. PCCARDD_PESSIMAL restores the old behavior of waiting for three days before bringing the card up. I'm not sure why these huge delays were in there. I've also tweaked a couple of if statements to either get around compiler warnings or as prelude to other code that I'll add at a later date. Comments? Warner Index: cardd.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/cardd.c,v retrieving revision 1.34 diff -u -r1.34 cardd.c --- cardd.c 1999/02/05 16:00:17 1.34 +++ cardd.c 1999/07/14 06:33:06 @@ -33,6 +33,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include <fcntl.h> #include <sys/ioctl.h> #include "cardd.h" @@ -197,8 +198,11 @@ card_inserted(struct slot *sp) { struct card *cp; - +#ifdef PCCARDD_PESSIMAL sleep(5); +#else + usleep(500); +#endif sp->cis = readcis(sp->fd); if (sp->cis == 0) { logmsg("Error reading CIS on %s\n", sp->name); @@ -348,8 +352,11 @@ for (cisconf = cis->conf; cisconf; cisconf = cisconf->next) if (cisconf->id == sp->config->index) break; - if (cisconf == 0) + if (cisconf == 0) { + logmsg("Config id %d not present in this card", + sp->config->index); return (-1); + } sp->card_config = cisconf; /* @@ -480,7 +487,9 @@ logmsg("Setting config reg at offs 0x%lx to 0x%x, Reset time = %d ms\n", (unsigned long)offs, c, sp->card->reset_time); #endif +#ifdef PCCARDD_PESSIMAL sleep(5); +#endif usleep(sp->card->reset_time * 1000); /* If other config registers exist, set them up. */ @@ -541,14 +550,16 @@ drv.mem = 0; drv.memsize = 0; } - if (sp->io.size) + if (sp->io.size) { drv.iobase = sp->io.addr; - else + } else { drv.iobase = 0; -#ifdef DEBUG - logmsg("Assign %s%d, io 0x%x, mem 0x%lx, %d bytes, irq %d, flags %x\n", - drv.name, drv.unit, drv.iobase, drv.mem, drv.memsize, sp->irq, drv.flags); -#endif + } + if (dodebug) { + logmsg("Assign %s%d, io 0x%x, mem 0x%lx, %d bytes, irq %d, " + "flags %x\n", drv.name, drv.unit, drv.iobase, drv.mem, + drv.memsize, sp->irq, drv.flags); + } /* * If the driver fails to be connected to the device, @@ -556,7 +567,8 @@ */ memcpy(drv.misc, sp->eaddr, 6); if (ioctl(sp->fd, PIOCSDRV, &drv)) { - logmsg("driver allocation failed for %s", sp->card->manuf); + logmsg("driver allocation failed for %s(%s): %s", + sp->card->manuf, sp->card->version, strerror(errno)); return (0); } return (1); Index: file.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/file.c,v retrieving revision 1.17 diff -u -r1.17 file.c --- file.c 1999/06/17 21:07:58 1.17 +++ file.c 1999/07/13 21:21:09 @@ -336,7 +336,7 @@ struct allocblk *mem; int i, j; - if ((i = num_tok()) >= 0) + if ((i = num_tok()) >= 0) { if ((j = num_tok()) < 0) error("illegal memory block"); else { @@ -353,6 +353,7 @@ } return (mem); } + } if (force) error("illegal or missing memory block spec"); return (0); Index: util.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/util.c,v retrieving revision 1.12 diff -u -r1.12 util.c --- util.c 1998/03/09 05:18:59 1.12 +++ util.c 1999/07/14 06:20:48 @@ -202,7 +202,11 @@ lseek(sp->fd, offs, SEEK_SET); c = 0x80; write(sp->fd, &c, sizeof(c)); +#ifdef PCCARDD_PESSIMAL usleep(10 * 1000); +#else + usleep(1000); +#endif c = 0; lseek(sp->fd, offs, SEEK_SET); write(sp->fd, &c, sizeof(c)); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907140636.AAA53085>