usb: phy: nop: use devm_kzalloc()

Use resource managed kzalloc.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Roger Quadros 2013-03-12 13:24:20 +02:00 committed by Felipe Balbi
parent 1f0972f5b0
commit e4d7dc6674

View file

@ -100,15 +100,14 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
enum usb_phy_type type = USB_PHY_TYPE_USB2; enum usb_phy_type type = USB_PHY_TYPE_USB2;
int err; int err;
nop = kzalloc(sizeof *nop, GFP_KERNEL); nop = devm_kzalloc(&pdev->dev, sizeof(*nop), GFP_KERNEL);
if (!nop) if (!nop)
return -ENOMEM; return -ENOMEM;
nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL); nop->phy.otg = devm_kzalloc(&pdev->dev, sizeof(*nop->phy.otg),
if (!nop->phy.otg) { GFP_KERNEL);
kfree(nop); if (!nop->phy.otg)
return -ENOMEM; return -ENOMEM;
}
if (pdata) if (pdata)
type = pdata->type; type = pdata->type;
@ -127,7 +126,7 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
if (err) { if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n", dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err); err);
goto exit; return err;
} }
platform_set_drvdata(pdev, nop); platform_set_drvdata(pdev, nop);
@ -135,10 +134,6 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier); ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier);
return 0; return 0;
exit:
kfree(nop->phy.otg);
kfree(nop);
return err;
} }
static int nop_usb_xceiv_remove(struct platform_device *pdev) static int nop_usb_xceiv_remove(struct platform_device *pdev)
@ -148,8 +143,6 @@ static int nop_usb_xceiv_remove(struct platform_device *pdev)
usb_remove_phy(&nop->phy); usb_remove_phy(&nop->phy);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(nop->phy.otg);
kfree(nop);
return 0; return 0;
} }