]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: rkvdec: Enable all clocks without naming them
authorDetlev Casanova <detlev.casanova@collabora.com>
Fri, 9 Jan 2026 16:15:28 +0000 (11:15 -0500)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 21 Jan 2026 13:43:10 +0000 (14:43 +0100)
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>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/rockchip/rkvdec/rkvdec.c
drivers/media/platform/rockchip/rkvdec/rkvdec.h

index 174536ebdcc7c7ae843f658415836118d297dce6..ce96a0470d4d95154b4f30b358bd4a9245bc7f6d 100644 (file)
@@ -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
index faabedd2b9d885b069fbf75e18d722891407fb4b..7766a79caf68b7bedc2f7a328914b1818eb0c873 100644 (file)
@@ -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;