Skip to contentSkip to conversation

regcache: Use sort()'s default swap() implementation

PATCH In review Thorsten Blum 3 participants 4 messages Apr 28, 2025 – Apr 30, 2025

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

PATCH 1/1 regcache: Use sort()'s default swap() implementation

Use sort()'s default swap() implementation and remove the custom regcache_defaults_swap() function.

---
 drivers/base/regmap/regcache.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/base/regmap/regcache.c +1 -12
index f7fcf2de1301..c7650fa434ad 100644
@@ -34,21 +34,10 @@ static int regcache_defaults_cmp(const void *a, const void *b)
 		return 0;
 }
 
-static void regcache_defaults_swap(void *a, void *b, int size)
-{
-	struct reg_default *x = a;
-	struct reg_default *y = b;
-	struct reg_default tmp;
-
-	tmp = *x;
-	*x = *y;
-	*y = tmp;
-}
-
 void regcache_sort_defaults(struct reg_default *defaults, unsigned int ndefaults)
 {
 	sort(defaults, ndefaults, sizeof(*defaults),
-	     regcache_defaults_cmp, regcache_defaults_swap);
+	     regcache_defaults_cmp, NULL);
 }
 EXPORT_SYMBOL_GPL(regcache_sort_defaults);
 
Signature · 1 line
2.49.0
#1 lore raw

…

Quoted 1 line

+++ b/drivers/base/regmap/regcache.c

…

drivers/base/regmap/regcache.c static int regcache_defaults_cmp(const void *a, const void *b) · line 41

Quoted 6 lines

void regcache_sort_defaults(struct reg_default *defaults, unsigned int ndefaults) {

drivers/base/regmap/regcache.c +1 -1
 	sort(defaults, ndefaults, sizeof(*defaults),
-	     regcache_defaults_cmp, regcache_defaults_swap);
+	     regcache_defaults_cmp, NULL);
 }

…

Would the following source code formatting become applicable?

+ sort(defaults, ndefaults, sizeof(*defaults), regcache_defaults_cmp, NULL);

Regards,
Markus

maintainer
#2 lore raw

Review

Quoted 3 lines · Markus Elfring

Would the following source code formatting become applicable?

(quoted diff) +1 -0
+	sort(defaults, ndefaults, sizeof(*defaults), regcache_defaults_cmp, NULL);

Feel free to ignore Markus, he has a long history of sending unhelpful review comments and continues to ignore repeated requests to stop.

maintainer
#3 lore raw
In reply to Thorsten Blum
Quoted 4 lines · Thorsten Blum

Use sort()'s default swap() implementation and remove the custom regcache_defaults_swap() function.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regcache: Use sort()'s default swap() implementation

      commit: d30e845b0ae63400738709ca624a4a7bb69c4ba2

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark