]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
clk: eyeq: use the auxiliary device creation helper
authorJerome Brunet <jbrunet@baylibre.com>
Wed, 25 Feb 2026 16:55:05 +0000 (17:55 +0100)
committerStephen Boyd <sboyd@kernel.org>
Wed, 29 Apr 2026 02:03:47 +0000 (19:03 -0700)
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.

Use it and remove some boilerplate code.

Tested-by: Théo Lebrun <theo.lebrun@bootlin.com> # On Mobileye EyeQ5
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/clk-eyeq.c

index c1dccedf8d5b1f04b55d7ce230bdd8832eebe82d..ae1aaf274336dd57f14e6da8da6239837d450ee3 100644 (file)
@@ -321,38 +321,18 @@ static void eqc_probe_init_fixed_factors(struct device *dev,
        }
 }
 
-static void eqc_auxdev_release(struct device *dev)
-{
-       struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
-       kfree(adev);
-}
-
-static int eqc_auxdev_create(struct device *dev, void __iomem *base,
-                            const char *name, u32 id)
+static void eqc_auxdev_create_optional(struct device *dev, void __iomem *base,
+                                      const char *name)
 {
        struct auxiliary_device *adev;
-       int ret;
-
-       adev = kzalloc_obj(*adev);
-       if (!adev)
-               return -ENOMEM;
-
-       adev->name = name;
-       adev->dev.parent = dev;
-       adev->dev.platform_data = (void __force *)base;
-       adev->dev.release = eqc_auxdev_release;
-       adev->id = id;
 
-       ret = auxiliary_device_init(adev);
-       if (ret)
-               return ret;
-
-       ret = auxiliary_device_add(adev);
-       if (ret)
-               auxiliary_device_uninit(adev);
-
-       return ret;
+       if (name) {
+               adev = devm_auxiliary_device_create(dev, name,
+                                                   (void __force *)base);
+               if (!adev)
+                       dev_warn(dev, "failed creating auxiliary device %s.%s\n",
+                                KBUILD_MODNAME, name);
+       }
 }
 
 static int eqc_probe(struct platform_device *pdev)
@@ -364,7 +344,6 @@ static int eqc_probe(struct platform_device *pdev)
        unsigned int i, clk_count;
        struct resource *res;
        void __iomem *base;
-       int ret;
 
        data = device_get_match_data(dev);
        if (!data)
@@ -378,21 +357,9 @@ static int eqc_probe(struct platform_device *pdev)
        if (!base)
                return -ENOMEM;
 
-       /* Init optional reset auxiliary device. */
-       if (data->reset_auxdev_name) {
-               ret = eqc_auxdev_create(dev, base, data->reset_auxdev_name, 0);
-               if (ret)
-                       dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
-                                KBUILD_MODNAME, data->reset_auxdev_name, ret);
-       }
-
-       /* Init optional pinctrl auxiliary device. */
-       if (data->pinctrl_auxdev_name) {
-               ret = eqc_auxdev_create(dev, base, data->pinctrl_auxdev_name, 0);
-               if (ret)
-                       dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
-                                KBUILD_MODNAME, data->pinctrl_auxdev_name, ret);
-       }
+       /* Init optional auxiliary devices. */
+       eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
+       eqc_auxdev_create_optional(dev, base, data->pinctrl_auxdev_name);
 
        if (data->pll_count + data->div_count + data->fixed_factor_count == 0)
                return 0; /* Zero clocks, we are done. */