Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c If cold, automagically set I2C_F_POLL.



details:   https://anonhg.NetBSD.org/src/rev/cd4c8d7d1792
branches:  trunk
changeset: 457950:cd4c8d7d1792
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 25 04:20:13 2019 +0000

description:
If cold, automagically set I2C_F_POLL.

diffstat:

 sys/dev/i2c/i2c_exec.c |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (67 lines):

diff -r 669e7bd56c76 -r cd4c8d7d1792 sys/dev/i2c/i2c_exec.c
--- a/sys/dev/i2c/i2c_exec.c    Thu Jul 25 03:02:44 2019 +0000
+++ b/sys/dev/i2c/i2c_exec.c    Thu Jul 25 04:20:13 2019 +0000
@@ -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 @@
 #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 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 @@
 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 @@
 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 @@
        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];



Home | Main Index | Thread Index | Old Index