* [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; 2+ 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] 2+ 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
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2026-11-18 7:36 UTC | newest]
Thread overview: 2+ 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.