diff options
author | hosokawa <hosokawa@FreeBSD.org> | 1998-03-09 05:18:59 +0000 |
---|---|---|
committer | hosokawa <hosokawa@FreeBSD.org> | 1998-03-09 05:18:59 +0000 |
commit | 971d61ef3e282284bb792d2d8a167910fa71e027 (patch) | |
tree | 627bbe6f02fb896dfe2dd0845ca907e0c6d104e0 /usr.sbin/pccard | |
parent | 50a31a7bd88a5931796a12c26498f5ea68386176 (diff) | |
download | FreeBSD-src-971d61ef3e282284bb792d2d8a167910fa71e027.zip FreeBSD-src-971d61ef3e282284bb792d2d8a167910fa71e027.tar.gz |
Reviewed by: mike@smith.net.au
Submitted by: nate@mt.sri.com
Removed global variables. (and style(9) fix.)
Diffstat (limited to 'usr.sbin/pccard')
-rw-r--r-- | usr.sbin/pccard/pccardd/cardd.c | 36 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/cardd.h | 34 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/file.c | 5 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/pccardd.c | 20 | ||||
-rw-r--r-- | usr.sbin/pccard/pccardd/util.c | 20 |
5 files changed, 54 insertions, 61 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c index cf4e162..2b4d649 100644 --- a/usr.sbin/pccard/pccardd/cardd.c +++ b/usr.sbin/pccard/pccardd/cardd.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: cardd.c,v 1.28 1998/03/02 19:00:01 guido Exp $"; + "$Id: cardd.c,v 1.29 1998/03/02 20:51:06 guido Exp $"; #endif /* not lint */ #include <stdio.h> @@ -38,12 +38,12 @@ static const char rcsid[] = #include "cardd.h" static struct card_config *assign_driver(struct card *); -static int assign_io(struct slot *); -static int setup_slot(struct slot *); -static void card_inserted(struct slot *); -static void card_removed(struct slot *); -static void pr_cmd(struct cmd *); -static void read_ether(struct slot *); +static int assign_io(struct slot *); +static int setup_slot(struct slot *); +static void card_inserted(struct slot *); +static void card_removed(struct slot *); +static void pr_cmd(struct cmd *); +static void read_ether(struct slot *); /* * Dump configuration file data. @@ -84,13 +84,14 @@ pr_cmd(struct cmd *cp) * readslots - read all the PCMCIA slots, and build * a list of the slots. */ -void +struct slot * readslots(void) { char name[128]; int i, fd; - struct slot *sp; + struct slot *slots, *sp; + slots = NULL; for (i = 0; i < MAXSLOT; i++) { sprintf(name, CARD_DEVICE, i); fd = open(name, 2); @@ -126,6 +127,7 @@ readslots(void) slots = sp; slot_change(sp); } + return (slots); } /* @@ -137,7 +139,6 @@ slot_change(struct slot *sp) { struct slotstate state; - current_slot = sp; if (ioctl(sp->fd, PIOCGSTATE, &state)) { logerr("ioctl (PIOCGSTATE)"); return; @@ -192,7 +193,7 @@ card_removed(struct slot *sp) sp->config->driver->inuse = 0; } if ((cp = sp->card) != 0) - execute(cp->remove); + execute(cp->remove, sp); sp->cis = 0; sp->config = 0; /* release io */ @@ -240,11 +241,8 @@ card_inserted(struct slot *sp) } if (cp->ether) read_ether(sp); - sp->config = assign_driver(cp); - if (sp->config == 0) { - execute(cp->insert); + if ((sp->config = assign_driver(cp)) == NULL) return; - } if (assign_io(sp)) { logmsg("Resource allocation failure for %s", sp->cis->manuf); return; @@ -256,7 +254,7 @@ card_inserted(struct slot *sp) * windows, and then attach the driver. */ if (setup_slot(sp)) - execute(cp->insert); + execute(cp->insert, sp); #if 0 else reset_slot(sp); @@ -316,7 +314,7 @@ assign_driver(struct card *cp) break; if (conf == 0) { logmsg("No free configuration for card %s", cp->manuf); - return (0); + return (NULL); } /* * Now we have a free driver and a matching configuration. @@ -328,7 +326,7 @@ assign_driver(struct card *cp) /* If none available, then we can't use this card. */ if (drvp->inuse) { logmsg("Driver already being used for %s", cp->manuf); - return (0); + return (NULL); } /* Allocate a free IRQ if none has been specified */ if (conf->irq == 0) { @@ -341,7 +339,7 @@ assign_driver(struct card *cp) } if (conf->irq == 0) { logmsg("Failed to allocate IRQ for %s\n", cp->manuf); - return (0); + return (NULL); } } drvp->card = cp; diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h index a5b63e6..ec2ed02 100644 --- a/usr.sbin/pccard/pccardd/cardd.h +++ b/usr.sbin/pccard/pccardd/cardd.h @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cardd.h,v 1.10 1997/11/19 02:31:39 nate Exp $ + * $Id: cardd.h,v 1.11 1998/02/27 08:19:24 hosokawa Exp $ * * Common include file for PCMCIA daemon */ @@ -111,8 +111,6 @@ struct slot { int irq; /* Irq value */ }; -EXTERN struct slot *slots, *current_slot; - EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */ EXTERN struct allocblk *pool_mem; /* Memory in the pool */ EXTERN int pool_irq[16]; /* IRQ allocations */ @@ -121,27 +119,25 @@ EXTERN struct card *cards; EXTERN bitstr_t *mem_avail; EXTERN bitstr_t *io_avail; -EXTERN int verbose; - /* cardd.c functions */ -void dump_config_file(void); -void readslots(void); -void slot_change(struct slot *); +void dump_config_file(void); +struct slot *readslots(void); +void slot_change(struct slot *); /* util.c functions */ -unsigned long alloc_memory(int); -int bit_fns(bitstr_t *, int, int); -void die(char *); -void execute(struct cmd *); -void logmsg(const char *, ...); -void log_setup(void); -void logerr(char *); -char *newstr(); -void reset_slot(struct slot *); -void *xmalloc(int); +unsigned long alloc_memory(int); +int bit_fns(bitstr_t *, int, int); +void die(char *); +void execute(struct cmd *, struct slot *); +void logmsg(const char *, ...); +void log_setup(void); +void logerr(char *); +char *newstr(); +void reset_slot(struct slot *); +void *xmalloc(int); /* file.c */ -void readfile(char *); +void readfile(char *); #define IOPORTS 0x400 #define MEMUNIT 0x1000 diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c index 84bb5bd..1ea95a2 100644 --- a/usr.sbin/pccard/pccardd/file.c +++ b/usr.sbin/pccard/pccardd/file.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: file.c,v 1.12 1997/10/06 11:36:06 charnier Exp $"; + "$Id: file.c,v 1.13 1997/11/19 02:31:40 nate Exp $"; #endif /* not lint */ #include <stdio.h> @@ -272,8 +272,7 @@ new_driver(char *name) break; } #ifdef DEBUG - if (verbose) - printf("Drv %s%d created\n", drvp->kernel, drvp->unit); + printf("Drv %s%d created\n", drvp->kernel, drvp->unit); #endif return (drvp); } diff --git a/usr.sbin/pccard/pccardd/pccardd.c b/usr.sbin/pccard/pccardd/pccardd.c index 4ad682c..3525fac 100644 --- a/usr.sbin/pccard/pccardd/pccardd.c +++ b/usr.sbin/pccard/pccardd/pccardd.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: cardd.c,v 1.24 1998/02/04 20:19:39 guido Exp $"; + "$Id: pccardd.c,v 1.1 1998/02/27 08:19:25 hosokawa Exp $"; #endif /* not lint */ #include <stdio.h> @@ -45,19 +45,19 @@ char *config_file = "/etc/pccard.conf"; int main(int argc, char *argv[]) { - struct slot *sp; - int count, debug = 0; - int verbose = 0; + struct slot *slots, *sp; + int count, dodebug = 0; + int doverbose = 0; while ((count = getopt(argc, argv, ":dvf:")) != -1) { switch (count) { case 'd': setbuf(stdout, 0); setbuf(stderr, 0); - debug = 1; + dodebug = 1; break; case 'v': - verbose = 1; + doverbose = 1; break; case 'f': config_file = optarg; @@ -71,20 +71,20 @@ main(int argc, char *argv[]) } } #ifdef DEBUG - debug = 1; + dodebug = 1; #endif io_avail = bit_alloc(IOPORTS); /* Only supports ISA ports */ /* Mem allocation done in MEMUNIT units. */ mem_avail = bit_alloc(MEMBLKS); readfile(config_file); - if (verbose) + if (doverbose) dump_config_file(); log_setup(); - if (!debug) + if (!dodebug) if (daemon(0, 0)) die("fork failed"); - readslots(); + slots = readslots(); if (slots == 0) die("no PC-CARD slots"); logmsg("pccardd started", NULL); diff --git a/usr.sbin/pccard/pccardd/util.c b/usr.sbin/pccard/pccardd/util.c index d7db551..a9aa48b 100644 --- a/usr.sbin/pccard/pccardd/util.c +++ b/usr.sbin/pccard/pccardd/util.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] = - "$Id: util.c,v 1.10 1997/10/06 11:36:08 charnier Exp $"; + "$Id: util.c,v 1.11 1997/11/19 02:31:41 nate Exp $"; #endif /* not lint */ #include <err.h> @@ -222,7 +222,7 @@ reset_slot(struct slot *sp) * substitutions. */ void -execute(struct cmd *cmdp) +execute(struct cmd *cmdp, struct slot *sp) { char cmd[1024]; char *p, *cp, *lp; @@ -239,12 +239,12 @@ execute(struct cmd *cmdp) /* stringify ethernet address and place here. */ if (strncmp(p, "$ether", 6) == 0) { sprintf(cp, "%x:%x:%x:%x:%x:%x", - current_slot->eaddr[0], - current_slot->eaddr[1], - current_slot->eaddr[2], - current_slot->eaddr[3], - current_slot->eaddr[4], - current_slot->eaddr[5]); + sp->eaddr[0], + sp->eaddr[1], + sp->eaddr[2], + sp->eaddr[3], + sp->eaddr[4], + sp->eaddr[5]); while (*++cp) continue; lp += 6; @@ -252,8 +252,8 @@ execute(struct cmd *cmdp) /* replace device name */ if (strncmp(p, "$device", 7) == 0) { sprintf(cp, "%s%d", - current_slot->config->driver->kernel, - current_slot->config->driver->unit); + sp->config->driver->kernel, + sp->config->driver->unit); while (*cp) cp++; lp += 7; |