From patchwork Tue Sep 1 21:10:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B47FC433E7 for ; Tue, 1 Sep 2020 21:11:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4772B206FA for ; Tue, 1 Sep 2020 21:11:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lFlkmSD7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728802AbgIAVLb (ORCPT ); Tue, 1 Sep 2020 17:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728127AbgIAVL1 (ORCPT ); Tue, 1 Sep 2020 17:11:27 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BEA0C061246; Tue, 1 Sep 2020 14:11:27 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id a15so3304200ljk.2; Tue, 01 Sep 2020 14:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FRnx45u7/i2kry58qh4geYUb8/TK/AjF/UDJOIFPEeg=; b=lFlkmSD7LTWLNj4Vxpv/0mu+bucA/Wpf/Sxdf7+dq4J3C9Z1iQ8x7q3Ee8VAb86NhE WwaqLOmjhrlAyzA+sXlFAfFQkMDIStd0oPaVCJeWajz8qF4VB3SKB8zsSqEV+QMDPvGQ lFYlgOR+R7LPBpeNTGvm3zyCajLD+R2Ycy2YUjtfdEQAeBOGzSvCeUcf5WfBdXYNf9Tv nYUAl6geeD6ITidW+p2w0txKwuLzHnuQqaUhgx1C70jqyCZxdA3DYHTFIwIggsSXYq+V MJ3lkhySKySIgC3CEgMyUBoDX0N3UIUgG1y/11ENmOgHck9vf943y7YEjR3xnTcj3bD4 9mEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FRnx45u7/i2kry58qh4geYUb8/TK/AjF/UDJOIFPEeg=; b=Gvne01KUofItxe8J3KPZNQjz3h3bfwZtHVG/oehN3KjcKbKVdNYq3AlWR0dybpCUX+ /J31+tAr0jE0v4xOrdGOjq5HZgoRoCu8IJYmN0ntwD42aHxV1CZpwG5LycN2kZVuFrB3 GO++GNag/MhCCSpOwlMnxZU8LKjnAYkVGIORO4tudlQ/gEvmlCMGHqWkOuKQEsoWoKs2 oMKO3gx3JhUq5j7JVAdduq8upBO1JgOXhniljISn5oWjiofoLK+dX0sIuLIyDkReBprT SGC/wMxLgdIo5Gsxm6S1vvxq+w+COJDPKj1ep+sSuQy39I5Bg7wW7H/bSy8eWRfzcPhQ 6S3w== X-Gm-Message-State: AOAM531SbVj0oP0T7C5N/IzsGfMLrbPhTq6iggVQK2UFlqdj4M5/Ugxj RcsOgRize6BIvJ/JAXCBceUqXg2K/HI= X-Google-Smtp-Source: ABdhPJzgYQjh3/CTH++mR3nRXrWPPnTN6ZqbGJwDiU5Eo68NSJJTL5VwrNGf8EbP5zco4wJpLplhTg== X-Received: by 2002:a2e:8597:: with SMTP id b23mr1555675lji.41.1598994685513; Tue, 01 Sep 2020 14:11:25 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:25 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/17] i2c: tegra: Add missing newline before returns Date: Wed, 2 Sep 2020 00:10:47 +0300 Message-Id: <20200901211102.11072-3-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some places in the code are missing a newline before return, making code more difficult to read and creating inconsistency of the code. This patch adds the missing newlines. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index aab58395fb71..9bd91b6f32f4 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -317,6 +317,7 @@ static unsigned long tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; else if (i2c_dev->is_vi) reg = 0xc00 + (reg << 2); + return reg; } @@ -392,6 +393,7 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len) dma_desc->callback_param = i2c_dev; dmaengine_submit(dma_desc); dma_async_issue_pending(chan); + return 0; } @@ -500,6 +502,7 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev) ktime = ktime_get(); } + return 0; err_timeout: @@ -707,6 +710,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) clk_disable(i2c_dev->slow_clk); disable_fast_clk: clk_disable(i2c_dev->fast_clk); + return ret; } @@ -1421,6 +1425,7 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap) if (i2c_dev->hw->has_continue_xfer_support) ret |= I2C_FUNC_NOSTART; + return ret; } @@ -1888,6 +1893,7 @@ static int tegra_i2c_remove(struct platform_device *pdev) clk_unprepare(i2c_dev->fast_clk); tegra_i2c_release_dma(i2c_dev); + return 0; } From patchwork Tue Sep 1 21:10:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D402BC433E2 for ; Tue, 1 Sep 2020 21:13:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD4B9207D3 for ; Tue, 1 Sep 2020 21:13:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XponkNRv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729863AbgIAVNL (ORCPT ); Tue, 1 Sep 2020 17:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728730AbgIAVLb (ORCPT ); Tue, 1 Sep 2020 17:11:31 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E591C061245; Tue, 1 Sep 2020 14:11:30 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id h19so3256879ljg.13; Tue, 01 Sep 2020 14:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dZ6TJT0d2WHfPiQp5ZxQDWsFPOMSgFVrHCsGXELQF8Q=; b=XponkNRvckXfs6klc/3ZLBkX+6Uzlaof5yRSvgENVLsRKI3+jYQmVOgQhRrBFkymjU uYUDNwTVfCwW4ncmQ0NBqipZNdI39CthK3xAZ7W2B3xNYRVFh/MaIWdRDzjZiOkzCwXC Fmkzwojm5trS1Qkr1ApsyOxgsYy1aReIWRSvXTzGU7rlADmQOC0B4mmsDjbDuJH/Mm3/ y0DVK1kwJfb4XpC9jThoeaDm3AjEGu/oUGXzzwmSntMhGLtxECD0yKtCB3X7BgFkGz5z 7IfobfUfU75JTCmzuVgadJtkCGFpqtBd01wTH7eKpFSJs/KjmwZnXqFWzic8RwoK20v/ IGgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dZ6TJT0d2WHfPiQp5ZxQDWsFPOMSgFVrHCsGXELQF8Q=; b=CKDd2TzhxmI6SfxlrFacAzLpaC5SiE/YdndYLYwCpNf/0+fvj5Ff2dliycp+W07KnQ NQKZ+vbR06Fsjws8HxR6MiGkYtjP1mQxLq+hdMQMZxUtn3QGiZrPNoRNL10kD7D/mJu9 BzG9b3bCAD9Sjuv8Wj9D0oSmvWn4QTPKN0pWfFESJqzQArsGNR/+/5qt826b4YOHsi/n ZBN1+SHVO1MmZY+M76Xv4b8m1vhhUfEKY9UCEJr6lEdRLLhuJsx3gNU//NMMFIgCX/mt k3ZbdpsUryscgLimpLNZUpWPLTaElLjnzbRfdWZ9JL1aO5guYB2mjC/GGM7oUE8ODW9i dtLA== X-Gm-Message-State: AOAM532QaFfEgPkqNW8IowB7hRuIawx7N8OAEN90Sca7hfG+IbVxfGKO QPiZG9IAZ8cF72oYeRLpiQ4= X-Google-Smtp-Source: ABdhPJwiJytVcgBcne7J0ipyPrtfRdDtc1xB2F+SIki3k+XNyS6122ZHB1Zp3BHdZsIIZu0fz9GZiw== X-Received: by 2002:a05:651c:231:: with SMTP id z17mr1469756ljn.109.1598994688546; Tue, 01 Sep 2020 14:11:28 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/17] i2c: tegra: Use reset_control_reset() Date: Wed, 2 Sep 2020 00:10:50 +0300 Message-Id: <20200901211102.11072-6-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use a single reset_control_reset() instead of assert/deasset couple in order to make code cleaner a tad. Note that the reset_control_reset() uses 1 microsecond delay instead of 2 that was used previously, but this shouldn't matter. In addition don't ignore potential error of the reset. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 2da45ff32621..aa815e48f77e 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -790,9 +790,9 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) u32 tsu_thd; u8 tlow, thigh; - reset_control_assert(i2c_dev->rst); - udelay(2); - reset_control_deassert(i2c_dev->rst); + err = reset_control_reset(i2c_dev->rst); + if (WARN_ON_ONCE(err)) + return err; if (i2c_dev->is_dvc) tegra_dvc_init(i2c_dev); From patchwork Tue Sep 1 21:10:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDD07C28E83 for ; Tue, 1 Sep 2020 21:12:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBEC3214F1 for ; Tue, 1 Sep 2020 21:12:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kgVU0FQL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729709AbgIAVMo (ORCPT ); Tue, 1 Sep 2020 17:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbgIAVLc (ORCPT ); Tue, 1 Sep 2020 17:11:32 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9A50C061247; Tue, 1 Sep 2020 14:11:31 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w14so3293381ljj.4; Tue, 01 Sep 2020 14:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZYfcEkg6MN7XwZIXTI1VLSEAge97NsZf/nSNk/9wRjc=; b=kgVU0FQL1ZNctd2YFK0SWhXHis7NuQPcskeeA1kGqOjaNH4lBGDOICmwMwWb7S5z+A sEZ/fmxlOM21pMWMvucdrOFTz+w74ahkGGLLjsUUkOkmhWSK2hfwSJqzXWA0t1CuFvl1 dG3h4gcTiQus9ZcOFMtqKLe8zizZDsHYMURrhouenSyjdyMkaAMrt9+Q2TioLJQQbP2S 2i5ud6s7xIQzfBL7I/ysSm1fLs8G28O08bqlkm5QKHt49BZ1TU44A0eBVSresQGwrLp+ Uee5AYli00AU4wPA1iETlQoqyoNuYqaCSd5/JsdxzBdV2MACv4CpqevKQqom2H9YSIzD ZkZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZYfcEkg6MN7XwZIXTI1VLSEAge97NsZf/nSNk/9wRjc=; b=LM/rmWZBpis5ByOQZotR1oxwxRQKZaIvZZQxwZJk+vWtAjBRp9Qx53IOtBTH2eenfd PFrxRRSt5hzlXH/NIC1jM+KiplK8dZsSIjsWlIi4nbRLMjHUMWJAkpGtdAUyCo5U7iN3 r5OI8Rrz+NrI92Rtv2KEqk78lR8H0Y3Cl0XgsvI5B35NAPUUdTL0wywT2IJYkugbzuYx bX5JV+9IzFC0DIRdxAxEG5U8odt0FgqdwkOc24YQSNcuPJckhIJJz7REaDzjesA3edGN j790WKFPXsz83QPReKK9iMPKy0FNkR4CHSAF1kfPc6lt9VXZ488fEoZOn1T5t5xNsZr3 fegw== X-Gm-Message-State: AOAM530w2CWUApcrDceIXmhczsucmR/4rFoJIbFLnUzOHdChhYUA91ik gLsy0NGucVxHgx0UBFQDB+Y= X-Google-Smtp-Source: ABdhPJyIIDPj3sHfxDUiKnQ8Eti6WewnyWpF6xGCCDK0YJJPEvku3AmzrMN4LpGn3veJhqImU4reGg== X-Received: by 2002:a2e:b1c4:: with SMTP id e4mr1627979lja.379.1598994690234; Tue, 01 Sep 2020 14:11:30 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:29 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 07/17] i2c: tegra: Use dev_err_probe() Date: Wed, 2 Sep 2020 00:10:52 +0300 Message-Id: <20200901211102.11072-8-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use dev_err_probe() to replace the manual -EPROBE_DEFER handling, making code cleaner. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 16f105283145..c142b424e46d 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1646,8 +1646,8 @@ MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); static int tegra_i2c_probe(struct platform_device *pdev) { + struct clk *div_clk, *fast_clk, *slow_clk; struct device *dev = &pdev->dev; - struct clk *div_clk, *fast_clk; struct tegra_i2c_dev *i2c_dev; phys_addr_t base_phys; struct resource *res; @@ -1668,13 +1668,9 @@ static int tegra_i2c_probe(struct platform_device *pdev) irq = res->start; div_clk = devm_clk_get(&pdev->dev, "div-clk"); - if (IS_ERR(div_clk)) { - if (PTR_ERR(div_clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, "failed to get div-clk: %ld\n", - PTR_ERR(div_clk)); - - return PTR_ERR(div_clk); - } + if (IS_ERR(div_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(div_clk), + "failed to get div-clk\n"); i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL); if (!i2c_dev) @@ -1713,24 +1709,20 @@ static int tegra_i2c_probe(struct platform_device *pdev) if (!i2c_dev->hw->has_single_clk_source) { fast_clk = devm_clk_get(&pdev->dev, "fast-clk"); - if (IS_ERR(fast_clk)) { - dev_err(dev, "failed to get fast clock\n: %ld\n", - PTR_ERR(fast_clk)); + if (IS_ERR(fast_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(fast_clk), + "failed to get fast clock\n"); - return PTR_ERR(fast_clk); - } i2c_dev->fast_clk = fast_clk; } if (i2c_dev->is_vi) { - i2c_dev->slow_clk = devm_clk_get(dev, "slow"); - if (IS_ERR(i2c_dev->slow_clk)) { - if (PTR_ERR(i2c_dev->slow_clk) != -EPROBE_DEFER) - dev_err(dev, "failed to get slow clock: %ld\n", - PTR_ERR(i2c_dev->slow_clk)); + slow_clk = devm_clk_get(dev, "slow"); + if (IS_ERR(slow_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(slow_clk), + "failed to get slow clock\n"); - return PTR_ERR(i2c_dev->slow_clk); - } + i2c_dev->slow_clk = slow_clk; } platform_set_drvdata(pdev, i2c_dev); From patchwork Tue Sep 1 21:10:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3AE8C433E6 for ; Tue, 1 Sep 2020 21:12:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AE65207D3 for ; Tue, 1 Sep 2020 21:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="emqPFT9M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbgIAVMm (ORCPT ); Tue, 1 Sep 2020 17:12:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729020AbgIAVLf (ORCPT ); Tue, 1 Sep 2020 17:11:35 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905AAC061245; Tue, 1 Sep 2020 14:11:34 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id a15so3304638ljk.2; Tue, 01 Sep 2020 14:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dET0JzECK8CtHPygKgo78u1ZJ6NkxyMLuHDUClj7AMw=; b=emqPFT9MZ5MzoPt8KRw6cJRwm8IdQLrD8XVObCdwoSG5Vyvi37g1xOqN4IPqhztt3l D43G9faSazCJpjfwoJEoJHamI4PLUjw/C5wMqr7Ux5UtEnb644RRWDwtpp46KJDhOgmu MJFRoBeJC3cxo2P9s0QA0FPEY+VLLaIzaN86Arn1sQBb4tgqDD4w0kyhVeWJGSmFgI2k h/wBHVb6FWc7VsZxWTae7y6WXCD4+dvmNpiByyJz1xu7U35OkxuuO9bBWDM/EtfXe4c9 5HYIZrTsOyhUJKpfh190S55sTmc2izRHMSHXz8IvtlJhdeVOqzfKf1YKPoG6zDoI7EIj UErw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dET0JzECK8CtHPygKgo78u1ZJ6NkxyMLuHDUClj7AMw=; b=esmU7tOk8SyM3D9oFOIoWaydu6zlO7vLuXNhjyF6vfWH09+DGVmwpNtskdULxo5zXL 8HHTGP829BbzgwyXalRBCQzAb+pHdam8X+1XmbPwu5++jlVVdJEOKJAcgTThrWqClBTN nsCnLnXtM/PHTw0spiv3EbJoOKGJOe4kZ2mfi3/XMCyrBW9ez2cmBgk0WnV537JWuqw8 364GjjUUeTOxgh7dGsLdiVNLorge6LZKbjidf+0xlywriwLsepPiP2TCin/f4uwntt0X osRDDmsJp3uQjf0yMMvoGnnN10P97zlvwzSYdA3j7gteT5biXwEq/wm7FyMBgjlFP6c6 zEMg== X-Gm-Message-State: AOAM531CQPgF7Y+KnF+PIGHtn/kZqIH2MJTRxzKoAD9vkDh9LclHQ5WC /5xVl81SdwjygY1mSJ7DZps= X-Google-Smtp-Source: ABdhPJy6W6tslvIXa1o3bxUn0pHlnGL2jL0VLYc9Z5KOGszJy+ZWWZwet8jlxqthDLECxxBkFOB1tw== X-Received: by 2002:a05:651c:552:: with SMTP id q18mr1539028ljp.248.1598994693060; Tue, 01 Sep 2020 14:11:33 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:32 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/17] i2c: tegra: Drop '_timeout' from wait/poll function names Date: Wed, 2 Sep 2020 00:10:55 +0300 Message-Id: <20200901211102.11072-11-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Drop '_timeout' postfix from the wait/poll completion function names in order to make the names shorter, making code cleaner a tad. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index a8f6a32229c3..3d6189e200ba 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1067,10 +1067,9 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, i2c_writel(i2c_dev, val, reg); } -static unsigned long -tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev, - struct completion *complete, - unsigned int timeout_ms) +static unsigned long tegra_i2c_poll_completion(struct tegra_i2c_dev *i2c_dev, + struct completion *complete, + unsigned int timeout_ms) { ktime_t ktime = ktime_get(); ktime_t ktimeout = ktime_add_ms(ktime, timeout_ms); @@ -1094,16 +1093,14 @@ tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev, return 0; } -static unsigned long -tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev, - struct completion *complete, - unsigned int timeout_ms) +static unsigned long tegra_i2c_wait_completion(struct tegra_i2c_dev *i2c_dev, + struct completion *complete, + unsigned int timeout_ms) { unsigned long ret; if (i2c_dev->is_curr_atomic_xfer) { - ret = tegra_i2c_poll_completion_timeout(i2c_dev, complete, - timeout_ms); + ret = tegra_i2c_poll_completion(i2c_dev, complete, timeout_ms); } else { enable_irq(i2c_dev->irq); ret = wait_for_completion_timeout(complete, @@ -1121,8 +1118,7 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev, * needs to be checked after timeout. */ if (ret == 0) - ret = tegra_i2c_poll_completion_timeout(i2c_dev, - complete, 0); + ret = tegra_i2c_poll_completion(i2c_dev, complete, 0); } return ret; @@ -1149,8 +1145,8 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) i2c_writel(i2c_dev, reg, I2C_BUS_CLEAR_CNFG); tegra_i2c_unmask_irq(i2c_dev, I2C_INT_BUS_CLR_DONE); - time_left = tegra_i2c_wait_completion_timeout( - i2c_dev, &i2c_dev->msg_complete, 50); + time_left = tegra_i2c_wait_completion(i2c_dev, &i2c_dev->msg_complete, + 50); if (time_left == 0) { dev_err(i2c_dev->dev, "timed out for bus clear\n"); return -ETIMEDOUT; @@ -1296,8 +1292,9 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_readl(i2c_dev, I2C_INT_MASK)); if (dma) { - time_left = tegra_i2c_wait_completion_timeout( - i2c_dev, &i2c_dev->dma_complete, xfer_time); + time_left = tegra_i2c_wait_completion(i2c_dev, + &i2c_dev->dma_complete, + xfer_time); /* * Synchronize DMA first, since dmaengine_terminate_sync() @@ -1328,8 +1325,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, } } - time_left = tegra_i2c_wait_completion_timeout( - i2c_dev, &i2c_dev->msg_complete, xfer_time); + time_left = tegra_i2c_wait_completion(i2c_dev, &i2c_dev->msg_complete, + xfer_time); tegra_i2c_mask_irq(i2c_dev, int_mask); From patchwork Tue Sep 1 21:10:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F71FC433E6 for ; Tue, 1 Sep 2020 21:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFFC9207D3 for ; Tue, 1 Sep 2020 21:11:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QTg2THme" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729200AbgIAVLp (ORCPT ); Tue, 1 Sep 2020 17:11:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729031AbgIAVLh (ORCPT ); Tue, 1 Sep 2020 17:11:37 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72D4CC06124F; Tue, 1 Sep 2020 14:11:36 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id e11so3290805ljn.6; Tue, 01 Sep 2020 14:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mv0yu222OJEMYIiqJ/vthowt2F9JGEiQsw/LQHLwEgU=; b=QTg2THmeoUlgLmN2bUFlxtuRYygcEYwmCBodh19ykmXbOmO5yHg1erdhsTzfAps6gz i3a/3R//kPQHxRUgYYiyZh712dlikYjoIs7KF6hsVRTMx/t9D47R9NFGuT2J7YlOjN53 suPt3NC5kDEUUW5l1hOBv+6Sq7j2RvhFeV95nCeeOEBG10jpQPBOxXHAisUHRWRQmpNe 2mOfLiSC+Rw6ppp1irXImXhp0EZCPOZZF327XX/LINebF5smm43ZJDsD2SBWYjhcGupM G5SDcLU6RqrxS+HXnROqQw76smufy+OVb404JecWIwasWXqod5cdVuYDf8OBmu4iNFLF 0eqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mv0yu222OJEMYIiqJ/vthowt2F9JGEiQsw/LQHLwEgU=; b=dow4gB0vhpXhm8Xx9vCYwxl2Qmqu5HhyXH7zwtalkQVmVWw7hqAx9I9t+RjgmaA2uL KLPBwlDXUZITcuE2CgyqHhF/UKkM29VJxzSWNRz2ABYExlYn676Smp+khStLR545OmcR fzozVV46wp8VqOxNSHYzPT2BbkQ2U6bPiveRjSoaUFCI8TW/urts1k1wNXr6K3fVWOvq 22aD7LymvA9cMQzeJXB9bwTndg871l36mTzAWtD8O8GmwUWeq4aJ+tJdGs+CwhVchjfq zK1+8RmY7ecFcOXGEfm0+fkeV3sZHThHk6ubtgYaFXqMW2dSigCe7SzRzSU90dPSl2Br VNVg== X-Gm-Message-State: AOAM530VfFGy+GqWGqYD/y2JRgu5HLmQHiURwpfozVpxlQzk4yOXhyAs 0ZxOBegNFulHial49RQaZOU= X-Google-Smtp-Source: ABdhPJzKbRsQiqhofuzntiit4K/W8LLLu4HZ4/AGK1nSHBgPYR9TxloWk/j30Psz5j8PLCfQ6grRiQ== X-Received: by 2002:a2e:9185:: with SMTP id f5mr1515470ljg.394.1598994694927; Tue, 01 Sep 2020 14:11:34 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:34 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/17] i2c: tegra: Factor out error recovery from tegra_i2c_xfer_msg() Date: Wed, 2 Sep 2020 00:10:57 +0300 Message-Id: <20200901211102.11072-13-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Factor out error recovery code from tegra_i2c_xfer_msg() in order to make this function easier to read and follow. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 46 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 300a6576ff94..bc891d4b41ad 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1161,6 +1161,32 @@ static int tegra_i2c_issue_bus_clear(struct i2c_adapter *adap) return -EAGAIN; } +static int tegra_i2c_error_recover(struct tegra_i2c_dev *i2c_dev, + struct i2c_msg *msg) +{ + if (i2c_dev->msg_err == I2C_ERR_NONE) + return 0; + + tegra_i2c_init(i2c_dev, true); + + /* start recovery upon arbitration loss in single master mode */ + if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) { + if (!i2c_dev->is_multimaster_mode) + return i2c_recover_bus(&i2c_dev->adapter); + + return -EAGAIN; + } + + if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { + if (msg->flags & I2C_M_IGNORE_NAK) + return 0; + + return -EREMOTEIO; + } + + return -EIO; +} + static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, struct i2c_msg *msg, enum msg_end_type end_state) @@ -1341,24 +1367,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->msg_err); i2c_dev->is_curr_dma_xfer = false; - if (i2c_dev->msg_err == I2C_ERR_NONE) - return 0; - tegra_i2c_init(i2c_dev, true); - /* start recovery upon arbitration loss in single master mode */ - if (i2c_dev->msg_err == I2C_ERR_ARBITRATION_LOST) { - if (!i2c_dev->is_multimaster_mode) - return i2c_recover_bus(&i2c_dev->adapter); - return -EAGAIN; - } - - if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { - if (msg->flags & I2C_M_IGNORE_NAK) - return 0; - return -EREMOTEIO; - } + err = tegra_i2c_error_recover(i2c_dev, msg); + if (err) + return err; - return -EIO; + return 0; } static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], From patchwork Tue Sep 1 21:10:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB998C433E6 for ; Tue, 1 Sep 2020 21:13:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88963207D3 for ; Tue, 1 Sep 2020 21:13:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fiPCEwrX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgIAVMl (ORCPT ); Tue, 1 Sep 2020 17:12:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729039AbgIAVLh (ORCPT ); Tue, 1 Sep 2020 17:11:37 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DB7C061246; Tue, 1 Sep 2020 14:11:37 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id v12so3273115ljc.10; Tue, 01 Sep 2020 14:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BFRnoOZ6XZak8+RaE/bfJzD46w7iNGKhaqsvbF27kaM=; b=fiPCEwrXN2oOGrzQ8OnuQRA9X2LvP0HXIqq5o9JIat/OLR3aef0MKjFXbAQ04NBJXs 5qeGJio6otdCBPOBsZlHqWatsuQsIBW5REhZi6Mi/OH9/JLjtIi8l4w0FpW3ajtaK1rf OnXj85CS1X8rT3jo2lAP3APiUsGBABOi57ocjcM9yOjaePhCMU9c+7jEg5gvZMxVPt/O 67TINVm6TI+WpYi0Uu+tGp/FcBSqerLhyLZXOEuggEdlD7zxwpLFXDWnv0zH4i4uHGt/ pv7/KvnP8VRoDutrmqNtoARuu/j8ekdwW27Zo2/CUUKYy/95fe3aQfGwwVWCSQWySy6o skrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BFRnoOZ6XZak8+RaE/bfJzD46w7iNGKhaqsvbF27kaM=; b=bwp7KI/ppIJBvn3Ib/J7JsM5tf1swCUV7RciD65YR6BeGihsr2GIOf236lGj5S/icQ NX8ZfZzH9Wqz+2l7KbIQ56gYpEwRAo+VHLEgduIKNumMjUq5K46naj/rFHoxX/Yrh3lA 6Xr59zxRy0uioS+11tzfocEw8IrW9BE3YFPKqKYTLC/Asfd7OjBhb/gH6LilNIYUPl+S /kZbJbXMqPGy0pqN4KPAHjP3mzs+jWYS9ostlXB5SX88J+kxaLOa1ykluA3J5zzxck6B YBzmyU5xSlEOBxZ/hTB2s098Z7BKFHkGzDXM91Om1qurjWhmZVAH80pFBmK5KbM6Gwho +0Nw== X-Gm-Message-State: AOAM530YNQGjMNg026VFlcLnhaPJzIMr7vIP1rtYebjKCcg/ljG8elU+ 3gNyRNTGNwSAFcZmS0VdHZtTV+7AGDo= X-Google-Smtp-Source: ABdhPJzMi/7F3hBq1UzOEv5cKZjVTuSKXnrqJ5sabV1DHfgXNJKWQcMgvsej5ZabP2CD2eOJl3a+fQ== X-Received: by 2002:a2e:8346:: with SMTP id l6mr1522669ljh.202.1598994695818; Tue, 01 Sep 2020 14:11:35 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:35 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 13/17] i2c: tegra: Check errors for both positive and negative values Date: Wed, 2 Sep 2020 00:10:58 +0300 Message-Id: <20200901211102.11072-14-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The driver's code is inconsistent in regards to the error values checking. The correct way should be to check both positive and negative values. This patch cleans up the error-checks in the code. Note that the pm_runtime_get_sync() could return positive value on success, hence only relevant parts of the code are changed by this patch. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index bc891d4b41ad..9a807caef4a6 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -674,19 +674,19 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) return ret; ret = clk_enable(i2c_dev->fast_clk); - if (ret < 0) { + if (ret) { dev_err(dev, "failed to enable fast clock: %d\n", ret); return ret; } ret = clk_enable(i2c_dev->slow_clk); - if (ret < 0) { + if (ret) { dev_err(dev, "failed to enable slow clock: %d\n", ret); goto disable_fast_clk; } ret = clk_enable(i2c_dev->div_clk); - if (ret < 0) { + if (ret) { dev_err(dev, "failed to enable div clock: %d\n", ret); goto disable_slow_clk; } @@ -1047,7 +1047,7 @@ static void tegra_i2c_config_fifo_trig(struct tegra_i2c_dev *i2c_dev, slv_config.device_fc = true; ret = dmaengine_slave_config(chan, &slv_config); - if (ret < 0) { + if (ret) { dev_err(i2c_dev->dev, "dma config failed: %d\n", ret); dev_err(i2c_dev->dev, "falling back to PIO\n"); tegra_i2c_release_dma(i2c_dev); @@ -1235,7 +1235,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_FROM_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err < 0) { + if (err) { dev_err(i2c_dev->dev, "starting rx dma failed: %d\n", err); return err; @@ -1294,7 +1294,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, xfer_size, DMA_TO_DEVICE); err = tegra_i2c_dma_submit(i2c_dev, xfer_size); - if (err < 0) { + if (err) { dev_err(i2c_dev->dev, "starting tx dma failed: %d\n", err); return err; From patchwork Tue Sep 1 21:11:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5266C433E7 for ; Tue, 1 Sep 2020 21:12:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B46D3206FA for ; Tue, 1 Sep 2020 21:12:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CKO27SUk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729501AbgIAVM0 (ORCPT ); Tue, 1 Sep 2020 17:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729064AbgIAVLk (ORCPT ); Tue, 1 Sep 2020 17:11:40 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321E3C061249; Tue, 1 Sep 2020 14:11:39 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id v23so3303453ljd.1; Tue, 01 Sep 2020 14:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IatbyruaBr7ZVBT4RiIWWB+zJJESjMXJ8GJDpXBSsnU=; b=CKO27SUkg+BYq+pN3KSibuwZtv/VwqiJQF0750cRmskuHl5cQdRFWvwGCv0SQoAvG/ 7a6M2281yunEy5TVnTrRa2Zx5C+GD/VBwBXTNoX+yF9ujgxZT8o8gY8qHxd9xn6Daiea 6+akDKgRpb09x/LY3WUUlv5hJ3eWCtph5XcHX//3fNA9SLa6d/xxfwha/ojS2dJHmeaz 0ls74hh6/N7Up1jZBgIwTc5G1BEYIRqDIn/6wx/Hnwb70ZkjjYU/x6aKfouba9fmfijw ac+fdBEshqYXfiOfMja2xCB32IbtbNXQx9LpCnkeQrmhWf4Y9HvdOEhnSoonndOeNXB7 /WeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IatbyruaBr7ZVBT4RiIWWB+zJJESjMXJ8GJDpXBSsnU=; b=ihrloC9okWY3gHQoinwZatSH1/mb9eB/JIc9PjA+ZuH6VEvmxrvk5O15mgnwRJ6H1J 1qM2J86YDtIssL4fyTB39Ym9gNnI31EP6dtsMXpqfIYoQvI4J9khAdCyWTjaJMo9mdr6 +sxbXpl0LYSyXSXe24ogMQ2U9ouf7g94NZXAeQXtEm3TIs9GoaJ+r2NZGPHmNZTdYe8k qvUGSajF5hMYIkZmlmpuJyCKWNJcbIILIZS06v26IsH3IUk7HU31O7oyt/Xb7p25c1MH xhrL/ECrFrbQxG+ObpBgGAo2pBPf/cDt5hZdOzzfXO9fLPqhd2dXTd034wpgvtzpyeGJ dwvg== X-Gm-Message-State: AOAM533BkucNYaMiU5zKAyRwwSDyYnwisC/848/MKh94rO+mRf10mtei 3yyvXXwRocNInt5UdpvTRp8= X-Google-Smtp-Source: ABdhPJyX4rN70uekb7zWu1dM3PrnrmKNSTkWQlw3fh74qyfuuGNKqleI2p2rAl572LOpYanly+950A== X-Received: by 2002:a2e:9dd3:: with SMTP id x19mr1393967ljj.459.1598994697678; Tue, 01 Sep 2020 14:11:37 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:37 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 15/17] i2c: tegra: Remove unnecessary whitespaces and newlines Date: Wed, 2 Sep 2020 00:11:00 +0300 Message-Id: <20200901211102.11072-16-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Clean up couple places in the code by removing unnecessary whitespaces and newlines. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 70691179f170..bdfccf055959 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1345,8 +1345,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->dma_phys, xfer_size, DMA_FROM_DEVICE); - memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, - msg->len); + memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len); } } @@ -2008,15 +2007,14 @@ static const struct dev_pm_ops tegra_i2c_pm = { }; static struct platform_driver tegra_i2c_driver = { - .probe = tegra_i2c_probe, - .remove = tegra_i2c_remove, - .driver = { - .name = "tegra-i2c", + .probe = tegra_i2c_probe, + .remove = tegra_i2c_remove, + .driver = { + .name = "tegra-i2c", .of_match_table = tegra_i2c_of_match, - .pm = &tegra_i2c_pm, + .pm = &tegra_i2c_pm, }, }; - module_platform_driver(tegra_i2c_driver); MODULE_DESCRIPTION("nVidia Tegra2 I2C Bus Controller driver"); From patchwork Tue Sep 1 21:11:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 254857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62AE0C433E6 for ; Tue, 1 Sep 2020 21:12:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43555206FA for ; Tue, 1 Sep 2020 21:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H55wt3uH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729429AbgIAVMZ (ORCPT ); Tue, 1 Sep 2020 17:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729108AbgIAVLm (ORCPT ); Tue, 1 Sep 2020 17:11:42 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1BC3C061244; Tue, 1 Sep 2020 14:11:41 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id h19so3257543ljg.13; Tue, 01 Sep 2020 14:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eqKOQDvIcPzfOGcXYYks52bq5lwS718ve2YcDrMIuHM=; b=H55wt3uHOE3KFKRMg3AiFK/LitlwYRTebZTN0sIEM2Qv3KVWp5CGA6XqfSI4uuour9 RoCs+v0iVZeazrK//glLCXRzKXNdAEo2cpmknQi+iy0pG6vb8uKjY0sxatROPi2NATp7 JnRU1CTIqIir4y+IU3rlsXu6Hf/LWDIApe2LGFJI9Cuv72nZaPAgZkCEd4rEpqpsaa7c PGbL60fW0kt0t7IMHpVcCZbKWGfPRbwBGq7ClKkoJ0KogTCylnOqKDMGABZ1V93X+clY eLS8zU7cHWQ/QYOAL5PeqFZWRj/FqwN2lErO5f1TeUYnSPbuL2lI/xVTMRVXXu1GXPBs 8D2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eqKOQDvIcPzfOGcXYYks52bq5lwS718ve2YcDrMIuHM=; b=VmBVFOnKbvnLhhDgcmQqLloJZfM2rQuQVzgEkE8QbK0nlWyCLqj2pUClFDnz6Lx9x3 /6YaxcCVezRIvavk9H5iHSLHKA7gG3HORBg007vzkkNh1a4aCTmzteyGSnTAdjglwK8F /fZoU3NqcyQMzcLz8JZS4wnhMEzuPFdmQbTa8vAgDkJBO+AG5xVupx/hhoM7H2PIuv85 cGn+5psaCovO0Tfd97mnrxGO5+z5b6+tjemQvQVE46tZiA/mgYsP/yGlqngARJYJVT9m mf61NLRaLCRKDEPe+c6obbTT1uR0nx2utsz0MDpt2TCZlXCaWek1nPILKxrgvom8hOLU PA+w== X-Gm-Message-State: AOAM5317lWPnb9fHFDQMMrc9BdVzZoCVxjNdPMQlLsQGKeARtY3QxaPM HW6xjlD06vBEjfjFwQbozIM= X-Google-Smtp-Source: ABdhPJzZqZPe1kDWmHV13iCdd5DCKNtWdqOLR8U8Wx8xVnIfc736WAtYtQhy3sl7/ejKYd4ADp1Xkg== X-Received: by 2002:a2e:b174:: with SMTP id a20mr1686334ljm.200.1598994699484; Tue, 01 Sep 2020 14:11:39 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id g19sm502656ljk.125.2020.09.01.14.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 14:11:39 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 17/17] i2c: tegra: Improve driver module description Date: Wed, 2 Sep 2020 00:11:02 +0300 Message-Id: <20200901211102.11072-18-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200901211102.11072-1-digetx@gmail.com> References: <20200901211102.11072-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use proper spelling of "NVIDIA" and don't designate driver as Tegra2-only since newer SoC generations are supported as well. Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 628674ed8440..a3113faa2d0b 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -2017,6 +2017,6 @@ static struct platform_driver tegra_i2c_driver = { }; module_platform_driver(tegra_i2c_driver); -MODULE_DESCRIPTION("nVidia Tegra2 I2C Bus Controller driver"); +MODULE_DESCRIPTION("NVIDIA Tegra I2C Bus Controller driver"); MODULE_AUTHOR("Colin Cross"); MODULE_LICENSE("GPL v2");