Skip to contentSkip to conversation

hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place

PATCH Applied Axel Lin 3 participants 5 messages Aug 1, 2014 – Aug 4, 2014

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place

Simplify the code a bit and also improve readability.

---
 drivers/hwmon/ibmpowernv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/ibmpowernv.c +3 -4
index e6b652a..d2bf2c9 100644
@@ -227,7 +227,7 @@ static int __init create_device_attrs(struct platform_device *pdev)
 	const struct attribute_group **pgroups = pdata->attr_groups;
 	struct device_node *opal, *np;
 	struct sensor_data *sdata;
-	const __be32 *sensor_id;
+	u32 sensor_id;
 	enum sensors type;
 	u32 count = 0;
 	int err = 0;
@@ -252,15 +252,14 @@ static int __init create_device_attrs(struct platform_device *pdev)
 		if (type = MAX_SENSOR_TYPE)
 			continue;
 
-		sensor_id = of_get_property(np, "sensor-id", NULL);
-		if (!sensor_id) {
+		if (of_property_read_u32(np, "sensor-id", &sensor_id)) {
 			dev_info(&pdev->dev,
 				 "'sensor-id' missing in the node '%s'\n",
 				 np->name);
 			continue;
 		}
 
-		sdata[count].id = be32_to_cpup(sensor_id);
+		sdata[count].id = sensor_id;
 		sdata[count].type = type;
 		err = create_hwmon_attr_name(&pdev->dev, type, np->name,
 					     sdata[count].name);
Signature · 9 lines
1.9.1




_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 1 line · Axel Lin

Simplify the code a bit and also improve readability.

Verified the patch in my test environment and it works fine.

Thanks,
- Neelesh

Quoted 27 lines
---
  drivers/hwmon/ibmpowernv.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/ibmpowernv.c +2 -3
index e6b652a..d2bf2c9 100644
@@ -227,7 +227,7 @@ static int __init create_device_attrs(struct platform_device *pdev)
  	const struct attribute_group **pgroups = pdata->attr_groups;
  	struct device_node *opal, *np;
  	struct sensor_data *sdata;
-	const __be32 *sensor_id;
+	u32 sensor_id;
  	enum sensors type;
  	u32 count = 0;
  	int err = 0;
@@ -252,15 +252,14 @@ static int __init create_device_attrs(struct platform_device *pdev)
  		if (type = MAX_SENSOR_TYPE)
  			continue;
 
-		sensor_id = of_get_property(np, "sensor-id", NULL);
-		if (!sensor_id) {
+		if (of_property_read_u32(np, "sensor-id", &sensor_id)) {
  			dev_info(&pdev->dev,

drivers/hwmon/ibmpowernv.c static int __init create_device_attrs(struct platform_device *pdev) · line 265

Quoted 10 lines
drivers/hwmon/ibmpowernv.c +1 -1
  				 "'sensor-id' missing in the node '%s'\n",
  				 np->name);
  			continue;
  		}
 
-		sdata[count].id = be32_to_cpup(sensor_id);
+		sdata[count].id = sensor_id;
  		sdata[count].type = type;
  		err = create_hwmon_attr_name(&pdev->dev, type, np->name,
  					     sdata[count].name);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

maintainer
#2 lore raw
In reply to Axel Lin
Quoted 6 lines · Neelesh Gupta
Quoted 1 line · Axel Lin

Simplify the code a bit and also improve readability.

Verified the patch in my test environment and it works fine.

Great. Can I add your Tested-by: tag ?

Thanks,
Guenter

Quoted 35 lines

Thanks,
- Neelesh

Quoted 32 lines
---
  drivers/hwmon/ibmpowernv.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/ibmpowernv.c +2 -3
index e6b652a..d2bf2c9 100644
@@ -227,7 +227,7 @@ static int __init create_device_attrs(struct platform_device *pdev)
      const struct attribute_group **pgroups = pdata->attr_groups;
      struct device_node *opal, *np;
      struct sensor_data *sdata;
-    const __be32 *sensor_id;
+    u32 sensor_id;
      enum sensors type;
      u32 count = 0;
      int err = 0;
@@ -252,15 +252,14 @@ static int __init create_device_attrs(struct platform_device *pdev)
          if (type = MAX_SENSOR_TYPE)
              continue;
 
-        sensor_id = of_get_property(np, "sensor-id", NULL);
-        if (!sensor_id) {
+        if (of_property_read_u32(np, "sensor-id", &sensor_id)) {
              dev_info(&pdev->dev,
                   "'sensor-id' missing in the node '%s'\n",
                   np->name);
              continue;
          }
 
Quoted 8 lines

drivers/hwmon/ibmpowernv.c static int __init create_device_attrs(struct platform_device *pdev) · line 265

Quoted 5 lines
drivers/hwmon/ibmpowernv.c +1 -1
-        sdata[count].id = be32_to_cpup(sensor_id);
+        sdata[count].id = sensor_id;
          sdata[count].type = type;
          err = create_hwmon_attr_name(&pdev->dev, type, np->name,
                           sdata[count].name);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Axel Lin
Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Neelesh Gupta
Quoted 1 line · Axel Lin

Simplify the code a bit and also improve readability.

Verified the patch in my test environment and it works fine.

Great. Can I add your Tested-by: tag ?

Sure.

Neelesh

Quoted 50 lines

Thanks,
Guenter

Quoted 45 lines

Thanks,
- Neelesh

Quoted 39 lines
---
  drivers/hwmon/ibmpowernv.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/ibmpowernv.c +1 -1
index e6b652a..d2bf2c9 100644
@@ -227,7 +227,7 @@ static int __init create_device_attrs(struct 
 platform_device *pdev)
      const struct attribute_group **pgroups = pdata->attr_groups;
      struct device_node *opal, *np;
      struct sensor_data *sdata;
-    const __be32 *sensor_id;
+    u32 sensor_id;
      enum sensors type;
      u32 count = 0;
      int err = 0;
drivers/hwmon/ibmpowernv.c +2 -3
@@ -252,15 +252,14 @@ static int __init create_device_attrs(struct 
 platform_device *pdev)
          if (type = MAX_SENSOR_TYPE)
              continue;
 
-        sensor_id = of_get_property(np, "sensor-id", NULL);
-        if (!sensor_id) {
+        if (of_property_read_u32(np, "sensor-id", &sensor_id)) {
              dev_info(&pdev->dev,
                   "'sensor-id' missing in the node '%s'\n",
                   np->name);
              continue;
          }
 
-        sdata[count].id = be32_to_cpup(sensor_id);
+        sdata[count].id = sensor_id;
          sdata[count].type = type;
          err = create_hwmon_attr_name(&pdev->dev, type, np->name,
                           sdata[count].name);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors