All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Rodrigo Alencar via B4 Relay
	<devnull+rodrigo.alencar.analog.com@kernel.org>
Cc: rodrigo.alencar@analog.com,
	Michael Auchter <michael.auchter@ni.com>,
	linux@analog.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH v6 1/6] iio: dac: ad5686: refactor command/data macros
Date: Mon, 6 Jul 2026 00:29:40 +0100	[thread overview]
Message-ID: <20260706002940.4cb95cbb@jic23-huawei> (raw)
In-Reply-To: <20260705-ad5686-new-features-v6-1-269594c7aae5@analog.com>

On Sun, 05 Jul 2026 12:38:56 +0100
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:

> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> 
> Replace usage of bit shifting macros for FIELD_PREP(), which would not
> ignore bit masking when preparing SPI/I2C commands.
> 
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>

...

> diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> index c424720f8f72..0d1bbf110926 100644
> --- a/drivers/iio/dac/ad5686.h
> +++ b/drivers/iio/dac/ad5686.h
> @@ -14,13 +14,6 @@
>  
>  #include <linux/iio/iio.h>
>  
> -#define AD5310_CMD(x)				((x) << 12)
> -
> -#define AD5683_DATA(x)				((x) << 4)
> -
> -#define AD5686_ADDR(x)				((x) << 16)
> -#define AD5686_CMD(x)				((x) << 20)
> -
>  #define AD5686_ADDR_DAC(chan)			(0x1 << (chan))
>  #define AD5686_ADDR_ALL_DAC			0xF
>  
> @@ -38,12 +31,18 @@
>  #define AD5686_CMD_CONTROL_REG			0x4
>  #define AD5686_CMD_READBACK_ENABLE_V2		0x5
>  
> +#define AD5310_CMD_MSK				GENMASK(15, 12)
> +#define AD5310_DATA_MSK				GENMASK(11, 0)

There is a sashiko bug report on the final patch that got me looking at
these - it's a false positive but took some time to figure out why
it was getting confused.  I think we need to do something to make it
more obvious what is going on..

>  #define AD5310_REF_BIT_MSK			BIT(8)

This is bit 8 of DATA - here DATA is 0 aligned so no mismatch.

>  #define AD5310_PD_MSK				GENMASK(10, 9)
>  
> +#define AD5683_DATA_MSK				GENMASK(19, 4)
>  #define AD5683_REF_BIT_MSK			BIT(12)

and this is bit 12 of AD5683_DATA rather than BIT(12) of the the whole thing
(given the 4 don't care bits.)  

Could either rename things to
#define AD5683_DATA_REF_BIT_MSK() or add a comment on the bit positions
in the overall message - which will then align with the ones of the datasheet.
where ref is DB16.

>  #define AD5683_PD_MSK				GENMASK(14, 13)
>  
> +#define AD5686_CMD_MSK				GENMASK(23, 20)
> +#define AD5686_ADDR_MSK				GENMASK(19, 16)
> +#define AD5686_DATA_MSK				GENMASK(15, 0)
>  #define AD5686_REF_BIT_MSK			BIT(0)
>  #define AD5686_PD_MSK				GENMASK(1, 0)
>  

  parent reply	other threads:[~2026-07-05 23:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 11:38 [PATCH v6 0/6] New features for the AD5686 IIO driver Rodrigo Alencar via B4 Relay
2026-07-05 11:38 ` Rodrigo Alencar
2026-07-05 11:38 ` [PATCH v6 1/6] iio: dac: ad5686: refactor command/data macros Rodrigo Alencar via B4 Relay
2026-07-05 11:38   ` Rodrigo Alencar
2026-07-05 14:24   ` Andy Shevchenko
2026-07-05 23:09     ` Jonathan Cameron
2026-07-05 23:29   ` Jonathan Cameron [this message]
2026-07-05 11:38 ` [PATCH v6 2/6] iio: dac: ad5686: introduce sync operation Rodrigo Alencar via B4 Relay
2026-07-05 11:38   ` Rodrigo Alencar
2026-07-05 11:38 ` [PATCH v6 3/6] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar via B4 Relay
2026-07-05 11:38   ` Rodrigo Alencar
2026-07-05 11:38 ` [PATCH v6 4/6] iio: dac: ad5686: read_raw/write_raw: use guard(mutex)() Rodrigo Alencar via B4 Relay
2026-07-05 11:38   ` Rodrigo Alencar
2026-07-05 11:47   ` sashiko-bot
2026-07-05 11:39 ` [PATCH v6 5/6] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar via B4 Relay
2026-07-05 11:39   ` Rodrigo Alencar
2026-07-05 11:39 ` [PATCH v6 6/6] iio: dac: ad5686: add gain control support Rodrigo Alencar via B4 Relay
2026-07-05 11:39   ` Rodrigo Alencar
2026-07-05 11:50   ` sashiko-bot
2026-07-05 23:30 ` [PATCH v6 0/6] New features for the AD5686 IIO driver Jonathan Cameron

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=20260706002940.4cb95cbb@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+rodrigo.alencar.analog.com@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=michael.auchter@ni.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=rodrigo.alencar@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.