From patchwork Thu Apr 7 11:44:21 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: 12805100 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41B25C433F5 for ; Thu, 7 Apr 2022 11:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dXyOw/E0d6gSz4IkjZYt5MpfV6/5Kuf9qabRBMHAGAc=; b=gQPwbecSm3iL2T HbTv7mVrLSLvCx8nTHbWSjitDz1Av1gvMpj8mzmiAiL0SCITIpU0vLqAeGhym6Our0dFcHVOXGCte WHdKpmXD7KuuEYCtdnYxlaD7JXjhHRuZkHmkgj+ra3VZ2f+cak5DHCWfd3Eff070/Rh6qcoib2OHB +jw6UxJJ2GKkvc+NxxAmt6W1amKncsHsR+zq6LfbU0P62En7mamQExlq7VOtHxocp/2EtZpmlYc8r +k7iVXriHBkzcYduX9Y3DlceWLsD8+Kg4muFN2//cWjNQOPhzOeZjk1vmzdpYxlJ9/8wQlqsj+E57 r0bM7OP8qfIaRQUTOa+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncQZL-00BbKn-MS; Thu, 07 Apr 2022 11:44:55 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncQZ9-00BbDm-6o; Thu, 07 Apr 2022 11:44:45 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 29DCE1F46126 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649331874; bh=Fw3AxGJB3md7hhOZg96E69MvUfwyG7YhoKw4DXM4Mw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RekK7T3pXz32IceFZbD5eJCxkiuO5Uvcy50lqRddynUi85vzh0Pzen+RbFo4XlpLC ZnzG8AyixDHJPgBE5YzLoBaM/juyiPRAq8MmwHp7mNr8K8nPoEG97t2q10NPD6rIiD r5p0HmlwQ4eIFZ3Ggo+IJOYALQ20GsW7IlOQFJnwNa9IaDek3MWCv19FK+uigmvVce 9c0gnOfO98lkaX21UBN5LWZONkyjWSkWmvRD2binfuZM4hi0WctTtgmR9i1fzfhAmg GYdCx5iP//I9y+DqVGN9j99FvmmrKe/jYPCfVuENUNI3tA6RPjE1XBEoEVghEphmed VNzbG/TlWrvag== 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 1/8] spi: mt65xx: Simplify probe function with devm_spi_alloc_master Date: Thu, 7 Apr 2022 13:44:21 +0200 Message-Id: <20220407114428.167091-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_044443_615086_1D1A3BC0 X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to the devm variant of spi_alloc_master() to save some gotos. This patch is a cleanup that brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 43 +++++++++++++++------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 99ce570a88a7..4c84b67ac85c 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -1087,7 +1087,7 @@ static int mtk_spi_probe(struct platform_device *pdev) const struct of_device_id *of_id; int i, irq, ret, addr_bits; - master = spi_alloc_master(&pdev->dev, sizeof(*mdata)); + master = devm_spi_alloc_master(&pdev->dev, sizeof(*mdata)); if (!master) { dev_err(&pdev->dev, "failed to alloc spi master\n"); return -ENOMEM; @@ -1108,8 +1108,7 @@ static int mtk_spi_probe(struct platform_device *pdev) of_id = of_match_node(mtk_spi_of_match, pdev->dev.of_node); if (!of_id) { dev_err(&pdev->dev, "failed to probe of_node\n"); - ret = -EINVAL; - goto err_put_master; + return -EINVAL; } mdata = spi_master_get_devdata(master); @@ -1136,16 +1135,13 @@ static int mtk_spi_probe(struct platform_device *pdev) if (mdata->pad_num < 0) { dev_err(&pdev->dev, "No 'mediatek,pad-select' property\n"); - ret = -EINVAL; - goto err_put_master; + return -EINVAL; } mdata->pad_sel = devm_kmalloc_array(&pdev->dev, mdata->pad_num, sizeof(u32), GFP_KERNEL); - if (!mdata->pad_sel) { - ret = -ENOMEM; - goto err_put_master; - } + if (!mdata->pad_sel) + return -ENOMEM; for (i = 0; i < mdata->pad_num; i++) { of_property_read_u32_index(pdev->dev.of_node, @@ -1154,24 +1150,19 @@ static int mtk_spi_probe(struct platform_device *pdev) if (mdata->pad_sel[i] > MT8173_SPI_MAX_PAD_SEL) { dev_err(&pdev->dev, "wrong pad-sel[%d]: %u\n", i, mdata->pad_sel[i]); - ret = -EINVAL; - goto err_put_master; + return -EINVAL; } } } platform_set_drvdata(pdev, master); mdata->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(mdata->base)) { - ret = PTR_ERR(mdata->base); - goto err_put_master; - } + if (IS_ERR(mdata->base)) + return PTR_ERR(mdata->base); irq = platform_get_irq(pdev, 0); - if (irq < 0) { - ret = irq; - goto err_put_master; - } + if (irq < 0) + return irq; if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; @@ -1180,41 +1171,41 @@ static int mtk_spi_probe(struct platform_device *pdev) IRQF_TRIGGER_NONE, dev_name(&pdev->dev), master); if (ret) { dev_err(&pdev->dev, "failed to register irq (%d)\n", ret); - goto err_put_master; + return ret; } mdata->parent_clk = devm_clk_get(&pdev->dev, "parent-clk"); if (IS_ERR(mdata->parent_clk)) { ret = PTR_ERR(mdata->parent_clk); dev_err(&pdev->dev, "failed to get parent-clk: %d\n", ret); - goto err_put_master; + return ret; } mdata->sel_clk = devm_clk_get(&pdev->dev, "sel-clk"); if (IS_ERR(mdata->sel_clk)) { ret = PTR_ERR(mdata->sel_clk); dev_err(&pdev->dev, "failed to get sel-clk: %d\n", ret); - goto err_put_master; + return ret; } mdata->spi_clk = devm_clk_get(&pdev->dev, "spi-clk"); if (IS_ERR(mdata->spi_clk)) { ret = PTR_ERR(mdata->spi_clk); dev_err(&pdev->dev, "failed to get spi-clk: %d\n", ret); - goto err_put_master; + return ret; } mdata->spi_hclk = devm_clk_get_optional(&pdev->dev, "hclk"); if (IS_ERR(mdata->spi_hclk)) { ret = PTR_ERR(mdata->spi_hclk); dev_err(&pdev->dev, "failed to get hclk: %d\n", ret); - goto err_put_master; + return ret; } ret = clk_prepare_enable(mdata->spi_hclk); if (ret < 0) { dev_err(&pdev->dev, "failed to enable hclk (%d)\n", ret); - goto err_put_master; + return ret; } ret = clk_prepare_enable(mdata->spi_clk); @@ -1281,8 +1272,6 @@ static int mtk_spi_probe(struct platform_device *pdev) clk_disable_unprepare(mdata->spi_clk); err_disable_spi_hclk: clk_disable_unprepare(mdata->spi_hclk); -err_put_master: - spi_master_put(master); return ret; }