summaryrefslogtreecommitdiffstats
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2003-06-11 18:33:03 +0000
committertmm <tmm@FreeBSD.org>2003-06-11 18:33:03 +0000
commitf485313aecde1852d5e7341ade02a8c7d6fb19f3 (patch)
tree2c48c12f506bec4c4d0651b1f16efe071d0cc1e4 /sys/dev/ofw
parentba4106f8e02a61d2ce21f979d0bbc71cf460299e (diff)
downloadFreeBSD-src-f485313aecde1852d5e7341ade02a8c7d6fb19f3.zip
FreeBSD-src-f485313aecde1852d5e7341ade02a8c7d6fb19f3.tar.gz
- Add an OFIOCGETPROPLEN ioctl() to get the length of a property.
- Do not use a fixed major. - Minor cleanups.
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/openfirmio.c23
-rw-r--r--sys/dev/ofw/openfirmio.h2
2 files changed, 12 insertions, 13 deletions
diff --git a/sys/dev/ofw/openfirmio.c b/sys/dev/ofw/openfirmio.c
index c197eb8..2faf2ee 100644
--- a/sys/dev/ofw/openfirmio.c
+++ b/sys/dev/ofw/openfirmio.c
@@ -62,7 +62,6 @@ static dev_t openfirm_dev;
static d_ioctl_t openfirm_ioctl;
-#define CDEV_MAJOR 177
#define OPENFIRM_MINOR 0
static struct cdevsw openfirm_cdevsw = {
@@ -70,7 +69,6 @@ static struct cdevsw openfirm_cdevsw = {
.d_close = nullclose,
.d_ioctl = openfirm_ioctl,
.d_name = "openfirm",
- .d_maj = CDEV_MAJOR,
};
static phandle_t lastnode; /* speed hack */
@@ -124,6 +122,9 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
char *name, *value;
char newname[32];
+ if ((flags & FREAD) == 0)
+ return (EBADF);
+
of = (struct ofiocdesc *)data;
switch (cmd) {
case OFIOCGETOPTNODE:
@@ -135,6 +136,7 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
#endif
case OFIOCNEXTPROP:
case OFIOCFINDDEVICE:
+ case OFIOCGETPROPLEN:
node = of->of_nodeid;
break;
case OFIOCGETNEXT:
@@ -142,7 +144,7 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
node = *(phandle_t *)data;
break;
default:
- return (ENOTTY);
+ return (ENOIOCTL);
}
if (node != 0 && node != lastnode) {
@@ -158,14 +160,17 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
switch (cmd) {
case OFIOCGET:
- if ((flags & FREAD) == 0)
- return (EBADF);
+ case OFIOCGETPROPLEN:
if (node == 0)
return (EINVAL);
error = openfirm_getstr(of->of_namelen, of->of_name, &name);
if (error)
break;
len = OF_getproplen(node, name);
+ if (cmd == OFIOCGETPROPLEN) {
+ of->of_buflen = len;
+ break;
+ }
if (len > of->of_buflen) {
error = ENOMEM;
break;
@@ -202,8 +207,6 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
#endif
case OFIOCNEXTPROP:
- if ((flags & FREAD) == 0)
- return (EBADF);
if (node == 0 || of->of_buflen < 0)
return (EINVAL);
if (of->of_namelen != 0) {
@@ -230,15 +233,11 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
break;
case OFIOCGETNEXT:
- if ((flags & FREAD) == 0)
- return (EBADF);
node = OF_peer(node);
*(phandle_t *)data = lastnode = node;
break;
case OFIOCGETCHILD:
- if ((flags & FREAD) == 0)
- return (EBADF);
if (node == 0)
return (EINVAL);
node = OF_child(node);
@@ -246,8 +245,6 @@ openfirm_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
break;
case OFIOCFINDDEVICE:
- if ((flags & FREAD) == 0)
- return (EBADF);
error = openfirm_getstr(of->of_namelen, of->of_name, &name);
if (error)
break;
diff --git a/sys/dev/ofw/openfirmio.h b/sys/dev/ofw/openfirmio.h
index 2a1a7c1..42ba18b 100644
--- a/sys/dev/ofw/openfirmio.h
+++ b/sys/dev/ofw/openfirmio.h
@@ -77,5 +77,7 @@ struct ofiocdesc {
#define OFIOCGETCHILD _IOWR(OFIOC_BASE, 6, phandle_t)
/* Find a specific device. */
#define OFIOCFINDDEVICE _IOWR(OFIOC_BASE, 7, struct ofiocdesc)
+/* Retrieve the size of a property. */
+#define OFIOCGETPROPLEN _IOWR(OFIOC_BASE, 8, struct ofiocdesc)
#endif /* _DEV_OFW_OPENFIRMIO_H_ */
OpenPOWER on IntegriCloud