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: <d35eea56bfef394717611ac43c4e02cd4c813380.camel@gmail.com>
Date: Tue, 18 Jun 2024 11:37:18 +0200
From: Nuno Sá <noname.nuno@...il.com>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>, Michael Turquette
 <mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>, Rob Herring
 <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
 <conor+dt@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>, Michael
 Hennerich <Michael.Hennerich@...log.com>, Jonathan Cameron
 <jic23@...nel.org>,  linux-clk@...r.kernel.org, devicetree@...r.kernel.org,
  linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org
Subject: Re: [PATCH v5 2/2] iio: frequency: adf4350: add clk provider

On Tue, 2024-06-18 at 11:20 +0300, Antoniu Miclaus wrote:
> Add clk provider feature for the adf4350.
> 
> Even though the driver was sent as an IIO driver in most cases the
> device is actually seen as a clock provider.
> 
> This patch aims to cover actual usecases requested by users in order to
> completely control the output frequencies from userspace.
> 
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@...log.com>
> ---

Hi Antoniu,

For some reason your DT patch is missing (or still did not arrived)... Some
comments below.

...
> 
> +static int adf4350_clk_register(struct adf4350_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;
> +
> +	init.name = devm_kasprintf(&spi->dev, GFP_KERNEL, "%s-clk",
> +				   fwnode_get_name(dev_fwnode(&spi->dev)));
> +	if (!init.name)
> +		return -ENOMEM;
> +
> +	if (device_property_read_string(&spi->dev, "clock-output-names",
> +					&init.name))
> +		init.name = spi->dev.of_node->name;

So this means the first devm_kasprintf() is useless :). I believe this should be
	
	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 = &adf4350_clk_ops;
> +	init.parent_names = &parent_name;
> +	init.num_parents = 1;
> +	init.flags = CLK_SET_RATE_PARENT;
> +
> +	st->hw.init = &init;
> +	clk = devm_clk_register(&spi->dev, &st->hw);
> +	if (IS_ERR(clk))
> +		return PTR_ERR(clk);
> +
> +	ret = of_clk_add_provider(spi->dev.of_node, of_clk_src_simple_get,
> clk);
> +	if (ret)
> +		return ret;
> +
> +	st->clkout = clk;
> +
> +	return devm_add_action_or_reset(&spi->dev, adf4350_clk_del_provider,
> st);
> +}
> +
>  static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
>  {
>  	struct adf4350_platform_data *pdata;
> @@ -522,8 +637,6 @@ static int adf4350_probe(struct spi_device *spi)
>  
>  	indio_dev->info = &adf4350_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
> -	indio_dev->channels = &adf4350_chan;
> -	indio_dev->num_channels = 1;
>  
>  	mutex_init(&st->lock);
>  
> @@ -551,6 +664,18 @@ static int adf4350_probe(struct spi_device *spi)
>  			return ret;
>  	}
>  
> +	ret = adf4350_clk_register(st);
> +	if (ret)
> +		return ret;
> +
> +	if (st->clkout) {
> +		indio_dev->channels = NULL;
> +		indio_dev->num_channels = 0;
> +	} else {
> +		indio_dev->channels = &adf4350_chan;
> +		indio_dev->num_channels = 1;
> +	}

nit: The above could be simplied to
if (!st->clkout) {
	indio_dev->channels = &adf4350_chan;
	indio_dev->num_channels = 1;
}

- Nuno Sá


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ