mirror of https://gitee.com/openkylin/linux.git
usb: mtu3: check return value of devm_extcon_register_notifier()
Check the return value of devm_extcon_register_notifier() and add error handling. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bb31b35251
commit
03d8bfc130
|
@ -238,14 +238,18 @@ static int ssusb_extcon_register(struct otg_switch_mtk *otg_sx)
|
|||
otg_sx->vbus_nb.notifier_call = ssusb_vbus_notifier;
|
||||
ret = devm_extcon_register_notifier(ssusb->dev, edev, EXTCON_USB,
|
||||
&otg_sx->vbus_nb);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
dev_err(ssusb->dev, "failed to register notifier for USB\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
otg_sx->id_nb.notifier_call = ssusb_id_notifier;
|
||||
ret = devm_extcon_register_notifier(ssusb->dev, edev, EXTCON_USB_HOST,
|
||||
&otg_sx->id_nb);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
dev_err(ssusb->dev, "failed to register notifier for USB-HOST\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_dbg(ssusb->dev, "EXTCON_USB: %d, EXTCON_USB_HOST: %d\n",
|
||||
extcon_get_state(edev, EXTCON_USB),
|
||||
|
@ -415,6 +419,7 @@ void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
|
|||
int ssusb_otg_switch_init(struct ssusb_mtk *ssusb)
|
||||
{
|
||||
struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
|
||||
int ret = 0;
|
||||
|
||||
INIT_WORK(&otg_sx->id_work, ssusb_id_work);
|
||||
INIT_WORK(&otg_sx->vbus_work, ssusb_vbus_work);
|
||||
|
@ -422,9 +427,9 @@ int ssusb_otg_switch_init(struct ssusb_mtk *ssusb)
|
|||
if (otg_sx->manual_drd_enabled)
|
||||
ssusb_debugfs_init(ssusb);
|
||||
else
|
||||
ssusb_extcon_register(otg_sx);
|
||||
ret = ssusb_extcon_register(otg_sx);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb)
|
||||
|
|
|
@ -401,7 +401,11 @@ static int mtu3_probe(struct platform_device *pdev)
|
|||
goto gadget_exit;
|
||||
}
|
||||
|
||||
ssusb_otg_switch_init(ssusb);
|
||||
ret = ssusb_otg_switch_init(ssusb);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to initialize switch\n");
|
||||
goto host_exit;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "unsupported mode: %d\n", ssusb->dr_mode);
|
||||
|
@ -411,6 +415,8 @@ static int mtu3_probe(struct platform_device *pdev)
|
|||
|
||||
return 0;
|
||||
|
||||
host_exit:
|
||||
ssusb_host_exit(ssusb);
|
||||
gadget_exit:
|
||||
ssusb_gadget_exit(ssusb);
|
||||
comm_exit:
|
||||
|
|
Loading…
Reference in New Issue