From: Jonathan Cameron <jic23@kernel.org>
To: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Michal Simek" <michal.simek@amd.com>,
"Conall O'Griofa" <conall.ogriofa@amd.com>,
linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, git@amd.com,
"Sai Krishna Potthuri" <sai.krishna.potthuri@amd.com>
Subject: Re: [PATCH v5 05/16] iio: adc: xilinx-xadc: Use bitfield helpers and bit macros
Date: Fri, 13 Nov 2026 03:07:11 +0000 [thread overview]
Message-ID: <20261113030711.3deb9cde@jic23-hlaptop> (raw)
In-Reply-To: <20261110050201.1850399-6-dileepkumar.nagavarapu@amd.com>
On Tue, 10 Nov 2026 10:31:50 +0530
Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com> wrote:
> Replace open-coded bit manipulation with FIELD_GET(),
> FIELD_PREP(), BIT(), and GENMASK() helpers.
>
> Using the kernel bitfield helpers improves readability and
> makes bit operations less error-prone.
>
> No functional changes intended.
>
> Co-developed-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> Signed-off-by: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
Sashiko seems to have found an issue. Looks plausible to me.
https://sashiko.dev/#/patchset/20261110050201.1850399-1-dileepkumar.nagavarapu%40amd.com
> ---
> drivers/iio/adc/xilinx-xadc-core.c | 50 ++++++++++++++++++------------
> drivers/iio/adc/xilinx-xadc.h | 29 +++++++++--------
> 2 files changed, 46 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
> index 66c6f3319ca0..eb63675464bb 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -11,6 +11,8 @@
> * - AXI XADC interface: Xilinx PG019
> */
>
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> #include <linux/clk.h>
> #include <linux/device.h>
> #include <linux/err.h>
> @@ -47,28 +49,28 @@ static const unsigned int XADC_ZYNQ_UNMASK_TIMEOUT = 500;
> #define XADC_ZYNQ_REG_CTL 0x18
>
> #define XADC_ZYNQ_CFG_ENABLE BIT(31)
> -#define XADC_ZYNQ_CFG_CFIFOTH_MASK (0xf << 20)
> +#define XADC_ZYNQ_CFG_CFIFOTH_MASK GENMASK(23, 20)
> #define XADC_ZYNQ_CFG_CFIFOTH_OFFSET 20
> -#define XADC_ZYNQ_CFG_DFIFOTH_MASK (0xf << 16)
> +#define XADC_ZYNQ_CFG_DFIFOTH_MASK GENMASK(19, 16)
> #define XADC_ZYNQ_CFG_DFIFOTH_OFFSET 16
As part of this patch I'd expect the changes to FIELD_PREP()
and FIELD_GET() to remove the need for these offsets.
This one is no longer used for example. I'd expect almost all
if not all the _OFFSET defines to be dropped.
Many of them weren't used in the first place. I didn't track
down if any are still used after this patch.
> #define XADC_ZYNQ_CFG_WEDGE BIT(13)
> #define XADC_ZYNQ_CFG_REDGE BIT(12)
> -#define XADC_ZYNQ_CFG_TCKRATE_MASK (0x3 << 8)
> -#define XADC_ZYNQ_CFG_TCKRATE_DIV2 (0x0 << 8)
>
> @@ -822,7 +832,7 @@ static int xadc_preenable(struct iio_dev *indio_dev)
> int ret;
>
> ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_SEQ_MASK,
> - XADC_CONF1_SEQ_DEFAULT);
> + FIELD_PREP(XADC_CONF1_SEQ_MASK, XADC_CONF1_SEQ_DEFAULT));
> if (ret)
> goto err;
>
Sashiko calls out there is another write of CONF1 later in the function that still
seems to be using the prior approach rather than FIELD_PREP().
> diff --git a/drivers/iio/adc/xilinx-xadc.h b/drivers/iio/adc/xilinx-xadc.h
> index fb911ed87600..f5bf2d08eedc 100644
> --- a/drivers/iio/adc/xilinx-xadc.h
> +++ b/drivers/iio/adc/xilinx-xadc.h
> @@ -9,6 +9,7 @@
>
> -#define XADC_CONF2_DIV_MASK 0xff00
> +#define XADC_CONF2_DIV_MASK GENMASK(15, 8)
> #define XADC_CONF2_DIV_OFFSET 8
Similar to above, I'd expect us to not need the _OFFSET defines
after moving to FIELD_PREP/GET()
next prev parent reply other threads:[~2026-11-13 3:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 5:01 [PATCH v5 00/16] iio: adc: xilinx-xadc: Add I2C interface support for System Management Wizard Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 01/16] iio: adc: xilinx-xadc: Correct write edge in CFG Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 02/16] iio: adc: xilinx-xadc: Fix coding style issues Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 03/16] iio: adc: xilinx-xadc: Use kernel integer types Dileep Kumar Nagavarapu
2026-11-10 11:15 ` Joshua Crofts
2026-11-10 5:01 ` [PATCH v5 04/16] iio: adc: xilinx-xadc: Drop unnecessary masking and dead code Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 05/16] iio: adc: xilinx-xadc: Use bitfield helpers and bit macros Dileep Kumar Nagavarapu
2026-11-13 3:07 ` Jonathan Cameron [this message]
2026-11-10 5:01 ` [PATCH v5 06/16] iio: adc: xilinx-xadc: Use guard()/scoped_guard() for spinlock locking Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 07/16] iio: adc: xilinx-xadc: Use guard() for mutex locking Dileep Kumar Nagavarapu
2026-11-10 16:13 ` Andy Shevchenko
2026-11-10 5:01 ` [PATCH v5 08/16] iio: adc: xilinx-xadc: Simplify common coding patterns Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 09/16] iio: adc: xilinx-xadc: Add unit suffixes to macro names Dileep Kumar Nagavarapu
2026-11-10 16:18 ` Andy Shevchenko
2026-11-10 5:01 ` [PATCH v5 10/16] iio: adc: xilinx-xadc: Include appropriate header files Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 11/16] iio: adc: xilinx-xadc: Add clarifying comments Dileep Kumar Nagavarapu
2026-11-10 5:01 ` [PATCH v5 12/16] iio: adc: xilinx-xadc: Refine Zynq read/write error handling on timeout/interrupt Dileep Kumar Nagavarapu
2026-11-10 16:21 ` Andy Shevchenko
2026-11-10 5:01 ` [PATCH v5 13/16] iio: adc: xilinx-xadc: Add helper functions for the device setup Dileep Kumar Nagavarapu
2026-11-10 16:25 ` Andy Shevchenko
2026-11-10 5:01 ` [PATCH v5 14/16] iio: adc: xilinx-xadc: Split driver into core and platform files Dileep Kumar Nagavarapu
2026-11-10 16:29 ` Andy Shevchenko
2026-11-13 3:16 ` Jonathan Cameron
2026-11-10 5:02 ` [PATCH v5 15/16] iio: adc: xilinx-xadc: Add .setup_channels() to struct xadc_ops Dileep Kumar Nagavarapu
2026-11-10 5:02 ` [PATCH v5 16/16] iio: adc: xilinx-xadc: Add I2C interface support Dileep Kumar Nagavarapu
2026-11-10 16:34 ` Andy Shevchenko
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=20261113030711.3deb9cde@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conall.ogriofa@amd.com \
--cc=dileepkumar.nagavarapu@amd.com \
--cc=dlechner@baylibre.com \
--cc=git@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=nuno.sa@analog.com \
--cc=sai.krishna.potthuri@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®