CVS commit: [nick-nhusb] src/sys/dev/usb

2016-01-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 11 22:24:58 UTC 2016

Modified Files:
src/sys/dev/usb [nick-nhusb]: ehci.c

Log Message:
Fix active control transfer aborts - need to run through the entire TD
chain from start to finish and not just on any data phase.


To generate a diff of this commit:
cvs rdiff -u -r1.234.2.78 -r1.234.2.79 src/sys/dev/usb/ehci.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/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.234.2.78 src/sys/dev/usb/ehci.c:1.234.2.79
--- src/sys/dev/usb/ehci.c:1.234.2.78	Sun Jan 10 16:06:07 2016
+++ src/sys/dev/usb/ehci.c	Mon Jan 11 22:24:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.234.2.78 2016/01/10 16:06:07 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.234.2.79 2016/01/11 22:24:58 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.78 2016/01/10 16:06:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.79 2016/01/11 22:24:58 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -3215,7 +3215,7 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
 	ehci_soft_qh_t *sqh = epipe->sqh;
-	ehci_soft_qtd_t *sqtd;
+	ehci_soft_qtd_t *sqtd, *fsqtd, *lsqtd;
 	ehci_physaddr_t cur;
 	uint32_t qhstatus;
 	int hit;
@@ -3273,7 +3273,15 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	sqh->offs + offsetof(ehci_qh_t, qh_qtd.qtd_status),
 	sizeof(sqh->qh.qh_qtd.qtd_status),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-	for (sqtd = exfer->ex_sqtdstart; ; sqtd = sqtd->nextqtd) {
+
+	if (exfer->ex_type == EX_CTRL) {
+		fsqtd = exfer->ex_setup;
+		lsqtd = exfer->ex_status;
+	} else {
+		fsqtd = exfer->ex_sqtdstart;
+		lsqtd = exfer->ex_sqtdend;
+	}
+	for (sqtd = fsqtd; sqtd != lsqtd; sqtd = sqtd->nextqtd) {
 		usb_syncmem(>dma,
 		sqtd->offs + offsetof(ehci_qtd_t, qtd_status),
 		sizeof(sqtd->qtd.qtd_status),
@@ -3283,8 +3291,6 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 		sqtd->offs + offsetof(ehci_qtd_t, qtd_status),
 		sizeof(sqtd->qtd.qtd_status),
 		BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-		if (sqtd == exfer->ex_sqtdend)
-			break;
 	}
 
 	/*
@@ -3311,10 +3317,8 @@ ehci_abort_xfer(struct usbd_xfer *xfer, 
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	cur = EHCI_LINK_ADDR(le32toh(sqh->qh.qh_curqtd));
 	hit = 0;
-	for (sqtd = exfer->ex_sqtdstart; ; sqtd = sqtd->nextqtd) {
+	for (sqtd = fsqtd; sqtd != lsqtd; sqtd = sqtd->nextqtd) {
 		hit |= cur == sqtd->physaddr;
-		if (sqtd == exfer->ex_sqtdend)
-			break;
 	}
 	sqtd = sqtd->nextqtd;
 	/* Zap curqtd register if hardware pointed inside the xfer. */



CVS commit: src/external/gpl3

2016-01-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jan 11 22:41:48 UTC 2016

Modified Files:
src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std: complex
src/external/gpl3/gcc/dist/libstdc++-v3/include/std: complex

Log Message:
Add missing word in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex

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

Modified files:

Index: src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex
diff -u src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.4 src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.5
--- src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.4	Mon Jan 11 16:49:09 2016
+++ src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex	Mon Jan 11 22:41:48 2016
@@ -45,7 +45,7 @@
 #include 
 
 #if _GLIBCXX_USE_C99_COMPLEX
-// This is disgusting; we can't include ccomplex because that c++11
+// This is disgusting; we can't include ccomplex because that requires c++11
 // and we can't use the builtins because those point to the wrong
 // ABI-wise cabs/cabsf so we manually declare those here and use
 // them directly.

Index: src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex
diff -u src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex:1.2 src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex:1.3
--- src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex:1.2	Mon Jan 11 16:52:53 2016
+++ src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex	Mon Jan 11 22:41:48 2016
@@ -45,7 +45,7 @@
 #include 
 
 #if _GLIBCXX_USE_C99_COMPLEX
-// This is disgusting; we can't include ccomplex because that c++11
+// This is disgusting; we can't include ccomplex because that requires c++11
 // and we can't use the builtins because those point to the wrong
 // ABI-wise cabs/cabsf so we manually declare those here and use
 // them directly.



CVS commit: src/doc

2016-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 11 22:50:35 UTC 2016

Modified Files:
src/doc: HACKS

Log Message:
Add hack for cabs{,f,l} in 


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.162 src/doc/HACKS:1.163
--- src/doc/HACKS:1.162	Thu Aug 27 08:32:05 2015
+++ src/doc/HACKS	Mon Jan 11 17:50:35 2016
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.162 2015/08/27 12:32:05 pooka Exp $
+# $NetBSD: HACKS,v 1.163 2016/01/11 22:50:35 christos Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -402,6 +402,23 @@ descr
 		pthread_spin_t ptm_errorcheck;
 kcah
 
+hack	libm cabs{,f,l} and g++
+cdata	11 Jan 2016
+who	christos
+pr	lib/50646
+file	src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex : 1.2
+file	src/external/gpl3/gcc/dist/libstdc++-v3/include/std/complex : 1.2
+descr
+	Our cabs and cabsf have a different argument format on some architectures
+	and for that we have created in libm/compat_cabs{,f}.c. The standard
+	versions in libc are __c99_cabs{,f,l} and there are __RENAME()'s in
+	. G++ uses __builtin_cabs{,f,l} to implement those and they
+	translate by default to cabs{,f,l} which gets defined to cabs{,f} (the
+	wrong function) and an undefined cabsl. I've changed  to use
+	the __c99_cabs{,f,l} directly. Using the __builtin_cabs{,f,l} in gcc is
+	still broken.
+kcah
+
 port	vax
 
 	hack	gcc4/vax ICE



CVS commit: src/sys/arch/hppa/include

2016-01-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 11 08:14:08 UTC 2016

Modified Files:
src/sys/arch/hppa/include: db_machdep.h

Log Message:
PR port-hppa/50642: src/sys/arch/hppa/include/db_machdep.h:118: bad if test ?

Correct the test for rfir and add one for rfi while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/include/db_machdep.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/arch/hppa/include/db_machdep.h
diff -u src/sys/arch/hppa/include/db_machdep.h:1.12 src/sys/arch/hppa/include/db_machdep.h:1.13
--- src/sys/arch/hppa/include/db_machdep.h:1.12	Wed Jan 18 09:35:48 2012
+++ src/sys/arch/hppa/include/db_machdep.h	Mon Jan 11 08:14:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.h,v 1.12 2012/01/18 09:35:48 skrll Exp $	*/
+/*	$NetBSD: db_machdep.h,v 1.13 2016/01/11 08:14:08 skrll Exp $	*/
 
 /*	$OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $	*/
 
@@ -115,7 +115,8 @@ static __inline int inst_return(u_int in
 	   (ins & 0xfc00) == 0xe000;
 }
 static __inline int inst_trap_return(u_int ins)	{
-	return (ins & 0xfc001fc0) == 0x0ca0;
+	return (ins & 0xfc001fe0) == 0x0c00 ||
+	   (ins & 0xfc001fe0) == 0x0ca0;
 }
 
 #define db_clear_single_step(r)	((r)->tf_ipsw &= ~PSW_R)



CVS commit: src/sys/sys

2016-01-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 11 08:40:52 UTC 2016

Modified Files:
src/sys/sys: buf.h

Log Message:
Protect a few forward declarations for kernel only use, as suggested
by ryoon@


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/sys/buf.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/sys/buf.h
diff -u src/sys/sys/buf.h:1.124 src/sys/sys/buf.h:1.125
--- src/sys/sys/buf.h:1.124	Mon Jan 11 01:22:36 2016
+++ src/sys/sys/buf.h	Mon Jan 11 08:40:52 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.124 2016/01/11 01:22:36 dholland Exp $ */
+/* $NetBSD: buf.h,v 1.125 2016/01/11 08:40:52 martin Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
@@ -88,7 +88,9 @@ struct kauth_cred;
 extern kmutex_t bufcache_lock;
 extern kmutex_t buffer_lock;
 
+#if defined(_KERNEL)
 extern void (*biodone_vfs)(buf_t *);
+#endif
 
 /*
  * The buffer header describes an I/O operation in the kernel.
@@ -105,7 +107,9 @@ extern void (*biodone_vfs)(buf_t *);
  */
 
 /* required for the conditional union member below to be ~safe */
+#if defined(_KERNEL)
 __CTASSERT(sizeof(struct work) <= sizeof(TAILQ_ENTRY(buf)));
+#endif
 
 struct buf {
 	union {



CVS commit: src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std

2016-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 11 16:49:09 UTC 2016

Modified Files:
src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std: complex

Log Message:
Hack around the cabs mess, and explain what's going on...


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex

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

Modified files:

Index: src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex
diff -u src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.3 src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.4
--- src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex:1.3	Tue Sep 22 23:39:29 2015
+++ src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/complex	Mon Jan 11 11:49:09 2016
@@ -44,6 +44,16 @@
 #include 
 #include 
 
+#if _GLIBCXX_USE_C99_COMPLEX
+// This is disgusting; we can't include ccomplex because that c++11
+// and we can't use the builtins because those point to the wrong
+// ABI-wise cabs/cabsf so we manually declare those here and use
+// them directly.
+extern "C" float __c99_cabsf(_Complex float);
+extern "C" double __c99_cabs(_Complex double);
+extern "C" long double __c99_cabsl(_Complex long double);
+#endif
+
 // Get rid of a macro possibly defined in 
 #undef complex
 
@@ -580,15 +590,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 
 #if _GLIBCXX_USE_C99_COMPLEX
+  // XXX: We can't use __builtin_cabs* because they are broken
   inline float
-  __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
+  __complex_abs(__complex__ float __z) { return __c99_cabsf(__z); }
 
   inline double
-  __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); }
+  __complex_abs(__complex__ double __z) { return __c99_cabs(__z); }
 
   inline long double
   __complex_abs(const __complex__ long double& __z)
-  { return __builtin_cabsl(__z); }
+  { return __c99_cabsl(__z); }
 
   template
 inline _Tp



CVS commit: src/sys/arch/arm/allwinner

2016-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Jan 11 17:09:25 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
moar register bits


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/arm/allwinner/awin_reg.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/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.85 src/sys/arch/arm/allwinner/awin_reg.h:1.86
--- src/sys/arch/arm/allwinner/awin_reg.h:1.85	Sat Dec 26 16:48:54 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Mon Jan 11 17:09:25 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.85 2015/12/26 16:48:54 macallan Exp $ */
+/* $NetBSD: awin_reg.h,v 1.86 2016/01/11 17:09:25 macallan Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -2343,7 +2343,9 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_TVE_CONFIG_2		0x0138
 #define AWIN_TVE_CONFIG_3		0x013C
 
-
+/* AWIN_TVE_ENABLE */
+#define AWIN_TVE_CLOCK_GATE_DISABLE	__BIT(31)
+#define AWIN_TVE_EN			__BIT(0)
 
 /*
  * A31 registers



CVS commit: src/sys/kern

2016-01-11 Thread Thor Lancelot Simon
Module Name:src
Committed By:   tls
Date:   Mon Jan 11 14:55:52 UTC 2016

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

Log Message:
memset() -> explicit_memset() for sensitive data.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.74 src/sys/kern/kern_rndq.c:1.75
--- src/sys/kern/kern_rndq.c:1.74	Fri Jan  1 16:09:00 2016
+++ src/sys/kern/kern_rndq.c	Mon Jan 11 14:55:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.74 2016/01/01 16:09:00 tls Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.75 2016/01/11 14:55:52 tls Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.74 2016/01/01 16:09:00 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.75 2016/01/11 14:55:52 tls Exp $");
 
 #include 
 #include 
@@ -572,7 +572,7 @@ rnd_init(void)
 		mutex_spin_exit(_global.lock);
 		rnd_printf("rnd: seeded with %d bits\n",
 		MIN(boot_rsp->entropy, RND_POOLBITS / 2));
-		memset(boot_rsp, 0, sizeof(*boot_rsp));
+		explicit_memset(boot_rsp, 0, sizeof(*boot_rsp));
 	}
 	rnd_attach_source(_printf_source, "printf", RND_TYPE_UNKNOWN,
 			  RND_FLAG_NO_ESTIMATE);
@@ -621,7 +621,7 @@ static void
 rnd_sample_free(rnd_sample_t *c)
 {
 
-	memset(c, 0, sizeof(*c));
+	explicit_memset(c, 0, sizeof(*c));
 	pool_cache_put(rnd_mempc, c);
 }
 
@@ -996,7 +996,7 @@ rnd_hwrng_test(rnd_sample_t *sample)
 			return 1;
 		}
 		source->test_cnt = -1;
-		memset(source->test, 0, sizeof(*source->test));
+		explicit_memset(source->test, 0, sizeof(*source->test));
 	}
 	return 0;
 }
@@ -1201,7 +1201,7 @@ rnd_extract_data(void *p, uint32_t len, 
 			"STATISTICAL TEST!\n");
 			continue;
 		}
-		memset(_rt, 0, sizeof(rnd_rt));
+		explicit_memset(_rt, 0, sizeof(rnd_rt));
 		rndpool_add_data(_global.pool, rnd_testbits,
 		sizeof(rnd_testbits), entropy_count);
 		memset(rnd_testbits, 0, sizeof(rnd_testbits));
@@ -1319,7 +1319,7 @@ rnd_seed(void *base, size_t len)
 		rndpool_add_data(_global.pool, boot_rsp->data,
 		sizeof(boot_rsp->data),
 		MIN(boot_rsp->entropy, RND_POOLBITS / 2));
-		memset(boot_rsp, 0, sizeof(*boot_rsp));
+		explicit_memset(boot_rsp, 0, sizeof(*boot_rsp));
 		mutex_spin_exit(_global.lock);
 	} else {
 		rnd_printf_verbose("rnd: not ready, deferring seed feed.\n");



CVS commit: src/sys/dev/ic

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:24:56 UTC 2016

Modified Files:
src/sys/dev/ic: pcf8584.c

Log Message:
Always take the bus lock (avoids collisions when drivers set I2C_F_POLL).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/pcf8584.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/ic/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.14 src/sys/dev/ic/pcf8584.c:1.15
--- src/sys/dev/ic/pcf8584.c:1.14	Mon Jan  4 10:00:33 2016
+++ src/sys/dev/ic/pcf8584.c	Mon Jan 11 18:24:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.14 2016/01/04 10:00:33 jdc Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.15 2016/01/11 18:24:56 jdc Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -116,9 +116,6 @@ pcfiic_i2c_acquire_bus(void *arg, int fl
 {
 	struct pcfiic_softc	*sc = arg;
 
-	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
-		return (0);
-
 	rw_enter(>sc_lock, RW_WRITER);
 	return 0;
 }
@@ -128,9 +125,6 @@ pcfiic_i2c_release_bus(void *arg, int fl
 {
 	struct pcfiic_softc	*sc = arg;
 
-	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
-		return;
-
 	rw_exit(>sc_lock);
 }
 



CVS commit: src/sys/dev/i2c

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:23:53 UTC 2016

Modified Files:
src/sys/dev/i2c: adm1026.c

Log Message:
Increase the number of read retries (to 5).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/adm1026.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/i2c/adm1026.c
diff -u src/sys/dev/i2c/adm1026.c:1.1 src/sys/dev/i2c/adm1026.c:1.2
--- src/sys/dev/i2c/adm1026.c:1.1	Wed Dec 16 07:56:48 2015
+++ src/sys/dev/i2c/adm1026.c	Mon Jan 11 18:23:52 2016
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.1 2015/12/16 07:56:48 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.2 2016/01/11 18:23:52 jdc Exp $");
 
 #include 
 #include 
@@ -492,7 +492,7 @@ adm1026_read_volt(struct adm1026_softc *
 static int
 adm1026_read_reg(struct adm1026_softc *sc, uint8_t reg, uint8_t *val)
 {
-#define ADM1026_READ_RETRIES	4
+#define ADM1026_READ_RETRIES	5
 	int i, j, err = 0;
 	uint8_t creg, cval, tmp[ADM1026_READ_RETRIES + 1];
 



CVS commit: src/sys/dev/i2c

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:23:11 UTC 2016

Modified Files:
src/sys/dev/i2c: lm75.c

Log Message:
Don't use I2C_F_POLL when getting/setting limits.
Save/restore the correct values for LM77.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/i2c/lm75.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/i2c/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.28 src/sys/dev/i2c/lm75.c:1.29
--- src/sys/dev/i2c/lm75.c:1.28	Sun Jan  3 17:27:57 2016
+++ src/sys/dev/i2c/lm75.c	Mon Jan 11 18:23:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $	*/
+/*	$NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $");
 
 #include 
 #include 
@@ -206,16 +206,16 @@ lmtemp_attach(device_t parent, device_t 
 	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
 
 	/* Read temperature limit(s) and remember initial value(s). */
-	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, >sc_smax, 1)
-	!= 0) {
-		aprint_error_dev(self, "unable to read Tos register\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
-		return;
-	}
-	sc->sc_tmax = sc->sc_smax;
 	if (i == lmtemp_lm77) {
+		if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT,
+		>sc_scrit, 1) != 0) {
+			aprint_error_dev(self,
+			"unable to read low register\n");
+			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			return;
+		}
 		if (lmtemp_temp_read(sc, LM77_REG_TLOW_SET_POINT,
-		>sc_smax, 1) != 0) {
+		>sc_smin, 1) != 0) {
 			aprint_error_dev(self,
 			"unable to read low register\n");
 			iic_release_bus(sc->sc_tag, I2C_F_POLL);
@@ -228,7 +228,15 @@ lmtemp_attach(device_t parent, device_t 
 			iic_release_bus(sc->sc_tag, I2C_F_POLL);
 			return;
 		}
+	} else {	/* LM75 or compatible */
+		if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT,
+		>sc_smax, 1) != 0) {
+			aprint_error_dev(self, "unable to read Tos register\n");
+			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			return;
+		}
 	}
+	sc->sc_tmax = sc->sc_smax;
 
 	if (i == lmtemp_lm75)
 		lmtemp_setup_sysctl(sc);
@@ -349,12 +357,12 @@ lmtemp_getlim_lm75(struct sysmon_envsys 
 
 	*props &= ~(PROP_CRITMAX);
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, , 0) == 0) {
 		limits->sel_critmax = val;
 		*props |= PROP_CRITMAX;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -366,7 +374,7 @@ lmtemp_getlim_lm77(struct sysmon_envsys 
 
 	*props &= ~(PROP_CRITMAX | PROP_WARNMAX | PROP_WARNMIN);
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT, , 0) == 0) {
 		limits->sel_critmax = val;
 		*props |= PROP_CRITMAX;
@@ -379,7 +387,7 @@ lmtemp_getlim_lm77(struct sysmon_envsys 
 		limits->sel_warnmin = val;
 		*props |= PROP_WARNMIN;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -394,11 +402,11 @@ lmtemp_setlim_lm75(struct sysmon_envsys 
 			limit = sc->sc_smax;
 		else
 			limit = limits->sel_critmax;
-		iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+		iic_acquire_bus(sc->sc_tag, 0);
 		lmtemp_temp_write(sc, LM75_REG_THYST_SET_POINT,
 		limit - 500, 0);
 		lmtemp_temp_write(sc, LM75_REG_TOS_SET_POINT, limit, 0);
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
+		iic_release_bus(sc->sc_tag, 0);
 
 		/* Synchronise sysctl */
 		sc->sc_tmax = (limit - 27315) / 100;
@@ -412,10 +420,10 @@ lmtemp_setlim_lm77(struct sysmon_envsys 
 	struct lmtemp_softc *sc = sme->sme_cookie;
 	int32_t limit;
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (*props & PROP_CRITMAX) {
 		if (limits == NULL)	/* Restore defaults */
-			limit = sc->sc_smax;
+			limit = sc->sc_scrit;
 		else
 			limit = limits->sel_critmax;
 		lmtemp_temp_write(sc, LM77_REG_TCRIT_SET_POINT, limit, 0);
@@ -429,12 +437,12 @@ lmtemp_setlim_lm77(struct sysmon_envsys 
 	}
 	if (*props & PROP_WARNMIN) {
 		if (limits == NULL)	/* Restore defaults */
-			limit = sc->sc_smax;
+			limit = sc->sc_smin;
 		else
 			limit = limits->sel_warnmin;
 		lmtemp_temp_write(sc, LM77_REG_TLOW_SET_POINT, limit, 0);
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static uint32_t