* [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters
@ 2026-11-17 16:08 Andy Shevchenko
2026-11-18 7:36 ` Siratul Islam
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-11-17 16:08 UTC (permalink / raw)
To: linux, linux-iio
Cc: Nuno Sá, Michael Hennerich, Jonathan Cameron, David Lechner,
Andy Shevchenko, Andy Shevchenko
There is no need to use run-time calculated masks in the code. Besides,
GENMASK() over non-static parameters might lead compiler to generate
much worse code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fixed typo
drivers/iio/dac/ad5766.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/ad5766.c b/drivers/iio/dac/ad5766.c
index 061b43fc0345..ba6c54e2c9ac 100644
--- a/drivers/iio/dac/ad5766.c
+++ b/drivers/iio/dac/ad5766.c
@@ -18,9 +18,9 @@
#define AD5766_UPPER_WORD_SPI_MASK GENMASK(31, 16)
#define AD5766_LOWER_WORD_SPI_MASK GENMASK(15, 0)
-#define AD5766_DITHER_SOURCE_MASK(ch) GENMASK(((2 * ch) + 1), (2 * ch))
+#define AD5766_DITHER_SOURCE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
#define AD5766_DITHER_SOURCE(ch, source) BIT((ch * 2) + source)
-#define AD5766_DITHER_SCALE_MASK(x) AD5766_DITHER_SOURCE_MASK(x)
+#define AD5766_DITHER_SCALE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
#define AD5766_DITHER_SCALE(ch, scale) (scale << (ch * 2))
#define AD5766_DITHER_ENABLE_MASK(ch) BIT(ch)
#define AD5766_DITHER_ENABLE(ch, state) ((!state) << ch)
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters
2026-11-17 16:08 [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters Andy Shevchenko
@ 2026-11-18 7:36 ` Siratul Islam
2026-11-19 19:44 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Siratul Islam @ 2026-11-18 7:36 UTC (permalink / raw)
To: Andy Shevchenko, linux, linux-iio
Cc: Nuno Sá, Michael Hennerich, Jonathan Cameron, David Lechner,
Andy Shevchenko
On Tue, 2026-11-17 at 17:08 +0100, Andy Shevchenko wrote:
> There is no need to use run-time calculated masks in the code. Besides,
> GENMASK() over non-static parameters might lead compiler to generate
> much worse code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>
> v2: fixed typo
>
> drivers/iio/dac/ad5766.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5766.c b/drivers/iio/dac/ad5766.c
> index 061b43fc0345..ba6c54e2c9ac 100644
> --- a/drivers/iio/dac/ad5766.c
> +++ b/drivers/iio/dac/ad5766.c
> @@ -18,9 +18,9 @@
>
> #define AD5766_UPPER_WORD_SPI_MASK GENMASK(31, 16)
> #define AD5766_LOWER_WORD_SPI_MASK GENMASK(15, 0)
> -#define AD5766_DITHER_SOURCE_MASK(ch) GENMASK(((2 * ch) + 1), (2 * ch))
> +#define AD5766_DITHER_SOURCE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
> #define AD5766_DITHER_SOURCE(ch, source) BIT((ch * 2) + source)
> -#define AD5766_DITHER_SCALE_MASK(x) AD5766_DITHER_SOURCE_MASK(x)
> +#define AD5766_DITHER_SCALE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
This could have remained unchanged?
> #define AD5766_DITHER_SCALE(ch, scale) (scale << (ch * 2))
> #define AD5766_DITHER_ENABLE_MASK(ch) BIT(ch)
> #define AD5766_DITHER_ENABLE(ch, state) ((!state) << ch)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters
2026-11-18 7:36 ` Siratul Islam
@ 2026-11-19 19:44 ` Andy Shevchenko
2026-11-19 20:07 ` Siratul Islam
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-11-19 19:44 UTC (permalink / raw)
To: Siratul Islam
Cc: linux, linux-iio, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, Andy Shevchenko
On Wed, Nov 18, 2026 at 01:36:42PM +0600, Siratul Islam wrote:
> On Tue, 2026-11-17 at 17:08 +0100, Andy Shevchenko wrote:
> > There is no need to use run-time calculated masks in the code. Besides,
> > GENMASK() over non-static parameters might lead compiler to generate
> > much worse code.
...
> > #define AD5766_UPPER_WORD_SPI_MASK GENMASK(31, 16)
> > #define AD5766_LOWER_WORD_SPI_MASK GENMASK(15, 0)
> > -#define AD5766_DITHER_SOURCE_MASK(ch) GENMASK(((2 * ch) + 1), (2 * ch))
> > +#define AD5766_DITHER_SOURCE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
> > #define AD5766_DITHER_SOURCE(ch, source) BIT((ch * 2) + source)
> > -#define AD5766_DITHER_SCALE_MASK(x) AD5766_DITHER_SOURCE_MASK(x)
> > +#define AD5766_DITHER_SCALE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
> This could have remained unchanged?
Yes i could, but does it really show the tightness between two semantically?
I believe it's not, that's why I explicitly put the numbers instead of
indirection.
> > #define AD5766_DITHER_SCALE(ch, scale) (scale << (ch * 2))
> > #define AD5766_DITHER_ENABLE_MASK(ch) BIT(ch)
> > #define AD5766_DITHER_ENABLE(ch, state) ((!state) << ch)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters
2026-11-19 19:44 ` Andy Shevchenko
@ 2026-11-19 20:07 ` Siratul Islam
0 siblings, 0 replies; 4+ messages in thread
From: Siratul Islam @ 2026-11-19 20:07 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux, linux-iio, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, Andy Shevchenko
November 20, 2026 at 1:44 AM, "Andy Shevchenko" <andriy.shevchenko@linux.intel.com> wrote:
>
...
> > -#define AD5766_DITHER_SCALE_MASK(x) AD5766_DITHER_SOURCE_MASK(x)
> > +#define AD5766_DITHER_SCALE_MASK(ch) (GENMASK(1, 0) << ((ch) * 2))
> > This could have remained unchanged?
> >
> Yes i could, but does it really show the tightness between two semantically?
> I believe it's not, that's why I explicitly put the numbers instead of
> indirection.
Thats fair.
Reviewed-by: Siratul Islam <siratul.islam@linux.dev>
Best regards,
Sirat
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 20:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 16:08 [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters Andy Shevchenko
2026-11-18 7:36 ` Siratul Islam
2026-11-19 19:44 ` Andy Shevchenko
2026-11-19 20:07 ` Siratul Islam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox