|
|
@@ -660,24 +660,27 @@ static int power_init(void)
|
|
|
}
|
|
|
static int power_clear(cascade_handle_t *cas)
|
|
|
{
|
|
|
- GlobalPowerManger *tmp=NULL;
|
|
|
- GlobalTreeACManager x,*tmp3=NULL;
|
|
|
+ GlobalPowerManger *tmp,*pos;
|
|
|
+ GlobalTreeACManager *tmp3,*pos3;
|
|
|
GlobalDeviceManager *dm2=get_dm2();
|
|
|
|
|
|
if(!list_empty(&dm2->_globalPowerManger.list_Tree_AC)) {
|
|
|
- list_for_each_entry(tmp3,&dm2->_globalPowerManger.list_Tree_AC,list_Tree_AC)
|
|
|
+ list_for_each_entry_safe(tmp3,pos3,&dm2->_globalPowerManger.list_Tree_AC,list_Tree_AC)
|
|
|
{
|
|
|
if(tmp3==NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
list_del(&tmp3->list_Tree_AC);
|
|
|
+ if(tmp3->global_over_manager) {
|
|
|
+ free(tmp3->global_over_manager);
|
|
|
+ }
|
|
|
free(tmp3);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!list_empty(&dm2->_globalPowerManger.list)) {
|
|
|
- list_for_each_entry(tmp,&dm2->_globalPowerManger.list,list)
|
|
|
+ list_for_each_entry_safe(tmp,pos,&dm2->_globalPowerManger.list,list)
|
|
|
{
|
|
|
if(tmp==NULL) {
|
|
|
continue;
|
|
|
@@ -688,7 +691,7 @@ static int power_clear(cascade_handle_t *cas)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- list_for_each_entry(tmp3,&tmp->list_Tree_AC,list_Tree_AC)
|
|
|
+ list_for_each_entry_safe(tmp3,pos3,&tmp->list_Tree_AC,list_Tree_AC)
|
|
|
{
|
|
|
if(tmp3==NULL) {
|
|
|
continue;
|
|
|
@@ -731,6 +734,13 @@ static int power_add(cascade_handle_t *cas)
|
|
|
goto quit;
|
|
|
}
|
|
|
memset(tmp3, 0, sizeof(GlobalTreeACManager));
|
|
|
+
|
|
|
+ tmp3->global_over_manager = (GlobalOverManager *)malloc(sizeof(GlobalOverManager));
|
|
|
+ if (tmp3->global_over_manager == NULL) {
|
|
|
+ log_e("tmp3->global_over_manager malloc error.\n");
|
|
|
+ goto quit;
|
|
|
+ }
|
|
|
+ memset(tmp3->global_over_manager, 0, sizeof(GlobalOverManager));
|
|
|
|
|
|
tmp3->product_ch_addr = TreeACindex + 1;
|
|
|
tmp3->product_id = info->prod.product_id;
|
|
|
@@ -940,13 +950,6 @@ static int master_cmd(cascade_handle_t *cas, cmd_data_t *cmd)
|
|
|
wdata.dlen = sizeof(cmd_data_t);
|
|
|
wdata.data = (uint8_t*)cmd;
|
|
|
|
|
|
-/*
|
|
|
-cas->sInfo.cnt = 6;
|
|
|
-cas->sInfo.prod.product_pwr_type = SmartPDU_Tree_AC_Tree;
|
|
|
-power_add(cas);
|
|
|
-return 0;
|
|
|
-*/
|
|
|
-
|
|
|
rdata.dlen = sizeof(slave_info_t)-sizeof(channel_info_t)*CH_MAX;
|
|
|
rdata.data = (uint8_t*)&cas->sInfo;
|
|
|
|
|
|
@@ -986,7 +989,7 @@ static int master_query(cascade_handle_t *cas)
|
|
|
if(cur_dev_addr==0) {
|
|
|
return -1;
|
|
|
}
|
|
|
-return 0;
|
|
|
+
|
|
|
wdata.dlen = sizeof(*cmd);
|
|
|
wdata.data = (uint8_t*)cmd;
|
|
|
|