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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260116193236.55954b67@jic23-huawei>
Date: Fri, 16 Jan 2026 19:32:36 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: Francesco Lavra <flavra@...libre.com>, Ramona Gradinariu
 <ramona.gradinariu@...log.com>, Antoniu Miclaus
 <antoniu.miclaus@...log.com>, Lars-Peter Clausen <lars@...afoo.de>, Michael
 Hennerich <Michael.Hennerich@...log.com>, David Lechner
 <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, Andy
 Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function
 for activity detection

On Thu, 15 Jan 2026 22:28:05 +0200
Andy Shevchenko <andriy.shevchenko@...el.com> wrote:

> On Thu, Jan 15, 2026 at 06:53:49PM +0100, Francesco Lavra wrote:
> > Motion detection functionalities (such as activity and inactivity
> > detection) are only available when the chip is in a low-power mode; this
> > affects the available sampling frequency values.
> > In preparation for adding support for a new frequency value, introduce a
> > helper function that checks whether activity/inactivity detection is
> > currently enabled; this function will be reused in a future commit to
> > determine what frequency values are available at any given time.
> > No functional changes.  
> 
> ...
> 
> > +static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
> > +{
> > +	unsigned int act_inact_ctl;
> > +	int ret;
> > +
> > +	if (!st->chip_info->has_low_power) {
> > +		*enabled = false;
> > +		return 0;
> > +	}
> > +
> > +	ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);  
> 
> > +	if (!ret)  
> 
> What's wrong with the standard pattern?
> 
> 	if (ret)
> 		return ret;
> 
> > +		*enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
> > +			   FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
> > +
> > +	return ret;  
> 
> 	return 0;
> 
Fully agreed. Whilst it's a tiny bit longer, it is a lot more consistent
to always handle errors out of line and good flow inline.

Jonathan

> > +}  
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ