* [PATCH] staging: iio: frequency: ad9832: Replace macro AD9832_PHASE() with function
@ 2023-01-18 15:03 Brent Pappas
2023-01-18 15:10 ` Dan Carpenter
2023-01-18 15:12 ` Jonathan Cameron
0 siblings, 2 replies; 3+ messages in thread
From: Brent Pappas @ 2023-01-18 15:03 UTC (permalink / raw)
To: lars
Cc: Michael.Hennerich, jic23, gregkh, linux-iio, linux-staging,
linux-kernel, Brent Pappas
Replace the macro AD9832_PHASE() with a static function to comply with
Linux coding style standards.
Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
---
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);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: iio: frequency: ad9832: Replace macro AD9832_PHASE() with function
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
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-01-18 15:10 UTC (permalink / raw)
To: Brent Pappas
Cc: lars, Michael.Hennerich, jic23, gregkh, linux-iio, linux-staging,
linux-kernel
On Wed, Jan 18, 2023 at 10:03:06AM -0500, Brent Pappas 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>
> ---
> 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; }
The original is fine here. Just leave it as-is.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: iio: frequency: ad9832: Replace macro AD9832_PHASE() with function
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
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2023-01-18 15:12 UTC (permalink / raw)
To: Brent Pappas
Cc: lars, Michael.Hennerich, jic23, gregkh, linux-iio, linux-staging,
linux-kernel
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);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-18 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).