From nobody Wed Nov 30 22:31:24 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NMv7d2pwPz4jC3Z; Wed, 30 Nov 2022 22:31:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NMv7d0xzWz44bC; Wed, 30 Nov 2022 22:31:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X6F0bLzeKAbi3OjVI844F38iPG3ODfoBeh7JeVBhJCc=; b=KlA7mDCM3WSE5ht6SgFYgN5R5KClmp7kDBc3ZbDNuYEUlJc8U7610xhBtoS+3h9wFh5b/S naGucZ55HZoVbL9V8Aq5ol9r9DY2iQtKlOsAaewSYwP+3R+LIfs5rYLzUDkNHyFZyFmThB m5zGHPYTlPyIB7r4SUqqwkY42lP6rhOuRKxBvBotFWLItgwMNiIi52jLiBRPyBMibAQd9j 0u2Kk14Z7P8Rud9PEjLfrBON7sfRLfvV1fyK6Xs35Z+TyLauSWTtrsD4fUhKPU65tBEIMt QjVrN7VbwhNMlkAi+izlItcpNym/S5mhnACMFP7agUaqX8N0BqBdOACXpQ/qTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669847485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X6F0bLzeKAbi3OjVI844F38iPG3ODfoBeh7JeVBhJCc=; b=SQkIAR8aijZNBqkm9euyETuZo+oKmTLT18y8rf5a+ScR5l4M+JD13kJDbXoPTd7hJLofw1 qY5iQWkOUvr6rfcmDQorR5+5fxpOjDrPaBaPdhk3QMa1nPBOuLssDytb5XSSCP5Su1cZ76 2owwzPCuDbfF/kNc6tw69RrLkkQA3GlWfrUSuN9zj6fbweRijKmO6tZIH4oSMZKTyjUPf8 MjYY43ONEe8RWwftdjVw8CNMJ5LEI21H8xiYg2Dt+ypc9XkKZdK0/l6TUDuF7GbFVkL9so iYtf205SR85z4gjt6el8xpPp2ya3D6GBYQu82WTJav9G1/aCSLcBPXn21myqkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669847485; a=rsa-sha256; cv=none; b=QsYhEgLY/h3wkLEKhMtr9zz0Yp99UTrYy9FfzfKExDqWzz/6hjeMrWM/k33Lm3f+kvtLmI esnYpDqo4BXH+3yfmDV/cAXtMYfkqB8OB+UFJQbe/fudTJtAnTBhirSlkABpnR8QfcM7FW xSPHWYuAhXIbaqvbTS5KVFaQptlphaAS8ow+6zpven3mbo5mxpr51CyaN0hBvruXXdj2kn XdjZGrqVBWYqvzuqnWecE8QuFcNxOcJv7upJcQ1/JdAuva22S0fetP0vMlzRd5/XsgdSYU Zo7cj4VzpWYr4IuSjLsO/eNOfSR0VZKC7IZxNJ9xYt+/qlGtugDO2vLZH6w1Bg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NMv7d01s4zDdf; Wed, 30 Nov 2022 22:31:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AUMVOU2023583; Wed, 30 Nov 2022 22:31:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AUMVOMd023582; Wed, 30 Nov 2022 22:31:24 GMT (envelope-from git) Date: Wed, 30 Nov 2022 22:31:24 GMT Message-Id: <202211302231.2AUMVOMd023582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 66012c8fc4f9 - main - stand: create devinit List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 66012c8fc4f92b80a61405dc7e206617e9f08920 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=66012c8fc4f92b80a61405dc7e206617e9f08920 commit 66012c8fc4f92b80a61405dc7e206617e9f08920 Author: Warner Losh AuthorDate: 2022-11-30 22:09:29 +0000 Commit: Warner Losh CommitDate: 2022-11-30 22:30:33 +0000 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 --- stand/efi/loader/main.c | 4 +--- stand/i386/loader/main.c | 9 +-------- stand/i386/zfsboot/zfsboot.c | 4 +--- stand/libsa/dev.c | 18 ++++++++++++++++++ stand/libsa/libsa.3 | 8 ++++++++ stand/libsa/stand.h | 1 + stand/powerpc/ofw/main.c | 7 +------ stand/userboot/userboot/main.c | 8 +------- 8 files changed, 32 insertions(+), 27 deletions(-) diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 5edc06c9e0d5..85c545e0e72f 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -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 diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index dd1a35daead0..f3e1d4ff434d 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -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); diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index ea390b6ea7a6..1d64ace063e0 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -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); diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c index c0bcce07718b..158b4d69381b 100644 --- a/stand/libsa/dev.c +++ b/stand/libsa/dev.c @@ -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); +} diff --git a/stand/libsa/libsa.3 b/stand/libsa/libsa.3 index 210f54a5aa6a..fcfd22cbf0d0 100644 --- a/stand/libsa/libsa.3 +++ b/stand/libsa/libsa.3 @@ -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 diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index 6e52325ec166..660337db6980 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -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 */ diff --git a/stand/powerpc/ofw/main.c b/stand/powerpc/ofw/main.c index 81195d3f2444..177e665a4dc7 100644 --- a/stand/powerpc/ofw/main.c +++ b/stand/powerpc/ofw/main.c @@ -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); diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c index 9ede0cd360e9..6ec5c5ddbbb6 100644 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -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(); /*