[PATCH v7 12/17] media: rkvdec: Enable all clocks without naming them

Detlev Casanova
2025-12-18T23:29:07Z

For other variants, the clock names and number will differ.

There is no need to keep track of the clock names in the driver so drop
them to avoid having a list for each variant.

Tested-by: Diederik de Haas <didi.debian@cknow.org> # Rock 5B
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
---
.../media/platform/rockchip/rkvdec/rkvdec.c | 26 +++++--------------
.../media/platform/rockchip/rkvdec/rkvdec.h | 1 +
2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 174536ebdcc7c..ce96a0470d4d9 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -1312,15 +1312,10 @@ static const struct of_device_id of_rkvdec_match[] = {
};
MODULE_DEVICE_TABLE(of, of_rkvdec_match);

-static const char * const rkvdec_clk_names[] = {
- "axi", "ahb", "cabac", "core"
-};
-
static int rkvdec_probe(struct platform_device *pdev)
{
const struct rkvdec_variant *variant;
struct rkvdec_dev *rkvdec;
- unsigned int i;
int ret, irq;

variant = of_device_get_match_data(&pdev->dev);
@@ -1337,19 +1332,12 @@ static int rkvdec_probe(struct platform_device *pdev)
mutex_init(&rkvdec->vdev_lock);
INIT_DELAYED_WORK(&rkvdec->watchdog_work, rkvdec_watchdog_func);

- rkvdec->clocks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(rkvdec_clk_names),
- sizeof(*rkvdec->clocks), GFP_KERNEL);
- if (!rkvdec->clocks)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(rkvdec_clk_names); i++)
- rkvdec->clocks[i].id = rkvdec_clk_names[i];
-
- ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(rkvdec_clk_names),
- rkvdec->clocks);
- if (ret)
+ ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &rkvdec->clocks);
+ if (ret < 0)
return ret;

+ rkvdec->num_clocks = ret;
+
rkvdec->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(rkvdec->regs))
return PTR_ERR(rkvdec->regs);
@@ -1427,16 +1415,14 @@ static int rkvdec_runtime_resume(struct device *dev)
{
struct rkvdec_dev *rkvdec = dev_get_drvdata(dev);

- return clk_bulk_prepare_enable(ARRAY_SIZE(rkvdec_clk_names),
- rkvdec->clocks);
+ return clk_bulk_prepare_enable(rkvdec->num_clocks, rkvdec->clocks);
}

static int rkvdec_runtime_suspend(struct device *dev)
{
struct rkvdec_dev *rkvdec = dev_get_drvdata(dev);

- clk_bulk_disable_unprepare(ARRAY_SIZE(rkvdec_clk_names),
- rkvdec->clocks);
+ clk_bulk_disable_unprepare(rkvdec->num_clocks, rkvdec->clocks);
return 0;
}
#endif
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
index faabedd2b9d88..7766a79caf68b 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
@@ -125,6 +125,7 @@ struct rkvdec_dev {
struct v4l2_m2m_dev *m2m_dev;
struct device *dev;
struct clk_bulk_data *clocks;
+ unsigned int num_clocks;
void __iomem *regs;
struct mutex vdev_lock; /* serializes ioctls */
struct delayed_work watchdog_work;
--
2.52.0