From: deraadt Date: Fri, 22 Aug 2008 03:12:37 +0000 (+0000) Subject: ANSI and other cleanups; ok krw X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=083940cb6f27b8bcea69ff476f6e3cd5aff2ef3a;p=openbsd ANSI and other cleanups; ok krw --- diff --git a/sys/dev/ramdisk.c b/sys/dev/ramdisk.c index fd9a49c8c6f..b7f16daef28 100644 --- a/sys/dev/ramdisk.c +++ b/sys/dev/ramdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ramdisk.c,v 1.43 2008/07/12 19:58:48 miod Exp $ */ +/* $OpenBSD: ramdisk.c,v 1.44 2008/08/22 03:12:37 deraadt Exp $ */ /* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */ /* @@ -86,7 +86,7 @@ struct rd_softc { struct device sc_dev; /* REQUIRED first entry */ - struct disk sc_dkdev; /* hook for generic disk handling */ + struct disk sc_dk; /* hook for generic disk handling */ struct rd_conf sc_rd; #if RAMDISK_SERVER struct buf *sc_buflist; @@ -135,8 +135,7 @@ void *ramdisk_devs[RD_MAX_UNITS]; * This is called if we are configured as a pseudo-device */ void -rdattach(n) - int n; +rdattach(int n) { struct rd_softc *sc; struct cfdata *cf; @@ -150,7 +149,7 @@ rdattach(n) #endif /* XXX: Are we supposed to provide a default? */ - if (n <= 1) + if (n < 1) n = 1; if (n > RD_MAX_UNITS) n = RD_MAX_UNITS; @@ -189,9 +188,7 @@ rdattach(n) } void -rd_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +rd_attach(struct device *parent, struct device *self, void *aux) { struct rd_softc *sc = (struct rd_softc *)self; @@ -208,9 +205,9 @@ rd_attach(parent, self, aux) /* * Initialize and attach the disk structure. */ - sc->sc_dkdev.dk_driver = &rddkdriver; - sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname; - disk_attach(&sc->sc_dkdev); + sc->sc_dk.dk_driver = &rddkdriver; + sc->sc_dk.dk_name = sc->sc_dev.dv_xname; + disk_attach(&sc->sc_dk); } /* @@ -236,13 +233,9 @@ dev_type_size(rdsize); dev_type_dump(rddump); int -rddump(dev, blkno, va, size) - dev_t dev; - daddr64_t blkno; - caddr_t va; - size_t size; +rddump(dev_t dev, daddr64_t blkno, caddr_t va, size_t size) { - return ENODEV; + return (ENODEV); } daddr64_t @@ -254,45 +247,41 @@ rdsize(dev_t dev) /* Disallow control units. */ unit = DISKUNIT(dev); if (unit >= ramdisk_ndevs) - return 0; + return (0); sc = ramdisk_devs[unit]; if (sc == NULL) - return 0; + return (0); if (sc->sc_type == RD_UNCONFIGURED) - return 0; + return (0); - rdgetdisklabel(dev, sc, sc->sc_dkdev.dk_label, 0); + rdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0); part = DISKPART(dev); - if (part >= sc->sc_dkdev.dk_label->d_npartitions) - return 0; - else - return DL_GETPSIZE(&sc->sc_dkdev.dk_label->d_partitions[part]) * - (sc->sc_dkdev.dk_label->d_secsize / DEV_BSIZE); + if (part >= sc->sc_dk.dk_label->d_npartitions) + return (0); + return (DL_GETPSIZE(&sc->sc_dk.dk_label->d_partitions[part]) * + (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE)); } int -rdopen(dev, flag, fmt, proc) - dev_t dev; - int flag, fmt; - struct proc *proc; +rdopen(dev_t dev, int flag, int fmt, struct proc *proc) { int unit; struct rd_softc *sc; unit = DISKUNIT(dev); if (unit >= ramdisk_ndevs) - return ENXIO; + return (ENXIO); sc = ramdisk_devs[unit]; if (sc == NULL) - return ENXIO; + return (ENXIO); /* * The control device is not exclusive, and can * open uninitialized units (so you can setconf). */ if (RD_IS_CTRL(dev)) - return 0; + return (0); #ifdef RAMDISK_HOOKS /* Call the open hook to allow loading the device. */ @@ -304,40 +293,29 @@ rdopen(dev, flag, fmt, proc) * enforce initialized, exclusive open. */ if (sc->sc_type == RD_UNCONFIGURED) - return ENXIO; + return (ENXIO); /* * Make sure we have read the disklabel. */ - rdgetdisklabel(dev, sc, sc->sc_dkdev.dk_label, 0); - - return 0; + rdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0); + return (0); } int -rdclose(dev, flag, fmt, proc) - dev_t dev; - int flag, fmt; - struct proc *proc; +rdclose(dev_t dev, int flag, int fmt, struct proc *proc) { - - return 0; + return (0); } int -rdread(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +rdread(dev_t dev, struct uio *uio, int flags) { return (physio(rdstrategy, NULL, dev, B_READ, minphys, uio)); } int -rdwrite(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +rdwrite(dev_t dev, struct uio *uio, int flags) { return (physio(rdstrategy, NULL, dev, B_WRITE, minphys, uio)); } @@ -347,27 +325,25 @@ rdwrite(dev, uio, flags) * by passing them to the server process. */ void -rdstrategy(bp) - struct buf *bp; +rdstrategy(struct buf *bp) { - int unit; + int unit, s; struct rd_softc *sc; caddr_t addr; size_t off, xfer; - int s; unit = DISKUNIT(bp->b_dev); sc = ramdisk_devs[unit]; /* Sort rogue requests out */ if (sc == NULL || bp->b_blkno < 0 || - (bp->b_bcount % sc->sc_dkdev.dk_label->d_secsize) != 0) { + (bp->b_bcount % sc->sc_dk.dk_label->d_secsize) != 0) { bp->b_error = EINVAL; goto bad; } /* Do not write on "no trespassing" areas... */ - if (bounds_check_with_label(bp, sc->sc_dkdev.dk_label, 1) <= 0) + if (bounds_check_with_label(bp, sc->sc_dk.dk_label, 1) <= 0) goto bad; switch (sc->sc_type) { @@ -415,20 +391,13 @@ bad: } int -rdioctl(dev, cmd, data, flag, proc) - dev_t dev; - u_long cmd; - int flag; - caddr_t data; - struct proc *proc; +rdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc) { - int unit; struct disklabel *lp; struct rd_softc *sc; struct rd_conf *urd; - int error; + int unit = DISKUNIT(dev), error; - unit = DISKUNIT(dev); sc = ramdisk_devs[unit]; urd = (struct rd_conf *)data; @@ -438,78 +407,71 @@ rdioctl(dev, cmd, data, flag, proc) break; lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); rdgetdisklabel(dev, sc, lp, 0); - bcopy(lp, sc->sc_dkdev.dk_label, sizeof(*lp)); + bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp)); free(lp, M_TEMP); - return 0; + return (0); case DIOCGPDINFO: if (sc->sc_type == RD_UNCONFIGURED) break; rdgetdisklabel(dev, sc, (struct disklabel *)data, 1); - return 0; + return (0); case DIOCGDINFO: - if (sc->sc_type == RD_UNCONFIGURED) { + if (sc->sc_type == RD_UNCONFIGURED) break; - } - *(struct disklabel *)data = *(sc->sc_dkdev.dk_label); - return 0; + *(struct disklabel *)data = *(sc->sc_dk.dk_label); + return (0); case DIOCGPART: - ((struct partinfo *)data)->disklab = sc->sc_dkdev.dk_label; + ((struct partinfo *)data)->disklab = sc->sc_dk.dk_label; ((struct partinfo *)data)->part = - &sc->sc_dkdev.dk_label->d_partitions[DISKPART(dev)]; - return 0; + &sc->sc_dk.dk_label->d_partitions[DISKPART(dev)]; + return (0); case DIOCWDINFO: case DIOCSDINFO: - if (sc->sc_type == RD_UNCONFIGURED) { + if (sc->sc_type == RD_UNCONFIGURED) break; - } if ((flag & FWRITE) == 0) - return EBADF; + return (EBADF); - error = setdisklabel(sc->sc_dkdev.dk_label, + error = setdisklabel(sc->sc_dk.dk_label, (struct disklabel *)data, /*sd->sc_dk.dk_openmask : */0); if (error == 0) { if (cmd == DIOCWDINFO) error = writedisklabel(DISKLABELDEV(dev), - rdstrategy, sc->sc_dkdev.dk_label); + rdstrategy, sc->sc_dk.dk_label); } - - return error; + return (error); case DIOCWLABEL: - if (sc->sc_type == RD_UNCONFIGURED) { + if (sc->sc_type == RD_UNCONFIGURED) break; - } if ((flag & FWRITE) == 0) - return EBADF; - return 0; + return (EBADF); + return (0); case RD_GETCONF: /* If this is not the control device, punt! */ - if (RD_IS_CTRL(dev) == 0) { + if (RD_IS_CTRL(dev) == 0) break; - } *urd = sc->sc_rd; - return 0; + return (0); case RD_SETCONF: /* If this is not the control device, punt! */ - if (RD_IS_CTRL(dev) == 0) { + if (RD_IS_CTRL(dev) == 0) break; - } /* Can only set it once. */ - if (sc->sc_type != RD_UNCONFIGURED) { + if (sc->sc_type != RD_UNCONFIGURED) break; - } switch (urd->rd_type) { case RD_KMEM_ALLOCATED: - return rd_ioctl_kalloc(sc, urd, proc); + return (rd_ioctl_kalloc(sc, urd, proc)); #if RAMDISK_SERVER case RD_UMEM_SERVER: - return rd_ioctl_server(sc, urd, proc); + return (rd_ioctl_server(sc, urd, proc)); #endif default: break; @@ -517,9 +479,9 @@ rdioctl(dev, cmd, data, flag, proc) break; default: - return ENOTTY; + return (ENOTTY); } - return EINVAL; + return (EINVAL); } void @@ -561,10 +523,7 @@ rdgetdisklabel(dev_t dev, struct rd_softc *sc, struct disklabel *lp, * Just allocate some kernel memory and return. */ int -rd_ioctl_kalloc(sc, urd, proc) - struct rd_softc *sc; - struct rd_conf *urd; - struct proc *proc; +rd_ioctl_kalloc(struct rd_softc *sc, struct rd_conf *urd, struct proc *proc) { vaddr_t addr; vsize_t size; @@ -573,31 +532,31 @@ rd_ioctl_kalloc(sc, urd, proc) size = urd->rd_size; addr = uvm_km_zalloc(kernel_map, size); if (!addr) - return ENOMEM; + return (ENOMEM); /* This unit is now configured. */ sc->sc_addr = (caddr_t)addr; /* kernel space */ sc->sc_size = (size_t)size; sc->sc_type = RD_KMEM_ALLOCATED; - return 0; + return (0); } int rd_probe(struct device *parent, void *match_, void *aux) { - return 0; + return (0); } int rd_detach(struct device *self, int flags) { - return 0; + return (0); } int rd_activate(struct device *self, enum devact act) { - return 0; + return (0); } #if RAMDISK_SERVER @@ -607,10 +566,7 @@ rd_activate(struct device *self, enum devact act) * Set config, then become the I/O server for this unit. */ int -rd_ioctl_server(sc, urd, proc) - struct rd_softc *sc; - struct rd_conf *urd; - struct proc *proc; +rd_ioctl_server(struct rd_softc *sc, struct rd_conf *urd, struct proc *proc) { vaddr_t end; int error; @@ -619,7 +575,7 @@ rd_ioctl_server(sc, urd, proc) end = (vaddr_t) (urd->rd_addr + urd->rd_size); if ((end >= VM_MAXUSER_ADDRESS) || (end < ((vaddr_t) urd->rd_addr)) ) - return EINVAL; + return (EINVAL); /* This unit is now configured. */ sc->sc_addr = urd->rd_addr; /* user space */ @@ -633,29 +589,26 @@ rd_ioctl_server(sc, urd, proc) sc->sc_type = RD_UNCONFIGURED; sc->sc_addr = 0; sc->sc_size = 0; - return (error); } int rd_sleep_pri = PWAIT | PCATCH; int -rd_server_loop(sc) - struct rd_softc *sc; +rd_server_loop(struct rd_softc *sc) { struct buf *bp; caddr_t addr; /* user space address */ size_t off; /* offset into "device" */ size_t xfer; /* amount to transfer */ - int error; - int s; + int error, s; for (;;) { /* Wait for some work to arrive. */ while (sc->sc_buflist == NULL) { error = tsleep((caddr_t)sc, rd_sleep_pri, "rd_idle", 0); if (error) - return error; + return (error); } /* Unlink buf from head of list. */ diff --git a/sys/dev/rd.c b/sys/dev/rd.c index de63fb1f170..edc2f397883 100644 --- a/sys/dev/rd.c +++ b/sys/dev/rd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rd.c,v 1.1 2001/05/11 07:04:47 deraadt Exp $ */ +/* $OpenBSD: rd.c,v 1.2 2008/08/22 03:12:37 deraadt Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -52,9 +52,7 @@ char rd_root_image[ROOTBYTES] = "|This is the root ramdisk!\n"; * This is called during autoconfig. */ void -rd_attach_hook(unit, rd) - int unit; - struct rd_conf *rd; +rd_attach_hook(int unit, struct rd_conf *rd) { if (unit == 0) { /* Setup root ramdisk */ @@ -69,8 +67,6 @@ rd_attach_hook(unit, rd) * This is called during open (i.e. mountroot) */ void -rd_open_hook(unit, rd) - int unit; - struct rd_conf *rd; +rd_open_hook(int unit, struct rd_conf *rd) { }