Commit f834fa97 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

WR-EXT: optimization of hooks.c file. Change if/then with switch/case

parent 6868930e
...@@ -161,6 +161,7 @@ static int wr_handle_resp(struct pp_instance *ppi) ...@@ -161,6 +161,7 @@ static int wr_handle_resp(struct pp_instance *ppi)
static void wr_s1(struct pp_instance *ppi, struct pp_frgn_master *frgn_master) static void wr_s1(struct pp_instance *ppi, struct pp_frgn_master *frgn_master)
{ {
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
WR_DSPOR(ppi)->parentIsWRnode = WR_DSPOR(ppi)->parentIsWRnode =
((frgn_master->ext_specific & WR_NODE_MODE) != NON_WR); ((frgn_master->ext_specific & WR_NODE_MODE) != NON_WR);
...@@ -200,15 +201,16 @@ static int wr_handle_announce(struct pp_instance *ppi) ...@@ -200,15 +201,16 @@ static int wr_handle_announce(struct pp_instance *ppi)
{ {
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ((ppi->state == WRS_PRESENT) || switch (ppi->state) {
(ppi->state == WRS_S_LOCK) || case WRS_PRESENT:
(ppi->state == WRS_LOCKED) || case WRS_S_LOCK :
(ppi->state == WRS_CALIBRATION) || case WRS_LOCKED :
(ppi->state == WRS_CALIBRATED) || case WRS_CALIBRATION :
(ppi->state == WRS_RESP_CALIB_REQ) || case WRS_CALIBRATED :
(ppi->state == WRS_WR_LINK_ON)) { case WRS_RESP_CALIB_REQ :
/* reset announce timeout when in the WR slave states */ case WRS_WR_LINK_ON :
pp_timeout_set(ppi, PP_TO_ANN_RECEIPT); /* reset announce timeout when in the WR slave states */
pp_timeout_set(ppi, PP_TO_ANN_RECEIPT);
} }
/* handshake is started in slave mode */ /* handshake is started in slave mode */
...@@ -295,15 +297,17 @@ static int wr_state_decision(struct pp_instance *ppi, int next_state) ...@@ -295,15 +297,17 @@ static int wr_state_decision(struct pp_instance *ppi, int next_state)
* if in one of the WR states stay in them, * if in one of the WR states stay in them,
* they will eventually go back to the normal states * they will eventually go back to the normal states
*/ */
if ((ppi->state == WRS_PRESENT) || switch (ppi->state ) {
(ppi->state == WRS_M_LOCK) || case WRS_PRESENT :
(ppi->state == WRS_S_LOCK) || case WRS_M_LOCK :
(ppi->state == WRS_LOCKED) || case WRS_S_LOCK :
(ppi->state == WRS_CALIBRATION) || case WRS_LOCKED :
(ppi->state == WRS_CALIBRATED) || case WRS_CALIBRATION :
(ppi->state == WRS_RESP_CALIB_REQ) || case WRS_CALIBRATED :
(ppi->state == WRS_WR_LINK_ON)) case WRS_RESP_CALIB_REQ :
return ppi->state; case WRS_WR_LINK_ON :
return ppi->state;
}
/* else do the normal statemachine */ /* else do the normal statemachine */
return next_state; return next_state;
...@@ -315,15 +319,17 @@ static void wr_state_change(struct pp_instance *ppi) ...@@ -315,15 +319,17 @@ static void wr_state_change(struct pp_instance *ppi)
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if ((ppi->next_state == WRS_PRESENT) || switch (ppi->next_state) {
(ppi->next_state == WRS_M_LOCK) || case WRS_PRESENT :
(ppi->next_state == WRS_S_LOCK) || case WRS_M_LOCK :
(ppi->next_state == WRS_LOCKED) || case WRS_S_LOCK :
(ppi->next_state == WRS_CALIBRATION) || case WRS_LOCKED :
(ppi->next_state == WRS_CALIBRATED) || case WRS_CALIBRATION :
(ppi->next_state == WRS_RESP_CALIB_REQ) || case WRS_CALIBRATED :
(ppi->next_state == WRS_WR_LINK_ON)) case WRS_RESP_CALIB_REQ :
return; case WRS_WR_LINK_ON :
return;
}
/* if we are leaving the WR locked states reset the WR process */ /* if we are leaving the WR locked states reset the WR process */
if ((ppi->next_state != ppi->state) && if ((ppi->next_state != ppi->state) &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment