omit redundant code

This commit is contained in:
Gatsby Van
2024-03-07 11:41:52 +08:00
parent c09bd57408
commit dfecadac56
2 changed files with 5 additions and 16 deletions
@@ -660,10 +660,10 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
DBG_ERROR("Allocate memory for L2_InstPtr failed.\n"); DBG_ERROR("Allocate memory for L2_InstPtr failed.\n");
return ENOMEM; return ENOMEM;
} }
// Clear random content
memset(*instPtr, 0x00, sizeof(L2_INST)); memset(*instPtr, 0x00, sizeof(L2_INST));
memcpy(&((*instPtr)->config), config, sizeof(L2_CONFIG)); memcpy(&((*instPtr)->config), config, sizeof(L2_CONFIG));
// Clear log
memset(&((*instPtr)->log), 0x00, sizeof((*instPtr)->log));
// Packet buffer // Packet buffer
(*instPtr)->sendPktData = calloc(L2_PACK_LEN_MAX / sizeof(uint64_t), sizeof(uint64_t)); (*instPtr)->sendPktData = calloc(L2_PACK_LEN_MAX / sizeof(uint64_t), sizeof(uint64_t));
+3 -14
View File
@@ -420,7 +420,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
} }
else else
{ {
// Do not response // Ignore current command
DBG_ERROR("Unexpected config command 0x%02X:0x%02X", DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
WD_MODE_CMD, data[WD_MODE_CMD]); WD_MODE_CMD, data[WD_MODE_CMD]);
Status = EPARAM; Status = EPARAM;
@@ -453,19 +453,8 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL); Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
break; break;
} }
else
{ Linklayer_Start(linkInstPtr);
// Do not response
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
WD_EN_CMD, data[WD_EN_CMD]);
Status = EPARAM;
break;
}
if (reconfig == true)
{
Linklayer_Reconfig(linkInstPtr, &linkConfig);
Linklayer_Start(linkInstPtr);
}
instPtr->sysbusLog.lastConfig[0] = data[WD_MODE_CMD]; instPtr->sysbusLog.lastConfig[0] = data[WD_MODE_CMD];
instPtr->sysbusLog.lastConfig[1] = data[WD_EN_CMD]; instPtr->sysbusLog.lastConfig[1] = data[WD_EN_CMD];
Status = SUCCESS; Status = SUCCESS;