Skip to contentSkip to conversation

thermal: armada: simplify name sanitization

PATCH Applied Rasmus Villemoes 4 participants 4 messages Mar 20, 2024 – May 14, 2024

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

PATCH 1/1 thermal: armada: simplify name sanitization

Simplify the code by using the helper we have for doing exactly this.

---
 drivers/thermal/armada_thermal.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/thermal/armada_thermal.c +2 -7
index f783547ef964..fdcb077cfd54 100644
@@ -763,7 +763,6 @@ static void armada_set_sane_name(struct platform_device *pdev,
 				 struct armada_thermal_priv *priv)
 {
 	const char *name = dev_name(&pdev->dev);
-	char *insane_char;
 
 	if (strlen(name) > THERMAL_NAME_LENGTH) {
 		/*
@@ -781,12 +780,8 @@ static void armada_set_sane_name(struct platform_device *pdev,
 	/* Save the name locally */
 	strscpy(priv->zone_name, name, THERMAL_NAME_LENGTH);
 
-	/* Then check there are no '-' or hwmon core will complain */
-	do {
-		insane_char = strpbrk(priv->zone_name, "-");
-		if (insane_char)
-			*insane_char = '_';
-	} while (insane_char);
+	/* Then ensure there are no '-' or hwmon core will complain */
+	strreplace(priv->zone_name, '-', '_');
 }
 
 /*
Signature · 1 line
2.40.1.1.g1c60b9335d
#2 lore raw
In reply to Rasmus Villemoes
Quoted 4 lines · Rasmus Villemoes

Simplify the code by using the helper we have for doing exactly this.

---

Applied, thanks

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#3 lore raw

[thermal: thermal/fixes] thermal/drivers/armada: Simplify name sanitization

In reply to Rasmus Villemoes
The following commit has been merged into the thermal/fixes branch of thermal:

The following commit has been merged into the thermal/fixes branch of thermal:

Commit-ID:     58b1569244fea51cbf675774fad9423359d76c57
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//58b1569244fea51cbf675774fad9423359d76c57
Author:        Rasmus Villemoes <[email protected]>
AuthorDate:    Wed, 20 Mar 2024 11:49:39 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Tue, 23 Apr 2024 12:40:29 +02:00

thermal/drivers/armada: Simplify name sanitization

Simplify the code by using the helper we have for doing exactly this.

---
 drivers/thermal/armada_thermal.c |  9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/thermal/armada_thermal.c +2 -7
index f783547..fdcb077 100644
@@ -763,7 +763,6 @@ static void armada_set_sane_name(struct platform_device *pdev,
 				 struct armada_thermal_priv *priv)
 {
 	const char *name = dev_name(&pdev->dev);
-	char *insane_char;
 
 	if (strlen(name) > THERMAL_NAME_LENGTH) {
 		/*
@@ -781,12 +780,8 @@ static void armada_set_sane_name(struct platform_device *pdev,
 	/* Save the name locally */
 	strscpy(priv->zone_name, name, THERMAL_NAME_LENGTH);
 
-	/* Then check there are no '-' or hwmon core will complain */
-	do {
-		insane_char = strpbrk(priv->zone_name, "-");
-		if (insane_char)
-			*insane_char = '_';
-	} while (insane_char);
+	/* Then ensure there are no '-' or hwmon core will complain */
+	strreplace(priv->zone_name, '-', '_');
 }
 
 /*