git: daaf594e8469 - main - stand/ofw: ofw_disk isn't really a disk

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 30 Nov 2022 22:31:23 UTC
The branch main has been updated by imp:

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

commit daaf594e8469b1fb4fb7861c2f7129f4d61c6d4d
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-11-30 22:09:23 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-11-30 22:30:33 +0000

    stand/ofw: ofw_disk isn't really a disk
    
    The rest of the code in the tree assumes that a DEVT_DISK uses a
    disk_devdesc to represent the device. However ofw_disk diesn't, so we
    can't use disk_fmtdev, nor disk_parsedev. ofw needs to have a
    dv_match-like routine to use devpasrse, though, since we have two
    drivers (net and block) that claim the same sort of devices (eg
    /path/to/ofw-dev) based on the device-type property. In the interim, we
    can't use devmatch and ofw_disk's and the default net driver's parsing
    is offloaded ofw_parsedev.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D37347
---
 stand/libofw/libofw.h   |  2 ++
 stand/libofw/ofw_disk.c | 14 +++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h
index 0483c9dbf754..59c7ec1fa6b7 100644
--- a/stand/libofw/libofw.h
+++ b/stand/libofw/libofw.h
@@ -28,6 +28,8 @@
 #include "openfirm.h"
 #include <readin.h>
 
+#define DEVT_OFDISK	1001
+
 struct ofw_devdesc {
 	struct devdesc			dd;
 	union {
diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c
index 524bc7b77d5c..8f4c0162d32b 100644
--- a/stand/libofw/ofw_disk.c
+++ b/stand/libofw/ofw_disk.c
@@ -49,10 +49,12 @@ static int	ofwd_open(struct open_file *f, ...);
 static int	ofwd_close(struct open_file *f);
 static int	ofwd_ioctl(struct open_file *f, u_long cmd, void *data);
 static int	ofwd_print(int verbose);
+static char *	ofwd_fmtdev(struct devdesc *);
+
 
 struct devsw ofwdisk = {
 	.dv_name = "block",
-	.dv_type = DEVT_DISK,
+	.dv_type = DEVT_OFDISK,
 	.dv_init = ofwd_init,
 	.dv_strategy = ofwd_strategy,
 	.dv_open = ofwd_open,
@@ -60,8 +62,7 @@ struct devsw ofwdisk = {
 	.dv_ioctl = ofwd_ioctl,
 	.dv_print = ofwd_print,
 	.dv_cleanup = nullsys,
-	.dv_fmtdev = disk_fmtdev,
-	.dv_parsedev = disk_parsedev,
+	.dv_fmtdev = ofwd_fmtdev,
 };
 
 /*
@@ -185,3 +186,10 @@ ofwd_print(int verbose __unused)
 {
 	return (0);
 }
+static char *
+ofwd_fmtdev(struct devdesc *idev)
+{
+	struct ofw_devdesc *dev = (struct ofw_devdesc *)idev;
+
+	return (dev->d_path);
+}