From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Marcelo Machado Lage <marcelomlage@usp.br>
Cc: andy@kernel.org, dlechner@baylibre.com, jic23@kernel.org,
nuno.sa@analog.com, Vinicius Lira <vinilira@usp.br>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: adc: mcp3422: write bit operations with bitfield.h macros
Date: Mon, 20 Apr 2026 23:24:51 +0300 [thread overview]
Message-ID: <aeaLk7Cmhp7faQYn@ashevche-desk.local> (raw)
In-Reply-To: <20260420191455.529923-3-marcelomlage@usp.br>
On Mon, Apr 20, 2026 at 04:14:55PM -0300, Marcelo Machado Lage wrote:
> Replace manual bit manipulations with FIELD_GET(), FIELD_PREP() and
> FIELD_MODIFY() calls. The resulting code is more readable and
> maintainable, and 6 macros previously defined in the header are not
> needed anymore.
...
> /* meaningful default configuration */
> config = (MCP3422_CONT_SAMPLING
> - | MCP3422_CHANNEL_VALUE(0)
> - | MCP3422_PGA_VALUE(MCP3422_PGA_1)
> - | MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240));
> + | FIELD_PREP(MCP3422_CHANNEL_MASK, 0)
> + | FIELD_PREP(MCP3422_PGA_MASK, MCP3422_PGA_1)
> + | FIELD_PREP(MCP3422_SRATE_MASK, MCP3422_SRATE_240));
While at it, please fix the style by making the operator to be the last on
the respective lines.
config = MCP3422_CONT_SAMPLING |
FIELD_PREP(MCP3422_CHANNEL_MASK, 0) |
FIELD_PREP(MCP3422_PGA_MASK, MCP3422_PGA_1) |
FIELD_PREP(MCP3422_SRATE_MASK, MCP3422_SRATE_240));
But, to me sounds better if you just resplit it it to
config = MCP3422_CONT_SAMPLING;
FIELD_MODIFY(...);
FIELD_MODIFY(...);
FIELD_MODIFY(...);
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-04-20 20:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 19:14 [PATCH v3 0/2] iio: adc: mcp3422: apply bit manipulation macros Marcelo Machado Lage
2026-04-20 19:14 ` [PATCH v3 1/2] iio: adc: mcp3422: rewrite mask macros using bits.h macros Marcelo Machado Lage
2026-04-20 19:14 ` [PATCH v3 2/2] iio: adc: mcp3422: write bit operations with bitfield.h macros Marcelo Machado Lage
2026-04-20 20:24 ` Andy Shevchenko [this message]
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=aeaLk7Cmhp7faQYn@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=marcelomlage@usp.br \
--cc=nuno.sa@analog.com \
--cc=vinilira@usp.br \
/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