CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-18 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu May 18 07:35:01 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Fix previous, make it build again.


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.4 -r1.89.8.5 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.4 src/sys/dev/mscp/mscp_disk.c:1.89.8.5
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.4	Wed May 17 04:29:46 2017
+++ src/sys/dev/mscp/mscp_disk.c	Thu May 18 07:35:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.5 2017/05/18 07:35:01 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.5 2017/05/18 07:35:01 pgoyette Exp $");
 
 #include 
 #include 
@@ -289,7 +289,9 @@ raopen(dev_t dev, int flag, int fmt, str
 	error = 0;
  bad1:
 	mutex_exit(&ra->ra_disk.dk_openlock);
+#if notyet
  bad2:
+#endif
 	device_release(ra->ra_dev);
 	return (error);
 }
@@ -1184,7 +1186,7 @@ ra_putonline(dev_t dev, struct ra_softc 
 static inline struct ra_softc *
 mscp_device_lookup(dev_t dev)
 {
-	const struct dev_cdevsw;
+	const struct cdevsw *dev_cdevsw;
 	struct ra_softc *ra;
 	int unit;
 
@@ -1207,20 +1209,13 @@ mscp_device_lookup(dev_t dev)
 		cdevsw_release(dev_cdevsw);
 #endif
 #if NRX
-	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == &rx_cdevsw)
+	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == &rx_cdevsw) {
 		ra = device_lookup_private_acquire(&rx_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
-	else
+	} else
 		cdevsw_release(dev_cdevsw);
 #endif
 	panic("mscp_device_lookup: unexpected major %"PRIu32" unit %u",
 	major(dev), unit);
 }
-
-static void
-mscp_devsw_release(struct ra_softc *sc)
-{
-
-	device_release(sc->ra_dev);
-}



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:29:46 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Finish previous.  :(


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.3 -r1.89.8.4 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.3 src/sys/dev/mscp/mscp_disk.c:1.89.8.4
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.3	Wed May 17 04:26:14 2017
+++ src/sys/dev/mscp/mscp_disk.c	Wed May 17 04:29:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -1192,23 +1192,23 @@ mscp_device_lookup(dev_t dev)
 	ra = NULL;
 #if NRA
 	if (( dev_cdevsw = cdevsw_lookup_acquire(dev)) == &ra_cdevsw) {
-		ra = device_lookup_private(&ra_cd, unit);
+		ra = device_lookup_private_acquire(&ra_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	} else
 		cdevsw_release(dev_cdevsw);
 #endif
 #if NRACD
-	if ((dev_cdevsw = cdevsw_lookup(dev)) == &racd_cdevsw) {
-		ra = device_lookup_private(&racd_cd, unit);
+	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == &racd_cdevsw) {
+		ra = device_lookup_private_acquire(&racd_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	} else
 		cdevsw_release(dev_cdevsw);
 #endif
 #if NRX
-	if (cdevsw_lookup(dev) == &rx_cdevsw)
-		ra = device_lookup_private(&rx_cd, unit);
+	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == &rx_cdevsw)
+		ra = device_lookup_private_acquire(&rx_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	else



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:26:14 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Adapt to device_lookup_acquire


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.2 -r1.89.8.3 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.2 src/sys/dev/mscp/mscp_disk.c:1.89.8.3
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.2	Sun May 14 13:02:35 2017
+++ src/sys/dev/mscp/mscp_disk.c	Wed May 17 04:26:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $");
 
 #include 
 #include 
@@ -271,7 +271,7 @@ raopen(dev_t dev, int flag, int fmt, str
 		if ((error = tsleep((void *)ra, (PZERO + 1) | PCATCH,
 		devopn, 0))) {
 			splx(s);
-			return (error);
+			goto bad2;
 		}
 #endif
 
@@ -289,6 +289,8 @@ raopen(dev_t dev, int flag, int fmt, str
 	error = 0;
  bad1:
 	mutex_exit(&ra->ra_disk.dk_openlock);
+ bad2:
+	device_release(ra->ra_dev);
 	return (error);
 }
 
@@ -328,6 +330,7 @@ raclose(dev_t dev, int flags, int fmt, s
 	}
 #endif
 	mutex_exit(&ra->ra_disk.dk_openlock);
+	device_release(ra->ra_dev);
 	return (0);
 }
 
@@ -345,7 +348,7 @@ rastrategy(struct buf *bp)
 	 */
 	if (ra == NULL) {
 		bp->b_error = ENXIO;
-		goto done;
+		goto done1;
 	}
 	/*
 	 * If drive is open `raw' or reading label, let it at it.
@@ -356,6 +359,7 @@ rastrategy(struct buf *bp)
 	disk_busy(&ra->ra_disk);
 		splx(b);
 		mscp_strategy(bp, device_parent(ra->ra_dev));
+		device_release(ra->ra_dev);
 		return;
 	}
 
@@ -378,9 +382,12 @@ rastrategy(struct buf *bp)
 	disk_busy(&ra->ra_disk);
 	splx(b);
 	mscp_strategy(bp, device_parent(ra->ra_dev));
+	device_release(ra->ra_dev);
 	return;
 
-done:
+ done:
+	device_release(ra->ra_dev);
+ done1:
 	biodone(bp);
 }
 
@@ -414,9 +421,10 @@ raioctl(dev_t dev, u_long cmd, void *dat
 	lp = ra->ra_disk.dk_label;
 
 	error = disk_ioctl(&ra->ra_disk, dev, cmd, data, flag, l);
-	if (error != EPASSTHROUGH)
+	if (error != EPASSTHROUGH) {
+		device_release(ra->ra_dev);
 		return error;
-	else
+	} else
 		error = 0;
 
 	switch (cmd) {
@@ -489,6 +497,7 @@ raioctl(dev_t dev, u_long cmd, void *dat
 		error = ENOTTY;
 		break;
 	}
+	device_release(ra->ra_dev);
 	return (error);
 }
 
@@ -504,17 +513,22 @@ radump(dev_t dev, daddr_t blkno, void *v
 int
 rasize(dev_t dev)
 {
+	int rv;
 	struct ra_softc *ra = mscp_device_lookup(dev);
 
 	if (!ra)
 		return -1;
 
 	if (ra->ra_state == DK_CLOSED)
-		if (ra_putonline(dev, ra) == MSCP_FAILED)
+		if (ra_putonline(dev, ra) == MSCP_FAILED) {
+			device_release(ra->ra_dev);
 			return -1;
+		}
 
-	return ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
+	rv = ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
 	(ra->ra_disk.dk_label->d_secsize / DEV_BSIZE);
+	device_release(ra->ra_dev);
+	return rv;
 }
 
 #endif /* NRA || NRACD || NRX */
@@ -1107,6 +1121,7 @@ rrfillin(struct buf *bp, struct mscp *mp
 	mp->mscp_seq.seq_lbn = lp->d_partitions[part].p_offset + bp->b_blkno;
 	mp->mscp_unit = ra->ra_hwunit;
 	mp->mscp_seq.seq_bytecount = bp->b_bcount;
+	device_release(ra->ra_dev);
 }
 
 /*
@@ -1166,37 +1181,46 @@ ra_putonline(dev_t dev, struct ra_softc 
 	return MSCP_DONE;
 }
 
-/* XXX
- *	This code needs to be restructured to deal with the localcount(9)
- *	referencing counting on {b,c}devsw.  Since we're returning the
- *	softc address here, we need to use cdevsw_lookup_acquire() to
- *	keep a reference to the device.  So all callers need to be able
- *	to determine which device's cdevsw needs to be released later on.
- * XXX
- */
 static inline struct ra_softc *
 mscp_device_lookup(dev_t dev)
 {
+	const struct dev_cdevsw;
 	struct ra_softc *ra;
 	int unit;
 
 	unit = DISKUNIT(dev);
+	ra = NULL;
 #if NRA
-	if (cdevsw_lookup(dev) == &ra_cdevsw)
+	if (( dev_cdevsw = cdevsw_lookup_acquire(dev)) == &ra_cdevsw) {
 		ra = device_lookup_private(&ra_cd, unit);
-	else
+		cdevsw_release(dev_cdevsw);
+		return ra;
+	} else
+		cdevsw_release(dev_cdevsw);
 #endif
 #if NRACD
-	if (cdevsw_lookup(dev) == &racd_cdevsw)
+	if ((dev_cdevsw = cdevsw_lookup(dev)) == &racd_cdevsw) {
 		ra = device_lookup_private(&racd_cd, unit);
-	else
+		cdevsw_release(dev_cdevsw);
+		return ra;
+	} else
+		cdevsw_release(dev_cdevsw);
 #endif
 #if NRX
 	if (cdevsw_lookup(dev) == &rx_cdevsw)
 		ra = device_lookup_private(&rx_cd, unit);
+		cdevsw_release(dev_cdevsw);
+		return ra;
 	else
+		cdevsw_rel

CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 03:05:44 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
It's "device_t x" not "struct device_t x"


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.2 -r1.39.6.3 src/sys/dev/ata/ata_raid.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/ata/ata_raid.c
diff -u src/sys/dev/ata/ata_raid.c:1.39.6.2 src/sys/dev/ata/ata_raid.c:1.39.6.3
--- src/sys/dev/ata/ata_raid.c:1.39.6.2	Wed May 17 02:58:37 2017
+++ src/sys/dev/ata/ata_raid.c	Wed May 17 03:05:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $	*/
+/*	$NetBSD: ata_raid.c,v 1.39.6.3 2017/05/17 03:05:44 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.3 2017/05/17 03:05:44 pgoyette Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ ata_raid_type_name(u_int type)
 static int
 ata_raid_finalize(device_t self)
 {
-	struct device_t dev;
+	device_t dev;
 	static struct cfdata ataraid_cfdata = {
 		.cf_name = "ataraid",
 		.cf_atname = "ataraid",



CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:58:37 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.1 -r1.39.6.2 src/sys/dev/ata/ata_raid.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/ata/ata_raid.c
diff -u src/sys/dev/ata/ata_raid.c:1.39.6.1 src/sys/dev/ata/ata_raid.c:1.39.6.2
--- src/sys/dev/ata/ata_raid.c:1.39.6.1	Wed May 17 01:44:17 2017
+++ src/sys/dev/ata/ata_raid.c	Wed May 17 02:58:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $	*/
+/*	$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ ata_raid_type_name(u_int type)
 static int
 ata_raid_finalize(device_t self)
 {
-	stgruct device_t dev;
+	struct device_t dev;
 	static struct cfdata ataraid_cfdata = {
 		.cf_name = "ataraid",
 		.cf_atname = "ataraid",



CVS commit: [prg-localcount2] src/sys/dev/sysmon

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:37:02 UTC 2017

Modified Files:
src/sys/dev/sysmon [prg-localcount2]: swwdog.c

Log Message:
Use correct variable name


To generate a diff of this commit:
cvs rdiff -u -r1.19.8.1 -r1.19.8.2 src/sys/dev/sysmon/swwdog.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/sysmon/swwdog.c
diff -u src/sys/dev/sysmon/swwdog.c:1.19.8.1 src/sys/dev/sysmon/swwdog.c:1.19.8.2
--- src/sys/dev/sysmon/swwdog.c:1.19.8.1	Wed May 17 01:44:18 2017
+++ src/sys/dev/sysmon/swwdog.c	Wed May 17 02:37:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $	*/
+/*	$NetBSD: swwdog.c,v 1.19.8.2 2017/05/17 02:37:02 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2004, 2005 Steven M. Bellovin
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19.8.2 2017/05/17 02:37:02 pgoyette Exp $");
 
 /*
  *
@@ -145,7 +145,7 @@ swwdogattach(int n __unused)
 		workqueue_destroy(wq);
 		return 1;
 	}
-	device_release(dev);
+	device_release(swwdog_dev);
 	return 0;
 }
 



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-14 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun May 14 13:02:35 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Rearrange the else clauses to make it work.


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.1 -r1.89.8.2 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.1 src/sys/dev/mscp/mscp_disk.c:1.89.8.2
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.1	Thu Apr 27 05:36:35 2017
+++ src/sys/dev/mscp/mscp_disk.c	Sun May 14 13:02:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.1 2017/04/27 05:36:35 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $");
 
 #include 
 #include 
@@ -1145,21 +1145,20 @@ ra_putonline(dev_t dev, struct ra_softc 
 	rastrategy, dl, NULL)) == NULL) {
 		ra->ra_havelabel = 1;
 		ra->ra_state = DK_OPEN;
-	}
+	} else {
 #if NRACD
-	else {
 		cdev = cdevsw_lookup_acquire(dev);
 		if (cdev == &racd_cdevsw) {
 			dl->d_partitions[0].p_offset = 0;
 			dl->d_partitions[0].p_size = dl->d_secperunit;
 			dl->d_partitions[0].p_fstype = FS_ISO9660;
-		}
+		} else
+			printf(": %s", msg);
 		if (cdev != NULL)
 			cdevsw_release(cdev);
-	}
-#endif /* NRACD */
-	else {
+#else
 		printf(": %s", msg);
+#endif /* NRACD */
 	}
 
 	printf(": size %d sectors\n", dl->d_secperunit);



CVS commit: [prg-localcount2] src/sys/dev

2017-05-13 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun May 14 05:38:38 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: md.c

Log Message:
Mark variable as __diagused to fix build-break


To generate a diff of this commit:
cvs rdiff -u -r1.78.6.4 -r1.78.6.5 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.78.6.4 src/sys/dev/md.c:1.78.6.5
--- src/sys/dev/md.c:1.78.6.4	Sat Apr 29 11:12:14 2017
+++ src/sys/dev/md.c	Sun May 14 05:38:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.78.6.4 2017/04/29 11:12:14 pgoyette Exp $	*/
+/*	$NetBSD: md.c,v 1.78.6.5 2017/05/14 05:38:38 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.4 2017/04/29 11:12:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.5 2017/05/14 05:38:38 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -261,7 +261,8 @@ mdsize(dev_t dev)
 static int
 mdopen(dev_t dev, int flag, int fmt, struct lwp *l)
 {
-	device_t self, new_self;
+	device_t self;
+	device_t new_self __diagused;
 	int unit;
 	int part = DISKPART(dev);
 	int pmask = 1 << part;



CVS commit: [prg-localcount2] src/sys/dev

2017-04-30 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr 30 10:27:16 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: wd.c
src/sys/dev/ic [prg-localcount2]: mlx.c nvme.c

Log Message:
And a few more DEVSW_MODULE_INIT for modular drivers


To generate a diff of this commit:
cvs rdiff -u -r1.429 -r1.429.2.1 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.65 -r1.65.6.1 src/sys/dev/ic/mlx.c
cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/dev/ic/nvme.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.429 src/sys/dev/ata/wd.c:1.429.2.1
--- src/sys/dev/ata/wd.c:1.429	Mon Apr 24 09:42:52 2017
+++ src/sys/dev/ata/wd.c	Sun Apr 30 10:27:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.429 2017/04/24 09:42:52 jdolecek Exp $ */
+/*	$NetBSD: wd.c,v 1.429.2.1 2017/04/30 10:27:16 pgoyette Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.429 2017/04/24 09:42:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.429.2.1 2017/04/30 10:27:16 pgoyette Exp $");
 
 #include "opt_ata.h"
 
@@ -143,6 +143,7 @@ dev_type_size(wdsize);
 static dev_type_discard(wddiscard);
 
 const struct bdevsw wd_bdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = wdopen,
 	.d_close = wdclose,
 	.d_strategy = wdstrategy,
@@ -154,6 +155,7 @@ const struct bdevsw wd_bdevsw = {
 };
 
 const struct cdevsw wd_cdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = wdopen,
 	.d_close = wdclose,
 	.d_read = wdread,

Index: src/sys/dev/ic/mlx.c
diff -u src/sys/dev/ic/mlx.c:1.65 src/sys/dev/ic/mlx.c:1.65.6.1
--- src/sys/dev/ic/mlx.c:1.65	Tue Sep 27 03:33:32 2016
+++ src/sys/dev/ic/mlx.c	Sun Apr 30 10:27:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mlx.c,v 1.65 2016/09/27 03:33:32 pgoyette Exp $	*/
+/*	$NetBSD: mlx.c,v 1.65.6.1 2017/04/30 10:27:16 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.65 2016/09/27 03:33:32 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mlx.c,v 1.65.6.1 2017/04/30 10:27:16 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "ld.h"
@@ -132,6 +132,7 @@ dev_type_close(mlxclose);
 dev_type_ioctl(mlxioctl);
 
 const struct cdevsw mlx_cdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = mlxopen,
 	.d_close = mlxclose,
 	.d_read = noread,

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.26 src/sys/dev/ic/nvme.c:1.26.4.1
--- src/sys/dev/ic/nvme.c:1.26	Wed Apr  5 20:15:49 2017
+++ src/sys/dev/ic/nvme.c	Sun Apr 30 10:27:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.26 2017/04/05 20:15:49 jdolecek Exp $	*/
+/*	$NetBSD: nvme.c,v 1.26.4.1 2017/04/30 10:27:16 pgoyette Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.26 2017/04/05 20:15:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.26.4.1 2017/04/30 10:27:16 pgoyette Exp $");
 
 #include 
 #include 
@@ -1690,6 +1690,7 @@ dev_type_close(nvmeclose);
 dev_type_ioctl(nvmeioctl);
 
 const struct cdevsw nvme_cdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = nvmeopen,
 	.d_close = nvmeclose,
 	.d_read = noread,



CVS commit: [prg-localcount2] src/sys/dev/pci

2017-04-30 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr 30 10:17:26 UTC 2017

Modified Files:
src/sys/dev/pci [prg-localcount2]: twa.c twe.c

Log Message:
More DEVSW_MODULE_INIT for modular drivers


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.6.1 src/sys/dev/pci/twa.c
cvs rdiff -u -r1.106 -r1.106.6.1 src/sys/dev/pci/twe.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/pci/twa.c
diff -u src/sys/dev/pci/twa.c:1.55 src/sys/dev/pci/twa.c:1.55.6.1
--- src/sys/dev/pci/twa.c:1.55	Tue Sep 27 12:04:16 2016
+++ src/sys/dev/pci/twa.c	Sun Apr 30 10:17:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: twa.c,v 1.55 2016/09/27 12:04:16 pgoyette Exp $ */
+/*	$NetBSD: twa.c,v 1.55.6.1 2017/04/30 10:17:26 pgoyette Exp $ */
 /*	$wasabi: twa.c,v 1.27 2006/07/28 18:17:21 wrstuden Exp $	*/
 
 /*-
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: twa.c,v 1.55 2016/09/27 12:04:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: twa.c,v 1.55.6.1 2017/04/30 10:17:26 pgoyette Exp $");
 
 //#define TWA_DEBUG
 
@@ -2287,6 +2287,7 @@ fw_passthru_done:
 }
 
 const struct cdevsw twa_cdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = twaopen,
 	.d_close = twaclose,
 	.d_read = noread,

Index: src/sys/dev/pci/twe.c
diff -u src/sys/dev/pci/twe.c:1.106 src/sys/dev/pci/twe.c:1.106.6.1
--- src/sys/dev/pci/twe.c:1.106	Tue Sep 27 03:33:32 2016
+++ src/sys/dev/pci/twe.c	Sun Apr 30 10:17:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: twe.c,v 1.106 2016/09/27 03:33:32 pgoyette Exp $	*/
+/*	$NetBSD: twe.c,v 1.106.6.1 2017/04/30 10:17:26 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: twe.c,v 1.106 2016/09/27 03:33:32 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: twe.c,v 1.106.6.1 2017/04/30 10:17:26 pgoyette Exp $");
 
 #include 
 #include 
@@ -1908,6 +1908,7 @@ done:
 }
 
 const struct cdevsw twe_cdevsw = {
+	DEVSW_MODULE_INIT
 	.d_open = tweopen,
 	.d_close = tweclose,
 	.d_read = noread,



CVS commit: [prg-localcount2] src/sys/dev

2017-04-29 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Apr 29 08:55:37 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: cgd.c

Log Message:
add a comment - NFC


To generate a diff of this commit:
cvs rdiff -u -r1.114.4.4 -r1.114.4.5 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.114.4.4 src/sys/dev/cgd.c:1.114.4.5
--- src/sys/dev/cgd.c:1.114.4.4	Fri Apr 28 06:00:33 2017
+++ src/sys/dev/cgd.c	Sat Apr 29 08:55:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.4 2017/04/28 06:00:33 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.5 2017/04/29 08:55:37 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.4 2017/04/28 06:00:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.5 2017/04/29 08:55:37 pgoyette Exp $");
 
 #include 
 #include 
@@ -449,6 +449,8 @@ cgdclose(dev_t dev, int flags, int fmt, 
 		}
 		return error;
 	}
+
+	/* Unit is still attached - just return */
 	device_release(self);
 	return 0;
 }



CVS commit: [prg-localcount2] src/sys/dev

2017-04-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Apr 28 23:16:14 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: vnd.c

Log Message:
Don't call device_release() from vnd_detach().  The caller (typically,
config_detach()) will take care of this.  Without this fix, we end up
with a negative reference count, and panic.


To generate a diff of this commit:
cvs rdiff -u -r1.259.4.2 -r1.259.4.3 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.259.4.2 src/sys/dev/vnd.c:1.259.4.3
--- src/sys/dev/vnd.c:1.259.4.2	Fri Apr 28 06:00:33 2017
+++ src/sys/dev/vnd.c	Fri Apr 28 23:16:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.259.4.2 2017/04/28 06:00:33 pgoyette Exp $	*/
+/*	$NetBSD: vnd.c,v 1.259.4.3 2017/04/28 23:16:14 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.2 2017/04/28 06:00:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.3 2017/04/28 23:16:14 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -276,8 +276,7 @@ vnd_attach(device_t parent, device_t sel
 }
 
 /*
- * The caller must hold a reference to the device's localcount.  the
- * reference is released if the device is available for detach.
+ * The caller must hold a reference to the device's localcount. 
  */
 static int
 vnd_detach(device_t self, int flags)
@@ -295,7 +294,6 @@ vnd_detach(device_t self, int flags)
 	bufq_free(sc->sc_tab);
 	disk_destroy(&sc->sc_dkdev);
 
-	device_release(self);
 	return 0;
 }
 



CVS commit: [prg-localcount2] src/sys/dev

2017-04-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Apr 27 23:18:21 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: md.c

Log Message:
Don't reference a known-NULL pointer, and remove duplicated calls to
mutex_enter() and mutex_exit()


To generate a diff of this commit:
cvs rdiff -u -r1.78.6.1 -r1.78.6.2 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.78.6.1 src/sys/dev/md.c:1.78.6.2
--- src/sys/dev/md.c:1.78.6.1	Thu Apr 27 05:36:35 2017
+++ src/sys/dev/md.c	Thu Apr 27 23:18:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.78.6.1 2017/04/27 05:36:35 pgoyette Exp $	*/
+/*	$NetBSD: md.c,v 1.78.6.2 2017/04/27 23:18:21 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.2 2017/04/27 23:18:21 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -294,7 +294,7 @@ mdopen(dev_t dev, int flag, int fmt, str
 		sc = device_private(self);
 		if (sc == NULL) {
 			mutex_exit(&md_device_lock);
-			device_release(sc->sc_dev);
+			device_release(self);
 			return ENOMEM;
 		}
 	}
@@ -450,7 +450,6 @@ mdstrategy(struct buf *bp)
 		bp->b_error = ENXIO;
 		goto done;
 	}
-	mutex_enter(&sc->sc_lock);
 
 	mutex_enter(&sc->sc_lock);
 
@@ -499,8 +498,6 @@ mdstrategy(struct buf *bp)
 	}
 	mutex_exit(&sc->sc_lock);
 
-	mutex_exit(&sc->sc_lock);
-
  done:
 	biodone(bp);
 	if (sc != NULL)



CVS commit: [prg-localcount2] src/sys/dev

2017-04-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Apr 27 12:07:23 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: cgd.c

Log Message:
Once more let's try to fix the exit path in cgdclose()


To generate a diff of this commit:
cvs rdiff -u -r1.114.4.2 -r1.114.4.3 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.114.4.2 src/sys/dev/cgd.c:1.114.4.3
--- src/sys/dev/cgd.c:1.114.4.2	Thu Apr 27 11:58:58 2017
+++ src/sys/dev/cgd.c	Thu Apr 27 12:07:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.3 2017/04/27 12:07:23 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.3 2017/04/27 12:07:23 pgoyette Exp $");
 
 #include 
 #include 
@@ -448,8 +448,8 @@ cgdclose(dev_t dev, int flags, int fmt, 
 		if ((error = cgd_destroy(cs->sc_dksc.sc_dev)) != 0) {
 			aprint_error_dev(dksc->sc_dev,
 			"unable to detach instance\n");
-			return error;
 		}
+		return error;
 	}
 	device_release(self);
 	return 0;



CVS commit: [prg-localcount2] src/sys/dev

2017-04-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Apr 27 11:58:58 UTC 2017

Modified Files:
src/sys/dev [prg-localcount2]: cgd.c

Log Message:
Fix checking of failure-to-spawn a unit (check the returned address for
NULL, vs the pointer to that address).

Ensure that that device_release() is called in all exit paths from cgd_close().

Update handling of CGDIOCCLR ioctl the same as CGDIOCSET.  In particular,
don't return without calling device_release(), as any subsequent attempt to
detach the device will hang forever waiting for its localcount to drain.


To generate a diff of this commit:
cvs rdiff -u -r1.114.4.1 -r1.114.4.2 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.114.4.1 src/sys/dev/cgd.c:1.114.4.2
--- src/sys/dev/cgd.c:1.114.4.1	Thu Apr 27 05:36:35 2017
+++ src/sys/dev/cgd.c	Thu Apr 27 11:58:58 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $");
 
 #include 
 #include 
@@ -388,8 +388,7 @@ cgd_spawn(int unit, device_t *self)
 	if (config_attach_pseudo(cf) == NULL)
 		return NULL;
 
-	*self = device_lookup_acquire(&cgd_cd, unit);
-	if (self == NULL)
+	if ((*self = device_lookup_acquire(&cgd_cd, unit)) == NULL)
 		return NULL;
 	else {
 		/*
@@ -451,8 +450,8 @@ cgdclose(dev_t dev, int flags, int fmt, 
 			"unable to detach instance\n");
 			return error;
 		}
-	} else
-		device_release(self);
+	}
+	device_release(self);
 	return 0;
 }
 
@@ -788,8 +787,10 @@ cgdioctl(dev_t dev, u_long cmd, void *da
 		break;
 	case CGDIOCCLR:
 		if (DK_BUSY(&cs->sc_dksc, pmask))
-			return EBUSY;
-		return cgd_ioctl_clr(cs, l);
+			error = EBUSY;
+		else
+			error = cgd_ioctl_clr(cs, l);
+		break;
 	case DIOCGCACHE:
 	case DIOCCACHESYNC:
 		if (!DK_ATTACHED(dksc))