@@ -161,7 +161,7 @@ void Thermal::parser_thrermal_zone(){
161
161
zone_ptr->governor = read_cstring (governor_addr,20 , " governor name" );
162
162
int trip_cnt = 0 ;
163
163
ulong trip_addr = 0 ;
164
- if (field_offset (thermal_zone_device,num_trips ) != -1 ){
164
+ if (field_offset (thermal_zone_device,trips ) != -1 ){
165
165
trip_cnt = INT (dev_buf + field_offset (thermal_zone_device,num_trips));
166
166
trip_addr = ULONG (dev_buf + field_offset (thermal_zone_device,trips));
167
167
}else {
@@ -182,25 +182,32 @@ void Thermal::parser_thrermal_zone(){
182
182
zone_ptr->trip_list .push_back (trip_ptr);
183
183
}
184
184
}
185
- int node_offset = field_offset (thermal_instance, tz_node);
186
- ulong head_addr = addr + field_offset (thermal_zone_device,thermal_instances);
187
- for (const auto & ins_addr : for_each_list (head_addr,node_offset)) {
188
- void *ins_buf = read_struct (ins_addr," thermal_instance" );
189
- int trip = INT (ins_buf + field_offset (thermal_instance,trip));
190
- if (trip > zone_ptr->trip_list .size ()) {
191
- continue ;
192
- }
193
- ulong cdev = ULONG (ins_buf + field_offset (thermal_instance,cdev));
194
- FREEBUF (ins_buf);
195
- if (!is_kvaddr (cdev)) {
196
- continue ;
185
+ if (zone_ptr->trip_list .size () > 0 ){
186
+ int node_offset = field_offset (thermal_instance, tz_node);
187
+ ulong head_addr = addr + field_offset (thermal_zone_device,thermal_instances);
188
+ for (const auto & ins_addr : for_each_list (head_addr,node_offset)) {
189
+ void *ins_buf = read_struct (ins_addr," thermal_instance" );
190
+ int trip = INT (ins_buf + field_offset (thermal_instance,trip));
191
+ if (trip > zone_ptr->trip_list .size ()) {
192
+ continue ;
193
+ }
194
+ ulong cdev = ULONG (ins_buf + field_offset (thermal_instance,cdev));
195
+ FREEBUF (ins_buf);
196
+ if (!is_kvaddr (cdev)) {
197
+ continue ;
198
+ }
199
+ std::shared_ptr<cool_dev> cdev_ptr = std::make_shared<cool_dev>();
200
+ cdev_ptr->addr = cdev;
201
+ ulong type_addr = read_pointer (cdev + field_offset (thermal_cooling_device,type)," type addr" );
202
+ if (is_kvaddr (type_addr)){
203
+ cdev_ptr->name = read_cstring (type_addr,64 , " type" );
204
+ }else {
205
+ cdev_ptr->name = " " ;
206
+ }
207
+ cdev_ptr->id = read_int (cdev + field_offset (thermal_cooling_device,id), " id" );
208
+ // fprintf(fp, "trip:%d cdev name:%s\n",trip,cdev_ptr->name.c_str());
209
+ zone_ptr->trip_list [trip]->cool_list .push_back (cdev_ptr);
197
210
}
198
- std::shared_ptr<cool_dev> cdev_ptr = std::make_shared<cool_dev>();
199
- cdev_ptr->addr = cdev;
200
- cdev_ptr->name = read_cstring (cdev + field_offset (thermal_cooling_device,type),20 , " type" );
201
- cdev_ptr->id = read_int (cdev + field_offset (thermal_cooling_device,id), " id" );
202
- // fprintf(fp, "trip:%d cdev name:%s\n",trip,cdev_ptr->name.c_str());
203
- zone_ptr->trip_list [trip]->cool_list .push_back (cdev_ptr);
204
211
}
205
212
FREEBUF (dev_buf);
206
213
zone_list.push_back (zone_ptr);
0 commit comments