Merge tag 'for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux...
[linux-2.6-microblaze.git] / drivers / power / supply / axp20x_usb_power.c
index 8933ae2..a1d110f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/bitops.h>
 #include <linux/device.h>
+#include <linux/devm-helpers.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -593,7 +594,11 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
        power->axp20x_id = axp_data->axp20x_id;
        power->regmap = axp20x->regmap;
        power->num_irqs = axp_data->num_irq_names;
-       INIT_DELAYED_WORK(&power->vbus_detect, axp20x_usb_power_poll_vbus);
+
+       ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect,
+                                          axp20x_usb_power_poll_vbus);
+       if (ret)
+               return ret;
 
        if (power->axp20x_id == AXP202_ID) {
                /* Enable vbus valid checking */
@@ -614,8 +619,10 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
 
        if (power->axp20x_id == AXP813_ID) {
                /* Enable USB Battery Charging specification detection */
-               regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL,
+               ret = regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL,
                                   AXP813_BC_EN, AXP813_BC_EN);
+               if (ret)
+                       return ret;
        }
 
        psy_cfg.of_node = pdev->dev.of_node;
@@ -652,15 +659,6 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int axp20x_usb_power_remove(struct platform_device *pdev)
-{
-       struct axp20x_usb_power *power = platform_get_drvdata(pdev);
-
-       cancel_delayed_work_sync(&power->vbus_detect);
-
-       return 0;
-}
-
 static const struct of_device_id axp20x_usb_power_match[] = {
        {
                .compatible = "x-powers,axp202-usb-power-supply",
@@ -680,7 +678,6 @@ MODULE_DEVICE_TABLE(of, axp20x_usb_power_match);
 
 static struct platform_driver axp20x_usb_power_driver = {
        .probe = axp20x_usb_power_probe,
-       .remove = axp20x_usb_power_remove,
        .driver = {
                .name           = DRVNAME,
                .of_match_table = axp20x_usb_power_match,