From patchwork Fri Apr 25 14:38:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 4063631 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EEEA3BFF02 for ; Fri, 25 Apr 2014 14:39:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 119232037A for ; Fri, 25 Apr 2014 14:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A37220166 for ; Fri, 25 Apr 2014 14:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751494AbaDYOi6 (ORCPT ); Fri, 25 Apr 2014 10:38:58 -0400 Received: from mail-yk0-f177.google.com ([209.85.160.177]:46202 "EHLO mail-yk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750844AbaDYOi5 (ORCPT ); Fri, 25 Apr 2014 10:38:57 -0400 Received: by mail-yk0-f177.google.com with SMTP id q200so3346019ykb.22 for ; Fri, 25 Apr 2014 07:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Oi2v8lzNgzL8eEtFmoji9sQXtvejqsD/DbYgbc100a0=; b=itwDxwbkT8RZbLd/JtdgmP98+o9EKB4vc2KH0N8Q3bjR63Gco9PjlNKPRpxccRQuVS oqAOfaL6UAL68R6IJhcPgO2h8eZC1UqNVcm0iNnW/DRmw4xF+rLMJqfipxHPA07DYyu0 WtlwGM+yBcZoFX3GL2cZVi86/knLlEJg/xUkcAVTIxdqlSvxaBcXpTfJO1cm7fB3L0lz ZK9HBm4f3D9RGYGyQyavm6joLFeSxpjXRl3Yf+H4yPJkdQ3veJz4mKZyGrG2LVdRB4pR RBf+lrKjlRiN9saVzjE/FIr0Qxk/mLZ1Ho4upLK1iy+4Wi9eovwDGA8TayUlH2mjJGfg fURA== X-Received: by 10.236.128.180 with SMTP id f40mr11992355yhi.71.1398436736585; Fri, 25 Apr 2014 07:38:56 -0700 (PDT) Received: from localhost.localdomain ([177.194.43.224]) by mx.google.com with ESMTPSA id e70sm13819878yhk.9.2014.04.25.07.38.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 07:38:55 -0700 (PDT) From: Fabio Estevam To: dmitry.torokhov@gmail.com Cc: peter.ujfalusi@ti.com, linux-input@vger.kernel.org, Fabio Estevam Subject: [PATCH v2] Input: twl6040-vibra - use devm functions Date: Fri, 25 Apr 2014 11:38:28 -0300 Message-Id: <1398436708-3903-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam Using devm_regulator_bulk_get() and devm_input_allocate_device() can make the code cleaner and smaller as we do not need to call regulator_bulk_free() in the error and remove paths. Signed-off-by: Fabio Estevam --- Changes since v1: - Also use devm_input_allocate_device() drivers/input/misc/twl6040-vibra.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index 77dc23b..76aa602 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c @@ -323,8 +323,9 @@ static int twl6040_vibra_probe(struct platform_device *pdev) * When booted with Device tree the regulators are attached to the * parent device (twl6040 MFD core) */ - ret = regulator_bulk_get(twl6040_core_dev, ARRAY_SIZE(info->supplies), - info->supplies); + ret = devm_regulator_bulk_get(twl6040_core_dev, + ARRAY_SIZE(info->supplies), + info->supplies); if (ret) { dev_err(info->dev, "couldn't get regulators %d\n", ret); return ret; @@ -336,7 +337,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev) if (ret) { dev_err(info->dev, "failed to set VDDVIBL volt %d\n", ret); - goto err_regulator; + return ret; } } @@ -346,17 +347,16 @@ static int twl6040_vibra_probe(struct platform_device *pdev) if (ret) { dev_err(info->dev, "failed to set VDDVIBR volt %d\n", ret); - goto err_regulator; + return ret; } } INIT_WORK(&info->play_work, vibra_play_work); - info->input_dev = input_allocate_device(); + info->input_dev = devm_input_allocate_device(&pdev->dev); if (info->input_dev == NULL) { dev_err(info->dev, "couldn't allocate input device\n"); - ret = -ENOMEM; - goto err_regulator; + return -ENOMEM; } input_set_drvdata(info->input_dev, info); @@ -370,7 +370,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev) ret = input_ff_create_memless(info->input_dev, NULL, vibra_play); if (ret < 0) { dev_err(info->dev, "couldn't register vibrator to FF\n"); - goto err_ialloc; + return ret; } ret = input_register_device(info->input_dev); @@ -385,10 +385,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev) err_iff: input_ff_destroy(info->input_dev); -err_ialloc: - input_free_device(info->input_dev); -err_regulator: - regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); return ret; } @@ -397,7 +393,6 @@ static int twl6040_vibra_remove(struct platform_device *pdev) struct vibra_info *info = platform_get_drvdata(pdev); input_unregister_device(info->input_dev); - regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); return 0; }