extcon: max8997: Use devm_extcon_dev_allocate for extcon_dev
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 21 Apr 2014 11:37:51 +0000 (20:37 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 29 Apr 2014 00:46:28 +0000 (09:46 +0900)
This patch use devm_extcon_dev_allocate() to simplify the memory control
of extcon device.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
drivers/extcon/extcon-max8997.c

index 804a446..d9f7f1b 100644 (file)
@@ -699,16 +699,15 @@ 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 = devm_extcon_dev_register(&pdev->dev, info->edev);
        if (ret) {
                dev_err(&pdev->dev, "failed to register extcon device\n");