summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>2017-04-11 11:50:57 +0530
committerShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>2017-04-11 11:50:57 +0530
commit72b0f38edc370598c270a83d587dc771de788a85 (patch)
tree01cee34d412957d22e034894c7432791f8b7bde5
parent806226bf049e783813e2201b00aa080bf3563040 (diff)
downloadocc-inband-sensors-72b0f38edc370598c270a83d587dc771de788a85.tar.gz
occ-inband-sensors-72b0f38edc370598c270a83d587dc771de788a85.zip
sensor: Fixup reading DT entries
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
-rw-r--r--sensor.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/sensor.c b/sensor.c
index 731969f..efe1e2b 100644
--- a/sensor.c
+++ b/sensor.c
@@ -207,6 +207,29 @@ static int init_chip(void)
struct device_node *sensor_node, *node;
int rc = 0;
+ sensor_node = of_find_node_by_path("/occ_sensors");
+ if (!sensor_node) {
+ pr_info("Node occ_sensors not found\n");
+ return -EINVAL;
+ }
+
+ if (of_property_read_u32(sensor_node, "nr_system_sensors",
+ &nr_system_sensors)) {
+ pr_info("nr_system_sensors not found\n");
+ rc = -EINVAL;
+ }
+
+ if (of_property_read_u32(sensor_node, "nr_chip_sensors",
+ &nr_chip_sensors)) {
+ pr_info("nr_chip_sensors not found\n");
+ return -EINVAL;
+ }
+ if (of_property_read_u32(sensor_node, "nr_core_sensors",
+ &nr_cores_sensors)) {
+ pr_info("nr_core_sensors not found\n");
+ return -EINVAL;
+ }
+
for_each_possible_cpu(cpu) {
unsigned int id = cpu_to_chip_id(cpu);
@@ -242,25 +265,6 @@ static int init_chip(void)
chips[i].nr_cores = ncpus / threads_per_core;
}
- sensor_node = of_find_node_by_path("/occ_sensors");
-
- if (of_property_read_u32(sensor_node, "nr_system_sensors",
- &nr_system_sensors)) {
- pr_info("nr_system_sensors not found\n");
- return -EINVAL;
- }
-
- if (of_property_read_u32(sensor_node, "nr_chip_sensors",
- &nr_chip_sensors)) {
- pr_info("nr_chip_sensors not found\n");
- return -EINVAL;
- }
- if (of_property_read_u32(sensor_node, "nr_core_sensors",
- &nr_cores_sensors)) {
- pr_info("nr_core_sensors not found\n");
- return -EINVAL;
- }
-
system_sensors = kcalloc(nr_system_sensors, sizeof(sensor_t),
GFP_KERNEL);
for (i = 0; i < nr_chips; i++) {
@@ -354,7 +358,7 @@ static int sensor_init(void)
rc = sysfs_create_group(occ_sensor_kobj, &system_attr_group);
if (rc) {
pr_info("Failed to create system attribute group\n");
- goto out;
+ goto out_free_chips;
}
for (i = 0; i < nr_chips; i++) {
@@ -370,8 +374,9 @@ static int sensor_init(void)
out_clean_kobj:
kobject_put(occ_sensor_kobj);
-out:
+out_free_chips:
clear_chips();
+out:
return rc;
}
OpenPOWER on IntegriCloud