From nobody Sun Dec 26 10:16:03 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 6AE2B19060E8; Sun, 26 Dec 2021 10:16:04 +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 4JMGsc0hXmz3m0P; Sun, 26 Dec 2021 10:16: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 E2E18A31; Sun, 26 Dec 2021 10:16:03 +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 1BQAG3SA093513; Sun, 26 Dec 2021 10:16:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BQAG37V093512; Sun, 26 Dec 2021 10:16:03 GMT (envelope-from git) Date: Sun, 26 Dec 2021 10:16:03 GMT Message-Id: <202112261016.1BQAG37V093512@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 7b1bf3c12c23 - stable/12 - 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/stable/12 X-Git-Reftype: branch X-Git-Commit: 7b1bf3c12c23fa7a7ad952aa380a749b75f1f967 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640513764; 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=S8WknFuvFWLTvaGXTySIswQcgQ08WXFKY/tk2SQSrmU=; b=ZSsrzmmCOMRQzqxXJhXCoWAAO8EnDYAFolgvTLqIxL+I3HDorGu/JnjwnsWqK6gCBxl02J n+bfnlUt96o6J16vfEzu9aDmZnFZbFsNprte+2pD5kywFzlV9A6FjYoYGvYNPlGVPOAzre Pl1fvifWva8g8JH7WOgJcGDpKMK4o+8ucrS91elFEWCsKfWzeNSr16HRc5HoD+RdjtRuHS vUzVSEZ9oUiU9Pp3BHgmF13XOs8ASkOjNqlZhH0uUHnNl4VsWEFcuOqA2ItpV1JwdIBZJM jptRVx63g1G2Z1s4mVl/bRE77FGIpCHcobwU93FU5QCXuo6NfURq1SbrmXuUPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640513764; a=rsa-sha256; cv=none; b=priPDaKW3Y/4MY4jQZf9WVVxJ1IaLhOMxML98Kq2ysSn2KcYD70bAS15hg/ZjqsI2bYV02 bkr+xiVbhIqz+Vn9jqv1zJdhu40LQCJqgtaSXW27TQrtMBmHooyz9U5K00Q5CDBxB3/TIb d5+mR06D04/oC7FI/sp31L3sgyNVQelEgMjIW9h7X/vmvDx9uGZzWlwWzJfr14VX755xz5 4suuIpuHBt2Odl7hC5QHbJmO/5sRO7mNK0vYuZUb1JAj4Tw3G1IpO9ZmRyQoFG0+pBZPSE ZA5YJBr3kPeSNAek/z/SJQwf4f7mof5Rxdyswci85n6xNioDDmkGvFDuE0FkOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=7b1bf3c12c23fa7a7ad952aa380a749b75f1f967 commit 7b1bf3c12c23fa7a7ad952aa380a749b75f1f967 Author: Andriy Gapon AuthorDate: 2021-12-19 09:28:02 +0000 Commit: Andriy Gapon CommitDate: 2021-12-26 10:15:54 +0000 twsi: use twsi_error() to handle wrong bus status when starting (cherry picked from commit 46e0c03795443675f95db6da2195825d24a9fb7c) --- 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) {