From patchwork Wed Apr 6 10:04:03 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: 12803143 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 789F5C433F5 for ; Wed, 6 Apr 2022 10:28:27 +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=HFd7AXhCYW0dhsqn/TQgbYaoHE4yw2PkwzY0AX8ea94=; b=GC4DybqIPUJlUb SAV1DBsOuv3cmThatronvUwBstUuP6e0nI0qIFdaed3wVtnELZ29m1KjBXOJ3WfGlXiCggLJPk+K5 kjomiqYEBvlqoPRAc9yrpFlAsKh7bWG6ZK5yg6v1tlmJ33oxaMLdseuS9xbsOfqbanvpqYFrbTnef Rs+iyhj+Xh1RxeOg9LMrVv9QMRXGmaX/CzsLSrC5TZbhyR49bCcOuG1Q+bXiAeK7Pu58Nd53kvFj0 BojQBP3pITzGkZrR71/svBxnrVLJ2UYURvoirXl3LBxYd1ZdsWM+2uEbquRZ3G713+IbDuQf78ASW R0xB0m3GnURh6gzzjbwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2th-005NCR-IE; Wed, 06 Apr 2022 10:28:21 +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 1nc2WQ-005DqV-Ua; Wed, 06 Apr 2022 10:04:22 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 6A8431F43901 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239455; bh=vFZRSUCtzPmI05FbkG5koMycIxN2nba9jZW7kLwOcfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4Vk7efUMCoApCY0Gl4KRXzkQIm19g5H5ymp3IUIMtqQ68duLQ4OnQ/osMDQftCgX Hiw1XB27d6hmcCIUNlUQU0L6WOxMkyE9GLNiH/Sfuf88roOSG3PXosQhxUq1PqxlFr h81KxqflxYfgLRGh7kdWbc1/XjDR2Elgx4NzPp2HIX5g8u2Z/1dcD0P5ATPW6HNO8Z +3NfB6ZSMMqrhn+/IcZ5c1gf7OlGAcqsMZscyP5IJ8p8oNeW8CpLqJ65cA1Qv2zSn8 jf0b36XFRY7QYRvHErHA436VdjeRFpFtfDgKYn83a/Xeh2ec3VW0ev5BcGuQNv8om5 DeRrZJnzbe11Q== 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 1/7] spi: mt65xx: Simplify probe function with devm_spi_alloc_master Date: Wed, 6 Apr 2022 12:04:03 +0200 Message-Id: <20220406100409.93113-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030419_341076_6E550693 X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 | 46 ++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 1a0b3208dfca..4f53c3446bc0 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -794,7 +794,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; @@ -815,8 +815,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); @@ -837,16 +836,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, @@ -855,24 +851,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; @@ -881,41 +872,38 @@ 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 PTR_ERR(mdata->parent_clk); } 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 PTR_ERR(mdata->sel_clk); } 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 PTR_ERR(mdata->spi_clk); } ret = clk_prepare_enable(mdata->spi_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to enable spi_clk (%d)\n", ret); - goto err_put_master; + return ret; } ret = clk_set_parent(mdata->sel_clk, mdata->parent_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to clk_set_parent (%d)\n", ret); clk_disable_unprepare(mdata->spi_clk); - goto err_put_master; + return ret; } mdata->spi_clk_hz = clk_get_rate(mdata->spi_clk); @@ -963,8 +951,6 @@ static int mtk_spi_probe(struct platform_device *pdev) err_disable_runtime_pm: pm_runtime_disable(&pdev->dev); -err_put_master: - spi_master_put(master); return ret; } From patchwork Wed Apr 6 10:04:04 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: 12803144 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 964C9C433F5 for ; Wed, 6 Apr 2022 10:28:31 +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=SwpgyP/hCn9tKMk7joPOpJZGMQJ2NUeFMGrhyb30tTk=; b=yjdYFJVzQprma7 WK59FTuiKPstkESHKuKLKfZGSOmEjsTFD/yhTj+aOJ9CFu5B4GtSKKJBP8s3NhlpA9Xq5MSqfnELQ tfDyhOsZOHaR4Nt2WYWIBgLv0HdEp+jOYoepUiNH5ccXGSLYnBhEtIDaUZgI+Zaubkadnv3UGH4T5 QLynvRI3/d+xkD1HeUAhoU6OBv1lZWmNSi6YwZdjzdPqrg2YcWG7+nMBrQfQ+TE8e72ZRuHtgRYPB pfvRUJIBtRPtGCNe6lzF4n5uUraURGkHRh5NAvN5svGXK/rnoN0JctjSmZ1LfJ//Uzu8W2TJlh1fc Z3nhkuyHOQEwMBi7sZLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2tk-005NDg-FW; Wed, 06 Apr 2022 10:28:24 +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 1nc2WQ-005Dqj-UZ; Wed, 06 Apr 2022 10:04:21 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 33D671F4390A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239455; bh=gM01YsWssret3DlcqnhTF/BtXnVC04+x5ElT1IRlgI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0Q2tgsEVRMehpz2ney99idFvFBsLsJ4hn/p10FpAd94AjaDo+5PgPuPM75nJB7yS rv9agYGWf73Gmh0/CL01QY5iisR2T8n/oT5dDSiU6FUYVo4MkFfNEXzPI15jlin6yy wg+vwxbesA4ZNzDB7rFfnyeI3umSWY48GBJC7V0DBaFg8YfzB4+54+CrOh9sAWzRhI nLhhfN8mVgTN40Ktfb3flGpMRn/mJ+tvt4iN9oCu7SadI6NodLUK7qf0+ZRuOZ5JnQ /c4SocUpWZuwq+zAFrN+Am0DfoPvf4VHFSpHs/AQtD16u1Ct1dbXXW/5tlaOZgBzLW lrX3oVREHgekw== 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 2/7] spi: mt65xx: Switch to device_get_match_data() Date: Wed, 6 Apr 2022 12:04:04 +0200 Message-Id: <20220406100409.93113-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030419_169872_C6E59539 X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Instead of performing yet another match check in the probe function, simply switch to device_get_match_data(). This is a cleanup and brings no functional change. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 4f53c3446bc0..e3f3b77960ae 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -791,7 +791,6 @@ static int mtk_spi_probe(struct platform_device *pdev) { struct spi_master *master; struct mtk_spi *mdata; - const struct of_device_id *of_id; int i, irq, ret, addr_bits; master = devm_spi_alloc_master(&pdev->dev, sizeof(*mdata)); @@ -812,14 +811,8 @@ static int mtk_spi_probe(struct platform_device *pdev) master->set_cs_timing = mtk_spi_set_hw_cs_timing; master->use_gpio_descriptors = true; - 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"); - return -EINVAL; - } - mdata = spi_master_get_devdata(master); - mdata->dev_comp = of_id->data; + mdata->dev_comp = device_get_match_data(&pdev->dev); if (mdata->dev_comp->enhance_timing) master->mode_bits |= SPI_CS_HIGH; From patchwork Wed Apr 6 10:04:05 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: 12803138 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 4D607C433F5 for ; Wed, 6 Apr 2022 10:27:23 +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=ebwzWCPRZ0aDYLZOUzOL/UEI1oKOFgZobOkkJ5bTqbo=; b=IwfIagAWbayslw QZoS2dUmBV0AtBXugQbe63LFU/rQD5PwuvtTzrEgL40OAmOvG9pEonMTFxnEY4Kt3LlXBLcJFORcU H9hWNSphlCrAtGWWYc+VK2qu5fDRd3r1D8eqqi6WmlsVNScvagTEaxZSne6XflEp43RL0/bkZ/gxt nNAeRfkN8KVXDpMRSZCGPmcP4/LtizWYzavE4eyN2Tnu6ERUV/wr0gcltQHjIV1GxdWWmYTZqWTFQ cnJaV5FjvURZeuGkOjB1lIwN1qnrSTILf2bquvUhxhqCf8tlD4djDPLExaudU8OEmCfDrnDFZY6yX Isx51MONVtV9bQsZCZ2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2sf-005Mis-58; Wed, 06 Apr 2022 10:27:17 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2WQ-005Dr7-AL; Wed, 06 Apr 2022 10:04:20 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id D520C1F43903 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239456; bh=Y4dZfpX+QZpdk3RA6KXeJbX1Xoehgvj2vpzCH7vlOXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgdH3xUEwjmy/W2s64opZ6Ks8CxqBGUmLOWxzsBUUdDtFwgdUivUseUTEi2/n2xUa HmBv4TDrfVGqMiWKEw/XSJFgZCAQuWlwsYwrIzuRtR6sauQWgVCkXMhbIM4Nd66PzY Hnh7uwxc+Vghw4EWhshmDwZXrNR8nXSfxMyHLfqLyWc20PNy0ZgW5nt+7xcXytFoe2 6589Tl8uZhGQaPodjCYX4iY9jewxw29LMibSGdp+qX/fij9NZztcPkP9AR6AgK5e8S iUGM/9sVoK52J/f/Rl9qUMkBDIxn/vFAPdtk2F6LvqM8WmJuBxWHrBrSzJ+RhFM9ti QqwLHS4VuZCIA== 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 3/7] spi: mt65xx: Add and use pointer to struct device in mtk_spi_probe() Date: Wed, 6 Apr 2022 12:04:05 +0200 Message-Id: <20220406100409.93113-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030418_705355_75E98ED3 X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In preparation for switching to dev_err_probe() in this function, add a pointer to struct device and replace all occurrences of '&pdev->dev' to using this 'dev' pointer. This is done for one-line fitting of the dev_err_probe() calls. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 62 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index e3f3b77960ae..7f381d84a005 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -789,18 +789,19 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) static int mtk_spi_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct spi_master *master; struct mtk_spi *mdata; int i, irq, ret, addr_bits; - master = devm_spi_alloc_master(&pdev->dev, sizeof(*mdata)); + master = devm_spi_alloc_master(dev, sizeof(*mdata)); if (!master) { - dev_err(&pdev->dev, "failed to alloc spi master\n"); + dev_err(dev, "failed to alloc spi master\n"); return -ENOMEM; } master->auto_runtime_pm = true; - master->dev.of_node = pdev->dev.of_node; + master->dev.of_node = dev->of_node; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; master->set_cs = mtk_spi_set_cs; @@ -812,7 +813,7 @@ static int mtk_spi_probe(struct platform_device *pdev) master->use_gpio_descriptors = true; mdata = spi_master_get_devdata(master); - mdata->dev_comp = device_get_match_data(&pdev->dev); + mdata->dev_comp = device_get_match_data(dev); if (mdata->dev_comp->enhance_timing) master->mode_bits |= SPI_CS_HIGH; @@ -823,26 +824,25 @@ static int mtk_spi_probe(struct platform_device *pdev) master->mode_bits |= SPI_LOOP; if (mdata->dev_comp->need_pad_sel) { - mdata->pad_num = of_property_count_u32_elems( - pdev->dev.of_node, + mdata->pad_num = of_property_count_u32_elems(dev->of_node, "mediatek,pad-select"); if (mdata->pad_num < 0) { - dev_err(&pdev->dev, + dev_err(dev, "No 'mediatek,pad-select' property\n"); return -EINVAL; } - mdata->pad_sel = devm_kmalloc_array(&pdev->dev, mdata->pad_num, + mdata->pad_sel = devm_kmalloc_array(dev, mdata->pad_num, sizeof(u32), GFP_KERNEL); if (!mdata->pad_sel) return -ENOMEM; for (i = 0; i < mdata->pad_num; i++) { - of_property_read_u32_index(pdev->dev.of_node, + of_property_read_u32_index(dev->of_node, "mediatek,pad-select", i, &mdata->pad_sel[i]); if (mdata->pad_sel[i] > MT8173_SPI_MAX_PAD_SEL) { - dev_err(&pdev->dev, "wrong pad-sel[%d]: %u\n", + dev_err(dev, "wrong pad-sel[%d]: %u\n", i, mdata->pad_sel[i]); return -EINVAL; } @@ -858,43 +858,43 @@ static int mtk_spi_probe(struct platform_device *pdev) if (irq < 0) return irq; - if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + if (!dev->dma_mask) + dev->dma_mask = &dev->coherent_dma_mask; - ret = devm_request_irq(&pdev->dev, irq, mtk_spi_interrupt, - IRQF_TRIGGER_NONE, dev_name(&pdev->dev), master); + ret = devm_request_irq(dev, irq, mtk_spi_interrupt, + IRQF_TRIGGER_NONE, dev_name(dev), master); if (ret) { - dev_err(&pdev->dev, "failed to register irq (%d)\n", ret); + dev_err(dev, "failed to register irq (%d)\n", ret); return ret; } - mdata->parent_clk = devm_clk_get(&pdev->dev, "parent-clk"); + mdata->parent_clk = devm_clk_get(dev, "parent-clk"); if (IS_ERR(mdata->parent_clk)) { - dev_err(&pdev->dev, "failed to get parent-clk: %d\n", ret); + dev_err(dev, "failed to get parent-clk: %d\n", ret); return PTR_ERR(mdata->parent_clk); } - mdata->sel_clk = devm_clk_get(&pdev->dev, "sel-clk"); + mdata->sel_clk = devm_clk_get(dev, "sel-clk"); if (IS_ERR(mdata->sel_clk)) { - dev_err(&pdev->dev, "failed to get sel-clk: %d\n", ret); + dev_err(dev, "failed to get sel-clk: %d\n", ret); return PTR_ERR(mdata->sel_clk); } - mdata->spi_clk = devm_clk_get(&pdev->dev, "spi-clk"); + mdata->spi_clk = devm_clk_get(dev, "spi-clk"); if (IS_ERR(mdata->spi_clk)) { - dev_err(&pdev->dev, "failed to get spi-clk: %d\n", ret); + dev_err(dev, "failed to get spi-clk: %d\n", ret); return PTR_ERR(mdata->spi_clk); } ret = clk_prepare_enable(mdata->spi_clk); if (ret < 0) { - dev_err(&pdev->dev, "failed to enable spi_clk (%d)\n", ret); + dev_err(dev, "failed to enable spi_clk (%d)\n", ret); return ret; } ret = clk_set_parent(mdata->sel_clk, mdata->parent_clk); if (ret < 0) { - dev_err(&pdev->dev, "failed to clk_set_parent (%d)\n", ret); + dev_err(dev, "failed to clk_set_parent (%d)\n", ret); clk_disable_unprepare(mdata->spi_clk); return ret; } @@ -906,11 +906,11 @@ static int mtk_spi_probe(struct platform_device *pdev) else clk_disable_unprepare(mdata->spi_clk); - pm_runtime_enable(&pdev->dev); + pm_runtime_enable(dev); if (mdata->dev_comp->need_pad_sel) { if (mdata->pad_num != master->num_chipselect) { - dev_err(&pdev->dev, + dev_err(dev, "pad_num does not match num_chipselect(%d != %d)\n", mdata->pad_num, master->num_chipselect); ret = -EINVAL; @@ -918,7 +918,7 @@ static int mtk_spi_probe(struct platform_device *pdev) } if (!master->cs_gpiods && master->num_chipselect > 1) { - dev_err(&pdev->dev, + dev_err(dev, "cs_gpios not specified and num_chipselect > 1\n"); ret = -EINVAL; goto err_disable_runtime_pm; @@ -929,21 +929,21 @@ static int mtk_spi_probe(struct platform_device *pdev) addr_bits = DMA_ADDR_EXT_BITS; else addr_bits = DMA_ADDR_DEF_BITS; - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(addr_bits)); + ret = dma_set_mask(dev, DMA_BIT_MASK(addr_bits)); if (ret) - dev_notice(&pdev->dev, "SPI dma_set_mask(%d) failed, ret:%d\n", + dev_notice(dev, "SPI dma_set_mask(%d) failed, ret:%d\n", addr_bits, ret); - ret = devm_spi_register_master(&pdev->dev, master); + ret = devm_spi_register_master(dev, master); if (ret) { - dev_err(&pdev->dev, "failed to register master (%d)\n", ret); + dev_err(dev, "failed to register master (%d)\n", ret); goto err_disable_runtime_pm; } return 0; err_disable_runtime_pm: - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(dev); return ret; } From patchwork Wed Apr 6 10:04:06 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: 12803145 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 43F0CC433F5 for ; Wed, 6 Apr 2022 10:28:34 +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=plkA/JKJFuAPIrB7z5ttwNcp+1KayECIZK79Pd1nF8Q=; b=V0RBGivroRSuKZ LX/jYL1W/ypTcOcJue9g6R7R/I8I/qzaxHo46Rzv4ilxjAi9J/L9GtMdFeCdpcFZYKsPF3X3ZBfHw tVqYm01xjSVwxh0ffdY6ZUhsJMAy7ANEe+wzgT+hl/NzphIdwJdBiZJNDXqWa1b6GsBYRVd/zd0R9 L2GqgOOBTkw1hZ0lq0SvjsoveoUpU5z/m/fgBVG5K/E0jiTMGYfASpT8D3QHTfRv2k1AqnsBRaXX+ vv1FsXyI0cOrh9gudOKCbU7uklrXmnmR92i5YRGQd8DLid4XIx+7D1hMXZZqSQnxAlFshNj6ib2+r iENCBzNkJxCQ5wMHBDNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2to-005NFe-O0; Wed, 06 Apr 2022 10:28:28 +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 1nc2WQ-005DrR-VS; Wed, 06 Apr 2022 10:04:21 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 81D921F43907 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239457; bh=XUxXaare05hfWrZ9x/t+yRjVsjX8d4GEmSTC5zA1iFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L2muotn5s9Yp9A9I2KoCPXK9oM1ZQs4U/ilbTjYmHFiPb08VTpMMYuBGP/z8HtSii VZ52j4N8BKPRa5pTyeFokGbo5QYKuS7tluGgM1kSR7eLuK5ujIIbcMHNIcLB+K6pIY mqC2ro5QSywgX7c0J/lL7vDb2Omb99NvKhkoGYtjezN5l85n8VmMc7/tTm8dQKERSt UFQuGo7hYSEP5TMJ5dZj7OucuyJFcHjrBBDJDCJ8dXJDeQYFVJ13XnNQUtrW08rZ43 5UIeeCNUSoKEZoj6CUbyf19DBBTge2poGfmS4SmCDRli+rcQDZYVdcAnv1Dwiu6Beo 6FffnJMr+4cHg== 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 4/7] spi: mt65xx: Move pm_runtime_enable() call to remove all gotos Date: Wed, 6 Apr 2022 12:04:06 +0200 Message-Id: <20220406100409.93113-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030419_201543_15A2BA0C X-CRM114-Status: GOOD ( 10.90 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The last goto in the probe function can be removed by calling pm_runtime_enable() right before devm_spi_register_master(), as only some init checks were being performed after enabling pm. This is a cleanup and brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 7f381d84a005..b8ec04795141 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -906,22 +906,18 @@ static int mtk_spi_probe(struct platform_device *pdev) else clk_disable_unprepare(mdata->spi_clk); - pm_runtime_enable(dev); - if (mdata->dev_comp->need_pad_sel) { if (mdata->pad_num != master->num_chipselect) { dev_err(dev, "pad_num does not match num_chipselect(%d != %d)\n", mdata->pad_num, master->num_chipselect); - ret = -EINVAL; - goto err_disable_runtime_pm; + return -EINVAL; } if (!master->cs_gpiods && master->num_chipselect > 1) { dev_err(dev, "cs_gpios not specified and num_chipselect > 1\n"); - ret = -EINVAL; - goto err_disable_runtime_pm; + return -EINVAL; } } @@ -934,18 +930,16 @@ static int mtk_spi_probe(struct platform_device *pdev) dev_notice(dev, "SPI dma_set_mask(%d) failed, ret:%d\n", addr_bits, ret); + pm_runtime_enable(dev); + ret = devm_spi_register_master(dev, master); if (ret) { + pm_runtime_disable(dev); dev_err(dev, "failed to register master (%d)\n", ret); - goto err_disable_runtime_pm; + return ret; } return 0; - -err_disable_runtime_pm: - pm_runtime_disable(dev); - - return ret; } static int mtk_spi_remove(struct platform_device *pdev) From patchwork Wed Apr 6 10:04:07 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: 12803146 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 7FECCC433F5 for ; Wed, 6 Apr 2022 10:28:37 +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=8fzm6MchonwT1KbqNI3SduPEN3KHph1nUGw5lWeQCUY=; b=ShSIEBToE9gIFB RIKfO1OEgrQnrf/8PFZ/QoAHQMX7cjRhhVfFHHYC3bSiQGguLsRHnUZ0nnlH/aijfuR2tn0UYMrpU Frd9Yp/CrSCCGk/t7kEdFFbQ3YBt69EjRCMEr/CWK0TqqXWRWL3RX8bPx/Ut4Y1FNeXDWWHUgr/4U k4KLJ9eZ5BysrHuMJsWCh0LUESZag1/E7h85YM33n2awa1J1v51eMO4IFspkRDkZp0kZBGyqSiG9o CWNAAMJkGnfRr2ExP4qj307RHQDnfMXpOWxAkXVZ/Oil0GestyujibbmpFfogqWGXVFB1RSFHYYYZ 2jURKlrXL+Kil9ZrUKaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2tr-005NHY-RZ; Wed, 06 Apr 2022 10:28:31 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2WT-005DtQ-6Z; Wed, 06 Apr 2022 10:04:23 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 318F51F4390F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239457; bh=E8FhNhaGBVpp9KYAfMViAIYnlBsslTuXK5L56LwxxPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iDroqQIjwGb1F45SMf1ymLcMRoiCrTI2tU6b17nIfl9XUwDoeczop+FCOASkmf+9v 6+X4j77EdD+bcta1wEuiDuyhCrIZdbeJgKcLFniP4MwWnNpzjQXrUEAVW4c313/raH vfsjIlE3v2a3NeIs48Vu9k8BCgIGfrJoGMPDt65ixnTc5um3CcZKxP0tP8/4tagVbR R0lrZxrBNnSpxteEga3SI9ShWtcuPtpwJ0c/dacT9QMGZMdrgN9pJvzpllHM9XmSM9 2hix9HziDZMV/sonCUyxfErF1PTCPxDmozbB4g9FZ+srzoD6LMGjlNIE6L1n6LdRHR zFh8SamPhFS4w== 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 5/7] spi: mt65xx: Simplify probe function with dev_err_probe() Date: Wed, 6 Apr 2022 12:04:07 +0200 Message-Id: <20220406100409.93113-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030421_581409_74711994 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Switch to dev_err_probe() to remove all dev_err() -> return repeated patterns, simplifying and shortening the probe function. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 70 ++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index b8ec04795141..c5b8aecfada6 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -795,10 +795,8 @@ static int mtk_spi_probe(struct platform_device *pdev) int i, irq, ret, addr_bits; master = devm_spi_alloc_master(dev, sizeof(*mdata)); - if (!master) { - dev_err(dev, "failed to alloc spi master\n"); - return -ENOMEM; - } + if (!master) + return dev_err_probe(dev, -ENOMEM, "failed to alloc spi master\n"); master->auto_runtime_pm = true; master->dev.of_node = dev->of_node; @@ -826,11 +824,9 @@ static int mtk_spi_probe(struct platform_device *pdev) if (mdata->dev_comp->need_pad_sel) { mdata->pad_num = of_property_count_u32_elems(dev->of_node, "mediatek,pad-select"); - if (mdata->pad_num < 0) { - dev_err(dev, + if (mdata->pad_num < 0) + return dev_err_probe(dev, -EINVAL, "No 'mediatek,pad-select' property\n"); - return -EINVAL; - } mdata->pad_sel = devm_kmalloc_array(dev, mdata->pad_num, sizeof(u32), GFP_KERNEL); @@ -841,11 +837,10 @@ static int mtk_spi_probe(struct platform_device *pdev) of_property_read_u32_index(dev->of_node, "mediatek,pad-select", i, &mdata->pad_sel[i]); - if (mdata->pad_sel[i] > MT8173_SPI_MAX_PAD_SEL) { - dev_err(dev, "wrong pad-sel[%d]: %u\n", - i, mdata->pad_sel[i]); - return -EINVAL; - } + if (mdata->pad_sel[i] > MT8173_SPI_MAX_PAD_SEL) + return dev_err_probe(dev, -EINVAL, + "wrong pad-sel[%d]: %u\n", + i, mdata->pad_sel[i]); } } @@ -863,40 +858,30 @@ static int mtk_spi_probe(struct platform_device *pdev) ret = devm_request_irq(dev, irq, mtk_spi_interrupt, IRQF_TRIGGER_NONE, dev_name(dev), master); - if (ret) { - dev_err(dev, "failed to register irq (%d)\n", ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to register irq\n"); mdata->parent_clk = devm_clk_get(dev, "parent-clk"); - if (IS_ERR(mdata->parent_clk)) { - dev_err(dev, "failed to get parent-clk: %d\n", ret); - return PTR_ERR(mdata->parent_clk); - } + if (IS_ERR(mdata->parent_clk)) + return dev_err_probe(dev, PTR_ERR(mdata->parent_clk), + "failed to get parent-clk\n"); mdata->sel_clk = devm_clk_get(dev, "sel-clk"); - if (IS_ERR(mdata->sel_clk)) { - dev_err(dev, "failed to get sel-clk: %d\n", ret); - return PTR_ERR(mdata->sel_clk); - } + if (IS_ERR(mdata->sel_clk)) + return dev_err_probe(dev, PTR_ERR(mdata->sel_clk), "failed to get sel-clk\n"); mdata->spi_clk = devm_clk_get(dev, "spi-clk"); - if (IS_ERR(mdata->spi_clk)) { - dev_err(dev, "failed to get spi-clk: %d\n", ret); - return PTR_ERR(mdata->spi_clk); - } + if (IS_ERR(mdata->spi_clk)) + return dev_err_probe(dev, PTR_ERR(mdata->spi_clk), "failed to get spi-clk\n"); ret = clk_prepare_enable(mdata->spi_clk); - if (ret < 0) { - dev_err(dev, "failed to enable spi_clk (%d)\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "failed to enable spi_clk\n"); ret = clk_set_parent(mdata->sel_clk, mdata->parent_clk); if (ret < 0) { - dev_err(dev, "failed to clk_set_parent (%d)\n", ret); clk_disable_unprepare(mdata->spi_clk); - return ret; + return dev_err_probe(dev, ret, "failed to clk_set_parent\n"); } mdata->spi_clk_hz = clk_get_rate(mdata->spi_clk); @@ -907,18 +892,14 @@ static int mtk_spi_probe(struct platform_device *pdev) clk_disable_unprepare(mdata->spi_clk); if (mdata->dev_comp->need_pad_sel) { - if (mdata->pad_num != master->num_chipselect) { - dev_err(dev, + if (mdata->pad_num != master->num_chipselect) + return dev_err_probe(dev, -EINVAL, "pad_num does not match num_chipselect(%d != %d)\n", mdata->pad_num, master->num_chipselect); - return -EINVAL; - } - if (!master->cs_gpiods && master->num_chipselect > 1) { - dev_err(dev, + if (!master->cs_gpiods && master->num_chipselect > 1) + return dev_err_probe(dev, -EINVAL, "cs_gpios not specified and num_chipselect > 1\n"); - return -EINVAL; - } } if (mdata->dev_comp->dma_ext) @@ -935,8 +916,7 @@ static int mtk_spi_probe(struct platform_device *pdev) ret = devm_spi_register_master(dev, master); if (ret) { pm_runtime_disable(dev); - dev_err(dev, "failed to register master (%d)\n", ret); - return ret; + return dev_err_probe(dev, ret, "failed to register master\n"); } return 0; From patchwork Wed Apr 6 10:04:08 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: 12803147 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 ECD55C433FE for ; Wed, 6 Apr 2022 10:28:39 +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=DTNNrrDwzcdQOpsogYXmKLK0A1mF24FK9nJptSbm+HE=; b=y8H/tlckrzFTYY ant6psfswV2MuawiSHhYLA82w8SnlHvXFnX9Ip9RViCyFJtGjXXk/VVzxg4JG+vljjkxpAELGpI6p WEWFpb0MYQ688Q8caaCfHQ1RTY9Km+AOA7RZNMNKN5DMQJkfEj24xlDVN7gjdHR4D7TfMCo/8nzSS V4ucwRgTu6dht6Q5VBZnalOVzCkwHdWc+NBqVHy/XjsbVlms+3kel9pTpQZUroSWlTOb2FTYHbgYD rSdCuUkuuY67hlwM05kj4x3bQvNtqLvG9YruuAXUQAp4CoJnDEh73yiTkgAyE2tljxcy5R4pgDZN1 a6nSgbs5oCkiOGx+A3+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2tu-005NJN-NM; Wed, 06 Apr 2022 10:28:34 +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 1nc2WT-005DtP-6H; Wed, 06 Apr 2022 10:04:23 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id D4C671F43913 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239458; bh=HsnypJDObY+gS8EShVy4Rcq2TEJ4ccVeiDXFBBCM2qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itzf/Py+3LlJBLGZWuLt3X1VLEua3FbCQFwhOdQZZ7MQv5ktJekedJdd4stOr5Pg/ Wh6j8NGD9m/1Cikso0U4tVd1seUA/wOX8C/RsM5LaTRpDE6PgWTDA9dnRa73GkQ9Uh JH6RPbGkDd886G3eGX4HwBMoe6Pp3jZ0fPChoesJS7pRZRO08+rX7La0hHH5sP1a8B 4F5/ilG+GmcwZSvNBf8hdUwS9wb4eY4ZkCPkASp7GPXHyzHW85VsMTPIuBp+kg3gZk giMdMCOaT8fDYJ1F0xsqU+8quI7hNdRr55hVcOt5HOBAfxm5mBc51Q8yBDbzI0oM7a OJDCs/0uQD0Xw== 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 6/7] spi: mt65xx: Add kerneldoc for driver structures Date: Wed, 6 Apr 2022 12:04:08 +0200 Message-Id: <20220406100409.93113-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030421_436228_57174929 X-CRM114-Status: GOOD ( 10.46 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org One of the two structures was already partially documented, but not in kerneldoc format: enhance readability by adding the missing documentation bits and use kerneldoc. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index c5b8aecfada6..8bd0b7335ea0 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -95,21 +95,43 @@ #define DMA_ADDR_EXT_BITS (36) #define DMA_ADDR_DEF_BITS (32) +/** + * struct mtk_spi_compatible - device data structure + * @need_pad_sel: Enable pad (pins) selection in SPI controller + * @must_tx: Must explicitly send dummy TX bytes to do RX only transfer + * @enhance_timing: Enable adjusting cfg register to enhance time accuracy + * @dma_ext: DMA address extension supported + * @no_need_unprepare: Don't unprepare the SPI clk during runtime + * @ipm_design: Adjust/extend registers to support IPM design IP features + */ struct mtk_spi_compatible { bool need_pad_sel; - /* Must explicitly send dummy Tx bytes to do Rx only transfer */ bool must_tx; - /* some IC design adjust cfg register to enhance time accuracy */ bool enhance_timing; - /* some IC support DMA addr extension */ bool dma_ext; - /* some IC no need unprepare SPI clk */ bool no_need_unprepare; - /* IPM design adjust and extend register to support more features */ bool ipm_design; - }; +/** + * struct mtk_spi - SPI driver instance + * @base: Start address of the SPI controller registers + * @state: SPI controller state + * @pad_num: Number of pad_sel entries + * @pad_sel: Groups of pins to select + * @parent_clk: Parent of sel_clk + * @sel_clk: SPI master SCK clock + * @spi_clk: Peripheral clock + * @cur_transfer: Currently processed SPI transfer + * @xfer_len: Number of bytes to transfer + * @num_xfered: Number of transferred bytes + * @tx_sgl: TX transfer scatterlist + * @rx_sgl: RX transfer scatterlist + * @tx_sgl_len: Size of TX DMA transfer + * @rx_sgl_len: Size of RX DMA transfer + * @dev_comp: Device data structure + * @spi_clk_hz: Current SPI clock in Hz + */ struct mtk_spi { void __iomem *base; u32 state; From patchwork Wed Apr 6 10:04:09 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: 12803148 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 A1CECC433F5 for ; Wed, 6 Apr 2022 10:28:43 +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=LuzK6V4mrJc7xIqOdK+Sux0qHNqCS3eI/GVtZbDGwQ0=; b=XxJaO66lwOOszH 5jHr2RdytOG0dOJefaHhQRT/KtzbYLt2ddJk2EDeoYzhAtFbNa6e90H3ZCeQ4MXu4BYz0fvOugYWB ZUwIq9Dk8FMlFgA+blvO9FoQEYc7DtFmdHfTsJ4//wTncewRNyv0MyqCF1foUS4WZOZH6tlxK3Xmj 6KIkyKgtCrf/ONmEJfukeSiOo/NE93XN5Y6c6JZqqDKyOBmvZcMnKLNGhfP80QBqIPTYgqjvmj0KU /rlG6/CgnEesWTFV9BWVaZFpxSe2EPb4NWrdmELLdIdV+qvJpfPwNuF11732m48eCLPbNaVD2V5nf pbg+kycMPT4V8sAaQJXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc2ty-005NMT-6e; Wed, 06 Apr 2022 10:28:38 +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 1nc2WT-005Dte-QN; Wed, 06 Apr 2022 10:04:24 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 8C96C1F43915 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649239459; bh=R0eDnRvnMRlkoH4jk3J8OAKkFlYr2/OFWVtkmjDP4oI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PkBylaI3czVCG7HcbAwWWJx/RxXB+iz+Ocq6KAHfgsJboDp9vlmPLtgJxMYKt5aSv LuBJzLi5iwfRCtnarO2zYhEDWK7TQV7Xh9trEQ3T7IaICTIz/gD8rtbXGDw/iFQrQ5 F4owFcEW2OxpV3THtuFPPo2zgOSxie1Yet4lgPXhTUMufrMhLKq+k2vq5dcAHYO4Jq IWM9zH3EezRw70yWgHTUG9s9JCMXQnrrszkRVVhs6jAYlRNW309hL2DtjYuO3h7HTj ARhU2UXPaR/3WDEF5F9TZRqXrJnMdCMhvR8RlWZjLq290k5WrHMSJfK7gFu8WkzIFv VxAlzNnxhNrlw== 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 7/7] spi: mt65xx: Fix definitions indentation Date: Wed, 6 Apr 2022 12:04:09 +0200 Message-Id: <20220406100409.93113-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406100409.93113-1-angelogioacchino.delregno@collabora.com> References: <20220406100409.93113-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-20220406_030422_234665_57B1B99C X-CRM114-Status: UNSURE ( 8.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Some definitions at the beginning of this file were wrongly indented: fix the indentation for all of these and, while at it, also move the MTK_SPI_IDLE and MTK_SPI_PAUSED down, as to implicitly group the hardware related definitions to the software (driver) related ones. Signed-off-by: AngeloGioacchino Del Regno --- drivers/spi/spi-mt65xx.c | 132 +++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 8bd0b7335ea0..9733520effb8 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -19,79 +19,79 @@ #include #include -#define SPI_CFG0_REG 0x0000 -#define SPI_CFG1_REG 0x0004 -#define SPI_TX_SRC_REG 0x0008 -#define SPI_RX_DST_REG 0x000c -#define SPI_TX_DATA_REG 0x0010 -#define SPI_RX_DATA_REG 0x0014 -#define SPI_CMD_REG 0x0018 -#define SPI_STATUS0_REG 0x001c -#define SPI_PAD_SEL_REG 0x0024 -#define SPI_CFG2_REG 0x0028 -#define SPI_TX_SRC_REG_64 0x002c -#define SPI_RX_DST_REG_64 0x0030 -#define SPI_CFG3_IPM_REG 0x0040 - -#define SPI_CFG0_SCK_HIGH_OFFSET 0 -#define SPI_CFG0_SCK_LOW_OFFSET 8 -#define SPI_CFG0_CS_HOLD_OFFSET 16 -#define SPI_CFG0_CS_SETUP_OFFSET 24 -#define SPI_ADJUST_CFG0_CS_HOLD_OFFSET 0 -#define SPI_ADJUST_CFG0_CS_SETUP_OFFSET 16 - -#define SPI_CFG1_CS_IDLE_OFFSET 0 -#define SPI_CFG1_PACKET_LOOP_OFFSET 8 -#define SPI_CFG1_PACKET_LENGTH_OFFSET 16 -#define SPI_CFG1_GET_TICK_DLY_OFFSET 29 -#define SPI_CFG1_GET_TICK_DLY_OFFSET_V1 30 - -#define SPI_CFG1_GET_TICK_DLY_MASK 0xe0000000 -#define SPI_CFG1_GET_TICK_DLY_MASK_V1 0xc0000000 - -#define SPI_CFG1_CS_IDLE_MASK 0xff -#define SPI_CFG1_PACKET_LOOP_MASK 0xff00 -#define SPI_CFG1_PACKET_LENGTH_MASK 0x3ff0000 -#define SPI_CFG1_IPM_PACKET_LENGTH_MASK GENMASK(31, 16) -#define SPI_CFG2_SCK_HIGH_OFFSET 0 -#define SPI_CFG2_SCK_LOW_OFFSET 16 - -#define SPI_CMD_ACT BIT(0) -#define SPI_CMD_RESUME BIT(1) -#define SPI_CMD_RST BIT(2) -#define SPI_CMD_PAUSE_EN BIT(4) -#define SPI_CMD_DEASSERT BIT(5) -#define SPI_CMD_SAMPLE_SEL BIT(6) -#define SPI_CMD_CS_POL BIT(7) -#define SPI_CMD_CPHA BIT(8) -#define SPI_CMD_CPOL BIT(9) -#define SPI_CMD_RX_DMA BIT(10) -#define SPI_CMD_TX_DMA BIT(11) -#define SPI_CMD_TXMSBF BIT(12) -#define SPI_CMD_RXMSBF BIT(13) -#define SPI_CMD_RX_ENDIAN BIT(14) -#define SPI_CMD_TX_ENDIAN BIT(15) -#define SPI_CMD_FINISH_IE BIT(16) -#define SPI_CMD_PAUSE_IE BIT(17) -#define SPI_CMD_IPM_NONIDLE_MODE BIT(19) -#define SPI_CMD_IPM_SPIM_LOOP BIT(21) -#define SPI_CMD_IPM_GET_TICKDLY_OFFSET 22 +#define SPI_CFG0_REG 0x0000 +#define SPI_CFG1_REG 0x0004 +#define SPI_TX_SRC_REG 0x0008 +#define SPI_RX_DST_REG 0x000c +#define SPI_TX_DATA_REG 0x0010 +#define SPI_RX_DATA_REG 0x0014 +#define SPI_CMD_REG 0x0018 +#define SPI_STATUS0_REG 0x001c +#define SPI_PAD_SEL_REG 0x0024 +#define SPI_CFG2_REG 0x0028 +#define SPI_TX_SRC_REG_64 0x002c +#define SPI_RX_DST_REG_64 0x0030 +#define SPI_CFG3_IPM_REG 0x0040 + +#define SPI_CFG0_SCK_HIGH_OFFSET 0 +#define SPI_CFG0_SCK_LOW_OFFSET 8 +#define SPI_CFG0_CS_HOLD_OFFSET 16 +#define SPI_CFG0_CS_SETUP_OFFSET 24 +#define SPI_ADJUST_CFG0_CS_HOLD_OFFSET 0 +#define SPI_ADJUST_CFG0_CS_SETUP_OFFSET 16 + +#define SPI_CFG1_CS_IDLE_OFFSET 0 +#define SPI_CFG1_PACKET_LOOP_OFFSET 8 +#define SPI_CFG1_PACKET_LENGTH_OFFSET 16 +#define SPI_CFG1_GET_TICK_DLY_OFFSET 29 +#define SPI_CFG1_GET_TICK_DLY_OFFSET_V1 30 + +#define SPI_CFG1_GET_TICK_DLY_MASK 0xe0000000 +#define SPI_CFG1_GET_TICK_DLY_MASK_V1 0xc0000000 + +#define SPI_CFG1_CS_IDLE_MASK 0xff +#define SPI_CFG1_PACKET_LOOP_MASK 0xff00 +#define SPI_CFG1_PACKET_LENGTH_MASK 0x3ff0000 +#define SPI_CFG1_IPM_PACKET_LENGTH_MASK GENMASK(31, 16) +#define SPI_CFG2_SCK_HIGH_OFFSET 0 +#define SPI_CFG2_SCK_LOW_OFFSET 16 + +#define SPI_CMD_ACT BIT(0) +#define SPI_CMD_RESUME BIT(1) +#define SPI_CMD_RST BIT(2) +#define SPI_CMD_PAUSE_EN BIT(4) +#define SPI_CMD_DEASSERT BIT(5) +#define SPI_CMD_SAMPLE_SEL BIT(6) +#define SPI_CMD_CS_POL BIT(7) +#define SPI_CMD_CPHA BIT(8) +#define SPI_CMD_CPOL BIT(9) +#define SPI_CMD_RX_DMA BIT(10) +#define SPI_CMD_TX_DMA BIT(11) +#define SPI_CMD_TXMSBF BIT(12) +#define SPI_CMD_RXMSBF BIT(13) +#define SPI_CMD_RX_ENDIAN BIT(14) +#define SPI_CMD_TX_ENDIAN BIT(15) +#define SPI_CMD_FINISH_IE BIT(16) +#define SPI_CMD_PAUSE_IE BIT(17) +#define SPI_CMD_IPM_NONIDLE_MODE BIT(19) +#define SPI_CMD_IPM_SPIM_LOOP BIT(21) +#define SPI_CMD_IPM_GET_TICKDLY_OFFSET 22 #define SPI_CMD_IPM_GET_TICKDLY_MASK GENMASK(24, 22) -#define SPI_CFG3_IPM_HALF_DUPLEX_DIR BIT(2) -#define SPI_CFG3_IPM_HALF_DUPLEX_EN BIT(3) -#define MT8173_SPI_MAX_PAD_SEL 3 +#define SPI_CFG3_IPM_HALF_DUPLEX_DIR BIT(2) +#define SPI_CFG3_IPM_HALF_DUPLEX_EN BIT(3) +#define MT8173_SPI_MAX_PAD_SEL 3 -#define MTK_SPI_PAUSE_INT_STATUS 0x2 +#define MTK_SPI_PAUSE_INT_STATUS 0x2 + +#define MTK_SPI_MAX_FIFO_SIZE 32U +#define MTK_SPI_PACKET_SIZE 1024 +#define MTK_SPI_IPM_PACKET_SIZE SZ_64K +#define MTK_SPI_32BITS_MASK (0xffffffff) #define MTK_SPI_IDLE 0 #define MTK_SPI_PAUSED 1 -#define MTK_SPI_MAX_FIFO_SIZE 32U -#define MTK_SPI_PACKET_SIZE 1024 -#define MTK_SPI_IPM_PACKET_SIZE SZ_64K -#define MTK_SPI_32BITS_MASK (0xffffffff) - #define DMA_ADDR_EXT_BITS (36) #define DMA_ADDR_DEF_BITS (32)