From patchwork Mon Sep 24 06:17:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11657 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 5A68D23F66 for ; Mon, 24 Sep 2012 06:21:36 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0C77BA18205 for ; Mon, 24 Sep 2012 06:21:35 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so9154810iej.11 for ; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) 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:in-reply-to:references :x-gm-message-state; bh=qsrSoz8b/TAOSmh4UFQChMQeaDROEp4fyu5qacDaeAs=; b=bn4dT9WKcizkDA2IAq9BQzG3XwZl76smDNUrzfzY8F0y9xV4eZ8YK/qBX4x4IN7UY4 cWSNEFENVnnapYR126AYvI1Sjf6BPANaHM1NeUbdNkcmVD+q82sDisz0jIfDZ52t3DkT dKi1HWDkcqHIQI7mYTdvAUvkSoRdu4PF5jAttHtCI/QWB7UP2Q5wmVFOeOzd441l/4Wp SNWREv8i9EtBZZmFbmrDkuQ3bhjAcp+C/z95nARYW75+qJPfUJmGSMf4U1wrgCIC/Dea ZiFEap4ETfLXrDIopWqdQgG8m5BAoPvmKhsd4OhHLXtQX79wDke95knjQI4v5H64A0Oa qj/w== Received: by 10.50.7.212 with SMTP id l20mr4329491iga.43.1348467695828; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) 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.184.232 with SMTP id ex8csp228639igc; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received: by 10.68.138.170 with SMTP id qr10mr33859639pbb.53.1348467695303; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id s7si6036439pax.190.2012.09.23.23.21.35 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 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-pb0-f50.google.com with SMTP id md12so12518347pbc.37 for ; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received: by 10.66.83.129 with SMTP id q1mr30266762pay.4.1348467695047; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id ho7sm9161024pbc.3.2012.09.23.23.21.32 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Sep 2012 23:21:34 -0700 (PDT) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: mchehab@infradead.org, sachin.kamat@linaro.org, m.szyprowski@samsung.com, pawel@osciak.com, patches@linaro.org Subject: [PATCH 4/4] [media] mem2mem_testdev: Use devm_kzalloc() in probe Date: Mon, 24 Sep 2012 11:47:48 +0530 Message-Id: <1348467468-19854-4-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1348467468-19854-1-git-send-email-sachin.kamat@linaro.org> References: <1348467468-19854-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQlwkBVN/OZqnZREA9FsyCvQUTHtBXm7wImiRmAUXera7rOeiSqwLIGuxshySDqdKfIIDbf4 devm_kzalloc() makes error handling and cleanup simpler. Signed-off-by: Sachin Kamat Acked-by: Marek Szyprowski --- drivers/media/platform/mem2mem_testdev.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c index f7d15ec..cd1c844 100644 --- a/drivers/media/platform/mem2mem_testdev.c +++ b/drivers/media/platform/mem2mem_testdev.c @@ -1019,7 +1019,7 @@ static int m2mtest_probe(struct platform_device *pdev) struct video_device *vfd; int ret; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; @@ -1027,7 +1027,7 @@ static int m2mtest_probe(struct platform_device *pdev) ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) - goto free_dev; + return ret; atomic_set(&dev->num_inst, 0); mutex_init(&dev->dev_mutex); @@ -1073,8 +1073,6 @@ rel_vdev: video_device_release(vfd); unreg_dev: v4l2_device_unregister(&dev->v4l2_dev); -free_dev: - kfree(dev); return ret; } @@ -1089,7 +1087,6 @@ static int m2mtest_remove(struct platform_device *pdev) del_timer_sync(&dev->timer); video_unregister_device(dev->vfd); v4l2_device_unregister(&dev->v4l2_dev); - kfree(dev); return 0; }