Received: by 10.192.165.148 with SMTP id m20csp3812590imm; Mon, 30 Apr 2018 06:53:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoulkhUGrjtvnsTDsporEoYAbYR89JSkI79T9cL8e9JhFQwNdMnsHI/cdWciS5kdJEyegPu X-Received: by 10.98.12.21 with SMTP id u21mr11348206pfi.218.1525096399523; Mon, 30 Apr 2018 06:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525096399; cv=none; d=google.com; s=arc-20160816; b=T+Pf2NB1bgfqgL6EFYm2ZoQBbb5qdymRnO207cIYUDuTnWZv8kK1QxCepwbW7ydkn2 vBT2gVkohset2xbuG0bIUyyBxGK/bdmp2jS9WjE6vI+vrz7arT4OhiQKQjo41+/WAV9u onkFuRRAOupdFkr5zj8UlifRHy83lyJp0XrtWZwWja63Phf1tBCMnQm5EWkG00VRfEj4 X0DJmR3gP4v3X3mxlMhLtLNPAOO8u3+HtI9uqZeD9iX/tKzSaqeiXhlkrdiU1l3nwoaJ qZsCI+ujx2YHY5BtBS89CFDz8pNkv6k+moUn+j/vazJWkn9lV6nWOFw9pQRxHjlStNfC h8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=uPfcp2Z2MC/XPGRQcp3wcTl/YjCRlXtxRpxYqQr+kKU=; b=LZqhY2yG726cjS5giZnfYlS0mtuRxTlo7MU2XqFpExV91SE1Bg9jyZ2rvvPRvC9QTQ fLQoI2aHxvuOATWySQcLcz6Xn/JNAAxtYiyUfsiUW7jSud2lg5QP1FzqKVjmDYOOuhIi J/T2eG8oN3mRhtr/rSeVmsTzbjLTYfE2t7BcB//RYdPCvgKCGcURmYnrQsziNR3doLNX TsBWUICZjG/+LKTNWXkia+XfVvlNhsc+HA84QKPaCvsiKL8dhkDKFIBHfX2UTT5xZAkh zLCMY626ryLqr4SLcG0Zil+MczzyfuVcluj9oubUtIGTaafWTKR9cHECimxmvw9fEV9U o21g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15-v6si7626047pln.526.2018.04.30.06.53.05; Mon, 30 Apr 2018 06:53:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754131AbeD3Nwr (ORCPT + 99 others); Mon, 30 Apr 2018 09:52:47 -0400 Received: from agrajag.zerfleddert.de ([88.198.237.222]:39184 "EHLO agrajag.zerfleddert.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753545AbeD3Nwq (ORCPT ); Mon, 30 Apr 2018 09:52:46 -0400 Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id 8C14F5B202AE; Mon, 30 Apr 2018 15:52:44 +0200 (CEST) Date: Mon, 30 Apr 2018 15:52:44 +0200 From: Tobias Jordan To: wsa@the-dreams.de Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: axxia: enable clock before calling clk_get_rate() Message-ID: <20180430135244.kud5hf5xjfxg4ufn@agrajag.zerfleddert.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org axxia_i2c_init() uses clk_get_rate() for idev->i2c_clk. clk_get_rate() should only be called if the clock is enabled, so ensure that by moving the clk_prepare_enable() call before the call to axxia_i2c_init(). Found by Linux Driver Verification project (linuxtesting.org). Fixes: 08678b850cd0 ("i2c: axxia: Add I2C driver for AXM55xx") Signed-off-by: Tobias Jordan --- drivers/i2c/busses/i2c-axxia.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c index 13f07482ec68..51338c48d193 100644 --- a/drivers/i2c/busses/i2c-axxia.c +++ b/drivers/i2c/busses/i2c-axxia.c @@ -532,6 +532,12 @@ static int axxia_i2c_probe(struct platform_device *pdev) if (idev->bus_clk_rate == 0) idev->bus_clk_rate = 100000; /* default clock rate */ + ret = clk_prepare_enable(idev->i2c_clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + return ret; + } + ret = axxia_i2c_init(idev); if (ret) { dev_err(&pdev->dev, "failed to initialize\n"); @@ -545,12 +551,6 @@ static int axxia_i2c_probe(struct platform_device *pdev) return ret; } - ret = clk_prepare_enable(idev->i2c_clk); - if (ret) { - dev_err(&pdev->dev, "failed to enable clock\n"); - return ret; - } - i2c_set_adapdata(&idev->adapter, idev); strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name)); idev->adapter.owner = THIS_MODULE; -- 2.11.0