From: Eugeniu Rosca Date: Wed, 11 Sep 2019 13:15:54 +0000 (+0200) Subject: usb: renesas_usbhs: simplify usbhs_status_get_device_state() X-Git-Tag: v5.5-rc1~137^2~130 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=5022204a464c598e36470717f5dda18576234bce;p=linux.git usb: renesas_usbhs: simplify usbhs_status_get_device_state() Similar to usbhs_status_get_ctrl_stage(), *_get_device_state() is not supposed to return any error code since its return value is the DVSQ bitfield of the INTSTS0 register. According to SoC HW manual rev1.00, every single value of DVSQ[2:0] is valid and none is an error: ----8<---- Device State 000: Powered state 001: Default state 010: Address state 011: Configuration state 1xx: Suspended state ----8<---- Hence, simplify the function body. The motivation behind dropping the switch/case construct is being able to implement reading the suspended state. The latter (based on the above DVSQ[2:0] description) doesn't have a unique value, but is rather a list of states (which makes switch/case less suitable for reading/validating it): 100: (Suspended) Powered state 101: (Suspended) Default state 110: (Suspended) Address state 111: (Suspended) Configuration state Signed-off-by: Eugeniu Rosca Signed-off-by: Veeraiyan Chidambaram Reviewed-by: Yoshihiro Shimoda Link: https://lore.kernel.org/r/1568207756-22325-1-git-send-email-external.veeraiyan.c@de.adit-jv.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 10fc65596014..1b3ae5c9baef 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c @@ -169,17 +169,7 @@ void usbhs_mod_remove(struct usbhs_priv *priv) */ int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state) { - int state = irq_state->intsts0 & DVSQ_MASK; - - switch (state) { - case POWER_STATE: - case DEFAULT_STATE: - case ADDRESS_STATE: - case CONFIGURATION_STATE: - return state; - } - - return -EIO; + return (int)irq_state->intsts0 & DVSQ_MASK; } int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state)