From patchwork Thu Aug 16 11:29:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1330881 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id AD33CE0000 for ; Thu, 16 Aug 2012 11:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751213Ab2HPLbm (ORCPT ); Thu, 16 Aug 2012 07:31:42 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39683 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063Ab2HPLbY (ORCPT ); Thu, 16 Aug 2012 07:31:24 -0400 Received: by pbbrr13 with SMTP id rr13so1450458pbb.19 for ; Thu, 16 Aug 2012 04:31:24 -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=U4hdB199IhxcCGZCpLlKN1R3drQviw398vqm2WMB5bs=; b=AIak0aaUdh6nTplGAqfj0T8kW/EKPpMEjaki7q8EkvhWm/9MDBzTK/n+AU083zfI6Y AtOOW9b3Jec7BzGDCGFfMZ+CpGgG8zLoA62ZNjXwEMX+I8aOmNOd2QPpElUNQAZxOkuD CXiolOdQ6cEFbJMb/+l5QWark3ZGFZ660iOt3N2LNWFQquOvFXauZ/m7Gf7PWmwPgYWc QdUClozH6Eli443sMyrqfMKaHbJkfVIis3PPgJvMkFNTVnvWJGHvZnKiJ2OTqLUaDBc5 A5eubtm+DfA7Z/uQUPIyFdgkfslFwexbnBxaoH37zMh82e6g+Iefv257ys79Vovyhv3R N4Ag== Received: by 10.68.130.65 with SMTP id oc1mr2942407pbb.29.1345116683895; Thu, 16 Aug 2012 04:31:23 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id pg9sm2518318pbb.26.2012.08.16.04.31.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 04:31:23 -0700 (PDT) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: mchehab@infradead.org, sakari.ailus@iki.fi, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH] smiapp: Use devm_kzalloc() in smiapp-core.c file Date: Thu, 16 Aug 2012 16:59:30 +0530 Message-Id: <1345116570-27335-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQnsnXYUNEGQoLmOZ0xJ1LjPBz5sgTDJewfhtjdZ0NV/Mr1q9cK805GlgDb1ypnvXReCZZMZ Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org devm_kzalloc is a device managed function and makes code a bit smaller and cleaner. Signed-off-by: Sachin Kamat --- This patch is based on Mauro's re-organized tree (media_tree staging/for_v3.7) and is compile tested. --- drivers/media/i2c/smiapp/smiapp-core.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 1cf914d..7d4280e 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2801,12 +2801,11 @@ static int smiapp_probe(struct i2c_client *client, const struct i2c_device_id *devid) { struct smiapp_sensor *sensor; - int rval; if (client->dev.platform_data == NULL) return -ENODEV; - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); if (sensor == NULL) return -ENOMEM; @@ -2821,12 +2820,8 @@ static int smiapp_probe(struct i2c_client *client, sensor->src->sensor = sensor; sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; - rval = media_entity_init(&sensor->src->sd.entity, 2, + return media_entity_init(&sensor->src->sd.entity, 2, sensor->src->pads, 0); - if (rval < 0) - kfree(sensor); - - return rval; } static int __exit smiapp_remove(struct i2c_client *client) @@ -2862,8 +2857,6 @@ static int __exit smiapp_remove(struct i2c_client *client) if (sensor->vana) regulator_put(sensor->vana); - kfree(sensor); - return 0; }