From patchwork Wed Jan 9 09:22:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1951371 Return-Path: X-Original-To: patchwork-linux-input@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 869D6DF25A for ; Wed, 9 Jan 2013 09:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757512Ab3AIJbi (ORCPT ); Wed, 9 Jan 2013 04:31:38 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:62207 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757510Ab3AIJbg (ORCPT ); Wed, 9 Jan 2013 04:31:36 -0500 Received: by mail-pa0-f46.google.com with SMTP id bh2so914236pad.5 for ; Wed, 09 Jan 2013 01:31:36 -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=i2hgFL5C2rxdWpftZ3XTEcZZFI6htoEjaDwIGoIch8Y=; b=c+qLA/A7sD7Nmdzee3jXgMPpmmOK/fAqFEmONFLWg+/Gg+WcbLBDPFcWT49M8Fxtm2 LmN3yW8uu5AlebIp2bM5HE5RE8+8WK+zpO9oqfgdNPWnGo6QBmvi3npdgyVG6Ygzw4s2 Z7mT2+uMmibi97/zx9D9ma4e7yRxlFPwekiIGlBX3+Iueb1HtajJbVdaIi6+0XlgIO1g 05DeG4vTA5eif0EhR4X0B/KnoJCrXsLDcTEYxzmh+22EPQgQB2VkldzEQnElr9X5RFC4 +BkwfGu+SswXTZfCbsQYedjVOTOviu2xVzOOhJ0Nrns098Iho1R8Yh6ur14vZUHsRvue At1w== X-Received: by 10.66.84.10 with SMTP id u10mr189019951pay.24.1357723896039; Wed, 09 Jan 2013 01:31:36 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id wg3sm41322390pbc.28.2013.01.09.01.31.33 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Jan 2013 01:31:35 -0800 (PST) From: Sachin Kamat To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, sachin.kamat@linaro.org, patches@linaro.org, Joonyoung Shim Subject: [PATCH v3] Input: mms114: Use devm_* APIs Date: Wed, 9 Jan 2013 14:52:33 +0530 Message-Id: <1357723353-11144-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQm44cDN7weiSp8LC9gdv+t4MK4Tf61bwEpquFSBJx+Haji070HzjDBaSMOYJnVX7p4E38gN 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 Acked-by: Laxman Dewangan --- Compile tested against linux-next (20130109). Changes since: v2: Addressed review comments. v1: Removed input_unregister_device() call. --- drivers/input/touchscreen/mms114.c | 54 ++++++++++------------------------- 1 files changed, 16 insertions(+), 38 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 98841d8..a9cb475 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,57 +466,36 @@ 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, + dev_name(&client->dev), 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 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); + if (error) { + dev_err(&client->dev, "Failed to register device\n"); + return error; + } return 0; } @@ -590,7 +569,6 @@ static struct i2c_driver mms114_driver = { .of_match_table = of_match_ptr(mms114_dt_match), }, .probe = mms114_probe, - .remove = mms114_remove, .id_table = mms114_id, };