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: 13935 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id AAA8123E21 for ; Wed, 9 Jan 2013 04:24:04 +0000 (UTC) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 3650FA18F00 for ; Wed, 9 Jan 2013 04:24:04 +0000 (UTC) Received: by mail-vb0-f52.google.com with SMTP id ez10so1156410vbb.39 for ; Tue, 08 Jan 2013 20:24:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=UG6c5U5wEtm4cSdPlH/4rl1nQlQXqJVAo23/xqn0QkM=; b=LSqqnqKjdOnwPuwSTkSQbPzFHJyB4DCzk2vSG2J5bUje9Ou278MdcprzxHbYRh8uaY z6QG1Iv7pYT4J45ntSzaJc/MnGSQsd3ccVlq5u+U4XmYgJBvzhId02jWu2pRl4ArC6UR JJ+2l3xyLPCYREQ2WiyduesKo+9NJyZ7NfE9jf7KQ+bMu/fdbSdNsw/JLshh2i8ZqdoV Di9wqShQ9cRlMEj40GFPSIH8jCMu8EPiFkc4MHvqCUpr/BtkU1PpVjC8tptpJ0v+RkJZ GIecDD1l89xJhbhDZ48JMYDwea0/CiQnvL8Upu0oNpiQEoP+xmex4fP1qB4wlbbZ7P8P DAqg== X-Received: by 10.58.210.65 with SMTP id ms1mr89321744vec.59.1357705443604; Tue, 08 Jan 2013 20:24:03 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp145325veb; Tue, 8 Jan 2013 20:24:03 -0800 (PST) X-Received: by 10.66.75.100 with SMTP id b4mr186096018paw.0.1357705442578; Tue, 08 Jan 2013 20:24:02 -0800 (PST) Received: from mail-pb0-f49.google.com (mail-pb0-f49.google.com [209.85.160.49]) by mx.google.com with ESMTPS id f9si65152490paw.343.2013.01.08.20.24.02 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:24:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.49 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.49; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.49 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pb0-f49.google.com with SMTP id un15so679457pbc.8 for ; Tue, 08 Jan 2013 20:24:02 -0800 (PST) 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: ALoCoQmqJUKF9PyaKP7IPxLtt2BP+OIuMM2ENwPUsCiuNowc/GgxTh9uVDhigxR5CYTQfl+8uQSQ 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, };