stand: create devinit
devinit() marches through all the devices, calling the inint routines if any exist. Replace all the identical copies of this code. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37349
This commit is contained in:
parent
daaf594e84
commit
66012c8fc4
@ -991,9 +991,7 @@ main(int argc, CHAR16 *argv[])
|
||||
"failures\n", i);
|
||||
}
|
||||
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
devinit();
|
||||
|
||||
/*
|
||||
* Detect console settings two different ways: one via the command
|
||||
|
@ -96,8 +96,6 @@ ptov(uintptr_t x)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Pick up arguments */
|
||||
kargs = (void *)__args;
|
||||
initial_howto = kargs->howto;
|
||||
@ -244,12 +242,7 @@ main(void)
|
||||
import_geli_boot_data(gbdata);
|
||||
#endif /* LOADER_GELI_SUPPORT */
|
||||
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
devinit();
|
||||
|
||||
printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024,
|
||||
bios_extmem / 1024);
|
||||
|
@ -211,9 +211,7 @@ main(void)
|
||||
env_setenv("currdev", EV_VOLATILE, "", i386_setcurrdev,
|
||||
env_nounset);
|
||||
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
devinit();
|
||||
|
||||
/* XXX assumes this will be a disk, but it looks likely give above */
|
||||
disk_parsedev((struct devdesc **)&devdesc, boot_devname + 4, NULL);
|
||||
|
@ -149,3 +149,21 @@ devparse(struct devdesc **dev, const char *devspec, const char **path)
|
||||
free(idev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
devinit(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for (int i = 0; devsw[i] != NULL; i++) {
|
||||
if (devsw[i]->dv_init != NULL) {
|
||||
if ((devsw[i]->dv_init)() != 0) {
|
||||
err++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
@ -537,6 +537,14 @@ is non-NULL, then a pointer to the remainder of the
|
||||
.Dv devdesc
|
||||
string after the device specification is written.
|
||||
.It Xo
|
||||
.Ft int
|
||||
.Fn devinit void
|
||||
Calls all the
|
||||
.Fa dv_init
|
||||
routines in the
|
||||
.Dv devsw
|
||||
array, returning the number of routines that returned an error.
|
||||
.It Xo
|
||||
.Ft void
|
||||
.Fn twiddle void
|
||||
.Xc
|
||||
|
@ -188,6 +188,7 @@ struct devdesc {
|
||||
|
||||
char *devformat(struct devdesc *d);
|
||||
int devparse(struct devdesc **, const char *, const char **);
|
||||
int devinit(void);
|
||||
|
||||
struct open_file {
|
||||
int f_flags; /* see F_* below */
|
||||
|
@ -182,12 +182,7 @@ main(int (*openfirm)(void *))
|
||||
/* Set up currdev variable to have hooks in place. */
|
||||
env_setenv("currdev", EV_VOLATILE, "", ofw_setcurrdev, env_nounset);
|
||||
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
devinit();
|
||||
|
||||
printf("\n%s", bootprog_info);
|
||||
printf("Memory: %lldKB\n", memsize() / 1024);
|
||||
|
@ -206,13 +206,7 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks)
|
||||
* Initialise the block cache. Set the upper limit.
|
||||
*/
|
||||
bcache_init(32768, 512);
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
|
||||
devinit();
|
||||
extract_currdev();
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user