From: mglocker Date: Wed, 14 Aug 2024 10:54:58 +0000 (+0000) Subject: In a qcspmi_cmd_read() error case, the register is only returning the error X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3f2f329f363f903bc04d7898d6c46a8b9c33819f;p=openbsd In a qcspmi_cmd_read() error case, the register is only returning the error bit, not SPMI_STATUS_DONE. Therefore, catch the error at the right place, and print the specific error type. ok patrick@ --- diff --git a/sys/dev/fdt/qcpmic.c b/sys/dev/fdt/qcpmic.c index 3a93fd5b86a..7b3a7117635 100644 --- a/sys/dev/fdt/qcpmic.c +++ b/sys/dev/fdt/qcpmic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcpmic.c,v 1.1 2022/11/08 19:40:08 patrick Exp $ */ +/* $OpenBSD: qcpmic.c,v 1.2 2024/08/14 10:54:58 mglocker Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -117,7 +117,7 @@ qcpmic_read(struct qcpmic_softc *sc, uint16_t addr) err = spmi_cmd_read(sc->sc_tag, sc->sc_sid, SPMI_CMD_EXT_READL, addr, ®, sizeof(reg)); if (err) - printf("%s: error (%u) reading 0x%x\n", sc->sc_dev.dv_xname, + printf("%s: error (%u) reading 0x%x", sc->sc_dev.dv_xname, err, addr); return reg; diff --git a/sys/dev/fdt/qcspmi.c b/sys/dev/fdt/qcspmi.c index 5cc807f71f2..656213afbb9 100644 --- a/sys/dev/fdt/qcspmi.c +++ b/sys/dev/fdt/qcspmi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcspmi.c,v 1.5 2024/07/04 21:54:38 kettenis Exp $ */ +/* $OpenBSD: qcspmi.c,v 1.6 2024/08/14 10:54:58 mglocker Exp $ */ /* * Copyright (c) 2022 Patrick Wildt * @@ -408,14 +408,23 @@ qcspmi_cmd_read(void *cookie, uint8_t sid, uint8_t cmd, uint16_t addr, SPMI_OBSV_OFF(sc, sc->sc_ee, apid) + SPMI_STATUS); if (reg & SPMI_STATUS_DONE) break; + if (reg & SPMI_STATUS_FAILURE) { + printf(": transaction failed\n"); + return EIO; + } + if (reg & SPMI_STATUS_DENIED) { + printf(": transaction denied\n"); + return EIO; + } + if (reg & SPMI_STATUS_DROPPED) { + printf(": transaction dropped\n"); + return EIO; + } } - if (i == 0) + if (i == 0) { + printf("\n"); return ETIMEDOUT; - - if (reg & SPMI_STATUS_FAILURE || - reg & SPMI_STATUS_DENIED || - reg & SPMI_STATUS_DROPPED) - return EIO; + } if (len > 0) { reg = HREAD4(sc, QCSPMI_REG_OBSRVR,