Skip to contentSkip to conversation

media: coda: Convert the driver to DT-only

PATCH In review Fabio Estevam 2 participants 3 messages Nov 24, 2020 – Dec 2, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: coda: Convert the driver to DT-only

Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code by removing the unused non-DT support.

---
 drivers/media/platform/coda/coda-common.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/media/platform/coda/coda-common.c +1 -20
index d30eafea701d..b1b29c13dba3 100644
@@ -3102,13 +3102,6 @@ static const struct coda_devtype coda_devdata[] = {
 	},
 };
 
-static const struct platform_device_id coda_platform_ids[] = {
-	{ .name = "coda-imx27", .driver_data = CODA_IMX27 },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(platform, coda_platform_ids);
-
-#ifdef CONFIG_OF
 static const struct of_device_id coda_dt_ids[] = {
 	{ .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
 	{ .compatible = "fsl,imx51-vpu", .data = &coda_devdata[CODA_IMX51] },
@@ -3118,13 +3111,9 @@ static const struct of_device_id coda_dt_ids[] = {
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, coda_dt_ids);
-#endif
 
 static int coda_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *of_id =
-			of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev);
-	const struct platform_device_id *pdev_id;
 	struct coda_platform_data *pdata = pdev->dev.platform_data;
 	struct device_node *np = pdev->dev.of_node;
 	struct gen_pool *pool;
@@ -3135,14 +3124,7 @@ static int coda_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
-	pdev_id = of_id ? of_id->data : platform_get_device_id(pdev);
-
-	if (of_id)
-		dev->devtype = of_id->data;
-	else if (pdev_id)
-		dev->devtype = &coda_devdata[pdev_id->driver_data];
-	else
-		return -EINVAL;
+	dev->devtype = of_device_get_match_data(&pdev->dev);
 
 	dev->dev = &pdev->dev;
 	dev->clk_per = devm_clk_get(&pdev->dev, "per");
@@ -3342,7 +3324,6 @@ static struct platform_driver coda_driver = {
 		.of_match_table = of_match_ptr(coda_dt_ids),
 		.pm	= &coda_pm_ops,
 	},
-	.id_table = coda_platform_ids,
 };
 
 module_platform_driver(coda_driver);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 28 lines · Fabio Estevam

Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code by removing the unused non-DT support.

---
 drivers/media/platform/coda/coda-common.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/media/platform/coda/coda-common.c +0 -7
index d30eafea701d..b1b29c13dba3 100644
@@ -3102,13 +3102,6 @@ static const struct coda_devtype coda_devdata[] = {
 	},
 };
 
-static const struct platform_device_id coda_platform_ids[] = {
-	{ .name = "coda-imx27", .driver_data = CODA_IMX27 },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(platform, coda_platform_ids);
-
-#ifdef CONFIG_OF
 static const struct of_device_id coda_dt_ids[] = {
 	{ .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
 	{ .compatible = "fsl,imx51-vpu", .data = &coda_devdata[CODA_IMX51] },
@@ -3118,13 +3111,9 @@ static const struct of_device_id coda_dt_ids[] = {
 	{ /* sentinel */ }

drivers/media/platform/coda/coda-common.c static const struct of_device_id coda_dt_ids[] = { · line 3117

Quoted 10 lines
drivers/media/platform/coda/coda-common.c +0 -4
 };
 MODULE_DEVICE_TABLE(of, coda_dt_ids);
-#endif
 
 static int coda_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *of_id =
-			of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev);
-	const struct platform_device_id *pdev_id;
 	struct coda_platform_data *pdata = pdev->dev.platform_data;

So this can be dropped as well (and all related code), right?

Quoted 20 lines
drivers/media/platform/coda/coda-common.c +1 -8
 	struct device_node *np = pdev->dev.of_node;
 	struct gen_pool *pool;
@@ -3135,14 +3124,7 @@ static int coda_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
-	pdev_id = of_id ? of_id->data : platform_get_device_id(pdev);
-
-	if (of_id)
-		dev->devtype = of_id->data;
-	else if (pdev_id)
-		dev->devtype = &coda_devdata[pdev_id->driver_data];
-	else
-		return -EINVAL;
+	dev->devtype = of_device_get_match_data(&pdev->dev);
 
 	dev->dev = &pdev->dev;
 	dev->clk_per = devm_clk_get(&pdev->dev, "per");

drivers/media/platform/coda/coda-common.c static struct platform_driver coda_driver = { · line 3329

Quoted 7 lines
drivers/media/platform/coda/coda-common.c +0 -1
@@ -3342,7 +3324,6 @@ static struct platform_driver coda_driver = {
 		.of_match_table = of_match_ptr(coda_dt_ids),
 		.pm	= &coda_pm_ops,
 	},
-	.id_table = coda_platform_ids,
 };
 
 module_platform_driver(coda_driver);

And you can also remove include/linux/platform_data/media/coda.h.

Regards,

Hans

#2 lore raw

Hi Hans,

Quoted 3 lines · Hans Verkuil
Quoted 1 line
      struct coda_platform_data *pdata = pdev->dev.platform_data;

So this can be dropped as well (and all related code), right?

Yes, you are right.

Quoted 1 line

And you can also remove include/linux/platform_data/media/coda.h.

Yes, thanks for the review. I have sent v2 with your suggestions.

Cheers