summaryrefslogtreecommitdiff
path: root/sys/arch/macppc/stand/ofdev.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2002-09-06 01:17:13 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2002-09-06 01:17:13 +0000
commitbb3697fb9cc85ac07243a0869652fed5fad7e422 (patch)
tree493265a17f5e7f343aa0747b03ef3a72a61254c4 /sys/arch/macppc/stand/ofdev.c
parent2218c0b11baa0824855546bb4f1638728ddcb23a (diff)
KNF, get this out of my tree finally.
Diffstat (limited to 'sys/arch/macppc/stand/ofdev.c')
-rw-r--r--sys/arch/macppc/stand/ofdev.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/sys/arch/macppc/stand/ofdev.c b/sys/arch/macppc/stand/ofdev.c
index a219fa6a630..e6716211e35 100644
--- a/sys/arch/macppc/stand/ofdev.c
+++ b/sys/arch/macppc/stand/ofdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofdev.c,v 1.3 2002/07/23 21:04:26 drahn Exp $ */
+/* $OpenBSD: ofdev.c,v 1.4 2002/09/06 01:17:12 drahn Exp $ */
/* $NetBSD: ofdev.c,v 1.1 1997/04/16 20:29:20 thorpej Exp $ */
/*
@@ -57,35 +57,43 @@ filename(str, ppart)
char savec;
int dhandle;
char devtype[16];
-
+
lp = str;
devtype[0] = 0;
*ppart = 0;
for (cp = str; *cp; lp = cp) {
/* For each component of the path name... */
- while (*++cp && *cp != '/');
+ while (*++cp && *cp != '/')
+ ;
savec = *cp;
*cp = 0;
/* ...look whether there is a device with this name */
dhandle = OF_finddevice(str);
*cp = savec;
if (dhandle == -1) {
- /* if not, lp is the delimiter between device and path */
+ /*
+ * if not, lp is the delimiter between device and path
+ */
+
/* if the last component was a block device... */
if (!strcmp(devtype, "block")) {
/* search for arguments */
for (cp = lp;
- --cp >= str && *cp != '/' && *cp != ':';);
+ --cp >= str && *cp != '/' && *cp != ':';)
+ ;
if (cp >= str && *cp == ':') {
- /* found arguments, make firmware ignore them */
- *cp = 0;
- for (cp = lp; *--cp && *cp != ',';);
- if (*++cp >= 'a' && *cp <= 'a' + MAXPARTITIONS)
+ /* found arguments */
+ for (cp = lp;
+ *--cp != ':' && *cp != ',';)
+ ;
+ if (*++cp >= 'a' &&
+ *cp <= 'a' + MAXPARTITIONS)
*ppart = *cp;
}
}
return lp;
- } else if (OF_getprop(dhandle, "device_type", devtype, sizeof devtype) < 0)
+ } else if (OF_getprop(dhandle, "device_type", devtype,
+ sizeof devtype) < 0)
devtype[0] = 0;
}
return 0;
@@ -103,14 +111,14 @@ strategy(devdata, rw, blk, size, buf, rsize)
struct of_dev *dev = devdata;
u_quad_t pos;
int n;
-
+
if (rw != F_READ)
return EPERM;
if (dev->type != OFDEV_DISK)
panic("strategy");
-
+
pos = (u_quad_t)(blk + dev->partoff) * dev->bsize;
-
+
for (;;) {
if (OF_seek(dev->handle, pos) < 0)
break;
@@ -130,7 +138,7 @@ devclose(of)
struct open_file *of;
{
struct of_dev *op = of->f_devdata;
-
+
if (op->type == OFDEV_NET)
net_close(op);
if (op->dmabuf) {
@@ -178,7 +186,7 @@ get_long(p)
const void *p;
{
const unsigned char *cp = p;
-
+
return cp[0] | (cp[1] << 8) | (cp[2] << 16) | (cp[3] << 24);
}
@@ -269,11 +277,11 @@ search_label(devp, off, buf, lp, off0)
int i;
u_long poff;
static int recursion;
-
+
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &read)
|| read != DEV_BSIZE)
return ERDLAB;
-
+
if (buf[510] != 0x55 || buf[511] != 0xaa)
return ERDLAB;
@@ -361,7 +369,10 @@ devopen(of, name, file)
if (OF_getprop(handle, "device_type", buf, sizeof buf) < 0)
return ENXIO;
if (!strcmp(buf, "block"))
- /* For block devices, indicate raw partition (:0 in OpenFirmware) */
+ /*
+ * For block devices, indicate raw partition
+ * (:0 in OpenFirmware)
+ */
strcat(fname, ":0");
if ((handle = OF_open(fname)) == -1)
return ENXIO;
@@ -396,7 +407,7 @@ devopen(of, name, file)
part = partition ? partition - 'a' : 0;
ofdev.partoff = label.d_partitions[part].p_offset;
}
-
+
of->f_dev = devsw;
of->f_devdata = &ofdev;
bcopy(&file_system_ufs, file_system, sizeof file_system[0]);