From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Torreno, Alexis Czezar" <AlexisCzezar.Torreno@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Sa, Nuno" <Nuno.Sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] iio: dac: ad5706r: Add support for AD5706R DAC
Date: Thu, 12 Mar 2026 15:03:42 +0200 [thread overview]
Message-ID: <abK5rhAP_w3GzD8u@ashevche-desk.local> (raw)
In-Reply-To: <PH0PR03MB63519615ACE22ADE4055D2DBF144A@PH0PR03MB6351.namprd03.prod.outlook.com>
On Thu, Mar 12, 2026 at 02:32:21AM +0000, Torreno, Alexis Czezar wrote:
...
> > > + st->tx_buf = cpu_to_be32((((u32)reg) << 16) |
> > > + ((u32)val << (16 - (num_bytes * 8))));
> >
> > What the heck is this?
>
> I'll make this more readable.
The problems with the above are:
- macro style (it's not a macro, no need so many parentheses)
- unneeded castings (C promotes types to int)
- "clever" compression of the standard patterns (see below)
> but the format goal is:
>
> if num_bytes = 1
> tx_buf [31:0] = [reg 31:16] [val 15:8] [ XXXX]
> if num_bytes = 2
> tx_buf [31:0] = [reg 31:16] [ val 15:0 ]
Assuming tx->buf is of u8:
put_unaligned_be16(reg, &st->tx_buf[0]);
if ( == 1)
st->tx_buf[2] = val;
else if ( == 2)
put_unaligned_be16(val, &st->tx_buf[2]);
else
ERR!
(can also be switch-case, but it will be more verbose).
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-03-12 13:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 0:23 [PATCH v2 0/3] " Alexis Czezar Torreno
2026-03-11 0:23 ` [PATCH v2 1/3] dt-bindings: iio: dac: Add binding for AD5706R Alexis Czezar Torreno
2026-03-11 0:48 ` Torreno, Alexis Czezar
2026-03-11 0:23 ` [PATCH v2 2/3] iio: dac: ad5706r: Add support for AD5706R DAC Alexis Czezar Torreno
2026-03-11 11:44 ` Andy Shevchenko
2026-03-12 2:32 ` Torreno, Alexis Czezar
2026-03-12 13:03 ` Andy Shevchenko [this message]
2026-03-11 0:23 ` [PATCH v2 3/3] MAINTAINERS: Add entry for AD5706R DAC driver Alexis Czezar Torreno
2026-03-11 11:36 ` Andy Shevchenko
2026-03-11 11:38 ` [PATCH v2 0/3] Add support for AD5706R DAC Andy Shevchenko
2026-03-13 9:35 ` Uwe Kleine-König
2026-03-18 4:48 ` Torreno, Alexis Czezar
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=abK5rhAP_w3GzD8u@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=AlexisCzezar.Torreno@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=Nuno.Sa@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ukleinek@kernel.org \
/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®