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: <20250414195311.6a406c35@jic23-huawei>
Date: Mon, 14 Apr 2025 19:53:11 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Marcelo Schmitt <marcelo.schmitt1@...il.com>
Cc: Siddharth Menon <simeddon@...il.com>, linux-iio@...r.kernel.org,
 lars@...afoo.de, Michael.Hennerich@...log.com, gregkh@...uxfoundation.org,
 linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev
Subject: Re: [PATCH v6] iio: frequency: ad9832: Use FIELD_PREP macro to set
 bit fields

On Sun, 13 Apr 2025 15:09:33 -0300
Marcelo Schmitt <marcelo.schmitt1@...il.com> wrote:

> Hi Siddharth,
> 
> Your patch looks good to me and I keep the review tag offered on the other email.
> One small thing I noticed right before closing the driver. See comments below.
> 
> On 04/13, Siddharth Menon wrote:
> > Use bitfield and bitmask macros to clearly specify AD9832 SPI
> > command fields to make register write code more readable.
> > 
> > Suggested-by: Marcelo Schmitt <marcelo.schmitt1@...il.com>
> > Signed-off-by: Siddharth Menon <simeddon@...il.com>
> > ---  
> ...
> > +
> > +		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_SYNCSELSRC) |
> >  					st->ctrl_ss);  
> I think st->ctrl_ss alignment with the preceding parenthesis could also have
> been adjusted since the patch is updating the very same assignment.
> 		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_SYNCSELSRC) |
> 						  st->ctrl_ss);
> There are some other places where similar change could be done but these are
> probably not a reason for a v7.
Good spot.

I'd like these cleaned up. I could do it whilst applying but as there are quite a few of
them it is probably quicker to send me a v7 ;)

Jonathan

> 
> >  		ret = spi_sync(st->spi, &st->msg);
> >  		break;  
> ...
> > -		st->data = cpu_to_be16((AD9832_CMD_FPSELECT << CMD_SHIFT) |
> > +		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_FPSELECT) |
> >  					st->ctrl_fp);  
> This one would have become 
> 		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_FPSELECT) |
> 						  st->ctrl_fp);
> 
> >  		ret = spi_sync(st->spi, &st->msg);
> >  		break;  
> ...
> > -		st->data = cpu_to_be16((AD9832_CMD_FPSELECT << CMD_SHIFT) |
> > +		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_FPSELECT) |
> >  					st->ctrl_fp);  
> Same here
> >  		ret = spi_sync(st->spi, &st->msg);
> >  		break;  
> ...
> >  
> > -		st->data = cpu_to_be16((AD9832_CMD_SLEEPRESCLR << CMD_SHIFT) |
> > +		st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_SLEEPRESCLR) |
> >  					st->ctrl_src);  
> ditto
> 
> >  		ret = spi_sync(st->spi, &st->msg);
> >  		break;
> > @@ -396,7 +400,7 @@ static int ad9832_probe(struct spi_device *spi)
> >  	spi_message_add_tail(&st->phase_xfer[1], &st->phase_msg);
> >  
> >  	st->ctrl_src = AD9832_SLEEP | AD9832_RESET | AD9832_CLR;
> > -	st->data = cpu_to_be16((AD9832_CMD_SLEEPRESCLR << CMD_SHIFT) |
> > +	st->data = cpu_to_be16(FIELD_PREP(AD9832_CMD_MSK, AD9832_CMD_SLEEPRESCLR) |
> >  					st->ctrl_src);  
> ditto
> 
> Regards,
> Marcelo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ