Skip to contentSkip to conversation

regmap: make range check functions static

PATCH In review Rasmus Villemoes 3 participants 4 messages Mar 28, 2022 – Apr 12, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: make range check functions static

regmap_reg_in_ranges() and regmap_check_range_table() have no callers outside regmap.c, so they have no reason to be exported nor have external linkage.

---
 drivers/base/regmap/regmap.c | 12 +++++-------
 include/linux/regmap.h       |  7 -------
 2 files changed, 5 insertions(+), 14 deletions(-)
drivers/base/regmap/regmap.c +5 -7
index 5e12f7cb5147..8b3fdc966ed6 100644
@@ -57,9 +57,9 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg,
 static int _regmap_bus_raw_write(void *context, unsigned int reg,
 				 unsigned int val);
 
-bool regmap_reg_in_ranges(unsigned int reg,
-			  const struct regmap_range *ranges,
-			  unsigned int nranges)
+static bool regmap_reg_in_ranges(unsigned int reg,
+				 const struct regmap_range *ranges,
+				 unsigned int nranges)
 {
 	const struct regmap_range *r;
 	int i;
@@ -69,10 +69,9 @@ bool regmap_reg_in_ranges(unsigned int reg,
 			return true;
 	return false;
 }
-EXPORT_SYMBOL_GPL(regmap_reg_in_ranges);
 
-bool regmap_check_range_table(struct regmap *map, unsigned int reg,
-			      const struct regmap_access_table *table)
+static bool regmap_check_range_table(struct regmap *map, unsigned int reg,
+				     const struct regmap_access_table *table)
 {
 	/* Check "no ranges" first */
 	if (regmap_reg_in_ranges(reg, table->no_ranges, table->n_no_ranges))
@@ -85,7 +84,6 @@ bool regmap_check_range_table(struct regmap *map, unsigned int reg,
 	return regmap_reg_in_ranges(reg, table->yes_ranges,
 				    table->n_yes_ranges);
 }
-EXPORT_SYMBOL_GPL(regmap_check_range_table);
 
 bool regmap_writeable(struct regmap *map, unsigned int reg)
 {
include/linux/regmap.h +0 -7
index de81a94d7b30..5008db9bf69a 100644
@@ -1210,9 +1210,6 @@ void regcache_cache_only(struct regmap *map, bool enable);
 void regcache_cache_bypass(struct regmap *map, bool enable);
 void regcache_mark_dirty(struct regmap *map);
 
-bool regmap_check_range_table(struct regmap *map, unsigned int reg,
-			      const struct regmap_access_table *table);
-
 int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs,
 			  int num_regs);
 int regmap_parse_val(struct regmap *map, const void *buf,
@@ -1224,10 +1221,6 @@ static inline bool regmap_reg_in_range(unsigned int reg,
 	return reg >= range->range_min && reg <= range->range_max;
 }
 
-bool regmap_reg_in_ranges(unsigned int reg,
-			  const struct regmap_range *ranges,
-			  unsigned int nranges);
-
 static inline int regmap_set_bits(struct regmap *map,
 				  unsigned int reg, unsigned int bits)
 {
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 3 lines · Rasmus Villemoes

regmap_reg_in_ranges() and regmap_check_range_table() have no callers outside regmap.c, so they have no reason to be exported nor have external linkage.

These are intentional API in case someone needs them, no need to encourage open coding.

#2 lore raw
Quoted 8 lines · Mark Brown
Quoted 3 lines · Rasmus Villemoes

regmap_reg_in_ranges() and regmap_check_range_table() have no callers outside regmap.c, so they have no reason to be exported nor have external linkage.

These are intentional API in case someone needs them, no need to encourage open coding.

But currently it's not used and simply consumes namespace resources. Isn't it our practice not to add dead code / etc?

In practice I assume that one will grep before implementing, or at least at review stage it may be pointed out for a helper, that might be exported when needed, no?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Mark Brown
Quoted 3 lines · Rasmus Villemoes

regmap_reg_in_ranges() and regmap_check_range_table() have no callers outside regmap.c, so they have no reason to be exported nor have external linkage.

These are intentional API in case someone needs them, no need to encourage open coding.

Quoted 6 lines

But currently it's not used and simply consumes namespace resources. Isn't it our practice not to add dead code / etc?

In practice I assume that one will grep before implementing, or at least at review stage it may be pointed out for a helper, that might be exported when needed, no?

Or they'll just look at it and think there must be some good reason they're missing, or that having to deal with cross tree issues is too much pain and just open code stuff. It's not insurmountable but there is a clarity and usability benefit here.