2022-03-28 23:33:56

by Rasmus Villemoes

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Rasmus Villemoes <[email protected]>
---
drivers/base/regmap/regmap.c | 12 +++++-------
include/linux/regmap.h | 7 -------
2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 5e12f7cb5147..8b3fdc966ed6 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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)
{
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index de81a94d7b30..5008db9bf69a 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -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)
{
--
2.31.1


2022-03-31 04:30:43

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regmap: make range check functions static

On Tue, Mar 29, 2022 at 12:56:28AM +0200, Rasmus Villemoes wrote:
> 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.


Attachments:
(No filename) (321.00 B)
signature.asc (499.00 B)
Download all attachments

2022-04-12 20:01:07

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] regmap: make range check functions static

On Wed, Mar 30, 2022 at 11:17 PM Mark Brown <[email protected]> wrote:
>
> On Tue, Mar 29, 2022 at 12:56:28AM +0200, Rasmus Villemoes wrote:
> > 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?

--
With Best Regards,
Andy Shevchenko

2022-04-12 22:03:19

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regmap: make range check functions static

On Mon, Apr 11, 2022 at 05:59:33PM +0300, Andy Shevchenko wrote:
> On Wed, Mar 30, 2022 at 11:17 PM Mark Brown <[email protected]> wrote:
> > On Tue, Mar 29, 2022 at 12:56:28AM +0200, Rasmus Villemoes wrote:

> > > 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?

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.


Attachments:
(No filename) (1.02 kB)
signature.asc (499.00 B)
Download all attachments