From nobody Sun Dec 19 10:06:04 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C1E7119038F3; Sun, 19 Dec 2021 10:06:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JGyzJ586dz3pNs; Sun, 19 Dec 2021 10:06:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 826BA203F8; Sun, 19 Dec 2021 10:06:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BJA64GJ000262; Sun, 19 Dec 2021 10:06:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJA64qv000261; Sun, 19 Dec 2021 10:06:04 GMT (envelope-from git) Date: Sun, 19 Dec 2021 10:06:04 GMT Message-Id: <202112191006.1BJA64qv000261@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 46e0c0379544 - main - twsi: use twsi_error() to handle wrong bus status when starting List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46e0c03795443675f95db6da2195825d24a9fb7c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639908365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MdVhkeoGCCU25num2MzJkU1WopiK6FdW5goWpSq2OVs=; b=U/ftGZvErs5w4wh68DWw9LbsUdcuqKIwys1OSy5BqYj4AgWrfJTYhnxKc6k3vThA4x2s2B OwB7jxUJBV6rjZf9LOpRZp1oSY78cSXKcyVVSvs9PW4/xhs+UV3/stXQ/bWW45b0/s2wVP VvEF/+RFm6yoQn0atKibnl3V+S+nUf/9N8AHPsVLwab3qFs3BFbM5CUitkZC+flea0+/hi aLH6kNN0xJ68J9/NjYYU1FrXbUeT8DVbDatLr02cvvEhVnK7YykIKHeSnrLptiKYEcFQFI KG/Y/IOKZuCxwBw8yETN+qdZi3U9g7N/IZp04Ig+PJk30bW76antFPPtmiCVnQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639908365; a=rsa-sha256; cv=none; b=CS8ukjnCu/mh58SjFfT2Sa+hJ9U01D/8VX8/nqt5oRiQ4cVbAhzuQZHc7TQ9UNB/beiK5e oiPrY1AajnIZv5Xz4LY+va0WPMKm2vP7m7mTbhKxEZdoUVYDOSXGCDLt/KUnvPnVii+ZTy Yvuvkva5KkRv3Fo55dau9yqcNXnJ90XZjFmfG86KvSxnnA8GHEp3cCe/yossIGwzDL3c7g vJLtddajJQRxahEdCD2IjRFf/q6eST3ug+yFShfRUruJburJUn0D8P2CNk8qOU1zVpN/P9 I8FXGvRHxKo7HoF+z4xk+HzRvcrxhI+0kXILBuU2mC6FfzrGZvEIgDkZ95fcxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=46e0c03795443675f95db6da2195825d24a9fb7c commit 46e0c03795443675f95db6da2195825d24a9fb7c Author: Andriy Gapon AuthorDate: 2021-12-19 09:28:02 +0000 Commit: Andriy Gapon CommitDate: 2021-12-19 10:05:52 +0000 twsi: use twsi_error() to handle wrong bus status when starting MFC after: 1 week --- sys/dev/iicbus/twsi/twsi.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/dev/iicbus/twsi/twsi.c b/sys/dev/iicbus/twsi/twsi.c index 740c7e14a31f..91433f2cfe4a 100644 --- a/sys/dev/iicbus/twsi/twsi.c +++ b/sys/dev/iicbus/twsi/twsi.c @@ -480,6 +480,19 @@ out: return (rv); } +static void +twsi_error(struct twsi_softc *sc, int err) +{ + /* + * Must send stop condition to abort the current transfer. + */ + debugf(sc, "Sending STOP condition for error %d\n", err); + sc->transfer = 0; + sc->error = err; + sc->control_val = 0; + TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_STOP); +} + static int twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) { @@ -501,9 +514,8 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) 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); + twsi_error(sc, IIC_ESTATUS); + goto end; } sc->nmsgs = nmsgs; @@ -531,6 +543,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) if (sc->error != 0) debugf(sc, "Error: %d\n", sc->error); +end: /* Disable module and interrupts */ debugf(sc, "status=0x%x\n", TWSI_READ(sc, sc->reg_status)); TWSI_WRITE(sc, sc->reg_control, 0); @@ -541,19 +554,6 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) return (error); } -static void -twsi_error(struct twsi_softc *sc, int err) -{ - /* - * Must send stop condition to abort the current transfer. - */ - debugf(sc, "Sending STOP condition for error %d\n", err); - sc->transfer = 0; - sc->error = err; - sc->control_val = 0; - TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_STOP); -} - static void twsi_intr(void *arg) {