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]
Date:   Sun, 22 May 2022 11:44:33 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Tomas Melin <tomas.melin@...sala.com>
Cc:     LI Qingwu <Qing-wu.Li@...ca-geosystems.com.cn>, lars@...afoo.de,
        robh+dt@...nel.org, andy.shevchenko@...il.com,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-iio@...r.kernel.org
Subject: Re: [PATCH V6 3/5] iio: accel: sca3300: modified to support multi
 chips

> >> +static int sca3300_set_frequency(struct sca3300_data *data, int val)
> >> +{
> >> +	const struct sca3300_chip_info *chip = data->chip;
> >> +	unsigned int index;
> >> +	unsigned int i;
> >> +
> >> +	if (sca3300_get_op_mode(data, &index))
> >> +		return -EINVAL;
> >> +
> >> +	for (i = 0; i < chip->num_avail_modes; i++) {
> >> +		if ((val == chip->freq_table[chip->freq_map[i]]) &&  
> > 
> > The conditions being checked here are far from obvious, so I think this would benefit
> > from an explanatory comment.
> > 
> > Something along the lines of,
> > "Find a mode in which the requested sampling frequency is available
> >  and the scaling currently set is retained".  
> 
> 
> In addition to a comment, how about small restructure of loop and giving
> local variables that tell the purpose, something like
> 
> 
> ...
> 
> unsigned int opmode_scale, new_scale;
> 
> opmode_scale = chip->accel_scale[chip->accel_scale_map[index]];
> 
> /*
> * Find a mode in which the requested sampling frequency is available
> * and the scaling currently set is retained
> */
> for (i = 0; i < chip->num_avail_modes; i++) {
>     if (val == chip->freq_table[chip->freq_map[i]]) {
>         new_scale = chip->accel_scale[chip->accel_scale_map[i]]);	
>         if (opmode_scale == new_scale)
>             break;
>     }
> }
> 
> 
> That way it's IMHO more clear what we are comparing.
LGTM.

Thanks,

Jonathan

> 
> Thanks,
> Tomas

Powered by blists - more mailing lists