CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 23:40:33 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Redo previous To generate a diff of this commit: cvs rdiff -u -r1.110.2.1 -r1.110.2.2 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116.2.1 -r1.116.2.2 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110.2.1 src/sys/dev/isa/fd.c:1.110.2.2 --- src/sys/dev/isa/fd.c:1.110.2.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/fd.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,9 +695,8 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(bp->b_dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(bp->b_dev)); + struct fd_softc *fd = device_private(self); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -925,12 +924,10 @@ fdopen(dev_t dev, int flags, int mode, s struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private_acquire(_cd, FDUNIT(dev), ); - if (fd == NULL) { - if (self != NULL) - device_release(self); - return (ENXIO); - } + self = device_lookup_acquire(_cd, FDUNIT(dev)); + if (self == NULL) + return ENXIO; + fd = device_private(self); type = fd_dev_to_type(fd, dev); if (type == NULL) { @@ -958,9 +955,8 @@ fdopen(dev_t dev, int flags, int mode, s int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); @@ -1411,9 +1407,8 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1642,10 +1637,9 @@ fdioctl(dev_t dev, u_long cmd, void *add int fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct lwp *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); int rv = 0; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + struct fd_softc *fd = device_private(self); struct fd_type *type = fd->sc_type; struct buf *bp; Index: src/sys/dev/isa/isv.c diff -u src/sys/dev/isa/isv.c:1.7.8.1 src/sys/dev/isa/isv.c:1.7.8.2 --- src/sys/dev/isa/isv.c:1.7.8.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/isv.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $"); #include #include @@ -259,16 +259,14 @@ isv_attach(device_t parent, device_t sel int isv_open(dev_t dev, int flag, int devtype, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, minor(dev)); vaddr_t va; - struct isv_softc *sc = - device_lookup_private_acquire(_cd, minor(dev), ); + struct isv_softc *sc; - if (sc == NULL) { - if (self != NULL) - device_release(self); + if (self == NULL) return ENXIO; - } + + sc = device_private(self); if (sc->sc_frame != NULL) { device_release(self); return 0; @@ -412,10 +410,9 @@ isv_capture(struct isv_softc *sc) int isv_ioctl(dev_t dev, u_long cmd, void *data, int flag, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, minor(dev)); struct isv_cmd ic; - struct isv_softc *sc = - device_lookup_private_acquire(_cd, minor(dev), ); + struct isv_softc *sc; int error; if (cmd != ISV_CMD) { @@ -432,6 +429,11 @@ isv_ioctl(dev_t dev, u_long cmd, void *d return EINVAL; } + if (self == NULL) + return ENXIO; + + sc = device_private(self); + ic.c_frameno =
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:30:52 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Update a few drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.110.2.1 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116 -r1.116.2.1 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110 src/sys/dev/isa/fd.c:1.110.2.1 --- src/sys/dev/isa/fd.c:1.110 Tue Dec 8 20:36:15 2015 +++ src/sys/dev/isa/fd.c Mon Jul 25 03:30:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,7 +695,9 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - struct fd_softc *fd = device_lookup_private(_cd, FDUNIT(bp->b_dev)); + device_t self; + struct fd_softc *fd = + device_lookup_private_acquire(_cd, FDUNIT(bp->b_dev), ); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -753,12 +755,14 @@ fdstrategy(struct buf *bp) } #endif mutex_exit(>sc_mtx); + device_release(self); return; done: /* Toss transfer; we're done early. */ bp->b_resid = bp->b_bcount; biodone(bp); + device_release(self); } void @@ -917,20 +921,28 @@ out_fdc(bus_space_tag_t iot, bus_space_h int fdopen(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private(_cd, FDUNIT(dev)); - if (fd == NULL) + fd = device_lookup_private_acquire(_cd, FDUNIT(dev), ); + if (fd == NULL) { + if (self != NULL) + device_release(self); return (ENXIO); + } type = fd_dev_to_type(fd, dev); - if (type == NULL) + if (type == NULL) { + device_release(self); return ENXIO; + } if ((fd->sc_flags & FD_OPEN) != 0 && - memcmp(fd->sc_type, type, sizeof(*type))) + memcmp(fd->sc_type, type, sizeof(*type))) { + device_release(self); return EBUSY; + } fd->sc_type_copy = *type; fd->sc_type = >sc_type_copy; @@ -939,17 +951,20 @@ fdopen(dev_t dev, int flags, int mode, s fd_set_geometry(fd); + device_release(self); return 0; } int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(_cd, FDUNIT(dev)); + device_lookup_private_acquire(_cd, FDUNIT(dev), ); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); + device_release(self); return 0; } @@ -1396,8 +1411,9 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(_cd, FDUNIT(dev)); + device_lookup_private_acquire(_cd, FDUNIT(dev), ); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1426,20 +1442,25 @@ fdioctl(dev_t dev, u_long cmd, void *add lp->d_secpercyl = fd->sc_type->seccyl; lp->d_secperunit = fd->sc_type->size; - if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) + if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) { + device_release(self); return EINVAL; + } break; } error = disk_ioctl(>sc_dk, dev, cmd, addr, flag, l); - if (error != EPASSTHROUGH) + if (error != EPASSTHROUGH) { + device_release(self); return error; + } switch (cmd) { case DIOCWLABEL: if ((flag & FWRITE) == 0) return EBADF; /* XXX do something */ + device_release(self); return 0; case DIOCWDINFO: @@ -1447,8 +1468,10 @@ fdioctl(dev_t dev, u_long cmd, void *add case ODIOCWDINFO: #endif { - if ((flag & FWRITE) == 0) + if ((flag & FWRITE) == 0) { + device_release(self); return EBADF; + } #ifdef __HAVE_OLD_DISKLABEL if (cmd == ODIOCWDINFO) { memset(, 0, sizeof newlabel); @@ -1457,10 +1480,10 @@ fdioctl(dev_t dev, u_long cmd, void *add } #endif error = setdisklabel(lp, addr, 0, NULL); - if (error) - return error; + if (error == 0) + error = writedisklabel(dev, fdstrategy, lp, NULL); - error = writedisklabel(dev, fdstrategy, lp, NULL); + device_release(self); return error; } @@ -1488,21 +1511,23 @@ fdioctl(dev_t dev, u_long cmd, void *add default: return EINVAL; } + device_release(self); return 0; case FDIOCSETFORMAT: if((flag & FWRITE) == 0) return EBADF; /* must be opened for writing */ form_parms = (struct fdformat_parms *)addr;