Skip to content

Commit 79a1886

Browse files
jbrun3tbebarino
authored andcommitted
clk: eyeq: use the auxiliary device creation helper
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>
1 parent 3e75021 commit 79a1886

1 file changed

Lines changed: 12 additions & 45 deletions

File tree

drivers/clk/clk-eyeq.c

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -321,38 +321,18 @@ static void eqc_probe_init_fixed_factors(struct device *dev,
321321
}
322322
}
323323

324-
static void eqc_auxdev_release(struct device *dev)
325-
{
326-
struct auxiliary_device *adev = to_auxiliary_dev(dev);
327-
328-
kfree(adev);
329-
}
330-
331-
static int eqc_auxdev_create(struct device *dev, void __iomem *base,
332-
const char *name, u32 id)
324+
static void eqc_auxdev_create_optional(struct device *dev, void __iomem *base,
325+
const char *name)
333326
{
334327
struct auxiliary_device *adev;
335-
int ret;
336-
337-
adev = kzalloc_obj(*adev);
338-
if (!adev)
339-
return -ENOMEM;
340-
341-
adev->name = name;
342-
adev->dev.parent = dev;
343-
adev->dev.platform_data = (void __force *)base;
344-
adev->dev.release = eqc_auxdev_release;
345-
adev->id = id;
346328

347-
ret = auxiliary_device_init(adev);
348-
if (ret)
349-
return ret;
350-
351-
ret = auxiliary_device_add(adev);
352-
if (ret)
353-
auxiliary_device_uninit(adev);
354-
355-
return ret;
329+
if (name) {
330+
adev = devm_auxiliary_device_create(dev, name,
331+
(void __force *)base);
332+
if (!adev)
333+
dev_warn(dev, "failed creating auxiliary device %s.%s\n",
334+
KBUILD_MODNAME, name);
335+
}
356336
}
357337

358338
static int eqc_probe(struct platform_device *pdev)
@@ -364,7 +344,6 @@ static int eqc_probe(struct platform_device *pdev)
364344
unsigned int i, clk_count;
365345
struct resource *res;
366346
void __iomem *base;
367-
int ret;
368347

369348
data = device_get_match_data(dev);
370349
if (!data)
@@ -378,21 +357,9 @@ static int eqc_probe(struct platform_device *pdev)
378357
if (!base)
379358
return -ENOMEM;
380359

381-
/* Init optional reset auxiliary device. */
382-
if (data->reset_auxdev_name) {
383-
ret = eqc_auxdev_create(dev, base, data->reset_auxdev_name, 0);
384-
if (ret)
385-
dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
386-
KBUILD_MODNAME, data->reset_auxdev_name, ret);
387-
}
388-
389-
/* Init optional pinctrl auxiliary device. */
390-
if (data->pinctrl_auxdev_name) {
391-
ret = eqc_auxdev_create(dev, base, data->pinctrl_auxdev_name, 0);
392-
if (ret)
393-
dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
394-
KBUILD_MODNAME, data->pinctrl_auxdev_name, ret);
395-
}
360+
/* Init optional auxiliary devices. */
361+
eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
362+
eqc_auxdev_create_optional(dev, base, data->pinctrl_auxdev_name);
396363

397364
if (data->pll_count + data->div_count + data->fixed_factor_count == 0)
398365
return 0; /* Zero clocks, we are done. */

0 commit comments

Comments
 (0)