Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c In as3722_poweroff and as3722_reboot(), check fo...



details:   https://anonhg.NetBSD.org/src/rev/a64f8380d214
branches:  trunk
changeset: 847461:a64f8380d214
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Dec 23 15:48:51 2019 +0000

description:
In as3722_poweroff and as3722_reboot(), check for errors from iic_acquire_bus()
before proceeding with writing to the device.

diffstat:

 sys/dev/i2c/as3722.c |  32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r c22384c079cf -r a64f8380d214 sys/dev/i2c/as3722.c
--- a/sys/dev/i2c/as3722.c      Mon Dec 23 15:41:34 2019 +0000
+++ b/sys/dev/i2c/as3722.c      Mon Dec 23 15:48:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $ */
+/* $NetBSD: as3722.c,v 1.18 2019/12/23 15:48:51 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.17 2019/12/23 02:35:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.18 2019/12/23 15:48:51 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -852,10 +852,16 @@
 
        const int flags = I2C_F_POLL;
 
-       iic_acquire_bus(sc->sc_i2c, flags);
-       error = as3722_write(sc, AS3722_RESET_CTRL_REG,
-           AS3722_RESET_CTRL_POWER_OFF, flags);
-       iic_release_bus(sc->sc_i2c, flags);
+       error = iic_acquire_bus(sc->sc_i2c, flags);
+       if (error == 0) {
+               error = as3722_write(sc, AS3722_RESET_CTRL_REG,
+                   AS3722_RESET_CTRL_POWER_OFF, flags);
+               iic_release_bus(sc->sc_i2c, flags);
+       }
+       if (error) {
+               device_printf(dev, "WARNING: unable to power off, error %d\n",
+                   error);
+       }
 
        return error;
 }
@@ -868,10 +874,16 @@
 
        const int flags = I2C_F_POLL;
 
-       iic_acquire_bus(sc->sc_i2c, flags);
-       error = as3722_write(sc, AS3722_RESET_CTRL_REG,
-           AS3722_RESET_CTRL_FORCE_RESET, flags);
-       iic_release_bus(sc->sc_i2c, flags);
+       error = iic_acquire_bus(sc->sc_i2c, flags);
+       if (error == 0) {
+               error = as3722_write(sc, AS3722_RESET_CTRL_REG,
+                   AS3722_RESET_CTRL_FORCE_RESET, flags);
+               iic_release_bus(sc->sc_i2c, flags);
+       }
+       if (error) {
+               device_printf(dev, "WARNING: unable to reboot, error %d\n",
+                   error);
+       }
 
        return error;
 }



Home | Main Index | Thread Index | Old Index