Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-localcount]: src/sys/dev/isa Redo previous



details:   https://anonhg.NetBSD.org/src/rev/5d774430cc9c
branches:  pgoyette-localcount
changeset: 852862:5d774430cc9c
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Jul 25 23:40:33 2016 +0000

description:
Redo previous

diffstat:

 sys/dev/isa/fd.c  |  34 ++++++++++++++--------------------
 sys/dev/isa/isv.c |  35 ++++++++++++++++++++---------------
 sys/dev/isa/mcd.c |  32 ++++++++++++++++----------------
 3 files changed, 50 insertions(+), 51 deletions(-)

diffs (258 lines):

diff -r 4edfd52cc5b6 -r 5d774430cc9c sys/dev/isa/fd.c
--- a/sys/dev/isa/fd.c  Mon Jul 25 22:06:09 2016 +0000
+++ b/sys/dev/isa/fd.c  Mon Jul 25 23:40:33 2016 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
 void
 fdstrategy(struct buf *bp)
 {
-       device_t self;
-       struct fd_softc *fd =
-           device_lookup_private_acquire(&fd_cd, FDUNIT(bp->b_dev), &self);
+       device_t self = device_lookup_acquire(&fd_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 @@
        struct fd_softc *fd;
        const struct fd_type *type;
 
-       fd = device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self);
-       if (fd == NULL) {
-               if (self != NULL)
-                       device_release(self);
-               return (ENXIO);
-       }
+       self = device_lookup_acquire(&fd_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 @@
 int
 fdclose(dev_t dev, int flags, int mode, struct lwp *l)
 {
-       device_t self;
-       struct fd_softc *fd =
-           device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self);
+       device_t self = device_lookup_acquire(&fd_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 @@
 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(&fd_cd, FDUNIT(dev), &self);
+       device_t self = device_lookup_acquire(&fd_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 @@
 int
 fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct lwp *l)
 {
-       device_t self;
+       device_t self = device_lookup_acquire(&fd_cd, FDUNIT(dev));
        int rv = 0;
-       struct fd_softc *fd = 
-           device_lookup_private_acquire(&fd_cd, FDUNIT(dev), &self);
+       struct fd_softc *fd = device_private(self);
        struct fd_type *type = fd->sc_type;
        struct buf *bp;
 
diff -r 4edfd52cc5b6 -r 5d774430cc9c sys/dev/isa/isv.c
--- a/sys/dev/isa/isv.c Mon Jul 25 22:06:09 2016 +0000
+++ b/sys/dev/isa/isv.c Mon Jul 25 23:40:33 2016 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
 #include <sys/systm.h>
@@ -259,16 +259,14 @@
 int
 isv_open(dev_t dev, int flag, int devtype, lwp_t *l)
 {
-       device_t self;
+       device_t self = device_lookup_acquire(&isv_cd, minor(dev));
        vaddr_t va;
-       struct isv_softc *sc =
-           device_lookup_private_acquire(&isv_cd, minor(dev), &self);
+       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 @@
 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(&isv_cd, minor(dev));
        struct isv_cmd ic;
-       struct isv_softc *sc =
-           device_lookup_private_acquire(&isv_cd, minor(dev), &self);
+       struct isv_softc *sc;
        int error;
 
        if (cmd != ISV_CMD) {
@@ -432,6 +429,11 @@
                return EINVAL;
        }
 
+       if (self == NULL)
+               return ENXIO;
+
+       sc = device_private(self);
+
        ic.c_frameno = 0;
 
        error = isv_capture(sc);
@@ -442,15 +444,18 @@
 paddr_t
 isv_mmap(dev_t dev, off_t offset, int prot)
 {
-       device_t self;
-       struct isv_softc *sc =
-           device_lookup_private_acquire(&isv_cd, minor(dev), &self);
+       device_t self = device_lookup_acquire(&isv_cd, minor(dev));
+       struct isv_softc *sc;
        paddr_t pa, rpa;
 
+       if (self == NULL)
+               return -1;
+
        if ((prot & ~(VM_PROT_READ)) != 0) {
                device_release(self);
                return -1;
        }
+       sc = device_private(self);
        if (sc->sc_frame == NULL) {
                device_release(self);
                return -1;
diff -r 4edfd52cc5b6 -r 5d774430cc9c sys/dev/isa/mcd.c
--- a/sys/dev/isa/mcd.c Mon Jul 25 22:06:09 2016 +0000
+++ b/sys/dev/isa/mcd.c Mon Jul 25 23:40:33 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mcd.c,v 1.116.2.1 2016/07/25 03:30:52 pgoyette Exp $   */
+/*     $NetBSD: mcd.c,v 1.116.2.2 2016/07/25 23:40:33 pgoyette Exp $   */
 
 /*
  * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
@@ -56,7 +56,7 @@
 /*static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";*/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mcd.c,v 1.116.2.1 2016/07/25 03:30:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcd.c,v 1.116.2.2 2016/07/25 23:40:33 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -312,16 +312,14 @@
 int
 mcdopen(dev_t dev, int flag, int fmt, struct lwp *l)
 {
-       device_t self;
+       device_t self = device_lookup_acquire(&mcd_cd, MCDUNIT(dev));
        int error, part;
        struct mcd_softc *sc;
 
-       sc = device_lookup_private_acquire(&mcd_cd, MCDUNIT(dev), &self);
-       if (sc == NULL) {
-               if (self != NULL)
-                       device_release(self);
+       if (self == NULL)
                return ENXIO;
-       }
+
+       sc = device_private(self);
 
        mutex_enter(&sc->sc_lock);
 
@@ -416,13 +414,16 @@
 int
 mcdclose(dev_t dev, int flag, int fmt, struct lwp *l)
 {
-       device_t self;
-       struct mcd_softc *sc =
-           device_lookup_private_acquire(&mcd_cd, MCDUNIT(dev), &self);
+       device_t self = device_lookup_acquire(&mcd_cd, MCDUNIT(dev));
+       struct mcd_softc *sc;
        int part = MCDPART(dev);
 
        MCD_TRACE("close: partition=%d\n", part);
 
+       if (self == NULL)
+               return ENXIO;
+
+       sc = device_private(self);
        mutex_enter(&sc->sc_lock);
 
        switch (fmt) {
@@ -452,13 +453,13 @@
 void
 mcdstrategy(struct buf *bp)
 {
-       device_t self;
+       device_t self = device_lookup_acquire(&mcd_cd, MCDUNIT(dev));
        struct mcd_softc *sc;
        struct disklabel *lp;
        daddr_t blkno;
        int s;
 
-       sc = device_lookup_private_acquire(&mcd_cd, MCDUNIT(bp->b_dev), self);
+       sc = device_private(self);
        lp = sc->sc_dk.dk_label;
 
        /* Test validity. */
@@ -583,9 +584,8 @@
 int
 mcdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
 {
-       device_t self;
-       struct mcd_softc *sc =
-           device_lookup_private_acquire(&mcd_cd, MCDUNIT(dev), &self);
+       device_t self = device_lookup_acquire(&mcd_cd, MCDUNIT(dev));
+       struct mcd_softc *sc = device_private(self);
        int error;
        int part;
 #ifdef __HAVE_OLD_DISKLABEL



Home | Main Index | Thread Index | Old Index