Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154749118
D37559.id113719.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
D37559.id113719.diff
View Options
diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c
--- a/stand/libofw/devicename.c
+++ b/stand/libofw/devicename.c
@@ -32,9 +32,7 @@
#include "bootstrap.h"
#include "libofw.h"
-static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **);
-
-/*
+/*
* Point (dev) at an allocated device specifier for the device matching the
* path in (devspec). If it contains an explicit device specification,
* use that. If not, use the default device.
@@ -42,24 +40,24 @@
int
ofw_getdev(void **vdev, const char *devspec, const char **path)
{
- struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev;
+ struct devdesc **dev = (struct devdesc **)vdev;
int rv;
/*
- * If it looks like this is just a path and no device, go with the current
- * device.
+ * If it looks like this is just a path and no device, go with the
+ * current device.
*/
if (devspec == NULL || strpbrk(devspec, ":@") == NULL) {
- if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
- (path != NULL))
+ rv = devparse(dev, getenv("currdev"), NULL);
+ if (rv == 0 && path != NULL)
*path = devspec;
- return(rv);
+ return (rv);
}
-
+
/*
* Try to parse the device name off the beginning of the devspec
*/
- return(ofw_parsedev(dev, devspec, path));
+ return (devparse(dev, devspec, path));
}
/*
@@ -94,80 +92,13 @@
return ((phandle_t)-1);
}
-/*
- * Point (dev) at an allocated device specifier matching the string version
- * at the beginning of (devspec). Return a pointer to the remaining
- * text in (path).
- */
-static int
-ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path)
-{
- struct ofw_devdesc *idev;
- struct devsw *dv;
- phandle_t handle;
- const char *p;
- const char *s;
- char *ep;
- char name[256];
- char type[64];
- int err;
- int len;
- int i;
-
- /* XXX next step: use devparse -- don't forget to hack ofw_disk like you did ofw_net */
- for (p = s = devspec; *s != '\0'; p = s) {
- if ((s = strchr(p + 1, '/')) == NULL)
- s = strchr(p, '\0');
- len = s - devspec;
- bcopy(devspec, name, len);
- name[len] = '\0';
- if ((handle = OF_finddevice(name)) == -1) {
- bcopy(name, type, len);
- type[len] = '\0';
- } else if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1)
- continue;
- for (i = 0; (dv = devsw[i]) != NULL; i++) {
- if (strncmp(dv->dv_name, type, strlen(dv->dv_name)) == 0)
- goto found;
- }
- }
- return(ENOENT);
-
-found:
- if (path != NULL)
- *path = s;
- idev = malloc(sizeof(struct ofw_devdesc));
- if (idev == NULL) {
- printf("ofw_parsedev: malloc failed\n");
- return ENOMEM;
- }
- idev->dd.d_dev = dv;
- if (dv->dv_parsedev != NULL) {
- p = devspec + strlen(dv->dv_name);
- free(idev);
- err = dv->dv_parsedev((struct devdesc **)&idev, devspec, path);
- if (err != 0) {
- return (err);
- }
- } else {
- strcpy(idev->d_path, name);
- }
-
- if (dev == NULL) {
- free(idev);
- } else {
- *dev = idev;
- }
- return(0);
-}
-
int
ofw_setcurrdev(struct env_var *ev, int flags, const void *value)
{
- struct ofw_devdesc *ncurr;
- int rv;
+ struct devdesc *ncurr;
+ int rv;
- if ((rv = ofw_parsedev(&ncurr, value, NULL)) != 0)
+ if ((rv = devparse(&ncurr, value, NULL)) != 0)
return (rv);
free(ncurr);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 30, 9:09 AM (12 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32484374
Default Alt Text
D37559.id113719.diff (3 KB)
Attached To
Mode
D37559: stand/ofw: Use devparse
Attached
Detach File
Event Timeline
Log In to Comment