Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: Siddharth Menon <simeddon@gmail.com>,
	linux-iio@vger.kernel.org, lars@metafoo.de,
	Michael.Hennerich@analog.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH v6] iio: frequency: ad9832: Use FIELD_PREP macro to set bit fields
Date: Mon, 14 Apr 2025 19:53:11 +0100	[thread overview]
Message-ID: <20250414195311.6a406c35@jic23-huawei> (raw)
In-Reply-To: <Z_v93dtgks2CquIn@debian-BULLSEYE-live-builder-AMD64>

On Sun, 13 Apr 2025 15:09:33 -0300
Marcelo Schmitt <marcelo.schmitt1@gmail.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@gmail.com>
> > Signed-off-by: Siddharth Menon <simeddon@gmail.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


      reply	other threads:[~2025-04-14 18:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-13 11:58 [PATCH v6] iio: frequency: ad9832: Use FIELD_PREP macro to set bit fields Siddharth Menon
2025-04-13 17:44 ` Marcelo Schmitt
2025-04-13 18:09 ` Marcelo Schmitt
2025-04-14 18:53   ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250414195311.6a406c35@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=simeddon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox