The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6f8e9f22739aa7f5fe997741e9f50a66385c9e0c

commit 6f8e9f22739aa7f5fe997741e9f50a66385c9e0c
Author:     Warner Losh <[email protected]>
AuthorDate: 2022-12-02 18:10:06 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2022-12-02 18:17:27 +0000

    kboot: move to using devparse
    
    We can use devparse directly now. No need to invent a kboot_parsedev
    that just does what devparse does now that we've refactored.
    
    Sponsored by:           Netflix
---
 stand/kboot/main.c | 54 ++++++++++++++++++------------------------------------
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/stand/kboot/main.c b/stand/kboot/main.c
index 23211ce9df4c..3b2c43c20a0f 100644
--- a/stand/kboot/main.c
+++ b/stand/kboot/main.c
@@ -49,49 +49,31 @@ static void kboot_kseg_get(int *nseg, void **ptr);
 
 extern int command_fdt_internal(int argc, char *argv[]);
 
+/*
+ * NB: getdev should likely be identical to this most places, except maybe
+ * we should move to storing the length of the platform devdesc.
+ */
 int
 kboot_getdev(void **vdev, const char *devspec, const char **path)
 {
-       int i, rv;
-       const char *devpath, *filepath;
-       struct devsw *dv;
-       struct devdesc *desc;
-
-       if (devspec == NULL) {
-               rv = kboot_getdev(vdev, getenv("currdev"), NULL);
-               if (rv == 0 && path != NULL)
+       int rv;
+       struct devdesc **dev = (struct devdesc **)vdev;
+
+       /*
+        * If it looks like this is just a path and no device, go with the
+        * current device.
+        */
+       if (devspec == NULL || strchr(devspec, ':') == NULL) {
+               if (((rv = devparse(dev, getenv("currdev"), NULL)) == 0) &&
+                   (path != NULL))
                        *path = devspec;
                return (rv);
        }
-       if (strchr(devspec, ':') != NULL) {
-               devpath = devspec;
-               filepath = strchr(devspec, ':') + 1;
-       } else {
-               devpath = getenv("currdev");
-               filepath = devspec;
-       }
 
-       for (i = 0; (dv = devsw[i]) != NULL; i++) {
-               if (strncmp(dv->dv_name, devpath, strlen(dv->dv_name)) == 0)
-                       goto found;
-       }
-       return (ENOENT);
-
-found:
-       if (path != NULL && filepath != NULL)
-               *path = filepath;
-       else if (path != NULL)
-               *path = strchr(devspec, ':') + 1;
-
-       if (vdev != NULL) {
-               desc = malloc(sizeof(*desc));
-               desc->d_dev = dv;
-               desc->d_unit = 0;
-               desc->d_opendata = strdup(devpath);
-               *vdev = desc;
-       }
-
-       return (0);
+       /*
+        * Try to parse the device name off the beginning of the devspec
+        */
+       return (devparse(dev, devspec, path));
 }
 
 int

Reply via email to