From patchwork Wed Dec 12 10:43:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13500 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 75E1F23FD9 for ; Wed, 12 Dec 2012 10:50:24 +0000 (UTC) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by fiordland.canonical.com (Postfix) with ESMTP id 0CFADA186F6 for ; Wed, 12 Dec 2012 10:50:23 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id qd14so1397474ieb.34 for ; Wed, 12 Dec 2012 02:50:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=9JqqGc+Kx4PebSQhicpZY+j3nFPpNA+a5OhzPQIH87s=; b=jInMBtXhGS76hHGCnRAaoHrnITV5WTSVwtWoqXNkibeNRTdsWYO/uMar9H3QV/or1o +fs2T3KM3dSywhHBaBuCXBboI/SKzmo7RHIV1KZyMeAZLKU52X+vEs4ETQYq3uGSoaA2 LCDco5gmJtktiYoiX/r+3Ku0IdozrKgOLQJ9rT3Kn26eS/sDKq0dnzx1lwfHxhVJtT77 MDce9C7QB/P9ScoB3Lf0jywnBGKws/+i7sB/wnHy8jQ0ipG34XlwHsyR+0l3fS/wVNUN 7IzLznup2O8NjZ2CNX8c4XkGMTGavOtj6Rbho4RZeuRhdWgEFR2yNl0nSDzhvVYw09ht Th/w== Received: by 10.50.161.169 with SMTP id xt9mr12713378igb.62.1355309423471; Wed, 12 Dec 2012 02:50:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp191312igt; Wed, 12 Dec 2012 02:50:23 -0800 (PST) Received: by 10.68.232.201 with SMTP id tq9mr1600395pbc.12.1355309422803; Wed, 12 Dec 2012 02:50:22 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id ka8si28598118pbc.275.2012.12.12.02.50.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 02:50:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pa0-f46.google.com with SMTP id bh2so487345pad.19 for ; Wed, 12 Dec 2012 02:50:22 -0800 (PST) Received: by 10.68.209.133 with SMTP id mm5mr1612756pbc.42.1355309422493; Wed, 12 Dec 2012 02:50:22 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id mt15sm15470341pbc.49.2012.12.12.02.50.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 02:50:21 -0800 (PST) From: Sachin Kamat To: linux-usb@vger.kernel.org Cc: balbi@ti.com, gregkh@linuxfoundation.org, sachin.kamat@linaro.org, patches@linaro.org, Anton Tikhomirov Subject: [PATCH 1/1] usb: dwc3: Use devm_kzalloc Date: Wed, 12 Dec 2012 16:13:15 +0530 Message-Id: <1355308995-29631-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmb0R8duJEHFh85/CLJC8uNMRwxsQQ/2WYryKrGazr9vLf2fqnM2zCu2ZBfsmTL+ODMJQsD 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 Signed-off-by: Sachin Kamat --- Compile tested on linux-next tree. --- drivers/usb/dwc3/dwc3-exynos.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) 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; }