Skip to contentSkip to conversation

regmap: Make reg_field's definition always visible

PATCH New Nathan Chancellor 1 participant 1 message Nov 28 Register map abstraction

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: Make reg_field's definition always visible

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")
---
 include/linux/regmap.h | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
include/linux/regmap.h +17 -17
index 6194948ff9ed..ab43fb603c80 100644
@@ -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,

Signature · 2 lines
Cheers,
Nathan