From patchwork Wed Jan 9 04:15:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1950491 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 88C7BDFABD for ; Wed, 9 Jan 2013 04:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756606Ab3AIEYG (ORCPT ); Tue, 8 Jan 2013 23:24:06 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:51295 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757210Ab3AIEYC (ORCPT ); Tue, 8 Jan 2013 23:24:02 -0500 Received: by mail-pb0-f53.google.com with SMTP id jt11so677334pbb.40 for ; Tue, 08 Jan 2013 20:24:02 -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=UG6c5U5wEtm4cSdPlH/4rl1nQlQXqJVAo23/xqn0QkM=; b=jdn88vPq2oE1Lc5GUrAu+iSfqh0VF3qofTo1emofwCbDt1cm2lzjicvPbvm9sNY18T K7RUigSm6i9NUYZdh+dwPTFyhjMN72v0gKBP9/H8ZO+1azDwdrWF5/vgRtAUTVnP06Gx 9O5lph2SDrNrFo+4yXDPhzz37lnqnID2wxokB68jx2Xr+D6mpa/2Mulh+V3lQlmyO4PM rdAeqF9o+WZrSa38iJUBepyktp6E43XX9P+7IyOkecIFPDc5Ntn/bckN+ZA3be+yyrBL +E9rUOOaeSpSt8+JlNOAELAChAWimTyHRzkNTajadYtzZ57ym7kX7H9r4s5cFaK9UsRa 6QfQ== X-Received: by 10.68.222.232 with SMTP id qp8mr26356282pbc.99.1357705442080; Tue, 08 Jan 2013 20:24:02 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id x2sm42002364paw.8.2013.01.08.20.23.59 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:24:01 -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 Resend] Input: mms114: Use devm_* APIs Date: Wed, 9 Jan 2013 09:45:48 +0530 Message-Id: <1357704948-25758-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQli781+qXbF5+ywpbTZop0k06dCxThIH/Z8ZU/hLHy/PZc9anaGj1deABYimruTZpsHgPe1 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 --- drivers/input/touchscreen/mms114.c | 50 +++++++++-------------------------- 1 files changed, 13 insertions(+), 37 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 98841d8..656cc0b 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,34 @@ 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 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 error; return 0; } @@ -590,7 +567,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, };