From patchwork Thu Apr 7 11:44:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 559442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A0BC433EF for ; Thu, 7 Apr 2022 11:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244889AbiDGLqq (ORCPT ); Thu, 7 Apr 2022 07:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244875AbiDGLqo (ORCPT ); Thu, 7 Apr 2022 07:46:44 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6217518B26E; Thu, 7 Apr 2022 04:44:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id AA0181F4160F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649331884; bh=0ioxGeIAs1JjL3nFVCxi/VYYJ3Ie6yltSPaOrmtPeQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpGj8zYjD+zYxwNn8B8ypUt69daeQcIiMNXXBlvkPV1oBuVjcY68PppDu2ytuSAqy OrXKcMhMcOZQlMR0I3np7jbIQQfJqXbgOdGRIvpYr7+8n560l+2aQpt4uNK4yr6Cc1 WpRXc3lT6d9b3pH5O2jEpLMe+8bsfaZLVDgTWqPaW4FIDw/mybkTyDDxumQdb3J8jV UPnW+7FtVFhfkWi18ecVQJQnyKnNA1hpsv/b4SX8trkAaDOzSCQAvTzgsFtzuc4ICy U8EiIQxei8UHRtwTjDylngbX6ntsmgVJbxN+8Z6zcUA3mSAefA1zEUiihvBLx/awsM NvPYGUnhE4hoA== From: AngeloGioacchino Del Regno To: broonie@kernel.org Cc: matthias.bgg@gmail.com, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, nfraprado@collabora.com, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 4/8] spi: mt65xx: Move clock parent setting to remove clock disable gotos Date: Thu, 7 Apr 2022 13:44:24 +0200 Message-Id: <20220407114428.167091-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407114428.167091-1-angelogioacchino.delregno@collabora.com> References: <20220407114428.167091-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Reparenting sel_clk to parent_clk can be done before enabling any of spi_clk and spi_hclk. Move the call to clk_set_parent() for sel_clk earlier, and call disable_unprepare() upon spi_clk prepare_enable() failure to remove all clock disablement related gotos. This commit is in preparation of a later cleanup. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 250a508427ee..a2daba3bba91 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -1195,6 +1195,12 @@ static int mtk_spi_probe(struct platform_device *pdev) return ret; } + ret = clk_set_parent(mdata->sel_clk, mdata->parent_clk); + if (ret < 0) { + dev_err(dev, "failed to clk_set_parent (%d)\n", ret); + return ret; + } + ret = clk_prepare_enable(mdata->spi_hclk); if (ret < 0) { dev_err(dev, "failed to enable hclk (%d)\n", ret); @@ -1204,13 +1210,8 @@ static int mtk_spi_probe(struct platform_device *pdev) ret = clk_prepare_enable(mdata->spi_clk); if (ret < 0) { dev_err(dev, "failed to enable spi_clk (%d)\n", ret); - goto err_disable_spi_hclk; - } - - ret = clk_set_parent(mdata->sel_clk, mdata->parent_clk); - if (ret < 0) { - dev_err(dev, "failed to clk_set_parent (%d)\n", ret); - goto err_disable_spi_clk; + clk_disable_unprepare(mdata->spi_hclk); + return ret; } mdata->spi_clk_hz = clk_get_rate(mdata->spi_clk); @@ -1261,10 +1262,6 @@ static int mtk_spi_probe(struct platform_device *pdev) err_disable_runtime_pm: pm_runtime_disable(dev); -err_disable_spi_clk: - clk_disable_unprepare(mdata->spi_clk); -err_disable_spi_hclk: - clk_disable_unprepare(mdata->spi_hclk); return ret; }