drivers/usbmisc: remove redundant scope in switch/case

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2023-03-09 10:04:06 +02:00 committed by Alan Carvalho de Assis
parent ab196aebe4
commit 61e996af33

View File

@ -816,71 +816,69 @@ static void fusb302_worker(FAR void *arg)
switch (priv->state)
{
case WAITING_FOR_DRP_TOGG_I:
{
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* What has connected? */
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* What has connected? */
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
/* set everything up depending on what's been detected */
/* set everything up depending on what's been detected */
set_switches(priv, toggsval);
set_switches(priv, toggsval);
/* Power up Internal Oscillator as well now */
/* Power up Internal Oscillator as well now */
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_dump_registers(priv,
"After DRP toggle detect handling");
fusb302_dump_registers(priv,
"After DRP toggle detect handling");
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if ((interrupt & INTERRUPT_VBUS_OK) ||
(regval & STATUS0_VBUS_OK) ||
(regval & STATUS0_BC_LVL_MASK))
{
priv->state = WAITING_FOR_SNK_DISCONNECT;
priv->connect_status = SNK_DEVICE_CONNECTED;
}
else
{
priv->state = WAITING_FOR_VBUS;
}
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
priv->state = WAITING_FOR_SRC_DISCONNECT;
priv->connect_status = SRC_DEVICE_CONNECTED;
break;
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if ((interrupt & INTERRUPT_VBUS_OK) ||
(regval & STATUS0_VBUS_OK) ||
(regval & STATUS0_BC_LVL_MASK))
{
priv->state = WAITING_FOR_SNK_DISCONNECT;
priv->connect_status = SNK_DEVICE_CONNECTED;
}
else
{
priv->state = WAITING_FOR_VBUS;
}
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
priv->state = WAITING_FOR_SRC_DISCONNECT;
priv->connect_status = SRC_DEVICE_CONNECTED;
break;
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
/* turn off toggling */
/* turn off toggling */
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
/* Send new interrupt mask */
/* Send new interrupt mask */
set_int_mask(priv);
}
}
set_int_mask(priv);
}
break;
case WAITING_FOR_VBUS:
if (interrupt & INTERRUPT_VBUS_OK)
@ -927,165 +925,157 @@ static void fusb302_worker(FAR void *arg)
}
break;
case WAITING_FOR_SNK_TOGG_I:
{
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* Check what has connected? */
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* Check what has connected? */
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
/* set everything up depending on what's been detected */
/* set everything up depending on what's been detected */
set_switches(priv, toggsval);
set_switches(priv, toggsval);
/* Power up Internal Oscillator as well now */
/* Power up Internal Oscillator as well now */
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_dump_registers(priv,
"After SNK toggle detect handling");
fusb302_dump_registers(priv,
"After SNK toggle detect handling");
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if ((interrupt & INTERRUPT_VBUS_OK) ||
(regval & STATUS0_VBUS_OK) ||
(regval & STATUS0_BC_LVL_MASK))
{
priv->state = WAITING_FOR_SNK_DISCONNECT;
priv->connect_status = SNK_DEVICE_CONNECTED;
}
else
{
priv->state = WAITING_FOR_VBUS;
}
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if ((interrupt & INTERRUPT_VBUS_OK) ||
(regval & STATUS0_VBUS_OK) ||
(regval & STATUS0_BC_LVL_MASK))
{
priv->state = WAITING_FOR_SNK_DISCONNECT;
priv->connect_status = SNK_DEVICE_CONNECTED;
}
else
{
priv->state = WAITING_FOR_VBUS;
}
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
/* turn off toggling */
/* turn off toggling */
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
/* Send new interrupt mask */
/* Send new interrupt mask */
set_int_mask(priv);
}
}
set_int_mask(priv);
}
break;
case WAITING_FOR_SRC_TOGG_I:
{
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* Check what has connected? */
if (interrupta & INTERRUPTA_M_TOGDONE)
{
/* Check what has connected? */
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
fusb302_info("INFO: toggs val=%x\n", toggsval);
/* set everything up depending on what's been detected */
/* set everything up depending on what's been detected */
set_switches(priv, toggsval);
set_switches(priv, toggsval);
/* Power up Internal Oscillator as well now */
/* Power up Internal Oscillator as well now */
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_putreg(priv, FUSB302_POWER_REG,
POWER_MODE_ALL);
fusb302_dump_registers(priv,
"After SRC toggle detect handling");
fusb302_dump_registers(priv,
"After SRC toggle detect handling");
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
priv->state = WAITING_FOR_SRC_DISCONNECT;
priv->connect_status = SRC_DEVICE_CONNECTED;
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
switch (toggsval)
{
case TOGGS_RUNNING:
break;
case TOGGS_SRC_CC1:
case TOGGS_SRC_CC2:
case TOGGS_AUDIO_ACCESSORY:
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
priv->state = WAITING_FOR_SRC_DISCONNECT;
priv->connect_status = SRC_DEVICE_CONNECTED;
break;
case TOGGS_SNK_CC1:
case TOGGS_SNK_CC2:
default:
priv->connect_status = UNKNOWN_CONNECTED;
goto error_exit;
break;
}
/* turn off toggling */
/* turn off toggling */
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
regval &= ~CONTROL2_TOGGLE;
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
/* Send new interrupt mask */
/* Send new interrupt mask */
set_int_mask(priv);
}
}
set_int_mask(priv);
}
break;
case WAITING_FOR_SRC_DISCONNECT:
{
if ((priv->connect_status != SRC_DEVICE_CONNECTED) &&
(priv->connect_status != AUDIO_ACCESSORY_CONNECTED))
{
priv->connect_status = CONNECT_ERROR;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_COMP_CHNG)
{
priv->connect_status = SRC_DETACH_DETECTED;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_BC_LVL)
{
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
}
}
if ((priv->connect_status != SRC_DEVICE_CONNECTED) &&
(priv->connect_status != AUDIO_ACCESSORY_CONNECTED))
{
priv->connect_status = CONNECT_ERROR;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_COMP_CHNG)
{
priv->connect_status = SRC_DETACH_DETECTED;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_BC_LVL)
{
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
}
break;
case WAITING_FOR_SNK_DISCONNECT:
{
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if (regval & STATUS0_VBUS_OK)
/* A USB3 device can cause a spurious VBUS OK here.
* A USB2 device doesn't.
*/
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
if (regval & STATUS0_VBUS_OK)
/* A USB3 device can cause a spurious VBUS OK here.
* A USB2 device doesn't.
*/
break;
if (priv->connect_status != SNK_DEVICE_CONNECTED)
{
priv->connect_status = CONNECT_ERROR;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_VBUS_OK)
{
priv->connect_status = SNK_DETACH_DETECTED;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_BC_LVL)
{
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
}
}
break;
if (priv->connect_status != SNK_DEVICE_CONNECTED)
{
priv->connect_status = CONNECT_ERROR;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_VBUS_OK)
{
priv->connect_status = SNK_DETACH_DETECTED;
priv->state = WAITING_FOR_HOST_INTERVENTION;
}
else if (interrupt & INTERRUPT_BC_LVL)
{
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
}
break;
case WAITING_FOR_HOST_INTERVENTION:
/* the higher level software has not dealt with the previous