Skip to contentSkip to conversation

md: Convert to use int_pow()

PATCH Andy Shevchenko 3 participants 4 messages Jul 26, 2019 1 message not in the archive MD RAID

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 2 lines · Andy Shevchenko

Instead of linear approach to calculate power of 10, use generic int_pow() which does it better.

I took into Cc drivers/dm guys as they might have known something about md raid state of affairs. Sorry if I mistakenly added somebody.

Who is doing this?
Should it be orphaned?

(I got a bounce from Shaohua address)

Quoted 26 lines
---
 drivers/md/md.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/md/md.c +1 -5
index 24638ccedce4..3f1252440ad0 100644
@@ -3664,11 +3664,7 @@ int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale)
 		return -EINVAL;
 	if (decimals < 0)
 		decimals = 0;
-	while (decimals < scale) {
-		result *= 10;
-		decimals ++;
-	}
-	*res = result;
+	*res = result * int_pow(10, scale - decimals);
 	return 0;
 }
 
Signature · 1 line
2.20.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Instead of linear approach to calculate power of 10, use generic int_pow() which does it better.

Quoted 7 lines

I took into Cc drivers/dm guys as they might have known something about md raid state of affairs. Sorry if I mistakenly added somebody.

Who is doing this?
Should it be orphaned?

(I got a bounce from Shaohua address)

I process the patch. Sorry for the delay.

Song

Quoted 33 lines
Quoted 27 lines

---
drivers/md/md.c | 6 +-----

1 file changed, 1 insertion(+), 5 deletions(-)
drivers/md/md.c +1 -5
index 24638ccedce4..3f1252440ad0 100644
@@ -3664,11 +3664,7 @@ int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale)
 		return -EINVAL;
 	if (decimals < 0)
 		decimals = 0;
-	while (decimals < scale) {
-		result *= 10;
-		decimals ++;
-	}
-	*res = result;
+	*res = result * int_pow(10, scale - decimals);
 	return 0;
 }
 
Signature · 1 line
2.20.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 11 lines · Song Liu
Quoted 11 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Instead of linear approach to calculate power of 10, use generic int_pow() which does it better.

I took into Cc drivers/dm guys as they might have known something about md raid state of affairs. Sorry if I mistakenly added somebody.

Quoted 6 lines
Quoted 4 lines

Who is doing this?
Should it be orphaned?

(I got a bounce from Shaohua address)

I process the patch. Sorry for the delay.

Ah, no problem, thanks!

Perhaps someone can update MAINTAINERS data base?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Song Liu
Quoted 14 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

Instead of linear approach to calculate power of 10, use generic int_pow() which does it better.

I took into Cc drivers/dm guys as they might have known something about md raid state of affairs. Sorry if I mistakenly added somebody.

Who is doing this?
Should it be orphaned?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

(I got a bounce from Shaohua address)

I process the patch. Sorry for the delay.

Ah, no problem, thanks!

Perhaps someone can update MAINTAINERS data base?

I will discuss this with Jens.

I applied this patch to my local branch. It will go to Jens' tree for 5.4.

Thanks,
Song