From patchwork Tue Jun 16 17:57:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 485107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 57423140290 for ; Wed, 17 Jun 2015 03:57:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbbFPR5k (ORCPT ); Tue, 16 Jun 2015 13:57:40 -0400 Received: from sauhun.de ([89.238.76.85]:34229 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbbFPR5i (ORCPT ); Tue, 16 Jun 2015 13:57:38 -0400 Received: from p4fe251da.dip0.t-ipconnect.de ([79.226.81.218]:37671 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Z4v7A-0004o0-Rh; Tue, 16 Jun 2015 19:57:37 +0200 From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-tegra@vger.kernel.org, Wolfram Sang Subject: [PATCH] i2c: tegra: apply size limit quirk Date: Tue, 16 Jun 2015 19:57:29 +0200 Message-Id: <1434477449-8340-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org payload_size is a 12 bit field in the HW register, so add a limit for this size. That way we gracefully reject the message beforehand instead of generating an OOPS while transferring. Verified using some older Tegra2 documentation and a more recent Jetson TK1 board. Signed-off-by: Wolfram Sang Reviewed-by: Alexander Sverdlin --- drivers/i2c/busses/i2c-tegra.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 0a1b6eacef0fba..78a36681469674 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -669,6 +669,12 @@ static const struct i2c_algorithm tegra_i2c_algo = { .functionality = tegra_i2c_func, }; +/* payload size is only 12 bit */ +static struct i2c_adapter_quirks tegra_i2c_quirks = { + .max_read_len = 4096, + .max_write_len = 4096, +}; + static const struct tegra_i2c_hw_feature tegra20_i2c_hw = { .has_continue_xfer_support = false, .has_per_pkt_xfer_complete_irq = false, @@ -739,6 +745,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->base = base; i2c_dev->div_clk = div_clk; i2c_dev->adapter.algo = &tegra_i2c_algo; + i2c_dev->adapter.quirks = &tegra_i2c_quirks; i2c_dev->irq = irq; i2c_dev->cont_id = pdev->id; i2c_dev->dev = &pdev->dev;