Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1067542ybx; Fri, 1 Nov 2019 16:12:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7xV2p7kqsWr0Rnvx5TCB8c08SO4/curbG5ClD88BRlMHhHXgrGCSkjJo517QYTAm6IcCr X-Received: by 2002:a50:b634:: with SMTP id b49mr15637517ede.77.1572649950430; Fri, 01 Nov 2019 16:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572649950; cv=none; d=google.com; s=arc-20160816; b=gsS4ZdhW+hpnvFuKoB2AUNQ88WhJ5zAqk3BqfC2afGGA9BRVne/7HMemL1v0g+l1BM 2Wv3b8IPI3QtBebJbLPGEob9YBxROy8RV3SnsZHuavIkNsvZqLdTZ51PPzY0iFNX5QOe qEuqcm77vd6HFYfJk7IkZ4MCdWOH3ieMAyad9CnGBGu47s3/xt8o0GJLuNqG0ldb30Mc EsYVagfHJ56PgR9H1VGknb005XdT6DyNJge3Fy/iM21j4UtkQioqvVQ+oYQY//+6pU6G PPS3K/vp3WxBs0cGtGv9fuPcoy1VnCQ1x4wasPqzUkRBZUWaX1ntyVFGwglsrIsURwek 4fAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=xp3A8vdh1NO+887OUg4MRpz1hgoXlnInMjaDscwcRX4=; b=jdcH9yq//pjTdw4u2MvjN1tmGttHWgnciAWZ7hooor+ClKIGgUcokIGSOovq6fIzRY qme9AVsXmBbAo3zojAM9/R57GMUKUAHk0i8e8jSr4GpbU1S+GO4wO+GhMDeknNoNJtYQ txNcKXFAz5ILUqEj6WwuiXkB1JGLz3elGDyicIBY6UiGGf1oYpa08fJnEFJhDHZEMehH F6+yXkP6GnNNpmNAkmoMdIzuO3X/lcPi0nICFGth1YT6uuqA8ixPFtXs+LX4kKAS9qmZ AOWqrV06LDqXhT6QPSxSj/U8DXVeVhOqoEp7NLIL1GWqTbI30f2uCGTjVGnnvKXOR07i hFjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=yYriT6h5; 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 v24si1388980edm.399.2019.11.01.16.12.06; Fri, 01 Nov 2019 16:12:30 -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; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=yYriT6h5; 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 S1727269AbfKAXHe (ORCPT + 99 others); Fri, 1 Nov 2019 19:07:34 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41182 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfKAXHd (ORCPT ); Fri, 1 Nov 2019 19:07:33 -0400 Received: by mail-pl1-f196.google.com with SMTP id t10so4978603plr.8 for ; Fri, 01 Nov 2019 16:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=xp3A8vdh1NO+887OUg4MRpz1hgoXlnInMjaDscwcRX4=; b=yYriT6h58xv7hTXRzRB5iUZbmOc5hfCHewM2Mn+UNE2HN6q4ot/vtr6GVE9xr9Jq7v rTmrjCeexwllHIjaJ0T9qdR+VD4y89F7Zd1DNeouk0nXPojIgyGe4P9Jkb1L01bZk0Br MBif6u0NSdZpeTSvrepGMxTj5dlUg8gB2hYfkF4XDyPXffagLnSq9b66FkDavj5E4gsG WeworxdV9zPAcmnaMW6Bwwy+zXiFrtoHAytsvZ9iQNf5LVCBgJd+DxxwHjuJ2FjllLQc WHjW27/Vg4xxU7lMx4LeqLGpmdqnmy9VnqNtQRCld93taP9KRm5poqrJpna8obEFlAhy QKVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=xp3A8vdh1NO+887OUg4MRpz1hgoXlnInMjaDscwcRX4=; b=aVAVMNoAj9xNshEuNZ+dzhu7Jdj9YDQssY7yqsFLpQR1ybeMcRgDfkTRUe7PoYNQ3E EWjLU9fWbMTkNSLvjkZiElzCFgzM3gm/tARl15nlmNuSAfSx1+H1TBmvVI7VPtDQdWoI g+XJMp+C2M7OfNUiYF8FfXRswAh32ipB8Xa4yVNZjiKh3GVuZxvnCnfHLmnNodwwp+lj EDq1tvwVXyYXpMEB1ePFvZ3RXfAZTyRZAWWD72mtM6g2XdC8EC8w+c3k1TZs4Oz3hT+u Fa9yFNj4UVkJbK68u5s9ZzdPsu2lLfijZrqbUr18wRYGvgkUOGi9geJyb1C3HI0cWHLH +63w== X-Gm-Message-State: APjAAAXnQCh0a8XxstbvAoR96Q7CjcJjmHa2oB8/OtNeKIkrdf+69ung PMHaO6NIUpp98d9/hBuVJx14RA== X-Received: by 2002:a17:902:349:: with SMTP id 67mr2206815pld.221.1572649651082; Fri, 01 Nov 2019 16:07:31 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id v15sm8798149pfc.85.2019.11.01.16.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 16:07:29 -0700 (PDT) Date: Fri, 01 Nov 2019 16:07:29 -0700 (PDT) X-Google-Original-Date: Fri, 01 Nov 2019 15:53:59 PDT (-0700) Subject: Re: [PATCH] spi: sifive: disable clk when probe fails and remove In-Reply-To: <20191101121745.13413-1-hslester96@gmail.com> CC: broonie@kernel.org, Paul Walmsley , linux-spi@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, hslester96@gmail.com From: Palmer Dabbelt To: hslester96@gmail.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 01 Nov 2019 05:17:45 PDT (-0700), hslester96@gmail.com wrote: > The driver forgets to disable and unprepare clk when probe fails and > remove. > Add the calls to fix the problem. > > Signed-off-by: Chuhong Yuan > --- > drivers/spi/spi-sifive.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c > index 35254bdc42c4..f7c1e20432e0 100644 > --- a/drivers/spi/spi-sifive.c > +++ b/drivers/spi/spi-sifive.c > @@ -357,14 +357,14 @@ static int sifive_spi_probe(struct platform_device *pdev) > if (!cs_bits) { > dev_err(&pdev->dev, "Could not auto probe CS lines\n"); > ret = -EINVAL; > - goto put_master; > + goto disable_clk; > } > > num_cs = ilog2(cs_bits) + 1; > if (num_cs > SIFIVE_SPI_MAX_CS) { > dev_err(&pdev->dev, "Invalid number of spi slaves\n"); > ret = -EINVAL; > - goto put_master; > + goto disable_clk; > } > > /* Define our master */ > @@ -393,7 +393,7 @@ static int sifive_spi_probe(struct platform_device *pdev) > dev_name(&pdev->dev), spi); > if (ret) { > dev_err(&pdev->dev, "Unable to bind to interrupt\n"); > - goto put_master; > + goto disable_clk; > } > > dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n", > @@ -402,11 +402,13 @@ static int sifive_spi_probe(struct platform_device *pdev) > ret = devm_spi_register_master(&pdev->dev, master); > if (ret < 0) { > dev_err(&pdev->dev, "spi_register_master failed\n"); > - goto put_master; > + goto disable_clk; > } > > return 0; > > +disable_clk: > + clk_disable_unprepare(spi->clk); > put_master: > spi_master_put(master); > > @@ -420,6 +422,7 @@ static int sifive_spi_remove(struct platform_device *pdev) > > /* Disable all the interrupts just in case */ > sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0); > + clk_disable_unprepare(spi->clk); > > return 0; > } Reviewed-by: Palmer Dabbelt