Module Name:    src
Committed By:   thorpej
Date:           Thu Jul 25 04:20:13 UTC 2019

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

Log Message:
If cold, automagically set I2C_F_POLL.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/i2c_exec.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/i2c_exec.c
diff -u src/sys/dev/i2c/i2c_exec.c:1.11 src/sys/dev/i2c/i2c_exec.c:1.12
--- src/sys/dev/i2c/i2c_exec.c:1.11	Mon Dec 10 00:31:45 2018
+++ src/sys/dev/i2c/i2c_exec.c	Thu Jul 25 04:20:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c_exec.c,v 1.11 2018/12/10 00:31:45 thorpej Exp $	*/
+/*	$NetBSD: i2c_exec.c,v 1.12 2019/07/25 04:20:13 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.11 2018/12/10 00:31:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v 1.12 2019/07/25 04:20:13 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v
 #include <sys/module.h>
 #include <sys/event.h>
 #include <sys/conf.h>
+#include <sys/kernel.h>
 
 #define	_I2C_PRIVATE
 #include <dev/i2c/i2cvar.h>
@@ -53,6 +54,13 @@ static uint8_t	iic_smbus_pec(int, uint8_
 
 static int	i2cexec_modcmd(modcmd_t, void *);
 
+static inline int
+iic_op_flags(int flags)
+{
+
+	return flags | (cold ? I2C_F_POLL : 0);
+}
+
 /*
  * iic_acquire_bus:
  *
@@ -62,6 +70,8 @@ int
 iic_acquire_bus(i2c_tag_t tag, int flags)
 {
 
+	flags = iic_op_flags(flags);
+
 	return (*tag->ic_acquire_bus)(tag->ic_cookie, flags);
 }
 
@@ -74,6 +84,8 @@ void
 iic_release_bus(i2c_tag_t tag, int flags)
 {
 
+	flags = iic_op_flags(flags);
+
 	(*tag->ic_release_bus)(tag->ic_cookie, flags);
 }
 
@@ -96,6 +108,8 @@ iic_exec(i2c_tag_t tag, i2c_op_t op, i2c
 	int error;
 	size_t len;
 
+	flags = iic_op_flags(flags);
+
 	if ((flags & I2C_F_PEC) && cmdlen > 0 && tag->ic_exec != NULL) {
 		uint8_t data[33]; /* XXX */
 		uint8_t b[3];

Reply via email to