From patchwork Mon Jan 24 12:09:13 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: 12721907 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 9C8F4C433EF for ; Mon, 24 Jan 2022 12:10:49 +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: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:In-Reply-To:References: List-Owner; bh=Kf+aVzhmBVYZNgpZdYDcs9aHFS7mHnYoLIPo5rDC3RQ=; b=s58EADC53e4HGO VOuGuxR63SIn47TEK3F2JXS4QjoCFpHeqrYO8L5Z982RbOJabBcKNLfbmwUI5bJnSIoNxYhFgro9t LzprKs8V6qa4rEMlvlpQLWh5+oVjbkatBhsWatMpxYzrfo1IKLsaEGHkwt7JVA4dgIUDBEkEsF7+H Vrcx++naj6HJdM+hBmw/qjfRdFjqIkyyRutWQYVLWzxQ4k11ENQutC9XCuPS9u4Jp03O4pu7patAw 2WsIDf8rL5/jaqIW22WY+deXCFX3H90PKDT4L2sSmTWO96t1y3PRntYt9Rt9a92hS6abMhUq31ItM Cnu3g6C4aOAAgdhCCNgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nByA3-0039TW-1Y; Mon, 24 Jan 2022 12:09:27 +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 1nBy9z-0039ST-Ac; Mon, 24 Jan 2022 12:09:24 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 90FB01F42E77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1643026162; bh=aOuYPLM5L/mmuMP/xuJRrEHY6ka8AQ/+E0HBxwte4rk=; h=From:To:Cc:Subject:Date:From; b=UOSTw1zFcyrq8krivX1eQH6s3kCIy1msupv2GSjycaN5568uej4szCz8kk1Sgi+o2 +1+FDKEjUhFUOGHySgTcntP4O1W0NlSHNfGOxKzbe1zmvZjH0rqomv+hFcNQYbzFyI zSsTn+oYkWBGIwXm/bBDK1laxNHsJS/GvgqE57DPF6SzGS4ZFeRVrTy5T/if6vIHch elcKf3nJoGvhFwpKfGwFrqxXAji7nWvfFP4+Y287AK6iW6MC/ZSoElO/lzIqdV0RxT YvKlm5ONN+3u0C2HKZuxXAtOgSfhCuoYbTG0kNGgiX/EiV7tXMebMWQQCzhbO1MjPt h2/xEgF2c9jPw== From: AngeloGioacchino Del Regno To: bjorn.andersson@linaro.org Cc: mathieu.poirier@linaro.org, matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 1/3] remoteproc: mtk_scp: Use devm variant of rproc_alloc() Date: Mon, 24 Jan 2022 13:09:13 +0100 Message-Id: <20220124120915.41292-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_040923_542010_3A15E925 X-CRM114-Status: GOOD ( 11.81 ) 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 To simplify the probe function, switch from using rproc_alloc() to devm_rproc_alloc(); while at it, also put everything on a single line, as it acceptably fits in 82 columns. Signed-off-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 36e48cf58ed6..95a40e3f11e3 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -756,11 +756,7 @@ static int scp_probe(struct platform_device *pdev) char *fw_name = "scp.img"; int ret, i; - rproc = rproc_alloc(dev, - np->name, - &scp_ops, - fw_name, - sizeof(*scp)); + rproc = devm_rproc_alloc(dev, np->name, &scp_ops, fw_name, sizeof(*scp)); if (!rproc) { dev_err(dev, "unable to allocate remoteproc\n"); return -ENOMEM; @@ -776,8 +772,7 @@ static int scp_probe(struct platform_device *pdev) scp->sram_base = devm_ioremap_resource(dev, res); if (IS_ERR((__force void *)scp->sram_base)) { dev_err(dev, "Failed to parse and map sram memory\n"); - ret = PTR_ERR((__force void *)scp->sram_base); - goto free_rproc; + return PTR_ERR((__force void *)scp->sram_base); } scp->sram_size = resource_size(res); scp->sram_phys = res->start; @@ -789,7 +784,7 @@ static int scp_probe(struct platform_device *pdev) ret = PTR_ERR((__force void *)scp->l1tcm_base); if (ret != -EINVAL) { dev_err(dev, "Failed to map l1tcm memory\n"); - goto free_rproc; + return ret; } } else { scp->l1tcm_size = resource_size(res); @@ -851,8 +846,6 @@ static int scp_probe(struct platform_device *pdev) for (i = 0; i < SCP_IPI_MAX; i++) mutex_destroy(&scp->ipi_desc[i].lock); mutex_destroy(&scp->send_lock); -free_rproc: - rproc_free(rproc); return ret; } From patchwork Mon Jan 24 12:09:14 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: 12721908 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 38560C433F5 for ; Mon, 24 Jan 2022 12:10:59 +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=cJQTuw5njIpujhM+vDyoy5nT/1i55/XRbQfoCAfzOK8=; b=u2RzHeteuLXAIG DFM0wlLF3uXYSbhZKRDWR/RMv449XFk4MEb3JWU/S4AC00+2pCQUZQEeA0Kjk489rD1Jp9+T2DoaL sumoMYhVe0Ck+/EZ+KMg/W/WWbv6cY+ZFykV794PL1pi1BmErG4HpbrJX6wC11UzrRbzYhThdFwUU gVZqUcIyn1iEPYxEO9QKNmabPjBlhM+YKPUX+XmiGLU/AklQlxsHG5CqhTqFItxwIuHr/ceHRz6rx MMu/kxVDNtFTpmRv60SiWYGCd1YWyn6Ic/M90O0GRMWUbPku4ovXfzJ7NxPj7mj5qrhZsnTD6dgqZ Yy1b2tN3X2lCVKCJL74Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nByAF-0039We-Id; Mon, 24 Jan 2022 12:09:39 +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 1nByA1-0039Sx-US; Mon, 24 Jan 2022 12:09:27 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 4B1071F42E83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1643026164; bh=Bg+voHqmmOa1mdX+12mwmf2wNJLVsjZM+19lKzpTkcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+2N6lH9qF/w/anJtg8Giee1yOCXlKi1VxuhWnXU3qdvAImKTJAiNaU9QCRfRr6Ep SxMmG5QzEiME07L+9dLsHaxas1cGROkj86ISJHDZlyGvi/AD/SRUErKbT9JYepCI4C 8DoIabibPjV3LEJD/shtoULNFUXJbhb4m9/m7GWd5HW3dR+2Yl61OZPHFY4lyo2R3/ nPQ0RD0yAbaKbRGktPh0VmgMLeb4ereE4gN0z2Sww+/8VPeG4JdtewGu32vEbHK1QG R9+pbI5qv4a473QtPgw13ovrRZBDPhoGllsQPuVQRMJnRGmXnb15Ni+oXcs7tbUkEn i9lFYfjDo8XsA== From: AngeloGioacchino Del Regno To: bjorn.andersson@linaro.org Cc: mathieu.poirier@linaro.org, matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 2/3] remoteproc: mtk_scp: Reorder scp_probe() sequence Date: Mon, 24 Jan 2022 13:09:14 +0100 Message-Id: <20220124120915.41292-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220124120915.41292-1-angelogioacchino.delregno@collabora.com> References: <20220124120915.41292-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-20220124_040926_161567_D490B378 X-CRM114-Status: GOOD ( 13.66 ) 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 Cleanup the scp_probe() function by reordering some calls in this function, useful to reduce the usage of goto(s), and preparing for one more usage of dev_err_probe(). In particular, we can get the clocks before mapping the memory region, and move the mutexes initialization right before registering the ipi handler (which is the first mutex user in this driver). Signed-off-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 95a40e3f11e3..e40706b0e015 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -791,24 +791,23 @@ static int scp_probe(struct platform_device *pdev) scp->l1tcm_phys = res->start; } - mutex_init(&scp->send_lock); - for (i = 0; i < SCP_IPI_MAX; i++) - mutex_init(&scp->ipi_desc[i].lock); - scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); if (IS_ERR((__force void *)scp->reg_base)) { dev_err(dev, "Failed to parse and map cfg memory\n"); - ret = PTR_ERR((__force void *)scp->reg_base); - goto destroy_mutex; + return PTR_ERR((__force void *)scp->reg_base); } - ret = scp_map_memory_region(scp); + ret = scp->data->scp_clk_get(scp); if (ret) - goto destroy_mutex; + return ret; - ret = scp->data->scp_clk_get(scp); + ret = scp_map_memory_region(scp); if (ret) - goto release_dev_mem; + return ret; + + mutex_init(&scp->send_lock); + for (i = 0; i < SCP_IPI_MAX; i++) + mutex_init(&scp->ipi_desc[i].lock); /* register SCP initialization IPI */ ret = scp_ipi_register(scp, SCP_IPI_INIT, scp_init_ipi_handler, scp); @@ -842,7 +841,6 @@ static int scp_probe(struct platform_device *pdev) scp_ipi_unregister(scp, SCP_IPI_INIT); release_dev_mem: scp_unmap_memory_region(scp); -destroy_mutex: for (i = 0; i < SCP_IPI_MAX; i++) mutex_destroy(&scp->ipi_desc[i].lock); mutex_destroy(&scp->send_lock); From patchwork Mon Jan 24 12:09:15 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: 12721909 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 2F0FCC433FE for ; Mon, 24 Jan 2022 12:11:11 +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=wwvsMJhD90Dx1UznQR3HZ4eVmooCBcebmSY9BDIHhAE=; b=z9/L9e1Eoz7XNM dU8hnRApZ2lmHSBT9cTlOCVxctTjHBlCl4/kIJLHwZ4DFvxbsVEXy8puZFB90Pc5q+sQWH+ENvyJR kQePBAMMwBfN8TN6fMlPYF7sXYMt9fqIJ7EhrnCIPtUUBrFAfT4hmCnK+rmvjnofPpr08uBzJoMjQ o+rGTLmuQGkXqu7+idzLDqunpHdoJnv1FChNYHwqrdH9G9fFk7LrZyqI4w+8wKJ0mj1bOr3kf1Q85 KWrxZBM5xBtlhM/Sc+khZAljeIgLoUNdZZO1bDjm+aZaeuYCLzzBnm6ZEFY881CBGk7fKADsGfcHb bqp4Q0gHMG2HG5fg5sCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nByAR-0039b5-V2; Mon, 24 Jan 2022 12:09:52 +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 1nByA2-0039TT-Ln; Mon, 24 Jan 2022 12:09:28 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id EED441F42E77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1643026165; bh=K2ObFY3Vsm+qnoFl2QeGq49BSilMuqWVDQ+bAXw3Mog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MXIzTOobugUM0mowy79jjk1wphZsdQeaD09BgOWJkvg9YkRg2INPxE+3z59OGCbaP oGOgJZyLmJ/EDqaqCFR1peOp+C5HLSeEVSR8VN0fCVIerLlfa/PSP1gY89+4F7ymtk RmjpdpgsBEgOl0FqpJblVZj1Dsgw+lIhVOFigOX7JF8PmoIIh6/UCs+6NvySXOCRTo y5203U/mGV2mQ1spOsg1DoKw98o9G0kotfqk6RVIhRaDN8DxbfmdXuoyMl1P0n3i1d mZVoDugn6pJSvub6XGR1RYeiACs7trCsDaFVHFCgXjKt9Wq6pVhef28Ejy1BIlwamf GmUSTmUu1bXhg== From: AngeloGioacchino Del Regno To: bjorn.andersson@linaro.org Cc: mathieu.poirier@linaro.org, matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 3/3] remoteproc: mtk_scp: Use dev_err_probe() where possible Date: Mon, 24 Jan 2022 13:09:15 +0100 Message-Id: <20220124120915.41292-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220124120915.41292-1-angelogioacchino.delregno@collabora.com> References: <20220124120915.41292-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-20220124_040926_886202_2D97AE7C X-CRM114-Status: GOOD ( 11.68 ) 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 Simplify the probe function, where possible, by using dev_err_probe(). While at it, as to increase human readability, also remove some unnecessary forced void pointer casts that were previously used in error checking. Signed-off-by: AngeloGioacchino Del Regno --- drivers/remoteproc/mtk_scp.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index e40706b0e015..dcddb33e9997 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -757,10 +757,8 @@ static int scp_probe(struct platform_device *pdev) int ret, i; rproc = devm_rproc_alloc(dev, np->name, &scp_ops, fw_name, sizeof(*scp)); - if (!rproc) { - dev_err(dev, "unable to allocate remoteproc\n"); - return -ENOMEM; - } + if (!rproc) + return dev_err_probe(dev, -ENOMEM, "unable to allocate remoteproc\n"); scp = (struct mtk_scp *)rproc->priv; scp->rproc = rproc; @@ -770,21 +768,20 @@ static int scp_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); scp->sram_base = devm_ioremap_resource(dev, res); - if (IS_ERR((__force void *)scp->sram_base)) { - dev_err(dev, "Failed to parse and map sram memory\n"); - return PTR_ERR((__force void *)scp->sram_base); - } + if (IS_ERR(scp->sram_base)) + return dev_err_probe(dev, PTR_ERR(scp->sram_base), + "Failed to parse and map sram memory\n"); + scp->sram_size = resource_size(res); scp->sram_phys = res->start; /* l1tcm is an optional memory region */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm"); scp->l1tcm_base = devm_ioremap_resource(dev, res); - if (IS_ERR((__force void *)scp->l1tcm_base)) { - ret = PTR_ERR((__force void *)scp->l1tcm_base); + if (IS_ERR(scp->l1tcm_base)) { + ret = PTR_ERR(scp->l1tcm_base); if (ret != -EINVAL) { - dev_err(dev, "Failed to map l1tcm memory\n"); - return ret; + return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); } } else { scp->l1tcm_size = resource_size(res); @@ -792,10 +789,9 @@ static int scp_probe(struct platform_device *pdev) } scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg"); - if (IS_ERR((__force void *)scp->reg_base)) { - dev_err(dev, "Failed to parse and map cfg memory\n"); - return PTR_ERR((__force void *)scp->reg_base); - } + if (IS_ERR(scp->reg_base)) + return dev_err_probe(dev, PTR_ERR(scp->reg_base), + "Failed to parse and map cfg memory\n"); ret = scp->data->scp_clk_get(scp); if (ret)