Module Name: src
Committed By: thorpej
Date: Mon Dec 23 14:34:23 UTC 2019
Modified Files:
src/sys/dev/i2c: axppmic.c
Log Message:
In axppmic_power_poweroff(), check for errors from iic_acquire_bus()
before proceeding with writing to the device.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/i2c/axppmic.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/axppmic.c
diff -u src/sys/dev/i2c/axppmic.c:1.27 src/sys/dev/i2c/axppmic.c:1.28
--- src/sys/dev/i2c/axppmic.c:1.27 Mon Dec 23 02:57:32 2019
+++ src/sys/dev/i2c/axppmic.c Mon Dec 23 14:34:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $ */
+/* $NetBSD: axppmic.c,v 1.28 2019/12/23 14:34:23 thorpej Exp $ */
/*-
* Copyright (c) 2014-2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.27 2019/12/23 02:57:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: axppmic.c,v 1.28 2019/12/23 14:34:23 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -557,12 +557,20 @@ static void
axppmic_power_poweroff(device_t dev)
{
struct axppmic_softc *sc = device_private(dev);
+ int error;
delay(1000000);
- iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
- axppmic_write(sc->sc_i2c, sc->sc_addr, AXP_POWER_DISABLE_REG, AXP_POWER_DISABLE_CTRL, I2C_F_POLL);
- iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+ error = iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
+ if (error == 0) {
+ error = axppmic_write(sc->sc_i2c, sc->sc_addr,
+ AXP_POWER_DISABLE_REG, AXP_POWER_DISABLE_CTRL, I2C_F_POLL);
+ iic_release_bus(sc->sc_i2c, I2C_F_POLL);
+ }
+ if (error) {
+ device_printf(dev, "WARNING: unable to power off, error %d\n",
+ error);
+ }
}
static struct fdtbus_power_controller_func axppmic_power_funcs = {