From patchwork Wed Sep 5 11:25:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1408641 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id ECA863FC71 for ; Wed, 5 Sep 2012 11:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751238Ab2IEL2P (ORCPT ); Wed, 5 Sep 2012 07:28:15 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:41315 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826Ab2IEL2O (ORCPT ); Wed, 5 Sep 2012 07:28:14 -0400 Received: by dady13 with SMTP id y13so300122dad.19 for ; Wed, 05 Sep 2012 04:28:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=VvEVLlmNrRdma4p1ecvp4aRyB99h3g83XIIKHxZb160=; b=ppxy8N+CM+FDB8MIRxmf0aHqLNvwp1j0WdvyRnw7/rpu11Is+GXN/IMpv89Px2Zrc/ 2Y6RZPla/An9hkPuqlJKZRKgTjkCzTp49EYIYR57xieK8QEiH8SkFHnA1+K2ekw6pxBK +iOCCjQBu5g/of2qRNGyHDTAF1syIGUkU9p1mVjt41BFRNp2NHxnBdALwmSMmxxWyGFM qZ6sVcfZyvlWxwqfGPgGkBz7HTbYQE+o+isDXSZB2rYFnFhLXoiduJ8VdWIopz0JxUAt g7uKRTt3or9xAqwPSioenZCT1f4QLsPNS7VIAyUUJoGZzzj7XQqEjpiPDTMTpJbxxlX5 IzGg== Received: by 10.68.231.168 with SMTP id th8mr54679333pbc.14.1346844494003; Wed, 05 Sep 2012 04:28:14 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id uu6sm1216195pbc.70.2012.09.05.04.28.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 04:28:12 -0700 (PDT) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: mchehab@infradead.org, g.liakhovetski@gmx.de Subject: [PATCH 1/2] [media] soc_camera: Use devm_kzalloc function Date: Wed, 5 Sep 2012 16:55:26 +0530 Message-Id: <1346844327-5524-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQn7GVHlIuPThCbLda9RSj9bexILQLufiVggTTzaKV2YESaHiO9YJ+D6FMHbXXq7qg7TIWT4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org devm_kzalloc() has been used to simplify error handling. While at it, the soc_camera_device_register function has been moved to save a few lines of code and a variable. Signed-off-by: Sachin Kamat --- drivers/media/platform/soc_camera/soc_camera.c | 15 ++------------- 1 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 10b57f8..acf5289 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1529,12 +1529,11 @@ static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) { struct soc_camera_link *icl = pdev->dev.platform_data; struct soc_camera_device *icd; - int ret; if (!icl) return -EINVAL; - icd = kzalloc(sizeof(*icd), GFP_KERNEL); + icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL); if (!icd) return -ENOMEM; @@ -1543,19 +1542,11 @@ static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) icd->pdev = &pdev->dev; platform_set_drvdata(pdev, icd); - ret = soc_camera_device_register(icd); - if (ret < 0) - goto escdevreg; icd->user_width = DEFAULT_WIDTH; icd->user_height = DEFAULT_HEIGHT; - return 0; - -escdevreg: - kfree(icd); - - return ret; + return soc_camera_device_register(icd); } /* @@ -1572,8 +1563,6 @@ static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev) list_del(&icd->list); - kfree(icd); - return 0; }