hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place

Simplify the code a bit and also improve readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Tested-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Axel Lin 2014-08-01 12:38:47 +08:00 committed by Guenter Roeck
parent 746f68841a
commit 18d03f3cbd
1 changed files with 3 additions and 4 deletions

View File

@ -227,7 +227,7 @@ static int __init create_device_attrs(struct platform_device *pdev)
const struct attribute_group **pgroups = pdata->attr_groups; const struct attribute_group **pgroups = pdata->attr_groups;
struct device_node *opal, *np; struct device_node *opal, *np;
struct sensor_data *sdata; struct sensor_data *sdata;
const __be32 *sensor_id; u32 sensor_id;
enum sensors type; enum sensors type;
u32 count = 0; u32 count = 0;
int err = 0; int err = 0;
@ -252,15 +252,14 @@ static int __init create_device_attrs(struct platform_device *pdev)
if (type == MAX_SENSOR_TYPE) if (type == MAX_SENSOR_TYPE)
continue; continue;
sensor_id = of_get_property(np, "sensor-id", NULL); if (of_property_read_u32(np, "sensor-id", &sensor_id)) {
if (!sensor_id) {
dev_info(&pdev->dev, dev_info(&pdev->dev,
"'sensor-id' missing in the node '%s'\n", "'sensor-id' missing in the node '%s'\n",
np->name); np->name);
continue; continue;
} }
sdata[count].id = be32_to_cpup(sensor_id); sdata[count].id = sensor_id;
sdata[count].type = type; sdata[count].type = type;
err = create_hwmon_attr_name(&pdev->dev, type, np->name, err = create_hwmon_attr_name(&pdev->dev, type, np->name,
sdata[count].name); sdata[count].name);