From patchwork Tue Jun 6 01:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13268242 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 51CECC77B7A for ; Tue, 6 Jun 2023 05:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234220AbjFFFAI (ORCPT ); Tue, 6 Jun 2023 01:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234239AbjFFFAG (ORCPT ); Tue, 6 Jun 2023 01:00:06 -0400 X-Greylist: delayed 10809 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 05 Jun 2023 22:00:00 PDT Received: from 9.mo575.mail-out.ovh.net (9.mo575.mail-out.ovh.net [46.105.78.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DD119C for ; Mon, 5 Jun 2023 22:00:00 -0700 (PDT) Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.146.50]) by mo575.mail-out.ovh.net (Postfix) with ESMTP id 30332255CA for ; Tue, 6 Jun 2023 01:21:49 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-z4jdh (unknown [10.108.4.240]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 31F041FD54; Tue, 6 Jun 2023 01:21:48 +0000 (UTC) Received: from etezian.org ([37.59.142.98]) by ghost-submission-6684bf9d7b-z4jdh with ESMTPSA id tW7AAiyKfmS7BysAD7mFsg (envelope-from ); Tue, 06 Jun 2023 01:21:48 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-98R00274518744-50b6-452d-bc83-83386cd09704, 89204758E3263BAD5AD9D1E9907359A1AF45ECBD) smtp.auth=andi@etezian.org X-OVh-ClientIp: 178.238.172.216 From: Andi Shyti To: Mark Brown Cc: Krzysztof Kozlowski , Alim Akhtar , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Andi Shyti Subject: [PATCH 1/2] spi: s3c64xx: Use the managed spi master allocation function Date: Tue, 6 Jun 2023 03:20:50 +0200 Message-Id: <20230606012051.2139333-2-andi.shyti@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606012051.2139333-1-andi.shyti@kernel.org> References: <20230606012051.2139333-1-andi.shyti@kernel.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 9956614353698359879 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgedttddggeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughirdhshhihthhisehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnhepgfduveejteegteelhfetueetheegfeehhfektddvleehtefhheevkeduleeuueevnecukfhppeduvdejrddtrddtrddupddujeekrddvfeekrddujedvrddvudeipdefjedrheelrddugedvrdelkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegrnhguihesvghtvgiiihgrnhdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqshhpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheejhedpmhhouggvpehsmhhtphhouhht Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Use devm_spi_alloc_master() and get rid of one goto error path Signed-off-by: Andi Shyti --- drivers/spi/spi-s3c64xx.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index d5ec32bda1587..787a89c046860 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1177,8 +1177,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) return irq; } - master = spi_alloc_master(&pdev->dev, - sizeof(struct s3c64xx_spi_driver_data)); + master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd)); if (master == NULL) { dev_err(&pdev->dev, "Unable to allocate SPI Master\n"); return -ENOMEM; @@ -1197,7 +1196,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); - goto err_deref_master; + return ret; } sdd->port_id = ret; } else { @@ -1232,23 +1231,19 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) master->can_dma = s3c64xx_spi_can_dma; sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res); - if (IS_ERR(sdd->regs)) { - ret = PTR_ERR(sdd->regs); - goto err_deref_master; - } + if (IS_ERR(sdd->regs)) + return PTR_ERR(sdd->regs); if (sci->cfg_gpio && sci->cfg_gpio()) { dev_err(&pdev->dev, "Unable to config gpio\n"); - ret = -EBUSY; - goto err_deref_master; + return -EBUSY; } /* Setup clocks */ sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi"); if (IS_ERR(sdd->clk)) { dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); - ret = PTR_ERR(sdd->clk); - goto err_deref_master; + return PTR_ERR(sdd->clk); } sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); @@ -1256,16 +1251,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) if (IS_ERR(sdd->src_clk)) { dev_err(&pdev->dev, "Unable to acquire clock '%s'\n", clk_name); - ret = PTR_ERR(sdd->src_clk); - goto err_deref_master; + return PTR_ERR(sdd->src_clk); } if (sdd->port_conf->clk_ioclk) { sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk"); if (IS_ERR(sdd->ioclk)) { dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n"); - ret = PTR_ERR(sdd->ioclk); - goto err_deref_master; + return PTR_ERR(sdd->ioclk); } } @@ -1314,9 +1307,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); -err_deref_master: - spi_master_put(master); - return ret; } From patchwork Tue Jun 6 01:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13268241 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 3DC4EC77B73 for ; Tue, 6 Jun 2023 04:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbjFFE74 (ORCPT ); Tue, 6 Jun 2023 00:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbjFFE7u (ORCPT ); Tue, 6 Jun 2023 00:59:50 -0400 X-Greylist: delayed 10804 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 05 Jun 2023 21:59:42 PDT Received: from 13.mo550.mail-out.ovh.net (13.mo550.mail-out.ovh.net [178.33.253.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E66AB1B3 for ; Mon, 5 Jun 2023 21:59:42 -0700 (PDT) Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.138.83]) by mo550.mail-out.ovh.net (Postfix) with ESMTP id BA1C6252A2 for ; Tue, 6 Jun 2023 01:21:52 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-qpdjd (unknown [10.110.208.152]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 3645C1FD54; Tue, 6 Jun 2023 01:21:52 +0000 (UTC) Received: from etezian.org ([37.59.142.108]) by ghost-submission-6684bf9d7b-qpdjd with ESMTPSA id JrB/CjCKfmTF4QMAeP9eZw (envelope-from ); Tue, 06 Jun 2023 01:21:52 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S002af34c2b3-ca0e-452b-ab7a-bb05fbe5ea24, 89204758E3263BAD5AD9D1E9907359A1AF45ECBD) smtp.auth=andi@etezian.org X-OVh-ClientIp: 178.238.172.216 From: Andi Shyti To: Mark Brown Cc: Krzysztof Kozlowski , Alim Akhtar , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Andi Shyti Subject: [PATCH 2/2] spi: s3c64xx: Use dev_err_probe() Date: Tue, 6 Jun 2023 03:20:51 +0200 Message-Id: <20230606012051.2139333-3-andi.shyti@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606012051.2139333-1-andi.shyti@kernel.org> References: <20230606012051.2139333-1-andi.shyti@kernel.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 9957458778236652103 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgedttddggeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughirdhshhihthhisehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnhepgfduveejteegteelhfetueetheegfeehhfektddvleehtefhheevkeduleeuueevnecukfhppeduvdejrddtrddtrddupddujeekrddvfeekrddujedvrddvudeipdefjedrheelrddugedvrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeorghnughisegvthgviihirghnrdhorhhgqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhsphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehhedtpdhmohguvgepshhmthhpohhuth Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Simplify the code by using dev_err_probe() instead of dev_err() and 'return'. Signed-off-by: Andi Shyti --- drivers/spi/spi-s3c64xx.c | 65 ++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 787a89c046860..fd55697144cc2 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1160,28 +1160,23 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) return PTR_ERR(sci); } - if (!sci) { - dev_err(&pdev->dev, "platform_data missing!\n"); - return -ENODEV; - } + if (!sci) + return dev_err_probe(&pdev->dev, -ENODEV, + "Platform_data missing!\n"); mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (mem_res == NULL) { - dev_err(&pdev->dev, "Unable to get SPI MEM resource\n"); - return -ENXIO; - } + if (!mem_res) + return dev_err_probe(&pdev->dev, -ENXIO, + "Unable to get SPI MEM resource\n"); irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq); - return irq; - } + if (irq < 0) + return dev_err_probe(&pdev->dev, irq, "Failed to get IRQ\n"); master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd)); - if (master == NULL) { - dev_err(&pdev->dev, "Unable to allocate SPI Master\n"); - return -ENOMEM; - } + if (!master) + return dev_err_probe(&pdev->dev, -ENOMEM, + "Unable to allocate SPI Master\n"); platform_set_drvdata(pdev, master); @@ -1193,11 +1188,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; if (pdev->dev.of_node) { ret = of_alias_get_id(pdev->dev.of_node, "spi"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get alias id, errno %d\n", - ret); - return ret; - } + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, + "Failed to get alias id\n"); sdd->port_id = ret; } else { sdd->port_id = pdev->id; @@ -1234,32 +1227,28 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) if (IS_ERR(sdd->regs)) return PTR_ERR(sdd->regs); - if (sci->cfg_gpio && sci->cfg_gpio()) { - dev_err(&pdev->dev, "Unable to config gpio\n"); - return -EBUSY; - } + if (sci->cfg_gpio && sci->cfg_gpio()) + return dev_err_probe(&pdev->dev, -EBUSY, + "Unable to config gpio\n"); /* Setup clocks */ sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi"); - if (IS_ERR(sdd->clk)) { - dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); - return PTR_ERR(sdd->clk); - } + if (IS_ERR(sdd->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(sdd->clk), + "Unable to acquire clock 'spi'\n"); sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); sdd->src_clk = devm_clk_get_enabled(&pdev->dev, clk_name); - if (IS_ERR(sdd->src_clk)) { - dev_err(&pdev->dev, - "Unable to acquire clock '%s'\n", clk_name); - return PTR_ERR(sdd->src_clk); - } + if (IS_ERR(sdd->src_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(sdd->src_clk), + "Unable to acquire clock '%s'\n", + clk_name); if (sdd->port_conf->clk_ioclk) { sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk"); - if (IS_ERR(sdd->ioclk)) { - dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n"); - return PTR_ERR(sdd->ioclk); - } + if (IS_ERR(sdd->ioclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(sdd->ioclk), + "Unable to acquire 'ioclk'\n"); } pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);