From patchwork Wed Sep 5 11:43:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11194 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 8FF5D23E41 for ; Wed, 5 Sep 2012 11:46:13 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 21DA1A18599 for ; Wed, 5 Sep 2012 11:45:20 +0000 (UTC) Received: by iafj25 with SMTP id j25so595635iaf.11 for ; Wed, 05 Sep 2012 04:46:12 -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:x-gm-message-state; bh=VvEVLlmNrRdma4p1ecvp4aRyB99h3g83XIIKHxZb160=; b=gwPBY+K1L6mIDEizxiI2flbQ/VX4fY1QDPmwLojhNBrOKXoxD3Lbl2zQFCQscHHfpF jlnuYJb0X28kgGj0eVz8Z/xwxIvAioQTbYp9zplrzJRA1PVQFm45skg18xSMUmpolRzq AxGdd7uE+sGT+I0pI1mPlhtsCAV2o1xImAiPF5HLOMGY1cNAxkqQxNkYonTdVgeHQLjV 5HpQGcx0b0p7+mvSlyctT8GaysHvOEuLWK5hus4OoxM78yDb4p26xyBFspkjWf2g01Or gL9yUThnOObZpqNXzQ9nmHrtbnPHjL459LxfbiYh0l57Xmzut+K6NngAquG4LR74aLTG bRPQ== Received: by 10.50.180.129 with SMTP id do1mr17524970igc.28.1346845572339; Wed, 05 Sep 2012 04:46:12 -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 ex8csp248913igc; Wed, 5 Sep 2012 04:46:11 -0700 (PDT) Received: by 10.68.138.135 with SMTP id qq7mr54790899pbb.167.1346845571286; Wed, 05 Sep 2012 04:46:11 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id pv1si2228375pbb.149.2012.09.05.04.46.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 04:46:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 dade7 with SMTP id e7so348824dad.37 for ; Wed, 05 Sep 2012 04:46:10 -0700 (PDT) Received: by 10.66.76.197 with SMTP id m5mr48372494paw.66.1346845570722; Wed, 05 Sep 2012 04:46:10 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id oc2sm1249324pbb.69.2012.09.05.04.46.06 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 04:46:09 -0700 (PDT) From: Sachin Kamat To: patches@linaro.org Cc: sachin.kamat@linaro.org Subject: [PATCH 1/2] [media] soc_camera: Use devm_kzalloc function Date: Wed, 5 Sep 2012 17:13:19 +0530 Message-Id: <1346845400-24598-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmQAUiTnewQ7WRrv2aJukgfONMAInJ/Zuk5bCT+9Rb4fDZxgigc108Q0jaoDvJwQ6RZTGUm 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; }