linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Brent Pappas <bpappas@pappasbrent.com>
Cc: <lars@metafoo.de>, <Michael.Hennerich@analog.com>,
	<jic23@kernel.org>, <gregkh@linuxfoundation.org>,
	<linux-iio@vger.kernel.org>, <linux-staging@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: iio: frequency: ad9832: Replace macro AD9832_PHASE() with function
Date: Wed, 18 Jan 2023 15:12:57 +0000	[thread overview]
Message-ID: <20230118151257.0000663a@Huawei.com> (raw)
In-Reply-To: <20230118150306.16448-1-bpappas@pappasbrent.com>

On Wed, 18 Jan 2023 10:03:06 -0500
Brent Pappas <bpappas@pappasbrent.com> wrote:

> Replace the macro AD9832_PHASE() with a static function to comply with
> Linux coding style standards.
> 
> Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>

Hi Brent,

I'd rather see this changed to FIELD_GET() / FIELD_PREP() along
with all other similar cases in this driver.

That would mean defining just the field masks then using those
to mask relevant bits out and put in the new value.

Thanks

Jonathan


> ---
>  drivers/staging/iio/frequency/ad9832.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index 6f9eebd6c7ee..537825534a28 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -59,7 +59,9 @@
>  #define AD9832_CMD_SLEEPRESCLR	0xC
>  
>  #define AD9832_FREQ		BIT(11)
> -#define AD9832_PHASE(x)		(((x) & 3) << 9)
> +
> +static unsigned short ad9832_phase(int x) { return (x & 3) << 9; }
> +
>  #define AD9832_SYNC		BIT(13)
>  #define AD9832_SELSRC		BIT(12)
>  #define AD9832_SLEEP		BIT(13)
> @@ -221,8 +223,8 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr,
>  			break;
>  		}
>  
> -		st->ctrl_fp &= ~AD9832_PHASE(3);
> -		st->ctrl_fp |= AD9832_PHASE(val);
> +		st->ctrl_fp &= ~ad9832_phase(3);
> +		st->ctrl_fp |= ad9832_phase(val);
>  
>  		st->data = cpu_to_be16((AD9832_CMD_FPSELECT << CMD_SHIFT) |
>  					st->ctrl_fp);


      parent reply	other threads:[~2023-01-18 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 15:03 [PATCH] staging: iio: frequency: ad9832: Replace macro AD9832_PHASE() with function Brent Pappas
2023-01-18 15:10 ` Dan Carpenter
2023-01-18 15:12 ` 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=20230118151257.0000663a@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=bpappas@pappasbrent.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).