Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102745824
D37349.id113715.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D37349.id113715.diff
View Options
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -991,9 +991,7 @@
"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
diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c
--- a/stand/i386/loader/main.c
+++ b/stand/i386/loader/main.c
@@ -96,8 +96,6 @@
int
main(void)
{
- int i;
-
/* Pick up arguments */
kargs = (void *)__args;
initial_howto = kargs->howto;
@@ -244,12 +242,7 @@
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);
diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c
--- a/stand/i386/zfsboot/zfsboot.c
+++ b/stand/i386/zfsboot/zfsboot.c
@@ -211,9 +211,7 @@
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);
diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c
--- a/stand/libsa/dev.c
+++ b/stand/libsa/dev.c
@@ -149,3 +149,21 @@
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);
+}
diff --git a/stand/libsa/libsa.3 b/stand/libsa/libsa.3
--- a/stand/libsa/libsa.3
+++ b/stand/libsa/libsa.3
@@ -537,6 +537,14 @@
.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
diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h
--- a/stand/libsa/stand.h
+++ b/stand/libsa/stand.h
@@ -188,6 +188,7 @@
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 */
diff --git a/stand/powerpc/ofw/main.c b/stand/powerpc/ofw/main.c
--- a/stand/powerpc/ofw/main.c
+++ b/stand/powerpc/ofw/main.c
@@ -182,12 +182,7 @@
/* 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);
diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c
--- a/stand/userboot/userboot/main.c
+++ b/stand/userboot/userboot/main.c
@@ -206,13 +206,7 @@
* 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();
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 3:33 PM (1 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14678905
Default Alt Text
D37349.id113715.diff (3 KB)
Attached To
Mode
D37349: stand: create devinit
Attached
Detach File
Event Timeline
Log In to Comment