drivers/usbmisc: remove redundant scope in switch/case
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
ab196aebe4
commit
61e996af33
@ -816,71 +816,69 @@ static void fusb302_worker(FAR void *arg)
|
|||||||
switch (priv->state)
|
switch (priv->state)
|
||||||
{
|
{
|
||||||
case WAITING_FOR_DRP_TOGG_I:
|
case WAITING_FOR_DRP_TOGG_I:
|
||||||
{
|
if (interrupta & INTERRUPTA_M_TOGDONE)
|
||||||
if (interrupta & INTERRUPTA_M_TOGDONE)
|
{
|
||||||
{
|
/* What has connected? */
|
||||||
/* What has connected? */
|
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
||||||
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
fusb302_info("INFO: toggs val=%x\n", toggsval);
|
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,
|
fusb302_putreg(priv, FUSB302_POWER_REG,
|
||||||
POWER_MODE_ALL);
|
POWER_MODE_ALL);
|
||||||
|
|
||||||
fusb302_dump_registers(priv,
|
fusb302_dump_registers(priv,
|
||||||
"After DRP toggle detect handling");
|
"After DRP toggle detect handling");
|
||||||
|
|
||||||
switch (toggsval)
|
switch (toggsval)
|
||||||
{
|
{
|
||||||
case TOGGS_RUNNING:
|
case TOGGS_RUNNING:
|
||||||
break;
|
break;
|
||||||
case TOGGS_SNK_CC1:
|
case TOGGS_SNK_CC1:
|
||||||
case TOGGS_SNK_CC2:
|
case TOGGS_SNK_CC2:
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
if ((interrupt & INTERRUPT_VBUS_OK) ||
|
if ((interrupt & INTERRUPT_VBUS_OK) ||
|
||||||
(regval & STATUS0_VBUS_OK) ||
|
(regval & STATUS0_VBUS_OK) ||
|
||||||
(regval & STATUS0_BC_LVL_MASK))
|
(regval & STATUS0_BC_LVL_MASK))
|
||||||
{
|
{
|
||||||
priv->state = WAITING_FOR_SNK_DISCONNECT;
|
priv->state = WAITING_FOR_SNK_DISCONNECT;
|
||||||
priv->connect_status = SNK_DEVICE_CONNECTED;
|
priv->connect_status = SNK_DEVICE_CONNECTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
priv->state = WAITING_FOR_VBUS;
|
priv->state = WAITING_FOR_VBUS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOGGS_SRC_CC1:
|
case TOGGS_SRC_CC1:
|
||||||
case TOGGS_SRC_CC2:
|
case TOGGS_SRC_CC2:
|
||||||
case TOGGS_AUDIO_ACCESSORY:
|
case TOGGS_AUDIO_ACCESSORY:
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
priv->state = WAITING_FOR_SRC_DISCONNECT;
|
priv->state = WAITING_FOR_SRC_DISCONNECT;
|
||||||
priv->connect_status = SRC_DEVICE_CONNECTED;
|
priv->connect_status = SRC_DEVICE_CONNECTED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
priv->connect_status = UNKNOWN_CONNECTED;
|
priv->connect_status = UNKNOWN_CONNECTED;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn off toggling */
|
/* turn off toggling */
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
||||||
regval &= ~CONTROL2_TOGGLE;
|
regval &= ~CONTROL2_TOGGLE;
|
||||||
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
||||||
|
|
||||||
/* Send new interrupt mask */
|
/* Send new interrupt mask */
|
||||||
|
|
||||||
set_int_mask(priv);
|
set_int_mask(priv);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_VBUS:
|
case WAITING_FOR_VBUS:
|
||||||
if (interrupt & INTERRUPT_VBUS_OK)
|
if (interrupt & INTERRUPT_VBUS_OK)
|
||||||
@ -927,165 +925,157 @@ static void fusb302_worker(FAR void *arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_SNK_TOGG_I:
|
case WAITING_FOR_SNK_TOGG_I:
|
||||||
{
|
if (interrupta & INTERRUPTA_M_TOGDONE)
|
||||||
if (interrupta & INTERRUPTA_M_TOGDONE)
|
{
|
||||||
{
|
/* Check what has connected? */
|
||||||
/* Check what has connected? */
|
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
||||||
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
fusb302_info("INFO: toggs val=%x\n", toggsval);
|
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,
|
fusb302_putreg(priv, FUSB302_POWER_REG,
|
||||||
POWER_MODE_ALL);
|
POWER_MODE_ALL);
|
||||||
|
|
||||||
fusb302_dump_registers(priv,
|
fusb302_dump_registers(priv,
|
||||||
"After SNK toggle detect handling");
|
"After SNK toggle detect handling");
|
||||||
|
|
||||||
switch (toggsval)
|
switch (toggsval)
|
||||||
{
|
{
|
||||||
case TOGGS_RUNNING:
|
case TOGGS_RUNNING:
|
||||||
break;
|
break;
|
||||||
case TOGGS_SNK_CC1:
|
case TOGGS_SNK_CC1:
|
||||||
case TOGGS_SNK_CC2:
|
case TOGGS_SNK_CC2:
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
if ((interrupt & INTERRUPT_VBUS_OK) ||
|
if ((interrupt & INTERRUPT_VBUS_OK) ||
|
||||||
(regval & STATUS0_VBUS_OK) ||
|
(regval & STATUS0_VBUS_OK) ||
|
||||||
(regval & STATUS0_BC_LVL_MASK))
|
(regval & STATUS0_BC_LVL_MASK))
|
||||||
{
|
{
|
||||||
priv->state = WAITING_FOR_SNK_DISCONNECT;
|
priv->state = WAITING_FOR_SNK_DISCONNECT;
|
||||||
priv->connect_status = SNK_DEVICE_CONNECTED;
|
priv->connect_status = SNK_DEVICE_CONNECTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
priv->state = WAITING_FOR_VBUS;
|
priv->state = WAITING_FOR_VBUS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOGGS_SRC_CC1:
|
case TOGGS_SRC_CC1:
|
||||||
case TOGGS_SRC_CC2:
|
case TOGGS_SRC_CC2:
|
||||||
case TOGGS_AUDIO_ACCESSORY:
|
case TOGGS_AUDIO_ACCESSORY:
|
||||||
default:
|
default:
|
||||||
priv->connect_status = UNKNOWN_CONNECTED;
|
priv->connect_status = UNKNOWN_CONNECTED;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn off toggling */
|
/* turn off toggling */
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
||||||
regval &= ~CONTROL2_TOGGLE;
|
regval &= ~CONTROL2_TOGGLE;
|
||||||
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
||||||
|
|
||||||
/* Send new interrupt mask */
|
/* Send new interrupt mask */
|
||||||
|
|
||||||
set_int_mask(priv);
|
set_int_mask(priv);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_SRC_TOGG_I:
|
case WAITING_FOR_SRC_TOGG_I:
|
||||||
{
|
if (interrupta & INTERRUPTA_M_TOGDONE)
|
||||||
if (interrupta & INTERRUPTA_M_TOGDONE)
|
{
|
||||||
{
|
/* Check what has connected? */
|
||||||
/* Check what has connected? */
|
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS1A_REG);
|
||||||
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
toggsval = DECODE_TOGGS(regval & STATUS1A_TOGGS_MASK);
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
fusb302_info("INFO: toggs val=%x\n", toggsval);
|
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,
|
fusb302_putreg(priv, FUSB302_POWER_REG,
|
||||||
POWER_MODE_ALL);
|
POWER_MODE_ALL);
|
||||||
|
|
||||||
fusb302_dump_registers(priv,
|
fusb302_dump_registers(priv,
|
||||||
"After SRC toggle detect handling");
|
"After SRC toggle detect handling");
|
||||||
|
|
||||||
switch (toggsval)
|
switch (toggsval)
|
||||||
{
|
{
|
||||||
case TOGGS_RUNNING:
|
case TOGGS_RUNNING:
|
||||||
break;
|
break;
|
||||||
case TOGGS_SRC_CC1:
|
case TOGGS_SRC_CC1:
|
||||||
case TOGGS_SRC_CC2:
|
case TOGGS_SRC_CC2:
|
||||||
case TOGGS_AUDIO_ACCESSORY:
|
case TOGGS_AUDIO_ACCESSORY:
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
priv->state = WAITING_FOR_SRC_DISCONNECT;
|
priv->state = WAITING_FOR_SRC_DISCONNECT;
|
||||||
priv->connect_status = SRC_DEVICE_CONNECTED;
|
priv->connect_status = SRC_DEVICE_CONNECTED;
|
||||||
break;
|
break;
|
||||||
case TOGGS_SNK_CC1:
|
case TOGGS_SNK_CC1:
|
||||||
case TOGGS_SNK_CC2:
|
case TOGGS_SNK_CC2:
|
||||||
default:
|
default:
|
||||||
priv->connect_status = UNKNOWN_CONNECTED;
|
priv->connect_status = UNKNOWN_CONNECTED;
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn off toggling */
|
/* turn off toggling */
|
||||||
|
|
||||||
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
regval = fusb302_getreg(priv, FUSB302_CONTROL2_REG);
|
||||||
regval &= ~CONTROL2_TOGGLE;
|
regval &= ~CONTROL2_TOGGLE;
|
||||||
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
fusb302_putreg(priv, FUSB302_CONTROL2_REG, regval);
|
||||||
|
|
||||||
/* Send new interrupt mask */
|
/* Send new interrupt mask */
|
||||||
|
|
||||||
set_int_mask(priv);
|
set_int_mask(priv);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_SRC_DISCONNECT:
|
case WAITING_FOR_SRC_DISCONNECT:
|
||||||
{
|
if ((priv->connect_status != SRC_DEVICE_CONNECTED) &&
|
||||||
if ((priv->connect_status != SRC_DEVICE_CONNECTED) &&
|
(priv->connect_status != AUDIO_ACCESSORY_CONNECTED))
|
||||||
(priv->connect_status != AUDIO_ACCESSORY_CONNECTED))
|
{
|
||||||
{
|
priv->connect_status = CONNECT_ERROR;
|
||||||
priv->connect_status = CONNECT_ERROR;
|
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
||||||
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
}
|
||||||
}
|
else if (interrupt & INTERRUPT_COMP_CHNG)
|
||||||
else if (interrupt & INTERRUPT_COMP_CHNG)
|
{
|
||||||
{
|
priv->connect_status = SRC_DETACH_DETECTED;
|
||||||
priv->connect_status = SRC_DETACH_DETECTED;
|
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
||||||
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
}
|
||||||
}
|
else if (interrupt & INTERRUPT_BC_LVL)
|
||||||
else if (interrupt & INTERRUPT_BC_LVL)
|
{
|
||||||
{
|
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
|
||||||
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_SNK_DISCONNECT:
|
case WAITING_FOR_SNK_DISCONNECT:
|
||||||
{
|
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
||||||
regval = fusb302_getreg(priv, FUSB302_STATUS0_REG);
|
if (regval & STATUS0_VBUS_OK)
|
||||||
if (regval & STATUS0_VBUS_OK)
|
/* A USB3 device can cause a spurious VBUS OK here.
|
||||||
/* A USB3 device can cause a spurious VBUS OK here.
|
* A USB2 device doesn't.
|
||||||
* A USB2 device doesn't.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
if (priv->connect_status != SNK_DEVICE_CONNECTED)
|
if (priv->connect_status != SNK_DEVICE_CONNECTED)
|
||||||
{
|
{
|
||||||
priv->connect_status = CONNECT_ERROR;
|
priv->connect_status = CONNECT_ERROR;
|
||||||
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
||||||
}
|
}
|
||||||
else if (interrupt & INTERRUPT_VBUS_OK)
|
else if (interrupt & INTERRUPT_VBUS_OK)
|
||||||
{
|
{
|
||||||
priv->connect_status = SNK_DETACH_DETECTED;
|
priv->connect_status = SNK_DETACH_DETECTED;
|
||||||
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
priv->state = WAITING_FOR_HOST_INTERVENTION;
|
||||||
}
|
}
|
||||||
else if (interrupt & INTERRUPT_BC_LVL)
|
else if (interrupt & INTERRUPT_BC_LVL)
|
||||||
{
|
{
|
||||||
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
|
priv->connect_status = BC_LEVEL_CHANGE_REQUSTED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WAITING_FOR_HOST_INTERVENTION:
|
case WAITING_FOR_HOST_INTERVENTION:
|
||||||
/* the higher level software has not dealt with the previous
|
/* the higher level software has not dealt with the previous
|
||||||
|
Loading…
Reference in New Issue
Block a user