Received: by 10.192.165.148 with SMTP id m20csp933833imm; Wed, 25 Apr 2018 09:51:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+F3piJodwLx7AN4J0/FHXwRojFpaA7+DyK0OnkMEV8mrwPCwrPHZc7P5uakyoprsAFoK2q X-Received: by 10.98.87.150 with SMTP id i22mr28906339pfj.119.1524675109415; Wed, 25 Apr 2018 09:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524675109; cv=none; d=google.com; s=arc-20160816; b=klodbbWyF/xr2BpsivkyhkpiscFc6mdNwjY+vuRyu9g6ELAhHEHlXFqG3MKlCnI4yN OFBQBkupV7G7seirQPhfOF8Jvd+I8dpiGfOaKWrwTVu3JCTRILhE4Ri2mSdmu8LAtolk AqD0GiXEgxFNtln8ypHFOfM4Nqx8uGaNpQacUUHEiWhGX8YVdUkfyPRvTuz9EHDxyUv8 5K9I9DWDq+eE/XIMfr6OxHcb+hUuT2cT5fTWGUAtcc7/uBO3sY/nlGuSYyXkak2BqX7z Yc8d4yaHCqkFiPk2zEm4BlBpvk3d/UfjIN6NQx6CmkO5OV0kHZYpGrmqGe+chKdwALkP HBCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=f1N3KX1sxi3oRS5McZyC2RLWCMXshScc4YNXzLCc50o=; b=cglQ0aTzSiej+hQ0QT5vRGC1NbIdnkSrNTmeE/1mSrtC9cfxdCcPoOhnhLxxlvnXO8 j0vaiO9ix69E3a8gDZC/3c5mNqR52v3sEkATpUxcdIlNeeXYI6O0tgU9KofsT7y6+eOr RHMGOK86E2+C7Owlyx5QIC/hQY4w9Q55UNs0RoXXtMBovYaE+2GOzYAjlJfOMCxImUkl WDAcJfwX2hAQt9EuH9lbfLrkRdumpgeSXYhc4/NCxlsmMBYqca/KQYQ3FZh2iibADwMV 600ShQAvJcjCPBKv2UHNbS0+xaffQ8cZ+QEdu97ENIBVwUNOrNDAPj+EK+hF+y5QAdVV C3gg== 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 g18-v6si16429242plo.586.2018.04.25.09.51.34; Wed, 25 Apr 2018 09:51:49 -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 S1755573AbeDYQtw (ORCPT + 99 others); Wed, 25 Apr 2018 12:49:52 -0400 Received: from smtpgwcipde.automotive.elektrobit.com ([213.95.163.141]:58477 "EHLO smtpgwcipde.elektrobit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754585AbeDYQtq (ORCPT ); Wed, 25 Apr 2018 12:49:46 -0400 Received: from denue6es003.localdomain (denue6es003.automotive.elektrobit.com [213.95.163.136]) by smtpgwcipde.elektrobit.com with ESMTP id w3PGn7IS016539-w3PGn7IU016539 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Apr 2018 18:49:07 +0200 Received: from denue6es003.securemail.local (localhost [127.0.0.1]) by denue6es003.localdomain (Postfix) with SMTP id 73F0A2D481; Wed, 25 Apr 2018 18:49:07 +0200 (CEST) Received: from denue6es008.ebgroup.elektrobit.com (denue6es008.ebgroup.elektrobit.com [10.5.139.25]) by denue6es003.localdomain (Postfix) with ESMTPS; Wed, 25 Apr 2018 18:49:07 +0200 (CEST) Received: from localhost (10.0.24.181) by denue6es008.ebgroup.elektrobit.com (10.5.139.25) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 25 Apr 2018 18:49:06 +0200 Date: Wed, 25 Apr 2018 18:49:06 +0200 From: Stefan Potyra To: Mark Brown CC: Florian Fainelli , Florian Fainelli , , , , , Jonas Gorski , , Subject: [PATCH v4] spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate(). Message-ID: <20180425164904.GA30349@er01809n.ebgroup.elektrobit.com> References: <20180419130358.r7dva6owy2izyfus@agrajag.zerfleddert.de> <20180424161605.GA17825@er01809n.ebgroup.elektrobit.com> <20180424173253.GF22073@sirena.org.uk> <20180425134728.GA20897@er01809n.ebgroup.elektrobit.com> <20180425155028.GF24769@sirena.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mP3DRpeJDSE+ciuQ" Content-Disposition: inline In-Reply-To: <20180425155028.GF24769@sirena.org.uk> User-Agent: Mutt/1.9.5 (2018-04-13) X-Originating-IP: [10.0.24.181] X-ClientProxiedBy: denue6es008.ebgroup.elektrobit.com (10.5.139.25) To denue6es008.ebgroup.elektrobit.com (10.5.139.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Enable the clock prior to calling clk_get_rate(), because clk_get_rate() should only be called if the clock is enabled. Additionally, prepare/enable the pll_clk before calling clk_get_rate() for the same reason. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 142168eba9dc ("spi: bcm63xx-hsspi: add bcm63xx HSSPI driver") Signed-off-by: Stefan Potyra --- drivers/spi/spi-bcm63xx-hsspi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hssp= i.c index cbcba614b253..8475703543e5 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -352,22 +352,27 @@ static int bcm63xx_hsspi_probe(struct platform_device= *pdev) if (IS_ERR(clk)) return PTR_ERR(clk); =20 + ret =3D clk_prepare_enable(clk); + if (ret) + return ret; + rate =3D clk_get_rate(clk); if (!rate) { struct clk *pll_clk =3D devm_clk_get(dev, "pll"); =20 - if (IS_ERR(pll_clk)) - return PTR_ERR(pll_clk); + if (IS_ERR(pll_clk)) { + ret =3D PTR_ERR(pll_clk); + goto out_disable_clk; + } + =20 rate =3D clk_get_rate(pll_clk); - if (!rate) - return -EINVAL; + if (!rate) { + ret =3D -EINVAL; + goto out_disable_clk; + } } =20 - ret =3D clk_prepare_enable(clk); - if (ret) - return ret; - master =3D spi_alloc_master(&pdev->dev, sizeof(*bs)); if (!master) { ret =3D -ENOMEM; --=20 2.17.0 --mP3DRpeJDSE+ciuQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEATY+KFcrMtHMM+b3X8uyjJIzOwAFAlrgsXwACgkQX8uyjJIz OwBerg/9EqnUtTafdrKsu9IEkV8E+jzZCtp4JWQI4lmteNcdmufocEPwXQX9cZqZ f0GVexGMFQVhA7lK3Zzm8DgvaAT2hSFKLkZgQ1eutz1HyrMUWrMZQ7YeH6IwHu/8 /WevR7BieZKI+WWKJfZQz6I4/ofb5lSEK1fZ10AFVAdjAgNbV/6jOLWrTRrH++Dn 0I4e5HBTOzzKek7Rg9+oHG06GEVEdVu0mJweVmzXhVRH3ij5EHV0qftJ/Y5nI5It m26qXLL9ZAj6TOP5jMriJQ94Zw2Li+E23xiPoC1KTGYKcyk0THKBeWhsUldTCJzv ENkI+dG12TpXlRWtSPTea8LDo2cPxbbYs50DgGX1GwB2Dtz2NIngVL+OqfXmU4G4 rl6AgthYPKli6zOxVzLN69GHfOfp8V3Dw00oL6n4yfCVBCFtrmsEuJytHsghKoMl 6zpYZaxjtS2y9IM76NA5fiNtnY9Jtsr6jf+gcEQgZX45Rt8O9Rz6Jz4/JFSDh5dY eQEhvRGc8/dtXauPR5KNzqRdp6WZNoVl6ircLGXYlSVUQvMN06qyVlrybHbxxL76 R2l1H/GwNxyXAE1POw4JAED8g+vgRRmb5gZIiCcS8YR726i4KQwzdsAo8OLhRA7d HQMpU5NQ0ruZmICtVq8uAMgs9fD2Knsk49XWLx4ZqbYCNqnrqnY= =Z9YA -----END PGP SIGNATURE----- --mP3DRpeJDSE+ciuQ--