Skip to contentSkip to conversation

drivers: hwmon: remove redundant cast

PATCH Applied Rasmus Villemoes 2 participants 2 messages Oct 26, 2018 – Oct 27, 2018 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: hwmon: remove redundant cast

struct attribute::name which this local variable name is eventually assigned to is "const char*", and so is the template parameter. We might as well preserve the constness all the way through.

---
 drivers/hwmon/hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/hwmon.c +2 -2
index 975c95169884..ea42c5ec40d9 100644
@@ -267,7 +267,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 	struct device_attribute *dattr;
 	struct attribute *a;
 	umode_t mode;
-	char *name;
+	const char *name;
 	bool is_string = is_string_attr(type, attr);
 
 	/* The attribute is invisible if there is no template string */
@@ -289,7 +289,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 		return ERR_PTR(-ENOMEM);
 
 	if (type == hwmon_chip) {
-		name = (char *)template;
+		name = template;
 	} else {
 		scnprintf(hattr->name, sizeof(hattr->name), template,
 			  index + hwmon_attr_base(type));
Signature · 1 line
2.19.1.6.gbde171bbf5
maintainer Applied
#1 lore raw
Quoted 5 lines · Rasmus Villemoes

struct attribute::name which this local variable name is eventually assigned to is "const char*", and so is the template parameter. We might as well preserve the constness all the way through.

Applied to hwmon-next.

Note that the "drivers:" tag is unnecessary; I removed it when applying the patch.

Guenter

Quoted 26 lines
---
 drivers/hwmon/hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/hwmon.c +2 -2
index 975c95169884..ea42c5ec40d9 100644
@@ -267,7 +267,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 	struct device_attribute *dattr;
 	struct attribute *a;
 	umode_t mode;
-	char *name;
+	const char *name;
 	bool is_string = is_string_attr(type, attr);
 
 	/* The attribute is invisible if there is no template string */
@@ -289,7 +289,7 @@ static struct attribute *hwmon_genattr(struct device *dev,
 		return ERR_PTR(-ENOMEM);
 
 	if (type == hwmon_chip) {
-		name = (char *)template;
+		name = template;
 	} else {
 		scnprintf(hattr->name, sizeof(hattr->name), template,
 			  index + hwmon_attr_base(type));