Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3432417ybi; Mon, 10 Jun 2019 10:09:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyciTBSicofWCyeS6dJ4plzEDQ4gCAOamwtqBtpxu8U1JcHBVAYRsEl6vMmm0yBy/lxvROu X-Received: by 2002:a62:3741:: with SMTP id e62mr76101089pfa.213.1560186591749; Mon, 10 Jun 2019 10:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560186591; cv=none; d=google.com; s=arc-20160816; b=bNkM+WucnQUdlWwfCnDTVBhDtlhR9KI1fhDdSjHLfzVYKcFZnDFfwAjHZiTWD0wB4W k5nYCt7DkwR7bwH2y1dI7kFtXNdz+blpss/bbxUfA9MBI9qoGMFlVljxHZUOugL+Mr1F hXCwWNf5EWrKo46zKsNAootmt2UgDDRngIQ2iYD3phwTFqXgptQbjAxchNcPGzZ0+Yy5 ibZd+nFOG3G+namMjgq8VThWlTeLueGdnRcjce+vvxwy3M8iOHocTutR/sA3Rvk6ujuP x+EBd0om4mq46xcoYUuzbwD1CQZJ4pDZwrQabSArvL3s7PMVHUISaY9c5Xd5RBKjmlQ/ GcGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=Gfzngx0clR6d9UOZuOxpnc3aAu0Ti7qqGyhmjCpt1n4=; b=U9xeYdN8tOQOL1FZN6H3v0pJMYS7yJaNp87dTUe74mOdCpP5RMklV/Qggi19H6GclM dXID4CtsBOQcOql1tDMEjPJW5xd0AbctaEBCnx3ha5GizhijRjUHOcTTMN5qou0Ul1IY B6YZ8jaoivoddPcMkPQTkO/+/SeXsOAV3yAusaBQbo+/t3Ik2mbBLmOnSzm8v8fo9arv uq2PxR9MspV7gdo0cmEjPmRgduFnRgS3heQFKcAApKCwAijBFOIUI2X7x25evag0f3O+ oSEMO0SY2/bRaVeXN2qpf/qR/M9sL2xASgmGTk6m82CJF6i4I4P3JlJkzEudoS1YHz/F xAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=CnZ9KZRS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si10542865pfn.225.2019.06.10.10.09.37; Mon, 10 Jun 2019 10:09:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=CnZ9KZRS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbfFJRJE (ORCPT + 99 others); Mon, 10 Jun 2019 13:09:04 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:16633 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727679AbfFJRJC (ORCPT ); Mon, 10 Jun 2019 13:09:02 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 10 Jun 2019 10:09:02 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 10 Jun 2019 10:09:01 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 10 Jun 2019 10:09:01 -0700 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 10 Jun 2019 17:09:01 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 10 Jun 2019 17:09:01 +0000 Received: from dhcp-10-19-65-14.client.nvidia.com (Not Verified[10.19.65.14]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 10 Jun 2019 10:09:00 -0700 From: Bitan Biswas To: Laxman Dewangan , Thierry Reding , Jonathan Hunter , , , , Peter Rosin , Wolfram Sang , Dmitry Osipenko CC: Shardar Mohammed , Sowjanya Komatineni , Mantravadi Karthik , Bitan Biswas Subject: [PATCH V4 6/6] i2c: tegra: remove BUG, BUG_ON Date: Mon, 10 Jun 2019 10:08:35 -0700 Message-ID: <1560186515-30797-6-git-send-email-bbiswas@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560186515-30797-1-git-send-email-bbiswas@nvidia.com> References: <1560186515-30797-1-git-send-email-bbiswas@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1560186542; bh=Gfzngx0clR6d9UOZuOxpnc3aAu0Ti7qqGyhmjCpt1n4=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=CnZ9KZRSzFQr/Nh/EZ7I2TECnVjGCnyvPuX3xtQ5DQ/hp4HafifFDPi3l/NMdcFtq n/K0+d2icjKpWl0UyD3G/jVymPoF6Dfb79eUZ+ET1ZYvGIM2rBML9y3jqV6ugFkYgs nDtWPxrciogvVLsDXQn9kCesh12z036RkYhUvHk1WYrPOWmMvBivA3bQ8iiqituen9 3XBjTtBtotpS/cBfwVOMP//rBkO5XuHjQac6jw0SEGTTDBB5Fd6FU8YELpdr4cK9SP SVuUtrxQg7EqnSVbDKL1Wq3EYN6rpvyoxSBMiKoW2ElS35I5QgawBE1eEOo9WmEkzy xC87pccMwpl8w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove redundant BUG_ON calls or replace with WARN_ON_ONCE as needed. Remove BUG() and make Rx and Tx case handling similar. Signed-off-by: Bitan Biswas --- drivers/i2c/busses/i2c-tegra.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 4dfb4c1..30619d6 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -515,7 +515,6 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev) * prevent overwriting past the end of buf */ if (rx_fifo_avail > 0 && buf_remaining > 0) { - BUG_ON(buf_remaining > 3); val = i2c_readl(i2c_dev, I2C_RX_FIFO); val = cpu_to_le32(val); memcpy(buf, &val, buf_remaining); @@ -523,7 +522,6 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev) rx_fifo_avail--; } - BUG_ON(rx_fifo_avail > 0 && buf_remaining > 0); i2c_dev->msg_buf_remaining = buf_remaining; i2c_dev->msg_buf = buf; @@ -581,7 +579,6 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) * boundary and fault. */ if (tx_fifo_avail > 0 && buf_remaining > 0) { - BUG_ON(buf_remaining > 3); memcpy(&val, buf, buf_remaining); val = le32_to_cpu(val); @@ -850,7 +847,8 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) if (i2c_dev->msg_buf_remaining) tegra_i2c_empty_rx_fifo(i2c_dev); else - BUG(); + tegra_i2c_mask_irq(i2c_dev, + I2C_INT_RX_FIFO_DATA_REQ); } if (!i2c_dev->msg_read && (status & I2C_INT_TX_FIFO_DATA_REQ)) { @@ -876,7 +874,10 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) if (status & I2C_INT_PACKET_XFER_COMPLETE) { if (i2c_dev->is_curr_dma_xfer) i2c_dev->msg_buf_remaining = 0; - BUG_ON(i2c_dev->msg_buf_remaining); + if (WARN_ON_ONCE(i2c_dev->msg_buf_remaining)) { + i2c_dev->msg_err |= I2C_ERR_UNKNOWN_INTERRUPT; + goto err; + } complete(&i2c_dev->msg_complete); } goto done; -- 2.7.4