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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250607131905.4e42cbcd@jic23-huawei>
Date: Sat, 7 Jun 2025 13:19:05 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: andriy.shevchenko@...ux.intel.com, Andy Shevchenko <andy@...nel.org>,
 Jonathan Santos <Jonathan.Santos@...log.com>, linux-iio@...r.kernel.org,
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-gpio@...r.kernel.org, linux-acpi@...r.kernel.org, nuno.sa@...log.com,
 Michael.Hennerich@...log.com, marcelo.schmitt@...log.com, robh@...nel.org,
 krzk+dt@...nel.org, conor+dt@...nel.org, marcelo.schmitt1@...il.com,
 linus.walleij@...aro.org, brgl@...ev.pl, lgirdwood@...il.com,
 broonie@...nel.org, dlechner@...libre.com, rafael@...nel.org,
 djrscally@...il.com
Subject: Re: [PATCH v9 09/12] iio: adc: ad7768-1: add support for
 Synchronization over SPI

On Tue, 3 Jun 2025 00:25:40 +0300
Andy Shevchenko <andy.shevchenko@...il.com> wrote:

> Mon, Jun 02, 2025 at 02:15:23PM -0300, Jonathan Santos kirjoitti:
> > On 05/30, Andy Shevchenko wrote:  
> > > On Thu, May 29, 2025 at 07:50:29PM -0300, Jonathan Santos wrote:  
> 
> ...
> 
> > > > +static int ad7768_trigger_sources_sync_setup(struct device *dev,
> > > > +					     struct fwnode_handle *dev_fwnode,
> > > > +					     struct ad7768_state *st)
> > > > +{
> > > > +	struct fwnode_reference_args args;
> > > > +
> > > > +	struct fwnode_handle *fwnode __free(fwnode_handle) =
> > > > +		fwnode_find_reference_args(dev_fwnode, "trigger-sources",
> > > > +					   "#trigger-source-cells", 0,
> > > > +					   AD7768_TRIGGER_SOURCE_SYNC_IDX, &args);  
> > > 
> > > I don't see how args are being used. This puts in doubt the need of the first
> > > patch.  
> > 
> > If the wrapper is the issue, maybe it is better doing this instead?
> > 
> > static int ad7768_trigger_sources_sync_setup(struct device *dev,
> > 					     struct fwnode_handle *dev_fwnode,  
> 
> Name it fwnode...
> 
> > 					     struct ad7768_state *st)
> > {
> > 	struct fwnode_reference_args args;
> > 	struct fwnode_handle *fwnode __free(fwnode_handle) = NULL;  
> 
> ...and this one something like 'ref'. Also I'm not sure the __free() will do
> what you expect from it.
> 
> > 	int ret;
> > 
> > 	ret = fwnode_property_get_reference_args(dev_fwnode, "trigger-sources",
> > 						 "#trigger-source-cells", 0,
> > 						 AD7768_TRIGGER_SOURCE_SYNC_IDX, &args);
> > 	if (ret)
> > 		return ret;
> > 
> > 	fwnode = args.fwnode;  
> 
> Yes, please. This looks better.

Take a look at the guidance in cleanup.h first.  Linus made it very clear
that the = NULL then set it later pattern was not the way to go. That was
one of the things buried deep in a discussion thread soon after the cleanup.h
stuff was proposed and the lack of general knowledge of that preference lead
to Dan adding that documentation to cleanup.h.

If __free is used Linus always wants to see the constructor and destructor in the same line. 

That is why I suggested the approach in patch 1.

If that isn't acceptable (yet), wrap this up in a local function doing the equivalent
of patch 1 and we can wait and see how common this ends up being.

Jonathan


> 
> > > > +	/* First, try getting the GPIO trigger source */
> > > > +	if (fwnode_device_is_compatible(fwnode, "gpio-trigger")) {
> > > > +		st->gpio_sync_in = devm_fwnode_gpiod_get_index(dev, fwnode,
> > > > +							       NULL,
> > > > +							       0,
> > > > +							       GPIOD_OUT_LOW,
> > > > +							       "sync-in");
> > > > +		return PTR_ERR_OR_ZERO(st->gpio_sync_in);
> > > > +	}
> > > > +
> > > > +	/*
> > > > +	 * TODO: Support the other cases when we have a trigger subsystem
> > > > +	 * to reliably handle other types of devices as trigger sources.
> > > > +	 *
> > > > +	 * For now, return an error message. For self triggering, omit the
> > > > +	 * trigger-sources property.
> > > > +	 */
> > > > +	return dev_err_probe(dev, -EOPNOTSUPP, "Invalid synchronization trigger source\n");
> > > > +}  
> > 
> > Then we can get rid of the first patch.  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ