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 <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 @@ 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(&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 @@ fdopen(dev_t dev, int flags, int mode, s
 	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 @@ 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(&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 @@ 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(&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 @@ 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(&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;
 

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 <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 @@ 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(&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 @@ 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(&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 @@ isv_ioctl(dev_t dev, u_long cmd, void *d
 		return EINVAL;
 	}
 
+	if (self == NULL)
+		return ENXIO;
+
+	sc = device_private(self);
+
 	ic.c_frameno = 0;
 
 	error = isv_capture(sc);
@@ -442,15 +444,18 @@ isv_ioctl(dev_t dev, u_long cmd, void *d
 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;

Index: src/sys/dev/isa/mcd.c
diff -u src/sys/dev/isa/mcd.c:1.116.2.1 src/sys/dev/isa/mcd.c:1.116.2.2
--- src/sys/dev/isa/mcd.c:1.116.2.1	Mon Jul 25 03:30:52 2016
+++ src/sys/dev/isa/mcd.c	Mon Jul 25 23:40:33 2016
@@ -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 @@ mcdattach(device_t parent, device_t self
 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 @@ bad3:
 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 @@ mcdclose(dev_t dev, int flag, int fmt, s
 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 @@ mcdwrite(dev_t dev, struct uio *uio, int
 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

Reply via email to