Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c - No need to use I2C_F_POLL here.



details:   https://anonhg.NetBSD.org/src/rev/caefebe2a533
branches:  trunk
changeset: 1005873:caefebe2a533
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Dec 23 19:00:59 2019 +0000

description:
- No need to use I2C_F_POLL here.
- If iic_acquire_bus() fails, return the error, not false (because false
  looks like "everything A-OK!" to the caller).

diffstat:

 sys/dev/i2c/nxt2k.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (57 lines):

diff -r 581c2c40e965 -r caefebe2a533 sys/dev/i2c/nxt2k.c
--- a/sys/dev/i2c/nxt2k.c       Mon Dec 23 18:57:30 2019 +0000
+++ b/sys/dev/i2c/nxt2k.c       Mon Dec 23 19:00:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nxt2k.c,v 1.5 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: nxt2k.c,v 1.6 2019/12/23 19:00:59 thorpej Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nxt2k.c,v 1.5 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nxt2k.c,v 1.6 2019/12/23 19:00:59 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -74,16 +74,16 @@
 
        KASSERT((len + 1) <= 384);
 
-       if (iic_acquire_bus(nxt->tag, I2C_F_POLL) != 0)
-               return false;
+       if ((error = iic_acquire_bus(nxt->tag, 0) != 0))
+               return error;
 
        buffer[0] = reg;
        memcpy(&buffer[1], data, len);
        
        error = iic_exec(nxt->tag, I2C_OP_WRITE_WITH_STOP, nxt->addr,
-                        buffer, len + 1, NULL, 0, I2C_F_POLL);
+                        buffer, len + 1, NULL, 0, 0);
        
-       iic_release_bus(nxt->tag, I2C_F_POLL);
+       iic_release_bus(nxt->tag, 0);
 
        return error;
 }
@@ -93,13 +93,13 @@
 {
        int error;
 
-       if (iic_acquire_bus(nxt->tag, I2C_F_POLL) != 0)
-               return false;
+       if ((error = iic_acquire_bus(nxt->tag, 0) != 0))
+               return error;
 
        error = iic_exec(nxt->tag, I2C_OP_READ_WITH_STOP, nxt->addr,
-                        &reg, 1, data, len, I2C_F_POLL);
+                        &reg, 1, data, len, 0);
 
-       iic_release_bus(nxt->tag, I2C_F_POLL);
+       iic_release_bus(nxt->tag, 0);
 
        return error;
 }



Home | Main Index | Thread Index | Old Index