Merge tag 'renesas-sh-drivers-for-v3.16' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / drivers / extcon / extcon-max8997.c
index 6a00464658c50a6fb1aadecdf8e22467bc7963ca..d9f7f1baaa030f50e8568caa7724194dbc8ea854 100644 (file)
@@ -699,23 +699,22 @@ static int max8997_muic_probe(struct platform_device *pdev)
        }
 
        /* External connector */
-       info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev),
-                                 GFP_KERNEL);
-       if (!info->edev) {
+       info->edev = devm_extcon_dev_allocate(&pdev->dev, max8997_extcon_cable);
+       if (IS_ERR(info->edev)) {
                dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
                ret = -ENOMEM;
                goto err_irq;
        }
        info->edev->name = DEV_NAME;
        info->edev->dev.parent = &pdev->dev;
-       info->edev->supported_cable = max8997_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");
                goto err_irq;
        }
 
-       if (pdata->muic_pdata) {
+       if (pdata && pdata->muic_pdata) {
                struct max8997_muic_platform_data *muic_pdata
                        = pdata->muic_pdata;
 
@@ -770,7 +769,8 @@ static int max8997_muic_probe(struct platform_device *pdev)
         * driver should notify cable state to upper layer.
         */
        INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq);
-       schedule_delayed_work(&info->wq_detcable, delay_jiffies);
+       queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
+                       delay_jiffies);
 
        return 0;
 
@@ -789,8 +789,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
                free_irq(muic_irqs[i].virq, info);
        cancel_work_sync(&info->irq_work);
 
-       extcon_dev_unregister(info->edev);
-
        return 0;
 }