Make config_found_sm() (and therefore config_found()) and config_rootfound()

return a struct device * of attached device, or NULL if device attach failed,
rather than 1/0 for success/failure, so that code that bus code which needs
to know what the child device is doesn't have to open-code a hacked variant
of config_found().  Make config_attach() return struct device *, rather than
void, to facilitate that.
This commit is contained in:
cgd 1996-04-04 06:06:18 +00:00
parent 34829de7f9
commit fbce6d4468
2 changed files with 16 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_autoconf.c,v 1.20 1996/04/04 00:25:49 cgd Exp $ */
/* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -250,7 +250,7 @@ static char *msgs[3] = { "", " not configured\n", " unsupported\n" };
* functions) and attach it, and return true. If the device was
* not configured, call the given `print' function and return 0.
*/
int
struct device *
config_found_sm(parent, aux, print, submatch)
struct device *parent;
void *aux;
@ -259,32 +259,27 @@ config_found_sm(parent, aux, print, submatch)
{
void *match;
if ((match = config_search(submatch, parent, aux)) != NULL) {
config_attach(parent, match, aux, print);
return (1);
}
if ((match = config_search(submatch, parent, aux)) != NULL)
return (config_attach(parent, match, aux, print));
if (print)
printf(msgs[(*print)(aux, parent->dv_xname)]);
return (0);
return (NULL);
}
/*
* As above, but for root devices.
*/
int
struct device *
config_rootfound(rootname, aux)
char *rootname;
void *aux;
{
void *match;
if ((match = config_rootsearch((cfmatch_t)NULL, rootname, aux))
!= NULL) {
config_attach(ROOT, match, aux, (cfprint_t)NULL);
return (1);
}
if ((match = config_rootsearch((cfmatch_t)NULL, rootname, aux)) != NULL)
return (config_attach(ROOT, match, aux, (cfprint_t)NULL));
printf("root device %s not configured\n", rootname);
return (0);
return (NULL);
}
/* just like sprintf(buf, "%d") except that it works from the end */
@ -306,7 +301,7 @@ number(ep, n)
/*
* Attach a found device. Allocates memory for device variables.
*/
void
struct device *
config_attach(parent, match, aux, print)
register struct device *parent;
void *match;
@ -358,6 +353,7 @@ config_attach(parent, match, aux, print)
cf->cf_unit++;
}
(*ca->ca_attach)(parent, dev, aux);
return (dev);
}
struct device *

View File

@ -1,4 +1,4 @@
/* $NetBSD: device.h,v 1.13 1996/04/04 00:25:44 cgd Exp $ */
/* $NetBSD: device.h,v 1.14 1996/04/04 06:06:20 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -159,10 +159,11 @@ extern struct evcntlist allevents; /* list of all event counters */
void config_init __P((void));
void *config_search __P((cfmatch_t, struct device *, void *));
void *config_rootsearch __P((cfmatch_t, char *, void *));
int config_found_sm __P((struct device *, void *, cfprint_t, cfmatch_t));
int config_rootfound __P((char *, void *));
struct device *config_found_sm __P((struct device *, void *, cfprint_t,
cfmatch_t));
struct device *config_rootfound __P((char *, void *));
void config_scan __P((cfscan_t, struct device *));
void config_attach __P((struct device *, void *, void *, cfprint_t));
struct device *config_attach __P((struct device *, void *, void *, cfprint_t));
void evcnt_attach __P((struct device *, const char *, struct evcnt *));
/* compatibility definitions */