From patchwork Tue Jan 8 10:05:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1944991 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id BA9A63FC5A for ; Tue, 8 Jan 2013 10:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755395Ab3AHKNY (ORCPT ); Tue, 8 Jan 2013 05:13:24 -0500 Received: from mail-da0-f41.google.com ([209.85.210.41]:53277 "EHLO mail-da0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755406Ab3AHKNV (ORCPT ); Tue, 8 Jan 2013 05:13:21 -0500 Received: by mail-da0-f41.google.com with SMTP id e20so125736dak.0 for ; Tue, 08 Jan 2013 02:13:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=e9bZULAyh0PS1KMq6zRYz6PfqriN3szg1mZS4KjGDHU=; b=nqssjr1zztceaeV74H6kEcK0bB7UynolkU5kRfI2KJGUsIjalxSuQhRb+rt986essT br+g2c9lG9ejdi9UN38bJAVNn1kxi/D5tDDkE/ouSVG5OjAaGPNx2m9wcSMgbPxUPniT 4YqPq+a+IAhB9eaLbcEnwKGHDQ/WJyHmVYtmz4K+1xOV/uPOHUfHwy11X65urIejy971 HSTGCYW4w3MT6Nt0BbQmLsU40f1jHDAOOM0t8Wvtiq4tGHWXnLJbPqrkgx5XclS0Aavy q37rK4jOdK4PYBI1/2fmq3BUjDiB/iNK+Nn8Uy77fAi2MnjNg9sQWi4HGJQskX+G0Qpt Xgxg== X-Received: by 10.68.220.161 with SMTP id px1mr45425242pbc.167.1357640001362; Tue, 08 Jan 2013 02:13:21 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id c2sm40495340pay.34.2013.01.08.02.13.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 02:13:20 -0800 (PST) From: Sachin Kamat To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, sachin.kamat@linaro.org, patche@linaro.org, Joonyoung Shim Subject: [PATCH 1/1] Input: mms114: Use devm_* APIs Date: Tue, 8 Jan 2013 15:35:08 +0530 Message-Id: <1357639508-15645-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQndGHoKWz6iJT+eURsTicZ6afRonXW6KClRwwuK+C4xEXzBH75lxi8oLppBMaxFOdbpLyp3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org devm_* APIs are device managed and make the exit and clean up code simpler. Signed-off-by: Sachin Kamat Cc: Joonyoung Shim --- Compile tested against linux-next tree (20130108). --- drivers/input/touchscreen/mms114.c | 41 +++++++++++------------------------ 1 files changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 98841d8..22295ec 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -429,12 +429,12 @@ static int mms114_probe(struct i2c_client *client, return -ENODEV; } - data = kzalloc(sizeof(struct mms114_data), GFP_KERNEL); - input_dev = input_allocate_device(); + data = devm_kzalloc(&client->dev, sizeof(struct mms114_data), + GFP_KERNEL); + input_dev = devm_input_allocate_device(&client->dev); if (!data || !input_dev) { dev_err(&client->dev, "Failed to allocate memory\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } data->client = client; @@ -466,58 +466,43 @@ static int mms114_probe(struct i2c_client *client, input_set_drvdata(input_dev, data); i2c_set_clientdata(client, data); - data->core_reg = regulator_get(&client->dev, "avdd"); + data->core_reg = devm_regulator_get(&client->dev, "avdd"); if (IS_ERR(data->core_reg)) { error = PTR_ERR(data->core_reg); dev_err(&client->dev, "Unable to get the Core regulator (%d)\n", error); - goto err_free_mem; + return error; } - data->io_reg = regulator_get(&client->dev, "vdd"); + data->io_reg = devm_regulator_get(&client->dev, "vdd"); if (IS_ERR(data->io_reg)) { error = PTR_ERR(data->io_reg); dev_err(&client->dev, "Unable to get the IO regulator (%d)\n", error); - goto err_core_reg; + return error; } - error = request_threaded_irq(client->irq, NULL, mms114_interrupt, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "mms114", data); + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, + mms114_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "mms114", data); if (error) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_io_reg; + return error; } disable_irq(client->irq); error = input_register_device(data->input_dev); if (error) - goto err_free_irq; + return error; return 0; - -err_free_irq: - free_irq(client->irq, data); -err_io_reg: - regulator_put(data->io_reg); -err_core_reg: - regulator_put(data->core_reg); -err_free_mem: - input_free_device(input_dev); - kfree(data); - return error; } static int mms114_remove(struct i2c_client *client) { struct mms114_data *data = i2c_get_clientdata(client); - free_irq(client->irq, data); - regulator_put(data->io_reg); - regulator_put(data->core_reg); input_unregister_device(data->input_dev); - kfree(data); - return 0; }