From patchwork Fri Mar 16 22:21:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 10290385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8063C601A0 for ; Fri, 16 Mar 2018 22:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 608B8290B3 for ; Fri, 16 Mar 2018 22:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 552E6290CE; Fri, 16 Mar 2018 22:21:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFC0D290B3 for ; Fri, 16 Mar 2018 22:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbeCPWVd (ORCPT ); Fri, 16 Mar 2018 18:21:33 -0400 Received: from mail.ispras.ru ([83.149.199.45]:44852 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233AbeCPWVc (ORCPT ); Fri, 16 Mar 2018 18:21:32 -0400 Received: from localhost.localdomain (unknown [85.140.189.150]) by mail.ispras.ru (Postfix) with ESMTPSA id 3291154006A; Sat, 17 Mar 2018 01:21:28 +0300 (MSK) From: Alexey Khoroshilov To: Mark Brown Cc: Alexey Khoroshilov , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] spi: jcore: disable clock on remove Date: Sat, 17 Mar 2018 01:21:18 +0300 Message-Id: <1521238878-27159-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver does not disable ref_clk on remove. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/spi/spi-jcore.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-jcore.c b/drivers/spi/spi-jcore.c index dafed6280df3..68cac15ff54a 100644 --- a/drivers/spi/spi-jcore.c +++ b/drivers/spi/spi-jcore.c @@ -38,6 +38,7 @@ struct jcore_spi { unsigned int speed_reg; unsigned int speed_hz; unsigned int clock_freq; + struct clk *clk; }; static int jcore_spi_wait(void __iomem *ctrl_reg) @@ -143,7 +144,6 @@ static int jcore_spi_probe(struct platform_device *pdev) struct spi_master *master; struct resource *res; u32 clock_freq; - struct clk *clk; int err = -ENODEV; master = spi_alloc_master(&pdev->dev, sizeof(struct jcore_spi)); @@ -183,10 +183,10 @@ static int jcore_spi_probe(struct platform_device *pdev) * requested rate. If the clock is omitted, 50 MHz is assumed. */ clock_freq = 50000000; - clk = devm_clk_get(&pdev->dev, "ref_clk"); - if (!IS_ERR_OR_NULL(clk)) { - if (clk_enable(clk) == 0) - clock_freq = clk_get_rate(clk); + hw->clk = devm_clk_get(&pdev->dev, "ref_clk"); + if (!IS_ERR_OR_NULL(hw->clk)) { + if (clk_enable(hw->clk) == 0) + clock_freq = clk_get_rate(hw->clk); else dev_warn(&pdev->dev, "could not enable ref_clk\n"); } @@ -199,7 +199,7 @@ static int jcore_spi_probe(struct platform_device *pdev) /* Register our spi controller */ err = devm_spi_register_master(&pdev->dev, master); if (err) { - clk_disable(clk); + clk_disable(hw->clk); goto exit; } @@ -212,6 +212,19 @@ static int jcore_spi_probe(struct platform_device *pdev) return err; } +static int jcore_spi_remove(struct platform_device *pdev) +{ + struct spi_master *master; + struct jcore_spi *hw; + + master = platform_get_drvdata(pdev); + hw = spi_master_get_devdata(master); + + clk_disable(hw->clk); + + return 0; +} + static const struct of_device_id jcore_spi_of_match[] = { { .compatible = "jcore,spi2" }, {}, @@ -220,6 +233,7 @@ MODULE_DEVICE_TABLE(of, jcore_spi_of_match); static struct platform_driver jcore_spi_driver = { .probe = jcore_spi_probe, + .remove = jcore_spi_remove, .driver = { .name = DRV_NAME, .of_match_table = jcore_spi_of_match,