diff options
Diffstat (limited to 'drivers/extcon/extcon-palmas.c')
| -rw-r--r-- | drivers/extcon/extcon-palmas.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index cea58d0cb457..d339b8680445 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -2,13 +2,14 @@ /* * Palmas USB transceiver driver * - * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2013 Texas Instruments Incorporated - https://www.ti.com * Author: Graeme Gregory <gg@slimlogic.co.uk> * Author: Kishon Vijay Abraham I <kishon@ti.com> * Based on twl6030_usb.c * Author: Hema HK <hemahk@ti.com> */ +#include <linux/devm-helpers.h> #include <linux/module.h> #include <linux/interrupt.h> #include <linux/platform_device.h> @@ -17,7 +18,6 @@ #include <linux/mfd/palmas.h> #include <linux/of.h> #include <linux/of_platform.h> -#include <linux/of_gpio.h> #include <linux/gpio/consumer.h> #include <linux/workqueue.h> @@ -106,7 +106,7 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) (id_src & PALMAS_USB_ID_INT_SRC_ID_GND)) { palmas_usb->linkstat = PALMAS_USB_STATE_ID; extcon_set_state_sync(edev, EXTCON_USB_HOST, true); - dev_dbg(palmas_usb->dev, " USB-HOST cable is attached\n"); + dev_dbg(palmas_usb->dev, "USB-HOST cable is attached\n"); } return IRQ_HANDLED; @@ -205,21 +205,15 @@ static int palmas_usb_probe(struct platform_device *pdev) palmas_usb->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id", GPIOD_IN); - if (PTR_ERR(palmas_usb->id_gpiod) == -EPROBE_DEFER) { - return -EPROBE_DEFER; - } else if (IS_ERR(palmas_usb->id_gpiod)) { - dev_err(&pdev->dev, "failed to get id gpio\n"); - return PTR_ERR(palmas_usb->id_gpiod); - } + if (IS_ERR(palmas_usb->id_gpiod)) + return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->id_gpiod), + "failed to get id gpio\n"); palmas_usb->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus", GPIOD_IN); - if (PTR_ERR(palmas_usb->vbus_gpiod) == -EPROBE_DEFER) { - return -EPROBE_DEFER; - } else if (IS_ERR(palmas_usb->vbus_gpiod)) { - dev_err(&pdev->dev, "failed to get vbus gpio\n"); - return PTR_ERR(palmas_usb->vbus_gpiod); - } + if (IS_ERR(palmas_usb->vbus_gpiod)) + return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->vbus_gpiod), + "failed to get id gpio\n"); if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) { palmas_usb->enable_id_detection = false; @@ -243,7 +237,11 @@ static int palmas_usb_probe(struct platform_device *pdev) palmas_usb->sw_debounce_jiffies = msecs_to_jiffies(debounce); } - INIT_DELAYED_WORK(&palmas_usb->wq_detectid, palmas_gpio_id_detect); + status = devm_delayed_work_autocancel(&pdev->dev, + &palmas_usb->wq_detectid, + palmas_gpio_id_detect); + if (status) + return status; palmas->usb = palmas_usb; palmas_usb->palmas = palmas; @@ -365,15 +363,6 @@ static int palmas_usb_probe(struct platform_device *pdev) return 0; } -static int palmas_usb_remove(struct platform_device *pdev) -{ - struct palmas_usb *palmas_usb = platform_get_drvdata(pdev); - - cancel_delayed_work_sync(&palmas_usb->wq_detectid); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int palmas_usb_suspend(struct device *dev) { @@ -428,7 +417,6 @@ static const struct of_device_id of_palmas_match_tbl[] = { static struct platform_driver palmas_usb_driver = { .probe = palmas_usb_probe, - .remove = palmas_usb_remove, .driver = { .name = "palmas-usb", .of_match_table = of_palmas_match_tbl, |
