From b1d6e7cbf81ef5237e1fdd9c6ea6c862778e40a3 Mon Sep 17 00:00:00 2001 From: William Wu Date: Tue, 12 Feb 2019 14:44:39 +0800 Subject: [PATCH] usb: dwc3: rockchip: use devm_extcon_register_notifier This patch uses the devm_extcon_register_notifier to manage the resource automatically. Change-Id: I427c54d59283ee97623ad829e42dac40516c3df4 Signed-off-by: William Wu --- drivers/usb/dwc3/dwc3-rockchip.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c index 4810d45deeed..89cfd02941a8 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -637,19 +637,6 @@ static int dwc3_rockchip_get_extcon_dev(struct dwc3_rockchip *rockchip) return 0; } -static void dwc3_rockchip_extcon_unregister(struct dwc3_rockchip *rockchip) -{ - if (!rockchip->edev) - return; - - extcon_unregister_notifier(rockchip->edev, EXTCON_USB, - &rockchip->device_nb); - extcon_unregister_notifier(rockchip->edev, EXTCON_USB_HOST, - &rockchip->host_nb); - - cancel_work_sync(&rockchip->otg_work); -} - static void dwc3_rockchip_async_probe(void *data, async_cookie_t cookie) { struct dwc3_rockchip *rockchip = data; @@ -664,20 +651,19 @@ static void dwc3_rockchip_async_probe(void *data, async_cookie_t cookie) device_property_read_bool(dev, "needs-reset-on-resume"); if (rockchip->edev) { - ret = extcon_register_notifier(rockchip->edev, EXTCON_USB, - &rockchip->device_nb); + ret = devm_extcon_register_notifier(dev, rockchip->edev, + EXTCON_USB, + &rockchip->device_nb); if (ret < 0) { dev_err(dev, "fail to register notifier for USB Dev\n"); goto err; } - ret = extcon_register_notifier(rockchip->edev, EXTCON_USB_HOST, - &rockchip->host_nb); + ret = devm_extcon_register_notifier(dev, rockchip->edev, + EXTCON_USB_HOST, + &rockchip->host_nb); if (ret < 0) { - dev_err(dev, - "fail to register notifier for USB HOST\n"); - extcon_unregister_notifier(rockchip->edev, EXTCON_USB, - &rockchip->device_nb); + dev_err(dev, "fail to register notifier for USB HOST\n"); goto err; } } @@ -878,7 +864,7 @@ static int dwc3_rockchip_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; int i; - dwc3_rockchip_extcon_unregister(rockchip); + cancel_work_sync(&rockchip->otg_work); sysfs_remove_group(&dev->kobj, &dwc3_rockchip_attr_group);