From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: matthias.bgg@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Subject: [PATCH] soc: mediatek: mutex: Simplify with devm_platform_get_and_ioremap_resource() Date: Thu, 23 Jun 2022 14:17:01 +0200 [thread overview] Message-ID: <20220623121701.107512-1-angelogioacchino.delregno@collabora.com> (raw) Convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does. While at it, also remove a redundant call to of_address_to_resource(), as this was getting the address of the same resource index 0: we can as well get the iostart from the 'regs' pointer. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/soc/mediatek/mtk-mutex.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c index 60cbafea577e..ca8440fb48cd 100644 --- a/drivers/soc/mediatek/mtk-mutex.c +++ b/drivers/soc/mediatek/mtk-mutex.c @@ -787,7 +787,7 @@ static int mtk_mutex_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mtk_mutex_ctx *mtx; - struct resource *regs, addr; + struct resource *regs; int i; #if IS_REACHABLE(CONFIG_MTK_CMDQ) int ret; @@ -811,11 +811,12 @@ static int mtk_mutex_probe(struct platform_device *pdev) } } - if (of_address_to_resource(dev->of_node, 0, &addr) < 0) { - dev_err(dev, "Failed to get addr\n"); - return -EINVAL; + mtx->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); + if (IS_ERR(mtx->regs)) { + dev_err(dev, "Failed to map mutex registers\n"); + return PTR_ERR(mtx->regs); } - mtx->addr = addr.start; + mtx->addr = regs->start; #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(dev, &mtx->cmdq_reg, 0); @@ -823,13 +824,6 @@ static int mtk_mutex_probe(struct platform_device *pdev) dev_dbg(dev, "No mediatek,gce-client-reg!\n"); #endif - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mtx->regs = devm_ioremap_resource(dev, regs); - if (IS_ERR(mtx->regs)) { - dev_err(dev, "Failed to map mutex registers\n"); - return PTR_ERR(mtx->regs); - } - platform_set_drvdata(pdev, mtx); return 0; -- 2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: matthias.bgg@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Subject: [PATCH] soc: mediatek: mutex: Simplify with devm_platform_get_and_ioremap_resource() Date: Thu, 23 Jun 2022 14:17:01 +0200 [thread overview] Message-ID: <20220623121701.107512-1-angelogioacchino.delregno@collabora.com> (raw) Convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does. While at it, also remove a redundant call to of_address_to_resource(), as this was getting the address of the same resource index 0: we can as well get the iostart from the 'regs' pointer. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/soc/mediatek/mtk-mutex.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c index 60cbafea577e..ca8440fb48cd 100644 --- a/drivers/soc/mediatek/mtk-mutex.c +++ b/drivers/soc/mediatek/mtk-mutex.c @@ -787,7 +787,7 @@ static int mtk_mutex_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mtk_mutex_ctx *mtx; - struct resource *regs, addr; + struct resource *regs; int i; #if IS_REACHABLE(CONFIG_MTK_CMDQ) int ret; @@ -811,11 +811,12 @@ static int mtk_mutex_probe(struct platform_device *pdev) } } - if (of_address_to_resource(dev->of_node, 0, &addr) < 0) { - dev_err(dev, "Failed to get addr\n"); - return -EINVAL; + mtx->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); + if (IS_ERR(mtx->regs)) { + dev_err(dev, "Failed to map mutex registers\n"); + return PTR_ERR(mtx->regs); } - mtx->addr = addr.start; + mtx->addr = regs->start; #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(dev, &mtx->cmdq_reg, 0); @@ -823,13 +824,6 @@ static int mtk_mutex_probe(struct platform_device *pdev) dev_dbg(dev, "No mediatek,gce-client-reg!\n"); #endif - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mtx->regs = devm_ioremap_resource(dev, regs); - if (IS_ERR(mtx->regs)) { - dev_err(dev, "Failed to map mutex registers\n"); - return PTR_ERR(mtx->regs); - } - platform_set_drvdata(pdev, mtx); return 0; -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-06-23 12:17 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-23 12:17 AngeloGioacchino Del Regno [this message] 2022-06-23 12:17 ` [PATCH] soc: mediatek: mutex: Simplify with devm_platform_get_and_ioremap_resource() AngeloGioacchino Del Regno 2022-07-08 8:29 ` Matthias Brugger 2022-07-08 8:29 ` Matthias Brugger
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220623121701.107512-1-angelogioacchino.delregno@collabora.com \ --to=angelogioacchino.delregno@collabora.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=matthias.bgg@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.