@@ -46,10 +46,10 @@ static int hd3ss3220_set_source_pref(struct hd3ss3220 *hd3ss3220, int src_pref)
src_pref);
}
-static enum usb_role hd3ss3220_get_attached_state(struct hd3ss3220 *hd3ss3220)
+static int hd3ss3220_get_attached_state(struct hd3ss3220 *hd3ss3220,
+ enum usb_role *attached_state)
{
unsigned int reg_val;
- enum usb_role attached_state;
int ret;
ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL,
@@ -59,17 +59,17 @@ static enum usb_role hd3ss3220_get_attached_state(struct hd3ss3220 *hd3ss3220)
switch (reg_val & HD3SS3220_REG_CN_STAT_CTRL_ATTACHED_STATE_MASK) {
case HD3SS3220_REG_CN_STAT_CTRL_AS_DFP:
- attached_state = USB_ROLE_HOST;
+ *attached_state = USB_ROLE_HOST;
break;
case HD3SS3220_REG_CN_STAT_CTRL_AS_UFP:
- attached_state = USB_ROLE_DEVICE;
+ *attached_state = USB_ROLE_DEVICE;
break;
default:
- attached_state = USB_ROLE_NONE;
+ *attached_state = USB_ROLE_NONE;
break;
}
- return attached_state;
+ return 0;
}
static int hd3ss3220_dr_set(struct typec_port *port, enum typec_data_role role)
@@ -99,9 +99,14 @@ static const struct typec_operations hd3ss3220_ops = {
.dr_set = hd3ss3220_dr_set
};
-static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220)
+static int hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220)
{
- enum usb_role role_state = hd3ss3220_get_attached_state(hd3ss3220);
+ enum usb_role role_state;
+ int ret;
+
+ ret = hd3ss3220_get_attached_state(hd3ss3220, &role_state);
+ if (ret < 0)
+ return ret;
usb_role_switch_set_role(hd3ss3220->role_sw, role_state);
if (role_state == USB_ROLE_NONE)
@@ -118,13 +123,18 @@ static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220)
default:
break;
}
+
+ return 0;
}
static irqreturn_t hd3ss3220_irq(struct hd3ss3220 *hd3ss3220)
{
int err;
- hd3ss3220_set_role(hd3ss3220);
+ err = hd3ss3220_set_role(hd3ss3220);
+ if (err < 0)
+ return IRQ_NONE;
+
err = regmap_update_bits_base(hd3ss3220->regmap,
HD3SS3220_REG_CN_STAT_CTRL,
HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS,
@@ -196,7 +206,10 @@ static int hd3ss3220_probe(struct i2c_client *client,
goto err_put_role;
}
- hd3ss3220_set_role(hd3ss3220);
+ ret = hd3ss3220_set_role(hd3ss3220);
+ if (ret < 0)
+ goto err_unreg_port;
+
ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL, &data);
if (ret < 0)
goto err_unreg_port;
This patch fixes the return code for the attached_state, as the low level call did not adequately propagate errors to its callers. Signed-off-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com> --- drivers/usb/typec/hd3ss3220.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)