CVS commit: src/share/man/man9

2015-08-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Aug  6 06:56:00 UTC 2015

Modified Files:
src/share/man/man9: pci_intr.9

Log Message:
Use Dv for NULL, remove dot at end of SEE ALSO


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man9/pci_intr.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/pci_intr.9
diff -u src/share/man/man9/pci_intr.9:1.19 src/share/man/man9/pci_intr.9:1.20
--- src/share/man/man9/pci_intr.9:1.19	Wed Aug  5 07:00:34 2015
+++ src/share/man/man9/pci_intr.9	Thu Aug  6 06:56:00 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: pci_intr.9,v 1.19 2015/08/05 07:00:34 mrg Exp $
+.\" $NetBSD: pci_intr.9,v 1.20 2015/08/06 06:56:00 wiz Exp $
 .\"
 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -112,8 +112,9 @@ when the driver is no longer interested 
 .Pp
 The
 .Fn pci_intr_evcnt
-function should return an evcnt structure pointer or NULL if there is
-no evcnt associated with this interrupt.
+function should return an evcnt structure pointer or
+.Dv NULL
+if there is no evcnt associated with this interrupt.
 See
 .Xr evcnt 9
 for more details.
@@ -160,4 +161,4 @@ contains the PCI tag of the device itsel
 contains the PCI tag of the uppermost bridge device.
 .Sh SEE ALSO
 .Xr evcnt 9 ,
-.Xr pci 9 .
+.Xr pci 9



CVS commit: src/usr.sbin/mountd

2015-08-05 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Wed Aug  5 23:23:47 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
PR/50125 - Jarle Greipsland -- Incorrect PID in /var/run/mountd.pid

Move call to pidfile() after daemon() so that correct (child) pid is
written to pidfile.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.126 src/usr.sbin/mountd/mountd.c:1.127
--- src/usr.sbin/mountd/mountd.c:1.126	Fri Apr  4 12:45:59 2014
+++ src/usr.sbin/mountd/mountd.c	Wed Aug  5 23:23:47 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $");
 #endif
 #endif/* not lint */
 
@@ -336,7 +336,6 @@ main(int argc, char **argv)
 		(void)fprintf(stderr, "Here we go.\n");
 	(void)signal(SIGHUP, get_exportlist);
 	(void)signal(SIGTERM, send_umntall);
-	pidfile(NULL);
 
 	rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL);
 	rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL);
@@ -463,6 +462,7 @@ main(int argc, char **argv)
 		(void)signal(SIGINT, SIG_IGN);
 		(void)signal(SIGQUIT, SIG_IGN);
 	}
+	pidfile(NULL);
 	svc_run();
 	syslog(LOG_ERR, "Mountd died");
 	exit(1);



CVS commit: src/sys/compat/netbsd32

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 23:17:06 UTC 2015

Modified Files:
src/sys/compat/netbsd32: netbsd32_nfssvc.c

Log Message:
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop.  oops.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/netbsd32/netbsd32_nfssvc.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/compat/netbsd32/netbsd32_nfssvc.c
diff -u src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.2 src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.3
--- src/sys/compat/netbsd32/netbsd32_nfssvc.c:1.2	Tue Jun 23 06:28:29 2015
+++ src/sys/compat/netbsd32/netbsd32_nfssvc.c	Wed Aug  5 23:17:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_nfssvc.c,v 1.2 2015/06/23 06:28:29 dholland Exp $	*/
+/*	$NetBSD: netbsd32_nfssvc.c,v 1.3 2015/08/05 23:17:06 mrg Exp $	*/
 
 /*
  * Copyright (c) 2015 Matthew R. Green
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_nfssvc.c,v 1.2 2015/06/23 06:28:29 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_nfssvc.c,v 1.3 2015/08/05 23:17:06 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -138,22 +138,24 @@ nfssvc32_nsd_out(void *argp, const struc
 static int
 nfssvc32_exp_in(struct export_args *exp, const void *argp, size_t nexports)
 {
-	struct netbsd32_export_args args32;
+	struct netbsd32_export_args exp32;
+	struct netbsd32_export_args const *argp32 = argp;
 	int error = 0;
 
 	for (size_t i = 0; i < nexports; i++) {
-		error = copyin(argp, &args32, sizeof args32);
+		error = copyin(argp32, &exp32, sizeof exp32);
 		if (error)
 			break;
-		exp->ex_flags = args32.ex_flags;
-		exp->ex_root = args32.ex_root;
-		exp->ex_anon = args32.ex_anon;
-		exp->ex_addr = NETBSD32PTR64(args32.ex_addr);
-		exp->ex_addrlen = args32.ex_addrlen;
-		exp->ex_mask = NETBSD32PTR64(args32.ex_mask);
-		exp->ex_masklen = args32.ex_masklen;
-		exp->ex_indexfile = NETBSD32PTR64(args32.ex_indexfile);
+		exp->ex_flags = exp32.ex_flags;
+		exp->ex_root = exp32.ex_root;
+		exp->ex_anon = exp32.ex_anon;
+		exp->ex_addr = NETBSD32PTR64(exp32.ex_addr);
+		exp->ex_addrlen = exp32.ex_addrlen;
+		exp->ex_mask = NETBSD32PTR64(exp32.ex_mask);
+		exp->ex_masklen = exp32.ex_masklen;
+		exp->ex_indexfile = NETBSD32PTR64(exp32.ex_indexfile);
 		exp++;
+		argp32++;
 	}
 
 	return error;



CVS commit: src/sys/kern

2015-08-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Aug  5 16:51:09 UTC 2015

Modified Files:
src/sys/kern: kern_rndq.c

Log Message:
KNF (Khange Not Functional)


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/kern_rndq.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/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.71 src/sys/kern/kern_rndq.c:1.72
--- src/sys/kern/kern_rndq.c:1.71	Wed Aug  5 16:37:27 2015
+++ src/sys/kern/kern_rndq.c	Wed Aug  5 16:51:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.71 2015/08/05 16:37:27 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.72 2015/08/05 16:51:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.71 2015/08/05 16:37:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.72 2015/08/05 16:51:09 riastradh Exp $");
 
 #include 
 #include 
@@ -190,7 +190,9 @@ rnd_printf(const char *fmt, ...)
 }
 
 void
-rnd_init_softint(void) {
+rnd_init_softint(void)
+{
+
 	rnd_process = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
 	rnd_intr, NULL);
 	rnd_wakeup = softint_establish(SOFTINT_CLOCK|SOFTINT_MPSAFE,
@@ -231,6 +233,7 @@ rnd_counter(void)
 static inline void
 rnd_schedule_softint(void *softint)
 {
+
 	kpreempt_disable();
 	softint_schedule(softint);
 	kpreempt_enable();
@@ -239,16 +242,18 @@ rnd_schedule_softint(void *softint)
 static inline void
 rnd_schedule_process(void)
 {
+
 	if (__predict_true(rnd_process)) {
 		rnd_schedule_softint(rnd_process);
 		return;
-	} 
+	}
 	rnd_process_events();
 }
 
 static inline void
 rnd_schedule_wakeup(void)
 {
+
 	if (__predict_true(rnd_wakeup)) {
 		rnd_schedule_softint(rnd_wakeup);
 		return;
@@ -328,10 +333,10 @@ rnd_delta_estimate(rnd_delta_t *d, uint3
 	 * might have something.
 	 */
 	if (delta == 0 || delta2 == 0 || delta3 == 0)
-		return (0);
+		return 0;
 
 	d->outbits++;
-	return (1);
+	return 1;
 }
 
 /*
@@ -593,13 +598,13 @@ rnd_sample_allocate(krndsource_t *source
 
 	c = pool_cache_get(rnd_mempc, PR_WAITOK);
 	if (c == NULL)
-		return (NULL);
+		return NULL;
 
 	c->source = source;
 	c->cursor = 0;
 	c->entropy = 0;
 
-	return (c);
+	return c;
 }
 
 /*
@@ -612,18 +617,19 @@ rnd_sample_allocate_isr(krndsource_t *so
 
 	c = pool_cache_get(rnd_mempc, PR_NOWAIT);
 	if (c == NULL)
-		return (NULL);
+		return NULL;
 
 	c->source = source;
 	c->cursor = 0;
 	c->entropy = 0;
 
-	return (c);
+	return c;
 }
 
 static void
 rnd_sample_free(rnd_sample_t *c)
 {
+
 	memset(c, 0, sizeof(*c));
 	pool_cache_put(rnd_mempc, c);
 }
@@ -656,17 +662,17 @@ rnd_attach_source(krndsource_t *rs, cons
 	}
 
 	switch (type) {
-	case RND_TYPE_NET:		/* Don't collect by default */
+	case RND_TYPE_NET:		/* Don't collect by default */
 		flags |= (RND_FLAG_NO_COLLECT | RND_FLAG_NO_ESTIMATE);
 		break;
-	case RND_TYPE_RNG:		/* Space for statistical testing */
+	case RND_TYPE_RNG:		/* Space for statistical testing */
 		rs->test = kmem_alloc(sizeof(rngtest_t), KM_NOSLEEP);
 		rs->test_cnt = 0;
 		/* FALLTHRU */
-	case RND_TYPE_VM:		/* Process samples in bulk always */
+	case RND_TYPE_VM:		/* Process samples in bulk always */
 		flags |= RND_FLAG_FAST;
 		break;
-	default:
+	default:
 		break;
 	}
 
@@ -686,9 +692,9 @@ rnd_attach_source(krndsource_t *rs, cons
 		rnd_printf_verbose("collecting");
 		if (flags & RND_FLAG_NO_ESTIMATE)
 			rnd_printf_verbose(" without estimation");
-	}
-	else
+	} else {
 		rnd_printf_verbose("off");
+	}
 	rnd_printf_verbose(")\n");
 #endif
 
@@ -774,7 +780,7 @@ rnd_estimate(krndsource_t *rs, uint32_t 
 void
 _rnd_add_uint32(krndsource_t *rs, uint32_t val)
 {
-	uint32_t ts;	
+	uint32_t ts;
 	uint32_t entropy = 0;
 
 	if (rs->flags & RND_FLAG_NO_COLLECT)
@@ -798,7 +804,7 @@ _rnd_add_uint32(krndsource_t *rs, uint32
 void
 _rnd_add_uint64(krndsource_t *rs, uint64_t val)
 {
-	uint32_t ts;   
+	uint32_t ts;
 	uint32_t entropy = 0;
 
 	if (rs->flags & RND_FLAG_NO_COLLECT)
@@ -823,6 +829,7 @@ void
 rnd_add_data(krndsource_t *rs, const void *const data, uint32_t len,
 	 uint32_t entropy)
 {
+
 	/*
 	 * This interface is meant for feeding data which is,
 	 * itself, random.  Don't estimate entropy based on
@@ -848,10 +855,10 @@ rnd_add_data_ts(krndsource_t *rs, const 
 	int sample_count;
 	struct rnd_sampleq tmp_samples = SIMPLEQ_HEAD_INITIALIZER(tmp_samples);
 
-	if (rs && (rs->flags & RND_FLAG_NO_COLLECT ||
-	__predict_false(!(rs->flags & 
-			 (RND_FLAG_COLLECT_TIME|
-			 RND_FLAG_COLLECT_VALUE) {
+	if (rs &&
+	(rs->flags & RND_FLAG_NO_COLLECT ||
+		__predict_false(!(rs->flags &
+			(RND_FLAG_COLLECT_TIME|RND_FLAG_COLLECT_VALUE) {
 		return;
 	}
 	todo = len / sizeof(dint);
@@ -869,7 +876,7 @@ rnd_add_data_ts(krndsource_t *rs, const 
 			struct timeval upt;
 
 			getmicrouptime(&upt);
-			if ( (upt.tv_sec 

CVS commit: src/sys/kern

2015-08-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Aug  5 16:37:27 UTC 2015

Modified Files:
src/sys/kern: kern_rndq.c

Log Message:
Terminate message with newline.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/kern_rndq.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/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.70 src/sys/kern/kern_rndq.c:1.71
--- src/sys/kern/kern_rndq.c:1.70	Tue Apr 21 12:55:57 2015
+++ src/sys/kern/kern_rndq.c	Wed Aug  5 16:37:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.70 2015/04/21 12:55:57 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.71 2015/08/05 16:37:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.70 2015/04/21 12:55:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.71 2015/08/05 16:37:27 riastradh Exp $");
 
 #include 
 #include 
@@ -1079,7 +1079,7 @@ rnd_process_events(void)
 		if (source->type == RND_TYPE_RNG) {
 			if (__predict_false(rnd_hwrng_test(sample))) {
 source->flags |= RND_FLAG_NO_COLLECT;
-rnd_printf("rnd: disabling source \"%s\".",
+rnd_printf("rnd: disabling source \"%s\".\n",
 source->name);
 goto skip;
 			}



CVS commit: src/sys/kern

2015-08-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug  5 15:58:01 UTC 2015

Modified Files:
src/sys/kern: exec_elf.c

Log Message:
stupid comment, and make sure we are not executing a lib


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/kern/exec_elf.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/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.74 src/sys/kern/exec_elf.c:1.75
--- src/sys/kern/exec_elf.c:1.74	Tue Aug  4 18:28:09 2015
+++ src/sys/kern/exec_elf.c	Wed Aug  5 15:58:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.74 2015/08/04 18:28:09 maxv Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.75 2015/08/05 15:58:01 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.74 2015/08/04 18:28:09 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.75 2015/08/05 15:58:01 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -646,10 +646,7 @@ exec_elf_makecmds(struct lwp *l, struct 
 		return error;
 
 	if (eh->e_type == ET_DYN)
-		/*
-		 * XXX allow for executing shared objects. It seems silly
-		 * but other ELF-based systems allow it as well.
-		 */
+		/* PIE */
 		is_dyn = true;
 	else if (eh->e_type != ET_EXEC)
 		return ENOEXEC;
@@ -695,6 +692,12 @@ exec_elf_makecmds(struct lwp *l, struct 
 		}
 	}
 
+	if (is_dyn && (interp == NULL)) {
+		/* PIEs must have an interpreter */
+		error = ENOEXEC;
+		goto bad;
+	}
+
 	/*
 	 * On the same architecture, we may be emulating different systems.
 	 * See which one will accept this executable.



CVS commit: src/sys/dev/sdmmc

2015-08-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug  5 12:28:47 UTC 2015

Modified Files:
src/sys/dev/sdmmc: sdhc.c sdhcreg.h

Log Message:
support re-tuning modes 1 and 2


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sdmmc/sdhcreg.h

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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.79 src/sys/dev/sdmmc/sdhc.c:1.80
--- src/sys/dev/sdmmc/sdhc.c:1.79	Wed Aug  5 10:30:25 2015
+++ src/sys/dev/sdmmc/sdhc.c	Wed Aug  5 12:28:47 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.79 2015/08/05 10:30:25 jmcneill Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.80 2015/08/05 12:28:47 jmcneill Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.79 2015/08/05 10:30:25 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.80 2015/08/05 12:28:47 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.7
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -78,6 +79,11 @@ struct sdhc_host {
 	kmutex_t intr_lock;
 	kcondvar_t intr_cv;
 
+	callout_t tuning_timer;
+	int tuning_timing;
+	u_int tuning_timer_count;
+	u_int tuning_timer_pending;
+
 	int specver;			/* spec. version */
 
 	uint32_t flags;			/* flags for this host */
@@ -184,6 +190,7 @@ static void	sdhc_exec_command(sdmmc_chip
 		struct sdmmc_command *);
 static int	sdhc_signal_voltage(sdmmc_chipset_handle_t, int);
 static int	sdhc_execute_tuning(sdmmc_chipset_handle_t, int);
+static void	sdhc_tuning_timer(void *);
 static int	sdhc_start_command(struct sdhc_host *, struct sdmmc_command *);
 static int	sdhc_wait_state(struct sdhc_host *, uint32_t, uint32_t);
 static int	sdhc_soft_reset(struct sdhc_host *, int);
@@ -279,6 +286,8 @@ sdhc_host_found(struct sdhc_softc *sc, b
 
 	mutex_init(&hp->intr_lock, MUTEX_DEFAULT, IPL_SDMMC);
 	cv_init(&hp->intr_cv, "sdhcintr");
+	callout_init(&hp->tuning_timer, CALLOUT_MPSAFE);
+	callout_setfunc(&hp->tuning_timer, sdhc_tuning_timer, hp);
 
 	if (ISSET(hp->sc->sc_flags, SDHC_FLAG_ENHANCED)) {
 		sdhcver = HREAD4(hp, SDHC_ESDHC_HOST_CTL_VERSION);
@@ -329,6 +338,18 @@ sdhc_host_found(struct sdhc_softc *sc, b
 		}
 	}
 
+	const u_int retuning_mode = (caps2 >> SDHC_RETUNING_MODES_SHIFT) &
+	SDHC_RETUNING_MODES_MASK;
+	if (retuning_mode == SDHC_RETUNING_MODE_1) {
+		hp->tuning_timer_count = (caps2 >> SDHC_TIMER_COUNT_SHIFT) &
+		SDHC_TIMER_COUNT_MASK;
+		if (hp->tuning_timer_count == 0xf)
+			hp->tuning_timer_count = 0;
+		if (hp->tuning_timer_count)
+			hp->tuning_timer_count =
+			1 << (hp->tuning_timer_count - 1);
+	}
+
 	/*
 	 * Use DMA if the host system and the controller support it.
 	 * Suports integrated or external DMA egine, with or without
@@ -442,6 +463,11 @@ sdhc_host_found(struct sdhc_softc *sc, b
 		SET(hp->ocr, MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V);
 		aprint_normal(" 3.3V");
 	}
+	if (hp->specver >= SDHC_SPEC_VERS_300) {
+		aprint_normal(", re-tuning mode %d", retuning_mode + 1);
+		if (hp->tuning_timer_count)
+			aprint_normal(" (%us timer)", hp->tuning_timer_count);
+	}
 
 	/*
 	 * Determine the maximum block length supported by the host
@@ -560,6 +586,7 @@ adma_done:
 	return 0;
 
 err:
+	callout_destroy(&hp->tuning_timer);
 	cv_destroy(&hp->intr_cv);
 	mutex_destroy(&hp->intr_lock);
 	free(hp, M_DEVBUF);
@@ -595,6 +622,8 @@ sdhc_detach(struct sdhc_softc *sc, int f
 			sdhc_soft_reset(hp, SDHC_RESET_ALL);
 			mutex_exit(&hp->intr_lock);
 		}
+		callout_halt(&hp->tuning_timer, NULL);
+		callout_destroy(&hp->tuning_timer);
 		cv_destroy(&hp->intr_cv);
 		mutex_destroy(&hp->intr_lock);
 		if (hp->ios > 0) {
@@ -841,6 +870,7 @@ sdhc_bus_power(sdmmc_chipset_handle_t sc
 	/* If power is disabled, reset the host and return now. */
 	if (ocr == 0) {
 		(void)sdhc_host_reset1(hp);
+		callout_halt(&hp->tuning_timer, &hp->intr_lock);
 		goto out;
 	}
 
@@ -1241,6 +1271,8 @@ sdhc_execute_tuning(sdmmc_chipset_handle
 	uint8_t hostctl;
 	int opcode, error, retry = 40;
 
+	hp->tuning_timing = timing;
+
 	switch (timing) {
 	case SDMMC_TIMING_MMC_HS200:
 		opcode = MMC_SEND_TUNING_BLOCK_HS200;
@@ -1318,9 +1350,22 @@ sdhc_execute_tuning(sdmmc_chipset_handle
 		return EIO;		/* tuning failed */
 	}
 
+	if (hp->tuning_timer_count) {
+		callout_schedule(&hp->tuning_timer,
+		hz * hp->tuning_timer_count);
+	}
+
 	return 0;		/* tuning completed */
 }
 
+static void
+sdhc_tuning_timer(void *arg)
+{
+	struct sdhc_host *hp = arg;
+
+	atomic_swap_uint(&hp->tuning_timer_pending, 1);
+}
+
 static int
 sdhc_wait_state(struct sdhc_host *hp, uint32_t mask, uint32_t value)
 {
@@ -1345,6 +1390,10 @@ sdhc_exec_command(sdmmc_chipset_handle_t
 
 	mutex_enter(&hp->intr_lock);
 
+	if (atomic_cas_uint(&hp->tuning_timer_p

CVS commit: src/sys/dev/sdmmc

2015-08-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug  5 10:30:25 UTC 2015

Modified Files:
src/sys/dev/sdmmc: sdhc.c sdhcreg.h

Log Message:
Implement SDHC sampling clock tuning procedure.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/sdmmc/sdhcreg.h

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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.78 src/sys/dev/sdmmc/sdhc.c:1.79
--- src/sys/dev/sdmmc/sdhc.c:1.78	Wed Aug  5 07:31:52 2015
+++ src/sys/dev/sdmmc/sdhc.c	Wed Aug  5 10:30:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.78 2015/08/05 07:31:52 mlelstv Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.79 2015/08/05 10:30:25 jmcneill Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.78 2015/08/05 07:31:52 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.79 2015/08/05 10:30:25 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -55,6 +55,7 @@ void	sdhc_dump_regs(struct sdhc_host *);
 #define SDHC_BUFFER_TIMEOUT	hz
 #define SDHC_TRANSFER_TIMEOUT	hz
 #define SDHC_DMA_TIMEOUT	(hz*3)
+#define SDHC_TUNING_TIMEOUT	hz
 
 struct sdhc_host {
 	struct sdhc_softc *sc;		/* host controller device */
@@ -182,6 +183,7 @@ static void	sdhc_card_intr_ack(sdmmc_chi
 static void	sdhc_exec_command(sdmmc_chipset_handle_t,
 		struct sdmmc_command *);
 static int	sdhc_signal_voltage(sdmmc_chipset_handle_t, int);
+static int	sdhc_execute_tuning(sdmmc_chipset_handle_t, int);
 static int	sdhc_start_command(struct sdhc_host *, struct sdmmc_command *);
 static int	sdhc_wait_state(struct sdhc_host *, uint32_t, uint32_t);
 static int	sdhc_soft_reset(struct sdhc_host *, int);
@@ -224,6 +226,7 @@ static struct sdmmc_chip_functions sdhc_
 	/* UHS functions */
 	.signal_voltage = sdhc_signal_voltage,
 	.bus_clock_ddr = sdhc_bus_clock_ddr,
+	.execute_tuning = sdhc_execute_tuning,
 };
 
 static int
@@ -318,11 +321,11 @@ sdhc_host_found(struct sdhc_softc *sc, b
 		caps = sc->sc_caps;
 		caps2 = sc->sc_caps2;
 	} else {
-		caps = HREAD4(hp, SDHC_CAPABILITIES);
+		caps = sc->sc_caps = HREAD4(hp, SDHC_CAPABILITIES);
 		if (hp->specver >= SDHC_SPEC_VERS_300) {
-			caps2 = HREAD4(hp, SDHC_CAPABILITIES2);
+			caps2 = sc->sc_caps2 = HREAD4(hp, SDHC_CAPABILITIES2);
 		} else {
-			caps2 = 0;
+			caps2 = sc->sc_caps2 = 0;
 		}
 	}
 
@@ -1227,6 +1230,97 @@ sdhc_signal_voltage(sdmmc_chipset_handle
 	return 0;
 }
 
+/*
+ * Sampling clock tuning procedure (UHS)
+ */
+static int
+sdhc_execute_tuning(sdmmc_chipset_handle_t sch, int timing)
+{
+	struct sdhc_host *hp = (struct sdhc_host *)sch;
+	struct sdmmc_command cmd;
+	uint8_t hostctl;
+	int opcode, error, retry = 40;
+
+	switch (timing) {
+	case SDMMC_TIMING_MMC_HS200:
+		opcode = MMC_SEND_TUNING_BLOCK_HS200;
+		break;
+	case SDMMC_TIMING_UHS_SDR50:
+		if (!ISSET(hp->sc->sc_caps2, SDHC_TUNING_SDR50))
+			return 0;
+		/* FALLTHROUGH */
+	case SDMMC_TIMING_UHS_SDR104:
+		opcode = MMC_SEND_TUNING_BLOCK;
+		break;
+	default:
+		return EINVAL;
+	}
+
+	hostctl = HREAD1(hp, SDHC_HOST_CTL);
+
+	/* enable buffer read ready interrupt */
+	HSET2(hp, SDHC_NINTR_SIGNAL_EN, SDHC_BUFFER_READ_READY);
+	HSET2(hp, SDHC_NINTR_STATUS_EN, SDHC_BUFFER_READ_READY);
+
+	/* disable DMA */
+	HCLR1(hp, SDHC_HOST_CTL, SDHC_DMA_SELECT);
+
+	/* reset tuning circuit */
+	HCLR2(hp, SDHC_HOST_CTL2, SDHC_SAMPLING_CLOCK_SEL);
+
+	/* start of tuning */
+	HWRITE2(hp, SDHC_HOST_CTL2, SDHC_EXECUTE_TUNING);
+
+	mutex_enter(&hp->intr_lock);
+	do {
+		memset(&cmd, 0, sizeof(cmd));
+		cmd.c_opcode = opcode;
+		cmd.c_arg = 0;
+		cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
+		if (ISSET(hostctl, SDHC_8BIT_MODE)) {
+			cmd.c_blklen = cmd.c_datalen = 128;
+		} else {
+			cmd.c_blklen = cmd.c_datalen = 64;
+		}
+
+		error = sdhc_start_command(hp, &cmd);
+		if (error)
+			break;
+
+		if (!sdhc_wait_intr(hp, SDHC_BUFFER_READ_READY,
+		SDHC_TUNING_TIMEOUT)) {
+			break;
+		}
+
+		delay(1000);
+	} while (HREAD2(hp, SDHC_HOST_CTL2) & SDHC_EXECUTE_TUNING && --retry);
+	mutex_exit(&hp->intr_lock);
+
+	/* disable buffer read ready interrupt */
+	HCLR2(hp, SDHC_NINTR_SIGNAL_EN, SDHC_BUFFER_READ_READY);
+	HCLR2(hp, SDHC_NINTR_STATUS_EN, SDHC_BUFFER_READ_READY);
+
+	if (HREAD2(hp, SDHC_HOST_CTL2) & SDHC_EXECUTE_TUNING) {
+		HCLR2(hp, SDHC_HOST_CTL2,
+		SDHC_SAMPLING_CLOCK_SEL|SDHC_EXECUTE_TUNING);
+		sdhc_soft_reset(hp, SDHC_RESET_DAT|SDHC_RESET_CMD);
+		aprint_error_dev(hp->sc->sc_dev,
+		"tuning did not complete, using fixed sampling clock\n");
+		return EIO;		/* tuning did not complete */
+	}
+
+	if ((HREAD2(hp, SDHC_HOST_CTL2) & SDHC_SAMPLING_CLOCK_SEL) == 0) {
+		HCLR2(hp, SDHC_HOST_CTL2,
+		SDHC_SAMPLING_CLOCK_SEL|SDHC_EXECUTE_TUNING);
+		sdhc_soft_reset(hp, SDHC_RESET_DAT|SDHC_RESET_CMD);
+		aprint_error_dev(hp

CVS commit: src/sys/dev/sdmmc

2015-08-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug  5 10:29:37 UTC 2015

Modified Files:
src/sys/dev/sdmmc: sdmmc_mem.c sdmmcchip.h sdmmcreg.h

Log Message:
Add support for sampling clock tuning, required for some UHS modes and
MMC HS200.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/sdmmc/sdmmc_mem.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sdmmc/sdmmcchip.h
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sdmmc/sdmmcreg.h

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/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.44 src/sys/dev/sdmmc/sdmmc_mem.c:1.45
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.44	Tue Aug  4 01:21:55 2015
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Wed Aug  5 10:29:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_mem.c,v 1.44 2015/08/04 01:21:55 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_mem.c,v 1.45 2015/08/05 10:29:37 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.44 2015/08/04 01:21:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.45 2015/08/05 10:29:37 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -142,13 +142,6 @@ sdmmc_mem_enable(struct sdmmc_softc *sc)
 	/* Reset memory (*must* do that before CMD55 or CMD1). */
 	sdmmc_go_idle_state(sc);
 
-	/* Set 3.3V signaling */
-	if (sc->sc_sct->signal_voltage) {
-		error = sdmmc_mem_signal_voltage(sc, SDMMC_SIGNAL_VOLTAGE_330);
-		if (error)
-			goto out;
-	}
-
 	if (ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) {
 		/* Check SD Ver.2 */
 		error = sdmmc_mem_send_if_cond(sc, 0x1aa, &card_ocr);
@@ -741,6 +734,44 @@ sdmmc_mem_select_transfer_mode(struct sd
 }
 
 static int
+sdmmc_mem_execute_tuning(struct sdmmc_softc *sc, struct sdmmc_function *sf)
+{
+	int timing = -1;
+
+	if (!ISSET(sc->sc_flags, SMF_UHS_MODE))
+		return 0;
+
+	if (ISSET(sc->sc_flags, SMF_SD_MODE)) {
+		if (!ISSET(sc->sc_flags, SMF_UHS_MODE))
+			return 0;
+
+		switch (sf->csd.tran_speed) {
+		case 10:
+			timing = SDMMC_TIMING_UHS_SDR50;
+			break;
+		case 208000:
+			timing = SDMMC_TIMING_UHS_SDR104;
+			break; 
+		default:
+			return 0;
+		}
+	} else {
+		switch (sf->csd.tran_speed) {
+		case 20:
+			timing = SDMMC_TIMING_MMC_HS200;
+			break;
+		default:
+			return 0;
+		}
+	}
+
+	DPRINTF(("%s: execute tuning for timing %d\n", SDMMCDEVNAME(sc),
+	timing));
+
+	return sdmmc_chip_execute_tuning(sc->sc_sct, sc->sc_sch, timing);
+}
+
+static int
 sdmmc_mem_sd_init(struct sdmmc_softc *sc, struct sdmmc_function *sf)
 {
 	int support_func, best_func, bus_clock, error, i;
@@ -854,6 +885,13 @@ sdmmc_mem_sd_init(struct sdmmc_softc *sc
 	sc->sc_transfer_mode = switch_group0_functions[best_func].name;
 	sc->sc_busddr = ddr;
 
+	/* execute tuning (UHS) */
+	error = sdmmc_mem_execute_tuning(sc, sf);
+	if (error) {
+		aprint_error_dev(sc->sc_dev, "can't execute SD tuning\n");
+		return error;
+	}
+
 	return 0;
 }
 
@@ -994,6 +1032,14 @@ sdmmc_mem_mmc_init(struct sdmmc_softc *s
 
 		if (hs_timing == 2) {
 			sc->sc_transfer_mode = "HS200";
+
+			/* execute tuning (HS200) */
+			error = sdmmc_mem_execute_tuning(sc, sf);
+			if (error) {
+aprint_error_dev(sc->sc_dev,
+"can't execute MMC tuning\n");
+return error;
+			}
 		} else {
 			sc->sc_transfer_mode = NULL;
 		}

Index: src/sys/dev/sdmmc/sdmmcchip.h
diff -u src/sys/dev/sdmmc/sdmmcchip.h:1.6 src/sys/dev/sdmmc/sdmmcchip.h:1.7
--- src/sys/dev/sdmmc/sdmmcchip.h:1.6	Mon Aug  3 10:08:51 2015
+++ src/sys/dev/sdmmc/sdmmcchip.h	Wed Aug  5 10:29:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmcchip.h,v 1.6 2015/08/03 10:08:51 jmcneill Exp $	*/
+/*	$NetBSD: sdmmcchip.h,v 1.7 2015/08/05 10:29:37 jmcneill Exp $	*/
 /*	$OpenBSD: sdmmcchip.h,v 1.3 2007/05/31 10:09:01 uwe Exp $	*/
 
 /*
@@ -61,6 +61,7 @@ struct sdmmc_chip_functions {
 	/* UHS functions */
 	int		(*signal_voltage)(sdmmc_chipset_handle_t, int);
 	int		(*bus_clock_ddr)(sdmmc_chipset_handle_t, int, bool);
+	int		(*execute_tuning)(sdmmc_chipset_handle_t, int);
 };
 
 /* host controller reset */
@@ -95,8 +96,10 @@ struct sdmmc_chip_functions {
 #define sdmmc_chip_card_intr_ack(tag, handle)\
 	((tag)->card_intr_ack((handle)))
 /* UHS functions */
-#define sdmmc_chip_signal_voltage(tag, handle, voltage)		\
+#define sdmmc_chip_signal_voltage(tag, handle, voltage)			\
 	((tag)->signal_voltage((handle), (voltage)))
+#define sdmmc_chip_execute_tuning(tag, handle, timing)			\
+	((tag)->execute_tuning ? (tag)->execute_tuning((handle), (timing)) : EINVAL)
 
 /* clock frequencies for sdmmc_chip_bus_clock() */
 #define SDMMC_SDCLK_OFF		0
@@ -106,6 +109,11 @@ struct sdmmc_chip_functions {
 #define SDMMC_SIGNAL_VOLTAGE_330	0
 #define SDMMC_SIGNAL_VOLTAGE_180	1
 
+/* timings for sdmmc_chip_execute_tuning() */
+#define SDMMC_TIMING_UHS_SDR50		0
+#define SDMMC_TIMING_U

CVS commit: src/sys/dev/sdmmc

2015-08-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Aug  5 07:34:56 UTC 2015

Modified Files:
src/sys/dev/sdmmc: sdmmc_io.c

Log Message:
lock around interrupt registration.
don't release lock around interrupt handlers, the code cannot
handle an unstable handler list.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/sdmmc/sdmmc_io.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/sdmmc/sdmmc_io.c
diff -u src/sys/dev/sdmmc/sdmmc_io.c:1.10 src/sys/dev/sdmmc/sdmmc_io.c:1.11
--- src/sys/dev/sdmmc/sdmmc_io.c:1.10	Mon Aug  3 10:08:51 2015
+++ src/sys/dev/sdmmc/sdmmc_io.c	Wed Aug  5 07:34:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_io.c,v 1.10 2015/08/03 10:08:51 jmcneill Exp $	*/
+/*	$NetBSD: sdmmc_io.c,v 1.11 2015/08/05 07:34:56 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmc_io.c,v 1.10 2007/09/17 01:33:33 krw Exp $	*/
 
 /*
@@ -20,7 +20,7 @@
 /* Routines for SD I/O cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.10 2015/08/03 10:08:51 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_io.c,v 1.11 2015/08/05 07:34:56 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -597,9 +597,11 @@ sdmmc_intr_enable(struct sdmmc_function 
 	uint8_t reg;
 
 	SDMMC_LOCK(sc);
+	mutex_enter(&sc->sc_intr_task_mtx);
 	reg = sdmmc_io_read_1(sf0, SD_IO_CCCR_FN_INTEN);
 	reg |= 1 << sf->number;
 	sdmmc_io_write_1(sf0, SD_IO_CCCR_FN_INTEN, reg);
+	mutex_exit(&sc->sc_intr_task_mtx);
 	SDMMC_UNLOCK(sc);
 }
 
@@ -611,9 +613,11 @@ sdmmc_intr_disable(struct sdmmc_function
 	uint8_t reg;
 
 	SDMMC_LOCK(sc);
+	mutex_enter(&sc->sc_intr_task_mtx);
 	reg = sdmmc_io_read_1(sf0, SD_IO_CCCR_FN_INTEN);
 	reg &= ~(1 << sf->number);
 	sdmmc_io_write_1(sf0, SD_IO_CCCR_FN_INTEN, reg);
+	mutex_exit(&sc->sc_intr_task_mtx);
 	SDMMC_UNLOCK(sc);
 }
 
@@ -709,11 +713,10 @@ sdmmc_intr_task(void *arg)
 
 	mutex_enter(&sc->sc_mtx);
 	TAILQ_FOREACH(ih, &sc->sc_intrq, entry) {
-		mutex_exit(&sc->sc_mtx);
 		/* XXX examine return value and do evcount stuff*/
 		(void)(*ih->ih_fun)(ih->ih_arg);
-		mutex_enter(&sc->sc_mtx);
 	}
-	sdmmc_chip_card_intr_ack(sc->sc_sct, sc->sc_sch);
 	mutex_exit(&sc->sc_mtx);
+
+	sdmmc_chip_card_intr_ack(sc->sc_sct, sc->sc_sch);
 }



CVS commit: src/sys/dev/sdmmc

2015-08-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Aug  5 07:31:52 UTC 2015

Modified Files:
src/sys/dev/sdmmc: sdhc.c

Log Message:
lock more hardware accesses


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/sdmmc/sdhc.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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.77 src/sys/dev/sdmmc/sdhc.c:1.78
--- src/sys/dev/sdmmc/sdhc.c:1.77	Mon Aug  3 12:11:36 2015
+++ src/sys/dev/sdmmc/sdhc.c	Wed Aug  5 07:31:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.77 2015/08/03 12:11:36 jmcneill Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.78 2015/08/05 07:31:52 mlelstv Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.77 2015/08/03 12:11:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.78 2015/08/05 07:31:52 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -583,12 +583,14 @@ sdhc_detach(struct sdhc_softc *sc, int f
 		}
 		/* disable interrupts */
 		if ((flags & DETACH_FORCE) == 0) {
+			mutex_enter(&hp->intr_lock);
 			if (ISSET(hp->sc->sc_flags, SDHC_FLAG_32BIT_ACCESS)) {
 HWRITE4(hp, SDHC_NINTR_SIGNAL_EN, 0);
 			} else {
 HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, 0);
 			}
 			sdhc_soft_reset(hp, SDHC_RESET_ALL);
+			mutex_exit(&hp->intr_lock);
 		}
 		cv_destroy(&hp->intr_cv);
 		mutex_destroy(&hp->intr_lock);
@@ -1209,6 +1211,7 @@ sdhc_signal_voltage(sdmmc_chipset_handle
 {
 	struct sdhc_host *hp = (struct sdhc_host *)sch;
 
+	mutex_enter(&hp->intr_lock);
 	switch (signal_voltage) {
 	case SDMMC_SIGNAL_VOLTAGE_180:
 		HSET2(hp, SDHC_HOST_CTL2, SDHC_1_8V_SIGNAL_EN);
@@ -1219,6 +1222,7 @@ sdhc_signal_voltage(sdmmc_chipset_handle
 	default:
 		return EINVAL;
 	}
+	mutex_exit(&hp->intr_lock);
 
 	return 0;
 }
@@ -1618,6 +1622,8 @@ sdhc_transfer_data_pio(struct sdhc_host 
 	u_int pmask;
 	int error = 0;
 
+	KASSERT(mutex_owned(&hp->intr_lock));
+
 	if (ISSET(cmd->c_flags, SCF_CMD_READ)) {
 		imask = SDHC_BUFFER_READ_READY;
 		pmask = SDHC_BUFFER_READ_ENABLE;
@@ -1832,6 +1838,8 @@ sdhc_soft_reset(struct sdhc_host *hp, in
 {
 	int timo;
 
+	KASSERT(mutex_owned(&hp->intr_lock));
+
 	DPRINTF(1,("%s: software reset reg=%08x\n", HDEVNAME(hp), mask));
 
 	/* Request the reset.  */



CVS commit: src/usr.bin/sort

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 07:10:03 UTC 2015

Modified Files:
src/usr.bin/sort: files.c sort.h

Log Message:
add a description about what was being attempted to failed writes messages.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/sort/files.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/sort/sort.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sort/files.c
diff -u src/usr.bin/sort/files.c:1.41 src/usr.bin/sort/files.c:1.42
--- src/usr.bin/sort/files.c:1.41	Fri Nov  6 18:34:22 2009
+++ src/usr.bin/sort/files.c	Wed Aug  5 07:10:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: files.c,v 1.41 2009/11/06 18:34:22 joerg Exp $	*/
+/*	$NetBSD: files.c,v 1.42 2015/08/05 07:10:03 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000-2003 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
 #include "sort.h"
 #include "fsort.h"
 
-__RCSID("$NetBSD: files.c,v 1.41 2009/11/06 18:34:22 joerg Exp $");
+__RCSID("$NetBSD: files.c,v 1.42 2015/08/05 07:10:03 mrg Exp $");
 
 #include 
 
@@ -226,7 +226,8 @@ seq(FILE *fp, u_char **line)
 void
 putrec(const RECHEADER *rec, FILE *fp)
 {
-	EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->length), fp);
+	EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->length), fp,
+	   "failed to write temp file");
 }
 
 /*
@@ -235,7 +236,8 @@ putrec(const RECHEADER *rec, FILE *fp)
 void
 putline(const RECHEADER *rec, FILE *fp)
 {
-	EWRITE(rec->data+rec->offset, 1, rec->length - rec->offset, fp);
+	EWRITE(rec->data+rec->offset, 1, rec->length - rec->offset, fp,
+	   "failed to write");
 }
 
 /*
@@ -244,7 +246,8 @@ putline(const RECHEADER *rec, FILE *fp)
 void
 putkeydump(const RECHEADER *rec, FILE *fp)
 {
-	EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->offset), fp);
+	EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->offset), fp,
+	   "failed to write debug key");
 }
 
 /*

Index: src/usr.bin/sort/sort.h
diff -u src/usr.bin/sort/sort.h:1.34 src/usr.bin/sort/sort.h:1.35
--- src/usr.bin/sort/sort.h:1.34	Fri Sep 16 15:39:29 2011
+++ src/usr.bin/sort/sort.h	Wed Aug  5 07:10:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sort.h,v 1.34 2011/09/16 15:39:29 joerg Exp $	*/
+/*	$NetBSD: sort.h,v 1.35 2015/08/05 07:10:03 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000-2003 The NetBSD Foundation, Inc.
@@ -100,9 +100,9 @@
 		err(2, "%p", file);	\
 }
 
-#define	EWRITE(ptr, size, n, f) {	\
+#define	EWRITE(ptr, size, n, f, fmt) {	\
 	if (!fwrite(ptr, size, n, f))	\
-		 err(2, NULL);		\
+		 err(2, fmt);		\
 }
 
 /* Records are limited to MAXBUFSIZE (8MB) and less if you want to sort



CVS commit: src/sys/arch/amiga/dev

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 07:02:20 UTC 2015

Modified Files:
src/sys/arch/amiga/dev: amidisplaycc.c

Log Message:
remove include of , which is not necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amiga/dev/amidisplaycc.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/arch/amiga/dev/amidisplaycc.c
diff -u src/sys/arch/amiga/dev/amidisplaycc.c:1.27 src/sys/arch/amiga/dev/amidisplaycc.c:1.28
--- src/sys/arch/amiga/dev/amidisplaycc.c:1.27	Sat Mar 29 12:55:11 2014
+++ src/sys/arch/amiga/dev/amidisplaycc.c	Wed Aug  5 07:02:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: amidisplaycc.c,v 1.27 2014/03/29 12:55:11 mlelstv Exp $ */
+/*	$NetBSD: amidisplaycc.c,v 1.28 2015/08/05 07:02:20 mrg Exp $ */
 
 /*-
  * Copyright (c) 2000 Jukka Andberg.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.27 2014/03/29 12:55:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.28 2015/08/05 07:02:20 mrg Exp $");
 
 /*
  * wscons interface to amiga custom chips. Contains the necessary functions
@@ -60,7 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: amidisplaycc
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 07:01:11 UTC 2015

Modified Files:
src/sys/arch/amd64/amd64: mainbus.c
src/sys/arch/i386/i386: mainbus.c

Log Message:
allow MPVERBOSE to be set to a value that sets the "mp_verbose" variable.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/mainbus.c
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/i386/i386/mainbus.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/arch/amd64/amd64/mainbus.c
diff -u src/sys/arch/amd64/amd64/mainbus.c:1.35 src/sys/arch/amd64/amd64/mainbus.c:1.36
--- src/sys/arch/amd64/amd64/mainbus.c:1.35	Mon Apr 27 07:03:57 2015
+++ src/sys/arch/amd64/amd64/mainbus.c	Wed Aug  5 07:01:10 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.35 2015/04/27 07:03:57 knakahara Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.36 2015/08/05 07:01:10 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.35 2015/04/27 07:03:57 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.36 2015/08/05 07:01:10 mrg Exp $");
 
 #include 
 #include 
@@ -126,11 +126,15 @@ int mp_nintr;
 int mp_isa_bus = -1;
 int mp_eisa_bus = -1;
 
-#ifdef MPVERBOSE
+# ifdef MPVERBOSE
+#  if MPVERBOSE > 0
+int mp_verbose = MPVERBOSE;
+#  else
 int mp_verbose = 1;
-#else
+#  endif
+# else
 int mp_verbose = 0;
-#endif
+# endif
 #endif
 
 

Index: src/sys/arch/i386/i386/mainbus.c
diff -u src/sys/arch/i386/i386/mainbus.c:1.100 src/sys/arch/i386/i386/mainbus.c:1.101
--- src/sys/arch/i386/i386/mainbus.c:1.100	Mon Apr 27 08:30:11 2015
+++ src/sys/arch/i386/i386/mainbus.c	Wed Aug  5 07:01:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.100 2015/04/27 08:30:11 knakahara Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.101 2015/08/05 07:01:11 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.100 2015/04/27 08:30:11 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.101 2015/08/05 07:01:11 mrg Exp $");
 
 #include 
 #include 
@@ -161,11 +161,15 @@ int mp_nintr;
 int mp_isa_bus = -1;/* XXX */
 int mp_eisa_bus = -1;   /* XXX */
 
-#ifdef MPVERBOSE
+# ifdef MPVERBOSE
+#  if MPVERBOSE > 0
+int mp_verbose = MPVERBOSE;
+#  else
 int mp_verbose = 1;
-#else
+#  endif
+# else
 int mp_verbose = 0;
-#endif
+# endif
 #endif
 
 void



CVS commit: src/libexec/httpd

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 06:50:44 UTC 2015

Modified Files:
src/libexec/httpd: Makefile bozohttpd.h

Log Message:
on QNX, use nbutil.h.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/libexec/httpd/Makefile
cvs rdiff -u -r1.35 -r1.36 src/libexec/httpd/bozohttpd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/httpd/Makefile
diff -u src/libexec/httpd/Makefile:1.23 src/libexec/httpd/Makefile:1.24
--- src/libexec/httpd/Makefile:1.23	Thu Apr 16 02:32:33 2015
+++ src/libexec/httpd/Makefile	Wed Aug  5 06:50:44 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2015/04/16 02:32:33 mrg Exp $
+#	$NetBSD: Makefile,v 1.24 2015/08/05 06:50:44 mrg Exp $
 #
 #	$eterna: Makefile,v 1.30 2010/07/11 00:34:27 mrg Exp $
 #
@@ -15,6 +15,10 @@
 #	DO_HTPASSWD		/* support .htpasswd files */
 #	NO_LUA_SUPPORT		/* don't support Lua for dynamic content */
 #
+# other system specific defines:
+#	HAVE_NBUTIL_H		/* netbsd compat is in 
+#(don't forget to also enable -lnbutil)
+#
 # these are usually set via the "COPTS" variable, or some other method
 # for setting CFLAGS relevant to your make, eg
 #   % make COPTS="-DDO_HTPASSWD"
@@ -33,6 +37,17 @@ DPADD=	${LIBCRYPT} ${LIBLUA} ${LIBM}
 
 WARNS?=	4
 
+.if defined(.OS.MAKE)
+OPSYS=	${.OS.MAKE}
+.else
+OPSYS:=	${:!uname -s!:S/-//g:S/\///g}
+.endif
+
+.if ${OPSYS} == "QNX"
+CPPFLAGS+=	-DHAVE_NBUTIL_H
+LDADD+=		-lnbutil
+.endif
+
 .include 
 
 .if ${MKCRYPTO} != "no"

Index: src/libexec/httpd/bozohttpd.h
diff -u src/libexec/httpd/bozohttpd.h:1.35 src/libexec/httpd/bozohttpd.h:1.36
--- src/libexec/httpd/bozohttpd.h:1.35	Sat May  2 11:35:48 2015
+++ src/libexec/httpd/bozohttpd.h	Wed Aug  5 06:50:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.h,v 1.35 2015/05/02 11:35:48 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.h,v 1.36 2015/08/05 06:50:44 mrg Exp $	*/
 
 /*	$eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -41,6 +41,11 @@
 #endif
 #include 
 
+/* QNX provides a lot of NetBSD things in nbutil.h */
+#ifdef USE_NBUTIL
+#include 
+#endif
+
 /* lots of "const" but gets free()'ed etc at times, sigh */
 
 /* headers */



CVS commit: src/share/man/man9

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 07:00:34 UTC 2015

Modified Files:
src/share/man/man9: pci_intr.9

Log Message:
document pci_intr_evcnt()


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/pci_intr.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/pci_intr.9
diff -u src/share/man/man9/pci_intr.9:1.18 src/share/man/man9/pci_intr.9:1.19
--- src/share/man/man9/pci_intr.9:1.18	Wed Feb 25 17:03:42 2015
+++ src/share/man/man9/pci_intr.9	Wed Aug  5 07:00:34 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: pci_intr.9,v 1.18 2015/02/25 17:03:42 riastradh Exp $
+.\" $NetBSD: pci_intr.9,v 1.19 2015/08/05 07:00:34 mrg Exp $
 .\"
 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,13 +27,14 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 25, 2015
+.Dd August 4, 2015
 .Dt PCI_INTR 9
 .Os
 .Sh NAME
 .Nm pci_intr ,
 .Nm pci_intr_map ,
 .Nm pci_intr_string ,
+.Nm pci_intr_evcnt ,
 .Nm pci_intr_establish ,
 .Nm pci_intr_disestablish
 .Nd PCI bus interrupt manipulation functions
@@ -43,6 +44,8 @@
 .Fn pci_intr_map "const struct pci_attach_args *pa" "pci_intr_handle_t *ih"
 .Ft const char *
 .Fn pci_intr_string "pci_chipset_tag_t pc" "pci_intr_handle_t ih" "char *buf" "size_t len"
+.Ft const struct evcnt *
+.Fn pci_intr_evcnt "pci_chipset_tag_t pc" "pci_intr_handle_t ih"
 .Ft void *
 .Fn pci_intr_establish "pci_chipset_tag_t pc" "pci_intr_handle_t ih" \
 "int ipl" "int (*intrhand)(void *)" "void *intrarg"
@@ -106,6 +109,14 @@ may be saved and passed to
 .Fn pci_intr_disestablish
 to disable the interrupt handler
 when the driver is no longer interested in interrupts from the device.
+.Pp
+The
+.Fn pci_intr_evcnt
+function should return an evcnt structure pointer or NULL if there is
+no evcnt associated with this interrupt.
+See
+.Xr evcnt 9
+for more details.
 .Ss PORTING
 A port's implementation of
 .Fn pci_intr_map
@@ -147,3 +158,6 @@ contains the original interrupt pin;
 contains the PCI tag of the device itself, and
 .Ft pa_intrtag
 contains the PCI tag of the uppermost bridge device.
+.Sh SEE ALSO
+.Xr evcnt 9 ,
+.Xr pci 9 .



CVS commit: src/usr.bin/audio

2015-08-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Aug  5 06:54:39 UTC 2015

Modified Files:
src/usr.bin/audio/common: audio.c libaudio.h sun.c wav.c
src/usr.bin/audio/play: play.c
src/usr.bin/audio/record: record.c

Log Message:
rename struct write_info as struct track_info, and the variable name 'wi'
as 'ti', as this info is useful for reading as well.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/audio/common/audio.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/audio/common/libaudio.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/audio/common/sun.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/audio/common/wav.c
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/audio/play/play.c
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/audio/record/record.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audio/common/audio.c
diff -u src/usr.bin/audio/common/audio.c:1.24 src/usr.bin/audio/common/audio.c:1.25
--- src/usr.bin/audio/common/audio.c:1.24	Sun Jun 21 06:06:01 2015
+++ src/usr.bin/audio/common/audio.c	Wed Aug  5 06:54:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $	*/
+/*	$NetBSD: audio.c,v 1.25 2015/08/05 06:54:39 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -32,7 +32,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $");
+__RCSID("$NetBSD: audio.c,v 1.25 2015/08/05 06:54:39 mrg Exp $");
 #endif
 
 
@@ -178,21 +178,21 @@ audio_errstring(int errval)
 }
 
 void
-write_header(struct write_info *wi)
+write_header(struct track_info *ti)
 {
 	struct iovec iv[3];
 	int veclen, left, tlen;
 	void *hdr;
 	size_t hdrlen;
 
-	switch (wi->format) {
+	switch (ti->format) {
 	case AUDIO_FORMAT_DEFAULT:
 	case AUDIO_FORMAT_SUN:
-		if (sun_prepare_header(wi, &hdr, &hdrlen, &left) != 0)
+		if (sun_prepare_header(ti, &hdr, &hdrlen, &left) != 0)
 			return;
 		break;
 	case AUDIO_FORMAT_WAV:
-		if (wav_prepare_header(wi, &hdr, &hdrlen, &left) != 0)
+		if (wav_prepare_header(ti, &hdr, &hdrlen, &left) != 0)
 			return;
 		break;
 	case AUDIO_FORMAT_NONE:
@@ -209,9 +209,9 @@ write_header(struct write_info *wi)
 		iv[veclen].iov_len = hdrlen;
 		tlen += iv[veclen++].iov_len;
 	}
-	if (wi->header_info) {
-		iv[veclen].iov_base = wi->header_info;
-		iv[veclen].iov_len = (int)strlen(wi->header_info) + 1;
+	if (ti->header_info) {
+		iv[veclen].iov_base = ti->header_info;
+		iv[veclen].iov_len = (int)strlen(ti->header_info) + 1;
 		tlen += iv[veclen++].iov_len;
 	}
 	if (left) {
@@ -223,20 +223,20 @@ write_header(struct write_info *wi)
 	if (tlen == 0)
 		return;
 
-	if (writev(wi->outfd, iv, veclen) != tlen)
+	if (writev(ti->outfd, iv, veclen) != tlen)
 		err(1, "could not write audio header");
 }
 
 write_conv_func
-write_get_conv_func(struct write_info *wi)
+write_get_conv_func(struct track_info *ti)
 {
 
-	switch (wi->format) {
+	switch (ti->format) {
 	case AUDIO_FORMAT_DEFAULT:
 	case AUDIO_FORMAT_SUN:
-		return sun_write_get_conv_func(wi);
+		return sun_write_get_conv_func(ti);
 	case AUDIO_FORMAT_WAV:
-		return wav_write_get_conv_func(wi);
+		return wav_write_get_conv_func(ti);
 	case AUDIO_FORMAT_NONE:
 		return NULL;
 	default:

Index: src/usr.bin/audio/common/libaudio.h
diff -u src/usr.bin/audio/common/libaudio.h:1.19 src/usr.bin/audio/common/libaudio.h:1.20
--- src/usr.bin/audio/common/libaudio.h:1.19	Tue Dec 30 01:22:09 2014
+++ src/usr.bin/audio/common/libaudio.h	Wed Aug  5 06:54:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: libaudio.h,v 1.19 2014/12/30 01:22:09 mrg Exp $	*/
+/*	$NetBSD: libaudio.h,v 1.20 2015/08/05 06:54:39 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2009 Matthew R. Green
@@ -157,7 +157,7 @@ typedef struct {
 } __packed wav_audiohdrextensible;
 
 /* returns size of header, or -ve for failure */
-ssize_t audio_wav_parse_hdr (void *, size_t, u_int *, u_int *, u_int *, u_int *, size_t *);
+ssize_t audio_wav_parse_hdr (void *, size_t, u_int *, u_int *, u_int *, u_int *, off_t *);
 
 extern int verbose;
 
@@ -185,34 +185,34 @@ void	decode_time (const char *, struct t
 void	decode_encoding (const char *, int *);
 
 /*
- * Write a sun/wav header, shared between record and merge.
+ * Track info, for reading/writing sun/wav header.
  *
  * Note that write_header() may change the values of format,
  * encoding.
  */
 
-struct write_info {
+struct track_info {
 	int	outfd;
 	char	*header_info;
 	int	format;
 	int	encoding;
 	int	precision;
 	int	qflag;
-	ssize_t	total_size;
+	off_t	total_size;
 	int	sample_rate;
 	int	channels;
 };
 
 typedef void (*write_conv_func) (u_char *, int);
 
-void	write_header (struct write_info *);
-write_conv_func write_get_conv_func(struct write_info *);
+void	write_header (struct track_info *);
+write_conv_func write_get_conv_func(struct track_info *);
 
 /* backends for the above */
-int sun_prepare_header(struct write_info *wi, void **hdrp, size_t *lenp, int *leftp);
-int wav