* [PATCH v3] soc: mediatek: mtk-mmsys: Simplify with dev_err_probe()
@ 2024-09-02 5:30 Yan Zhen
2024-09-02 15:35 ` Matthias Brugger
0 siblings, 1 reply; 2+ messages in thread
From: Yan Zhen @ 2024-09-02 5:30 UTC (permalink / raw)
To: matthias.bgg, angelogioacchino.delregno
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, opensource.kernel,
Yan Zhen
Use dev_err_probe() to simplify the error path and unify a
message template.
Using this helper is totally fine even if err is known to never
be -EPROBE_DEFER.
The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.
Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
Changes in v3:
- Modify the message.
- Add the '\n' at the end of the string.
drivers/soc/mediatek/mtk-mmsys.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
index 938240714e54..170319163c28 100644
--- a/drivers/soc/mediatek/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mtk-mmsys.c
@@ -397,11 +397,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
return -ENOMEM;
mmsys->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(mmsys->regs)) {
- ret = PTR_ERR(mmsys->regs);
- dev_err(dev, "Failed to ioremap mmsys registers: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(mmsys->regs))
+ return dev_err_probe(dev, PTR_ERR(mmsys->regs),
+ "Failed to ioremap mmsys registers\n");
mmsys->data = of_device_get_match_data(&pdev->dev);
@@ -413,10 +411,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
mmsys->rcdev.ops = &mtk_mmsys_reset_ops;
mmsys->rcdev.of_node = pdev->dev.of_node;
ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev);
- if (ret) {
- dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret);
- return ret;
- }
+ if (ret)
+ dev_err_probe(&pdev->dev, ret,
+ "Couldn't register mmsys reset controller\n");
}
/* CMDQ is optional */
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] soc: mediatek: mtk-mmsys: Simplify with dev_err_probe()
2024-09-02 5:30 [PATCH v3] soc: mediatek: mtk-mmsys: Simplify with dev_err_probe() Yan Zhen
@ 2024-09-02 15:35 ` Matthias Brugger
0 siblings, 0 replies; 2+ messages in thread
From: Matthias Brugger @ 2024-09-02 15:35 UTC (permalink / raw)
To: Yan Zhen, angelogioacchino.delregno
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, opensource.kernel
On 02/09/2024 07:30, Yan Zhen wrote:
> Use dev_err_probe() to simplify the error path and unify a
> message template.
>
> Using this helper is totally fine even if err is known to never
> be -EPROBE_DEFER.
>
> The benefit compared to a normal dev_err() is the standardized format
> of the error code, it being emitted symbolically and the fact that
> the error code is returned which allows more compact error paths.
>
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>
> Changes in v3:
> - Modify the message.
> - Add the '\n' at the end of the string.
>
> drivers/soc/mediatek/mtk-mmsys.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
> index 938240714e54..170319163c28 100644
> --- a/drivers/soc/mediatek/mtk-mmsys.c
> +++ b/drivers/soc/mediatek/mtk-mmsys.c
> @@ -397,11 +397,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> mmsys->regs = devm_platform_ioremap_resource(pdev, 0);
> - if (IS_ERR(mmsys->regs)) {
> - ret = PTR_ERR(mmsys->regs);
> - dev_err(dev, "Failed to ioremap mmsys registers: %d\n", ret);
> - return ret;
> - }
> + if (IS_ERR(mmsys->regs))
> + return dev_err_probe(dev, PTR_ERR(mmsys->regs),
> + "Failed to ioremap mmsys registers\n");
>
> mmsys->data = of_device_get_match_data(&pdev->dev);
>
> @@ -413,10 +411,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
> mmsys->rcdev.ops = &mtk_mmsys_reset_ops;
> mmsys->rcdev.of_node = pdev->dev.of_node;
> ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev);
> - if (ret) {
> - dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret,
> + "Couldn't register mmsys reset controller\n");
Your missing return of the error value.
> }
>
> /* CMDQ is optional */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-02 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 5:30 [PATCH v3] soc: mediatek: mtk-mmsys: Simplify with dev_err_probe() Yan Zhen
2024-09-02 15:35 ` Matthias Brugger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox