Received: by 10.192.165.148 with SMTP id m20csp1709961imm; Thu, 26 Apr 2018 00:45:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Ys1cCXMqsCZpyhwL0gDj1x1iwT3t0paelzy/oG+V4MGX9PKtVfc2J1tadNNOU0pWXvxwe X-Received: by 2002:a17:902:8f86:: with SMTP id z6-v6mr33235202plo.316.1524728749489; Thu, 26 Apr 2018 00:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524728749; cv=none; d=google.com; s=arc-20160816; b=kc/FKEjhI/Ew6TpKkOrjjHIsICd+T57hlMD9UUvf+e1w7duodvf9KrXDN4qtn/vfas NPgHZ2r3tY1xrXY8Fl8hlJAaGm8DElvhLoIDzByRtmAdQA//pOptZXN7RB8jMJI/emkJ jbcj8bgNMqeETzy/YTD71PuOO2ICcVcb74tBF+CcnrS37cT8+cE004a+fge1dX0detmi aLlCggibXc19JAvWPPenTEsm2QW4cD3f1ddEYNPMsM/a8W06ELhQmDyAzIbI2hCTr18u Mutm4byT74SD4ZCUVinFmLbgTnUjBNl/7E8nhEOZw+K95E1LuhBa74jp2YtONC9qDDm9 Kg+g== 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=fSnAIbcaaiQPjLVsuhtZoNOERqHu2griPK4JdFaZkxU=; b=kuQRoG7m6yd9Pqp8PFuZIqHSeGrf9pH3/KD91D/nOriYYzOEWnweYCt2t+NueaP+T6 zsChxCt4CoVq3UIeUbZ6HrdmR82HYv5IQlcHBTy1+0lpt/ik5R0sqcreq1JWS8dGVcSx q0IQETbrT2MNHwYuc/G7iy8ClkKSiu9bVQgBOPOBNQ662TSG/Z/AM5NRX6DOzfKhnq1n CAP8VhsXjgsZnQQsODlUWInuZ/eO49qkfliGVyf6VHF20Nv2bblBXmCldfwcZsbUPoeC 5Jc894dyCNdaZfQ6ygzvy+YP69myGcx93ISHOlJtbEoijpqe0BlPoRS0A2g0AupguEwi +3Mg== 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 92-v6si12780368plw.299.2018.04.26.00.45.35; Thu, 26 Apr 2018 00:45: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 S1754307AbeDZHoM (ORCPT + 99 others); Thu, 26 Apr 2018 03:44:12 -0400 Received: from smtpgwcipde.automotive.elektrobit.com ([213.95.163.141]:42558 "EHLO smtpgwcipde.elektrobit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754278AbeDZHoF (ORCPT ); Thu, 26 Apr 2018 03:44:05 -0400 X-Greylist: delayed 906 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Apr 2018 03:44:04 EDT Received: from denue6es003.localdomain (denue6es003.automotive.elektrobit.com [213.95.163.136]) by smtpgwcipde.elektrobit.com with ESMTP id w3Q7S5fd002845-w3Q7S5ff002845 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 26 Apr 2018 09:28:05 +0200 Received: from denue6es003.securemail.local (localhost [127.0.0.1]) by denue6es003.localdomain (Postfix) with SMTP id 535BB2D487; Thu, 26 Apr 2018 09:28:05 +0200 (CEST) Received: from denue6es008.ebgroup.elektrobit.com (denue6es008.ebgroup.elektrobit.com [10.5.139.25]) by denue6es003.localdomain (Postfix) with ESMTPS; Thu, 26 Apr 2018 09:28:04 +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; Thu, 26 Apr 2018 09:28:02 +0200 Date: Thu, 26 Apr 2018 09:28:02 +0200 From: Stefan Potyra To: Mark Brown CC: Florian Fainelli , Florian Fainelli , , , , , Jonas Gorski , , Subject: [PATCH v5] spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate(). Message-ID: <20180426072801.GB4117@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> <20180425164904.GA30349@er01809n.ebgroup.elektrobit.com> <20180425172816.GI24769@sirena.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="i0/AhcQY5QxfSsSZ" Content-Disposition: inline In-Reply-To: <20180425172816.GI24769@sirena.org.uk> User-Agent: Mutt/1.9.5 (2018-04-13) X-Originating-IP: [10.0.24.181] X-ClientProxiedBy: denue6es007.ebgroup.elektrobit.com (10.5.139.21) 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 --i0/AhcQY5QxfSsSZ 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 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hssp= i.c index cbcba614b253..c23849f7aa7b 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -352,22 +352,31 @@ 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; + } + + ret =3D clk_prepare_enable(pll_clk); + if (ret) + goto out_disable_clk; =20 rate =3D clk_get_rate(pll_clk); - if (!rate) - return -EINVAL; + clk_disable_unprepare(pll_clk); + 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 --i0/AhcQY5QxfSsSZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEATY+KFcrMtHMM+b3X8uyjJIzOwAFAlrhf4EACgkQX8uyjJIz OwAlzw/7BShRky1etSiW2sexxNjQ3D79Udtwed0gYUv9tl7+vddrym+sE3wGH0Le ZBVxqRh6TnDAue9KHFKZTl5aoHQIzWCIEp37ojI3qnC/AhiU4zV3h4CYkM4h7f/3 1SOdbNxfFaUxPS7oMbeDiIy7dou3B9I8bz5f8vOpMsxa15+2WbamoS/QG63Yn9N+ 5TZLquytaZkuWe33aUvwkImSGH4gIQKIr5wbhzlp0hQH5IGgOFOAm9zFV66fd+ev OjRhEj6YalbPivTt+gvd8HEvmJ6Ll/kMVCJtqp8zR4nE1pzaIDl8/ozh/O4efOS+ y6TnlWdRp648RFvaju1Pqj8+hc7ymQNy5nwpevtSOEpnTj23ql2+izJf309s9K4H ++XP6yMw26HWEQ4QFfDZKlvmXoT2m+QIzRvAJSthbCX5tsTMP6yAoHtFo8avM0Gi O5Rq8KLfpQmNu7hMB/a2jjMPFjIl0mrvP+8Q5rdqr+oDPbHG2FywBN6yBEZi0gYI LwJxcQrwqHF14+HBWRIKG1tlghFH7WRd3fJ8wNeURmdFT6NKJ7RV1ig0G0s48HEi nQJ4ncADCAHEcuRZb9iVogjrTArlpyJ5Bp8KcLI3bKid555m/dCK7JYCNR46WRsv T0tLx5UiZWSrYEyvr6FTOYr7tOhzDyxd2/cRlgIej8+/LYaNGco= =k+83 -----END PGP SIGNATURE----- --i0/AhcQY5QxfSsSZ--