usb: otg: twl: use devres API to allocate resources
used devres API while allocating memory resource in twl4030 and twl6030 so that these resources are released automatically on driver detach. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
b1183c242a
commit
b8a3efa3a3
|
@ -591,15 +591,13 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
twl = kzalloc(sizeof *twl, GFP_KERNEL);
|
twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL);
|
||||||
if (!twl)
|
if (!twl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
otg = kzalloc(sizeof *otg, GFP_KERNEL);
|
otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL);
|
||||||
if (!otg) {
|
if (!otg)
|
||||||
kfree(twl);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
twl->dev = &pdev->dev;
|
twl->dev = &pdev->dev;
|
||||||
twl->irq = platform_get_irq(pdev, 0);
|
twl->irq = platform_get_irq(pdev, 0);
|
||||||
|
@ -623,8 +621,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
|
||||||
err = twl4030_usb_ldo_init(twl);
|
err = twl4030_usb_ldo_init(twl);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "ldo init failed\n");
|
dev_err(&pdev->dev, "ldo init failed\n");
|
||||||
kfree(otg);
|
|
||||||
kfree(twl);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2);
|
usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2);
|
||||||
|
@ -648,8 +644,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
|
dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
|
||||||
twl->irq, status);
|
twl->irq, status);
|
||||||
kfree(otg);
|
|
||||||
kfree(twl);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,9 +687,6 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
|
||||||
regulator_put(twl->usb1v8);
|
regulator_put(twl->usb1v8);
|
||||||
regulator_put(twl->usb3v1);
|
regulator_put(twl->usb3v1);
|
||||||
|
|
||||||
kfree(twl->phy.otg);
|
|
||||||
kfree(twl);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,15 +395,13 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
pdata = dev->platform_data;
|
pdata = dev->platform_data;
|
||||||
|
|
||||||
twl = kzalloc(sizeof *twl, GFP_KERNEL);
|
twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL);
|
||||||
if (!twl)
|
if (!twl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
otg = kzalloc(sizeof *otg, GFP_KERNEL);
|
otg = devm_kzalloc(dev, sizeof *otg, GFP_KERNEL);
|
||||||
if (!otg) {
|
if (!otg)
|
||||||
kfree(twl);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
twl->dev = &pdev->dev;
|
twl->dev = &pdev->dev;
|
||||||
twl->irq1 = platform_get_irq(pdev, 0);
|
twl->irq1 = platform_get_irq(pdev, 0);
|
||||||
|
@ -430,8 +428,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
|
||||||
err = twl6030_usb_ldo_init(twl);
|
err = twl6030_usb_ldo_init(twl);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "ldo init failed\n");
|
dev_err(&pdev->dev, "ldo init failed\n");
|
||||||
kfree(otg);
|
|
||||||
kfree(twl);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2);
|
usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2);
|
||||||
|
@ -450,8 +446,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
|
||||||
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
||||||
twl->irq1, status);
|
twl->irq1, status);
|
||||||
device_remove_file(twl->dev, &dev_attr_vbus);
|
device_remove_file(twl->dev, &dev_attr_vbus);
|
||||||
kfree(otg);
|
|
||||||
kfree(twl);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,8 +457,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
|
||||||
twl->irq2, status);
|
twl->irq2, status);
|
||||||
free_irq(twl->irq1, twl);
|
free_irq(twl->irq1, twl);
|
||||||
device_remove_file(twl->dev, &dev_attr_vbus);
|
device_remove_file(twl->dev, &dev_attr_vbus);
|
||||||
kfree(otg);
|
|
||||||
kfree(twl);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,8 +487,6 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev)
|
||||||
pdata->phy_exit(twl->dev);
|
pdata->phy_exit(twl->dev);
|
||||||
device_remove_file(twl->dev, &dev_attr_vbus);
|
device_remove_file(twl->dev, &dev_attr_vbus);
|
||||||
cancel_work_sync(&twl->set_vbus_work);
|
cancel_work_sync(&twl->set_vbus_work);
|
||||||
kfree(twl->phy.otg);
|
|
||||||
kfree(twl);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue