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: 10768 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 8A07923E00 for ; Thu, 16 Aug 2012 11:31:26 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3EE3EA18C5D for ; Thu, 16 Aug 2012 11:31:26 +0000 (UTC) Received: by yenl8 with SMTP id l8so2931210yen.11 for ; Thu, 16 Aug 2012 04:31:25 -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=U4hdB199IhxcCGZCpLlKN1R3drQviw398vqm2WMB5bs=; b=V61dtT+V004nifKHMI3qCyOjZgZ6pvMScqGruKYyWCvSFEAZXIVcq7vJfgJFgp+L8m uNEp2H2lm1Yb50gZpX5hRDXkSjFtNrk4Hb/EjrSgGKpnf2FETFc++coMHx8QT7CXqZST fSJyOplqQlnfsdokIqygtNFGCOHdNNuXtlAdG4IiWEKdCCu0T2fU8/nJ/1QuYPz9pxkC V8k5LyZfvw7eEaT3ljIZJgmmZfoK69Zab5bnPzMGaJBZb4UIbydApSDSRaCUnAGdedLE zJuTyh/OarDLYUb4WLq+aqKpjlvw3aSodJbLhZJbsjVlWRMNnXUV1PfgpE4aPoqnlTQr TP1Q== Received: by 10.50.159.135 with SMTP id xc7mr993633igb.9.1345116685249; Thu, 16 Aug 2012 04:31:25 -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.200 with SMTP id ew8csp120359igc; Thu, 16 Aug 2012 04:31:24 -0700 (PDT) Received: by 10.68.240.138 with SMTP id wa10mr2729227pbc.145.1345116684538; Thu, 16 Aug 2012 04:31:24 -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 sb7si7459688pbc.1.2012.08.16.04.31.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 04:31:24 -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 e7so505354dad.37 for ; Thu, 16 Aug 2012 04:31:24 -0700 (PDT) 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: ALoCoQmR462D5zkAFZrqo9xWP/FnmtBtUzrwX2ul7HzYnDV6eZZ8YB3NHuU25C++MavNWP+OmksV 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; }