Merge branch 'for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
[firefly-linux-kernel-4.4.55.git] / drivers / extcon / extcon-max14577.c
index c76734a70171756a351167b58601712b0258c4fd..d49e891b5675985d7702d77ad958117a7713e4d8 100644 (file)
@@ -721,7 +721,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
                unsigned int virq = 0;
 
                virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);
-               if (!virq)
+               if (virq <= 0)
                        return -EINVAL;
                muic_irq->virq = virq;
 
@@ -739,15 +739,16 @@ static int max14577_muic_probe(struct platform_device *pdev)
        }
 
        /* Initialize extcon device */
-       info->edev = devm_kzalloc(&pdev->dev, sizeof(*info->edev), GFP_KERNEL);
-       if (!info->edev) {
+       info->edev = devm_extcon_dev_allocate(&pdev->dev,
+                                             max14577_extcon_cable);
+       if (IS_ERR(info->edev)) {
                dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
                return -ENOMEM;
        }
 
        info->edev->name = dev_name(&pdev->dev);
-       info->edev->supported_cable = max14577_extcon_cable;
-       ret = extcon_dev_register(info->edev);
+
+       ret = devm_extcon_dev_register(&pdev->dev, info->edev);
        if (ret) {
                dev_err(&pdev->dev, "failed to register extcon device\n");
                return ret;
@@ -766,7 +767,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
                        MAX14577_REG_DEVICEID, &id);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to read revision number\n");
-               goto err_extcon;
+               return ret;
        }
        dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -782,18 +783,9 @@ static int max14577_muic_probe(struct platform_device *pdev)
         * driver should notify cable state to upper layer.
         */
        INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq);
-       ret = queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
+       queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
                        delay_jiffies);
-       if (ret < 0) {
-               dev_err(&pdev->dev,
-                       "failed to schedule delayed work for cable detect\n");
-               goto err_extcon;
-       }
-
-       return ret;
 
-err_extcon:
-       extcon_dev_unregister(info->edev);
        return ret;
 }
 
@@ -802,7 +794,6 @@ static int max14577_muic_remove(struct platform_device *pdev)
        struct max14577_muic_info *info = platform_get_drvdata(pdev);
 
        cancel_work_sync(&info->irq_work);
-       extcon_dev_unregister(info->edev);
 
        return 0;
 }