All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux@analog.com, linux-iio@vger.kernel.org
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters
Date: Tue, 17 Nov 2026 17:08:43 +0100	[thread overview]
Message-ID: <20261117160857.1799863-1-andriy.shevchenko@linux.intel.com> (raw)

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


             reply	other threads:[~2026-11-17 16:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:08 Andy Shevchenko [this message]
2026-11-18  7:36 ` [PATCH v2 1/1] iio: dac: ad5766: Convert GENMASK() to use static parameters Siratul Islam

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=20261117160857.1799863-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=nuno.sa@analog.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 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.