Changes in v2:
- Removed drm_bridge_remove() call in patch 1
- Added dev_err_probe print to devm_drm_of_get_bridge()
call error handling
- Switched to devm_platform_ioremap_resource() to remove
the useless pointer to struct resource in probe function
- Added a commit to compress struct of_device_id entries
- Added a commit to switch to .remove_new() callback
This is a small cleanup of the mtk-dpi driver, switching it to devm
variants where possible and where it made sense, and reducing lines
while retaining and improving human readability.
AngeloGioacchino Del Regno (6):
drm/mediatek: mtk_dpi: Simplify with devm_drm_bridge_add()
drm/mediatek: mtk_dpi: Simplify with dev_err_probe()
drm/mediatek: mtk_dpi: Switch to devm_drm_of_get_bridge()
drm/mediatek: mtk_dpi: Switch to .remove_new() void callback
drm/mediatek: mtk_dpi: Use devm_platform_ioremap_resource()
drm/mediatek: mtk_dpi: Compress struct of_device_id entries
drivers/gpu/drm/mediatek/mtk_dpi.c | 100 +++++++++--------------------
1 file changed, 32 insertions(+), 68 deletions(-)
--
2.40.1
Function drm_of_find_panel_or_bridge() is marked as deprecated: since
the usage of that in this driver exactly corresponds to the new function
devm_drm_of_get_bridge(), switch to it.
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
Reviewed-by: Fei Shao <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dpi.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index 03a2b900bb50..e9c5a0f44537 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -1063,10 +1063,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
if (dpi->irq <= 0)
return -EINVAL;
- ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
- NULL, &dpi->next_bridge);
- if (ret)
- return ret;
+ dpi->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
+ if (IS_ERR(dpi->next_bridge))
+ return dev_err_probe(dev, PTR_ERR(dpi->next_bridge),
+ "Failed to get bridge\n");
dev_info(dev, "Found bridge node: %pOF\n", dpi->next_bridge->of_node);
@@ -1089,8 +1089,6 @@ static int mtk_dpi_probe(struct platform_device *pdev)
static int mtk_dpi_remove(struct platform_device *pdev)
{
- struct mtk_dpi *dpi = platform_get_drvdata(pdev);
-
component_del(&pdev->dev, &mtk_dpi_component_ops);
return 0;
--
2.40.1
Reduce line count by compressing the entries of struct of_device_id;
while at it, also add the usual /* sentinel */ comment to the last
entry.
This commit brings no functional changes.
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dpi.c | 30 ++++++++----------------------
1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index 244340df7468..ad1be4f9150c 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -1091,28 +1091,14 @@ static void mtk_dpi_remove(struct platform_device *pdev)
}
static const struct of_device_id mtk_dpi_of_ids[] = {
- { .compatible = "mediatek,mt2701-dpi",
- .data = &mt2701_conf,
- },
- { .compatible = "mediatek,mt8173-dpi",
- .data = &mt8173_conf,
- },
- { .compatible = "mediatek,mt8183-dpi",
- .data = &mt8183_conf,
- },
- { .compatible = "mediatek,mt8186-dpi",
- .data = &mt8186_conf,
- },
- { .compatible = "mediatek,mt8188-dp-intf",
- .data = &mt8188_dpintf_conf,
- },
- { .compatible = "mediatek,mt8192-dpi",
- .data = &mt8192_conf,
- },
- { .compatible = "mediatek,mt8195-dp-intf",
- .data = &mt8195_dpintf_conf,
- },
- { },
+ { .compatible = "mediatek,mt2701-dpi", .data = &mt2701_conf },
+ { .compatible = "mediatek,mt8173-dpi", .data = &mt8173_conf },
+ { .compatible = "mediatek,mt8183-dpi", .data = &mt8183_conf },
+ { .compatible = "mediatek,mt8186-dpi", .data = &mt8186_conf },
+ { .compatible = "mediatek,mt8188-dp-intf", .data = &mt8188_dpintf_conf },
+ { .compatible = "mediatek,mt8192-dpi", .data = &mt8192_conf },
+ { .compatible = "mediatek,mt8195-dp-intf", .data = &mt8195_dpintf_conf },
+ { /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);
--
2.40.1
On Wed, Jul 19, 2023 at 3:51 PM AngeloGioacchino Del Regno
<[email protected]> wrote:
>
> Reduce line count by compressing the entries of struct of_device_id;
> while at it, also add the usual /* sentinel */ comment to the last
> entry.
>
> This commit brings no functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
Reviewed-by: Fei Shao <[email protected]>
Hi, Angelo:
On Wed, 2023-07-19 at 09:50 +0200, AngeloGioacchino Del Regno wrote:
> Reduce line count by compressing the entries of struct of_device_id;
> while at it, also add the usual /* sentinel */ comment to the last
> entry.
>
> This commit brings no functional changes.
Reviewed-by: CK Hu <[email protected]>
>
> Signed-off-by: AngeloGioacchino Del Regno <
> [email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_dpi.c | 30 ++++++++------------------
> ----
> 1 file changed, 8 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c
> b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 244340df7468..ad1be4f9150c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -1091,28 +1091,14 @@ static void mtk_dpi_remove(struct
> platform_device *pdev)
> }
>
> static const struct of_device_id mtk_dpi_of_ids[] = {
> - { .compatible = "mediatek,mt2701-dpi",
> - .data = &mt2701_conf,
> - },
> - { .compatible = "mediatek,mt8173-dpi",
> - .data = &mt8173_conf,
> - },
> - { .compatible = "mediatek,mt8183-dpi",
> - .data = &mt8183_conf,
> - },
> - { .compatible = "mediatek,mt8186-dpi",
> - .data = &mt8186_conf,
> - },
> - { .compatible = "mediatek,mt8188-dp-intf",
> - .data = &mt8188_dpintf_conf,
> - },
> - { .compatible = "mediatek,mt8192-dpi",
> - .data = &mt8192_conf,
> - },
> - { .compatible = "mediatek,mt8195-dp-intf",
> - .data = &mt8195_dpintf_conf,
> - },
> - { },
> + { .compatible = "mediatek,mt2701-dpi", .data = &mt2701_conf },
> + { .compatible = "mediatek,mt8173-dpi", .data = &mt8173_conf },
> + { .compatible = "mediatek,mt8183-dpi", .data = &mt8183_conf },
> + { .compatible = "mediatek,mt8186-dpi", .data = &mt8186_conf },
> + { .compatible = "mediatek,mt8188-dp-intf", .data =
> &mt8188_dpintf_conf },
> + { .compatible = "mediatek,mt8192-dpi", .data = &mt8192_conf },
> + { .compatible = "mediatek,mt8195-dp-intf", .data =
> &mt8195_dpintf_conf },
> + { /* sentinel */ },
> };
> MODULE_DEVICE_TABLE(of, mtk_dpi_of_ids);
>
Hi, Angelo:
On Wed, 2023-07-19 at 09:50 +0200, AngeloGioacchino Del Regno wrote:
> Function drm_of_find_panel_or_bridge() is marked as deprecated: since
> the usage of that in this driver exactly corresponds to the new
> function
> devm_drm_of_get_bridge(), switch to it.
>
> Signed-off-by: AngeloGioacchino Del Regno <
> [email protected]>
> Reviewed-by: Fei Shao <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_dpi.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c
> b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 03a2b900bb50..e9c5a0f44537 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -1063,10 +1063,10 @@ static int mtk_dpi_probe(struct
> platform_device *pdev)
> if (dpi->irq <= 0)
> return -EINVAL;
>
> - ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> - NULL, &dpi->next_bridge);
> - if (ret)
> - return ret;
> + dpi->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0,
> 0);
> + if (IS_ERR(dpi->next_bridge))
> + return dev_err_probe(dev, PTR_ERR(dpi->next_bridge),
> + "Failed to get bridge\n");
>
> dev_info(dev, "Found bridge node: %pOF\n", dpi->next_bridge-
> >of_node);
>
> @@ -1089,8 +1089,6 @@ static int mtk_dpi_probe(struct platform_device
> *pdev)
>
> static int mtk_dpi_remove(struct platform_device *pdev)
> {
> - struct mtk_dpi *dpi = platform_get_drvdata(pdev);
Move this to the patch of "Simplify with devm_drm_bridge_add()".
Regards,
CK
> -
> component_del(&pdev->dev, &mtk_dpi_component_ops);
>
> return 0;