From: Ben Dooks Date: Tue, 17 Jun 2014 15:14:56 +0000 (+0100) Subject: usb: gadget: r8a66597-udc: use devm_kzalloc() to allocate driver state X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=531bc938f9c54c5c0998ec537195ed4a3c74a608;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git usb: gadget: r8a66597-udc: use devm_kzalloc() to allocate driver state Update driver to use devm_kzalloc() to make tracking of resources easier. Also remove the exit point via cleanup as there's no cleanup necessary from this point now. As a note, also removes the error print as the allocation calls produce errors if they do not return memory. Signed-off-by: Ben Dooks Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index 78f855ffb1da..48a9e0bbe6a6 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c @@ -1836,7 +1836,6 @@ static int __exit r8a66597_remove(struct platform_device *pdev) clk_put(r8a66597->clk); } - kfree(r8a66597); return 0; } @@ -1892,11 +1891,9 @@ static int __init r8a66597_probe(struct platform_device *pdev) } /* initialize ucd */ - r8a66597 = kzalloc(sizeof(struct r8a66597), GFP_KERNEL); - if (r8a66597 == NULL) { - ret = -ENOMEM; - goto clean_up; - } + r8a66597 = devm_kzalloc(dev, sizeof(struct r8a66597), GFP_KERNEL); + if (r8a66597 == NULL) + return -ENOMEM; spin_lock_init(&r8a66597->lock); platform_set_drvdata(pdev, r8a66597); @@ -1995,7 +1992,6 @@ clean_up: if (r8a66597->ep0_req) r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); - kfree(r8a66597); } return ret;