Re: [PATCH v2 4/7] iio: adc: ad4170: Add clock provider support

Andy Shevchenko
2025-04-29T22:10:59Z

On Mon, Apr 28, 2025 at 3:28 PM Marcelo Schmitt
<marcelo.schmitt@analog.com> wrote:
>
> The AD4170 chip can use an externally supplied clock at the XTAL2 pin, or
> an external crystal connected to the XTAL1 and XTAL2 pins. Alternatively,
> the AD4170 can provide it's 16 MHz internal clock at the XTAL2 pin. Extend

its

> the AD4170 driver so it effectively uses the provided external clock, if
> any, or supplies it's own clock as a clock provider.

its

...

> +static const char *const ad4170_clk_sel[] = {
> + "ext-clk", "xtal"

Keep trailing comma when it's not a oneliner assignment.

> +};

...

> +static int ad4170_register_clk_provider(struct iio_dev *indio_dev)
> +{
> + struct ad4170_state *st = iio_priv(indio_dev);
> + struct device *dev = indio_dev->dev.parent;
> + struct clk_init_data init = {};
> + int ret;
> +
> + if (!IS_ENABLED(CONFIG_COMMON_CLK))
> + return 0;
> +
> + if (device_property_read_string(dev, "clock-output-names", &init.name)) {
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s-clk",
> + fwnode_get_name(dev_fwnode(dev)));

Why not %pfw ?

> + if (!init.name)
> + return -ENOMEM;
> + }
> +
> + init.ops = &ad4170_int_clk_ops;
> +
> + st->int_clk_hw.init = &init;
> + ret = devm_clk_hw_register(dev, &st->int_clk_hw);
> + if (ret)
> + return ret;
> +
> + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
> + &st->int_clk_hw);
> +}

...

> + ret = ad4170_clock_select(indio_dev);
> + if (ret < 0)

Why ' < 0' part?

> + return dev_err_probe(dev, ret, "Failed to setup device clock\n");
> +
> + ret = regmap_write(st->regmap, AD4170_CLOCK_CTRL_REG, st->clock_ctrl);
> + if (ret)
> + return ret;

--
With Best Regards,
Andy Shevchenko