lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176369483456.11952.769972703298837189@localhost.localdomain>
Date: Thu, 20 Nov 2025 19:13:54 -0800
From: Stephen Boyd <sboyd@...nel.org>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>, conor+dt@...nel.org, devicetree@...r.kernel.org, jic23@...nel.org, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, robh@...nel.org
Cc: Antoniu Miclaus <antoniu.miclaus@...log.com>
Subject: Re: [PATCH 2/2] iio: frequency: adf4377: add clk provider support

Quoting Antoniu Miclaus (2025-11-14 04:09:08)
> diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
> index 08833b7035e4..08dc2110cf8c 100644
> --- a/drivers/iio/frequency/adf4377.c
> +++ b/drivers/iio/frequency/adf4377.c
> @@ -929,6 +935,120 @@ static int adf4377_freq_change(struct notifier_block *nb, unsigned long action,
>         return NOTIFY_OK;
>  }
>  
> +static void adf4377_clk_del_provider(void *data)
> +{
> +       struct adf4377_state *st = data;
> +
> +       of_clk_del_provider(st->spi->dev.of_node);
> +}
> +
> +
> +static int adf4377_clk_is_enabled(struct clk_hw *hw)
> +{
> +       struct adf4377_state *st = to_adf4377_state(hw);
> +       unsigned int readval;
> +       int ret;
> +
> +       ret = regmap_read(st->regmap, 0x1a, &readval);
> +       if (ret)
> +               return ret;
> +
> +       return !(readval & (ADF4377_001A_PD_CLKOUT1_MSK | ADF4377_001A_PD_CLKOUT2_MSK));
> +}
> +
> +static const struct clk_ops adf4377_clk_ops = {
> +       .recalc_rate = adf4377_clk_recalc_rate,
> +       .set_rate = adf4377_clk_set_rate,
> +       .prepare = adf4377_clk_prepare,
> +       .unprepare = adf4377_clk_unprepare,
> +       .is_enabled = adf4377_clk_is_enabled,

In theory .is_enabled shouldn't sleep to match the contract of
.enable/.disable. Probably should change this to .is_prepared?

> +};
> +
> +static int adf4377_clk_register(struct adf4377_state *st)
> +{
> +       struct spi_device *spi = st->spi;
> +       struct clk_init_data init;
> +       struct clk *clk;
> +       const char *parent_name;
> +       int ret;
> +
> +       if (!device_property_present(&spi->dev, "#clock-cells"))
> +               return 0;
> +
> +       if (device_property_read_string(&spi->dev, "clock-output-names", &init.name)) {
> +               init.name = devm_kasprintf(&spi->dev, GFP_KERNEL, "%s-clk",
> +                                          fwnode_get_name(dev_fwnode(&spi->dev)));
> +               if (!init.name)
> +                       return -ENOMEM;
> +       }
> +
> +       parent_name = of_clk_get_parent_name(spi->dev.of_node, 0);
> +       if (!parent_name)
> +               return -EINVAL;
> +
> +       init.ops = &adf4377_clk_ops;
> +       init.parent_names = &parent_name;

We should be able to use clk_parent_data here instead of
of_clk_get_parent_name(). It will require setting the proper DT
node/device when registering the clk but it looks like you're doing that
already.

> +       init.num_parents = 1;
> +       init.flags = CLK_SET_RATE_PARENT;
> +
> +       st->hw.init = &init;
> +       clk = devm_clk_register(&spi->dev, &st->hw);

Please use devm_clk_hw_register()

> +       if (IS_ERR(clk))
> +               return PTR_ERR(clk);
> +
> +       st->clk = clk;
> +
> +       ret = of_clk_add_provider(spi->dev.of_node, of_clk_src_simple_get, clk);

Please add a clk_hw provider. A clk provider isn't typically a clk
consumer of the clk it provides. I think we have devm for that too?

> +       if (ret)
> +               return ret;
> +
> +       st->clkout = clk;
> +
> +       return devm_add_action_or_reset(&spi->dev, adf4377_clk_del_provider, st);
> +}
> +
>  static const struct adf4377_chip_info adf4377_chip_info = {
>         .name = "adf4377",
>         .has_gpio_enclk2 = true,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ