Skip to content

Commit

Permalink
usb: phy: nop: use devm_kzalloc()
Browse files Browse the repository at this point in the history
Use resource managed kzalloc.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Roger Quadros authored and Felipe Balbi committed Mar 18, 2013
1 parent 1f0972f commit e4d7dc6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions drivers/usb/otg/nop-usb-xceiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
enum usb_phy_type type = USB_PHY_TYPE_USB2;
int err;

nop = kzalloc(sizeof *nop, GFP_KERNEL);
nop = devm_kzalloc(&pdev->dev, sizeof(*nop), GFP_KERNEL);
if (!nop)
return -ENOMEM;

nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL);
if (!nop->phy.otg) {
kfree(nop);
nop->phy.otg = devm_kzalloc(&pdev->dev, sizeof(*nop->phy.otg),
GFP_KERNEL);
if (!nop->phy.otg)
return -ENOMEM;
}

if (pdata)
type = pdata->type;
Expand All @@ -127,18 +126,14 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err);
goto exit;
return err;
}

platform_set_drvdata(pdev, nop);

ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier);

return 0;
exit:
kfree(nop->phy.otg);
kfree(nop);
return err;
}

static int nop_usb_xceiv_remove(struct platform_device *pdev)
Expand All @@ -148,8 +143,6 @@ static int nop_usb_xceiv_remove(struct platform_device *pdev)
usb_remove_phy(&nop->phy);

platform_set_drvdata(pdev, NULL);
kfree(nop->phy.otg);
kfree(nop);

return 0;
}
Expand Down

0 comments on commit e4d7dc6

Please sign in to comment.