Date: Fri, 10 Dec 2021 12:30:20 GMT From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 5efa75707b21 - stable/13 - twsi: do not attempt transfer if bus is not idle Message-ID: <202112101230.1BACUKhr064442@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=5efa75707b2155c74078b1189f6015662e2f478d commit 5efa75707b2155c74078b1189f6015662e2f478d Author: Andriy Gapon <avg@FreeBSD.org> AuthorDate: 2021-11-26 07:30:38 +0000 Commit: Andriy Gapon <avg@FreeBSD.org> CommitDate: 2021-12-10 12:30:12 +0000 twsi: do not attempt transfer if bus is not idle (cherry picked from commit cb167e1ae95473d836393a07456d8dbcfbb7f758) --- sys/dev/iicbus/twsi/twsi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/dev/iicbus/twsi/twsi.c b/sys/dev/iicbus/twsi/twsi.c index 05f67786cad0..5e899313ac45 100644 --- a/sys/dev/iicbus/twsi/twsi.c +++ b/sys/dev/iicbus/twsi/twsi.c @@ -484,6 +484,7 @@ static int twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) { struct twsi_softc *sc; + uint32_t status; int error; sc = device_get_softc(dev); @@ -496,7 +497,15 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) ("starting a transfer while another is active")); debugf(sc, "transmitting %d messages\n", nmsgs); - debugf(sc, "status=%x\n", TWSI_READ(sc, sc->reg_status)); + status = TWSI_READ(sc, sc->reg_status); + debugf(sc, "status=0x%x\n", status); + if (status != TWSI_STATUS_IDLE) { + debugf(sc, "Bad status at start of transfer\n"); + TWSI_WRITE(sc, sc->reg_control, TWSI_CONTROL_STOP); + mtx_unlock(&sc->mutex); + return (IIC_ESTATUS); + } + sc->nmsgs = nmsgs; sc->msgs = msgs; sc->msg_idx = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112101230.1BACUKhr064442>