2020-12-02 14:18:19

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH v4] 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.

Signed-off-by: Fabio Estevam <[email protected]>
---
Changes since v3:
- Add a explicit OF dependency - Andy

drivers/media/platform/Kconfig | 2 +-
drivers/media/platform/coda/coda-common.c | 27 ++---------------------
include/linux/platform_data/media/coda.h | 14 ------------
3 files changed, 3 insertions(+), 40 deletions(-)
delete mode 100644 include/linux/platform_data/media/coda.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index ffffef2267f4..9fdbfea06087 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -201,7 +201,7 @@ if V4L_MEM2MEM_DRIVERS

config VIDEO_CODA
tristate "Chips&Media Coda multi-standard codec IP"
- depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_MXC || COMPILE_TEST)
+ depends on VIDEO_DEV && VIDEO_V4L2 && OF && (ARCH_MXC || COMPILE_TEST)
select SRAM
select VIDEOBUF2_DMA_CONTIG
select VIDEOBUF2_VMALLOC
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index d30eafea701d..995e95272e51 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -25,7 +25,6 @@
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/of.h>
-#include <linux/platform_data/media/coda.h>
#include <linux/ratelimit.h>
#include <linux/reset.h>

@@ -3102,13 +3101,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,14 +3110,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;
struct coda_dev *dev;
@@ -3135,14 +3122,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");
@@ -3200,10 +3180,8 @@ static int coda_probe(struct platform_device *pdev)
return ret;
}

- /* Get IRAM pool from device tree or platform data */
+ /* Get IRAM pool from device tree */
pool = of_gen_pool_get(np, "iram", 0);
- if (!pool && pdata)
- pool = gen_pool_get(pdata->iram_dev, NULL);
if (!pool) {
dev_err(&pdev->dev, "iram pool not available\n");
return -ENOMEM;
@@ -3342,7 +3320,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);
diff --git a/include/linux/platform_data/media/coda.h b/include/linux/platform_data/media/coda.h
deleted file mode 100644
index 293b61b60c9d..000000000000
--- a/include/linux/platform_data/media/coda.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2013 Philipp Zabel, Pengutronix
- */
-#ifndef PLATFORM_CODA_H
-#define PLATFORM_CODA_H
-
-struct device;
-
-struct coda_platform_data {
- struct device *iram_dev;
-};
-
-#endif
--
2.17.1


2020-12-02 14:43:20

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v4] media: coda: Convert the driver to DT-only

On Wed, Dec 2, 2020 at 4:15 PM Fabio Estevam <[email protected]> wrote:
>
> Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code
> by removing the unused non-DT support.

I haven't checked full context but from what I see the patch looks
good to me, FWIW,
Reviewed-by: Andy Shevchenko <[email protected]>

>
> Signed-off-by: Fabio Estevam <[email protected]>
> ---
> Changes since v3:
> - Add a explicit OF dependency - Andy
>
> drivers/media/platform/Kconfig | 2 +-
> drivers/media/platform/coda/coda-common.c | 27 ++---------------------
> include/linux/platform_data/media/coda.h | 14 ------------
> 3 files changed, 3 insertions(+), 40 deletions(-)
> delete mode 100644 include/linux/platform_data/media/coda.h
>
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index ffffef2267f4..9fdbfea06087 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -201,7 +201,7 @@ if V4L_MEM2MEM_DRIVERS
>
> config VIDEO_CODA
> tristate "Chips&Media Coda multi-standard codec IP"
> - depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_MXC || COMPILE_TEST)
> + depends on VIDEO_DEV && VIDEO_V4L2 && OF && (ARCH_MXC || COMPILE_TEST)
> select SRAM
> select VIDEOBUF2_DMA_CONTIG
> select VIDEOBUF2_VMALLOC
> diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
> index d30eafea701d..995e95272e51 100644
> --- a/drivers/media/platform/coda/coda-common.c
> +++ b/drivers/media/platform/coda/coda-common.c
> @@ -25,7 +25,6 @@
> #include <linux/slab.h>
> #include <linux/videodev2.h>
> #include <linux/of.h>
> -#include <linux/platform_data/media/coda.h>
> #include <linux/ratelimit.h>
> #include <linux/reset.h>
>
> @@ -3102,13 +3101,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,14 +3110,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;
> struct coda_dev *dev;
> @@ -3135,14 +3122,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");
> @@ -3200,10 +3180,8 @@ static int coda_probe(struct platform_device *pdev)
> return ret;
> }
>
> - /* Get IRAM pool from device tree or platform data */
> + /* Get IRAM pool from device tree */
> pool = of_gen_pool_get(np, "iram", 0);
> - if (!pool && pdata)
> - pool = gen_pool_get(pdata->iram_dev, NULL);
> if (!pool) {
> dev_err(&pdev->dev, "iram pool not available\n");
> return -ENOMEM;
> @@ -3342,7 +3320,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);
> diff --git a/include/linux/platform_data/media/coda.h b/include/linux/platform_data/media/coda.h
> deleted file mode 100644
> index 293b61b60c9d..000000000000
> --- a/include/linux/platform_data/media/coda.h
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-or-later */
> -/*
> - * Copyright (C) 2013 Philipp Zabel, Pengutronix
> - */
> -#ifndef PLATFORM_CODA_H
> -#define PLATFORM_CODA_H
> -
> -struct device;
> -
> -struct coda_platform_data {
> - struct device *iram_dev;
> -};
> -
> -#endif
> --
> 2.17.1
>


--
With Best Regards,
Andy Shevchenko

2020-12-02 15:45:55

by Philipp Zabel

[permalink] [raw]
Subject: Re: [PATCH v4] media: coda: Convert the driver to DT-only

On Wed, 2020-12-02 at 11:13 -0300, Fabio Estevam wrote:
> Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code
> by removing the unused non-DT support.
>
> Signed-off-by: Fabio Estevam <[email protected]>

Thank you, this looks fine to me now.

Reviewed-by: Philipp Zabel <[email protected]>

regards
Philipp