From patchwork Tue Oct 21 15:07:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 5126061 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38A669F3ED for ; Tue, 21 Oct 2014 15:10:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57026201CE for ; Tue, 21 Oct 2014 15:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B88D4201DD for ; Tue, 21 Oct 2014 15:10:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755707AbaJUPHs (ORCPT ); Tue, 21 Oct 2014 11:07:48 -0400 Received: from ring0.de ([5.45.105.125]:54001 "EHLO ring0.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755692AbaJUPHq (ORCPT ); Tue, 21 Oct 2014 11:07:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 From: Sebastian Reichel To: Hans Verkuil , linux-media@vger.kernel.org Cc: Tony Lindgren , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Sebastian Reichel Subject: [RFCv2 3/8] [media] si4713: use managed memory allocation Date: Tue, 21 Oct 2014 17:07:02 +0200 Message-Id: <1413904027-16767-4-git-send-email-sre@kernel.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1413904027-16767-1-git-send-email-sre@kernel.org> References: <1413904027-16767-1-git-send-email-sre@kernel.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce the usage of managed memory allocation to simplify the code slightly. Signed-off-by: Sebastian Reichel --- drivers/media/radio/si4713/si4713.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c index e560a7e..efc5d6b 100644 --- a/drivers/media/radio/si4713/si4713.c +++ b/drivers/media/radio/si4713/si4713.c @@ -1450,7 +1450,7 @@ static int si4713_probe(struct i2c_client *client, struct v4l2_ctrl_handler *hdl; int rval, i; - sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); + sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL); if (!sdev) { dev_err(&client->dev, "Failed to alloc video device.\n"); rval = -ENOMEM; @@ -1467,7 +1467,7 @@ static int si4713_probe(struct i2c_client *client, } else { rval = PTR_ERR(sdev->gpio_reset); dev_err(&client->dev, "Failed to request gpio: %d\n", rval); - goto free_sdev; + goto exit; } sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd"); @@ -1615,8 +1615,6 @@ free_irq: free_irq(client->irq, sdev); free_ctrls: v4l2_ctrl_handler_free(hdl); -free_sdev: - kfree(sdev); exit: return rval; } @@ -1635,7 +1633,6 @@ static int si4713_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(sdev); return 0; }