mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Victor Chernyakin <chernyakin.victor.j@outlook.com>,
	 linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] regmap: Make reg_field's definition always visible
Date: Sat, 28 Nov 2026 15:21:48 -0700	[thread overview]
Message-ID: <20261128-regmap-fix-wvisibility-v1-1-9b53e2e85e47@kernel.org> (raw)

When building without CONFIG_REGMAP, there are a few warnings/errors
from stubs because 'struct reg_field' is only defined in a
CONFIG_REGMAP=y block.

  In file included from drivers/regulator/helpers.c:13:
  include/linux/regmap.h:2108:53: warning: 'struct reg_field' declared inside parameter list will not be visible outside of this definition or declaration
   2108 | regmap_reg_field_read(struct regmap *regmap, struct reg_field field,
        |                                                     ^~~~~~~~~
  include/linux/regmap.h:2108:63: error: parameter 2 ('field') has incomplete type
   2108 | regmap_reg_field_read(struct regmap *regmap, struct reg_field field,
        |                                              ~~~~~~~~~~~~~~~~~^~~~~
  include/linux/regmap.h:2108:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
   2108 | regmap_reg_field_read(struct regmap *regmap, struct reg_field field,
        | ^~~~~~~~~~~~~~~~~~~~~
  include/linux/regmap.h:2116:54: warning: 'struct reg_field' declared inside parameter list will not be visible outside of this definition or declaration
   2116 | regmap_reg_field_write(struct regmap *regmap, struct reg_field field,
        |                                                      ^~~~~~~~~
  include/linux/regmap.h:2116:64: error: parameter 2 ('field') has incomplete type
   2116 | regmap_reg_field_write(struct regmap *regmap, struct reg_field field,
        |                                               ~~~~~~~~~~~~~~~~~^~~~~
  include/linux/regmap.h:2116:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
   2116 | regmap_reg_field_write(struct regmap *regmap, struct reg_field field,
        | ^~~~~~~~~~~~~~~~~~~~~~
  cc1: some warnings being treated as errors

Move the definition of 'struct reg_field' out of the CONFIG_REGMAP block
so that it is always defined, clearing up the errors.

Fixes: 39e628387d32 ("regmap: add regmap_reg_field_* APIs")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 include/linux/regmap.h | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 6194948ff9ed..ab43fb603c80 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -212,6 +212,23 @@ struct reg_sequence {
 	__ret ?: __tmp; \
 })
 
+/**
+ * struct reg_field - Description of an register field
+ *
+ * @reg: Offset of the register within the regmap bank
+ * @lsb: lsb of the register field.
+ * @msb: msb of the register field.
+ * @id_size: port size if it has some ports
+ * @id_offset: address offset for each ports
+ */
+struct reg_field {
+	unsigned int reg;
+	unsigned int lsb;
+	unsigned int msb;
+	unsigned int id_size;
+	unsigned int id_offset;
+};
+
 #ifdef CONFIG_REGMAP
 
 enum regmap_endian {
@@ -1454,23 +1471,6 @@ static inline int regmap_assign_bits(struct regmap *map, unsigned int reg,
 
 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
 
-/**
- * struct reg_field - Description of an register field
- *
- * @reg: Offset of the register within the regmap bank
- * @lsb: lsb of the register field.
- * @msb: msb of the register field.
- * @id_size: port size if it has some ports
- * @id_offset: address offset for each ports
- */
-struct reg_field {
-	unsigned int reg;
-	unsigned int lsb;
-	unsigned int msb;
-	unsigned int id_size;
-	unsigned int id_offset;
-};
-
 #define REG_FIELD(_reg, _lsb, _msb) ((struct reg_field){ \
 				.reg = _reg,		 \
 				.lsb = _lsb,		 \

---
base-commit: 222b61e9c570dac6c7a786d039e4c226624b426d
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261128-regmap-fix-wvisibility-d3b884f4c723

Best regards,
--  
Cheers,
Nathan


                 reply	other threads:[~2026-11-28 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261128-regmap-fix-wvisibility-v1-1-9b53e2e85e47@kernel.org \
    --to=nathan@kernel.org \
    --cc=broonie@kernel.org \
    --cc=chernyakin.victor.j@outlook.com \
    --cc=linux-kernel@vger.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®