Message ID | 1355308995-29631-1-git-send-email-sachin.kamat@linaro.org |
---|---|
State | Superseded |
Headers | show |
On Wed, Dec 12, 2012 at 04:13:15PM +0530, Sachin Kamat wrote: > devm_kzalloc is device managed and makes error handling and cleanup > simpler. While at it also fixed the return value when platform_device_alloc > failed in probe function. > > Cc: Anton Tikhomirov <av.tikhomirov@samsung.com> > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> what's wrong with http://www.spinics.net/lists/linux-usb/msg74326.html ?
Hi, On Wed, Dec 12, 2012 at 05:08:09PM +0530, Sachin Kamat wrote: > On 12 December 2012 16:51, Felipe Balbi <balbi@ti.com> wrote: > > On Wed, Dec 12, 2012 at 04:13:15PM +0530, Sachin Kamat wrote: > >> devm_kzalloc is device managed and makes error handling and cleanup > >> simpler. While at it also fixed the return value when platform_device_alloc > >> failed in probe function. > >> > >> Cc: Anton Tikhomirov <av.tikhomirov@samsung.com> > >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> > > > > what's wrong with http://www.spinics.net/lists/linux-usb/msg74326.html ? > > Looks good to me though the creation of '*dev' was not really necessary. > I had not looked at the above patch. Please ignore mine. yeah, it's definitely not necessary and GCC will optimize it anyway ;-) cheers
On 12 December 2012 16:51, Felipe Balbi <balbi@ti.com> wrote: > On Wed, Dec 12, 2012 at 04:13:15PM +0530, Sachin Kamat wrote: >> devm_kzalloc is device managed and makes error handling and cleanup >> simpler. While at it also fixed the return value when platform_device_alloc >> failed in probe function. >> >> Cc: Anton Tikhomirov <av.tikhomirov@samsung.com> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> > > what's wrong with http://www.spinics.net/lists/linux-usb/msg74326.html ? Looks good to me though the creation of '*dev' was not really necessary. I had not looked at the above patch. Please ignore mine. > > -- > balbi
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index aae5328..db3bd49 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -98,10 +98,10 @@ static int dwc3_exynos_probe(struct platform_device *pdev) int ret = -ENOMEM; - exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); + exynos = devm_kzalloc(&pdev->dev, sizeof(*exynos), GFP_KERNEL); if (!exynos) { dev_err(&pdev->dev, "not enough memory\n"); - goto err0; + return -ENOMEM; } /* @@ -117,13 +117,13 @@ static int dwc3_exynos_probe(struct platform_device *pdev) ret = dwc3_exynos_register_phys(exynos); if (ret) { dev_err(&pdev->dev, "couldn't register PHYs\n"); - goto err1; + return ret; } dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); if (!dwc3) { dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); - goto err1; + return -ENOMEM; } clk = clk_get(&pdev->dev, "usbdrd30"); @@ -164,9 +164,6 @@ err4: clk_put(clk); err3: platform_device_put(dwc3); -err1: - kfree(exynos); -err0: return ret; } @@ -181,8 +178,6 @@ static int dwc3_exynos_remove(struct platform_device *pdev) clk_disable(exynos->clk); clk_put(exynos->clk); - kfree(exynos); - return 0; }
devm_kzalloc is device managed and makes error handling and cleanup simpler. While at it also fixed the return value when platform_device_alloc failed in probe function. Cc: Anton Tikhomirov <av.tikhomirov@samsung.com> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> --- Compile tested on linux-next tree. --- drivers/usb/dwc3/dwc3-exynos.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-)