From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Mark Brown <broonie@kernel.org>, Peng Fan <peng.fan@nxp.com>,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Johan Hovold <johan@kernel.org>,
Victor Chernyakin <chernyakin.victor.j@outlook.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/1] regmap: Add REG_FIELD_GENMASK() helper macro
Date: Thu, 5 Nov 2026 11:34:54 +0100 [thread overview]
Message-ID: <20261105103533.1426533-1-andriy.shevchenko@linux.intel.com> (raw)
One time in regmap and already a few times over the whole kernel
the users want to extract a mask from the regmap field data type.
Provide a helper and convert regmap core to use it. Others may
follow later on.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Inspired by a patch SN1PR12MB25282EC93A27F3577BB9B454A5772@SN1PR12MB2528.namprd12.prod.outlook.com
that leaves the driver to handle the custom macro for that.
drivers/base/regmap/regmap.c | 2 +-
include/linux/regmap.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 83f1f5942135..48e96bc9e7b6 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1215,7 +1215,7 @@ static void regmap_field_init(struct regmap_field *rm_field,
rm_field->regmap = regmap;
rm_field->reg = reg_field.reg;
rm_field->shift = reg_field.lsb;
- rm_field->mask = GENMASK(reg_field.msb, reg_field.lsb);
+ rm_field->mask = REG_FIELD_GENMASK(reg_field);
WARN_ONCE(rm_field->mask == 0, "invalid empty mask defined\n");
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index a72f17ab6264..8f3034881f8a 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -10,6 +10,7 @@
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
*/
+#include <linux/bits.h>
#include <linux/bug.h>
#include <linux/cleanup.h>
#include <linux/delay.h>
@@ -1477,6 +1478,8 @@ struct reg_field {
.id_offset = _offset, \
}
+#define REG_FIELD_GENMASK(_reg_field) GENMASK(_reg_field.msb, _reg_field.lsb)
+
struct regmap_field *regmap_field_alloc(struct regmap *regmap,
struct reg_field reg_field);
void regmap_field_free(struct regmap_field *field);
--
2.50.1
next reply other threads:[~2026-11-05 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 10:34 Andy Shevchenko [this message]
2026-11-05 15:39 ` Victor Chernyakin
2026-11-05 17:54 ` Andy Shevchenko
2026-11-05 23:10 ` Victor Chernyakin
2026-11-05 23:26 ` Victor Chernyakin
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=20261105103533.1426533-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=chernyakin.victor.j@outlook.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=rafael@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®