From patchwork Wed Apr 24 12:28:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 2484341 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 946ED3FCA5 for ; Wed, 24 Apr 2013 12:28:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758403Ab3DXM2N (ORCPT ); Wed, 24 Apr 2013 08:28:13 -0400 Received: from mga09.intel.com ([134.134.136.24]:54105 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758400Ab3DXM2N (ORCPT ); Wed, 24 Apr 2013 08:28:13 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 24 Apr 2013 05:26:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,542,1363158000"; d="scan'208";a="300482156" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.173]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2013 05:28:11 -0700 Received: from andy by smile with local (Exim 4.80) (envelope-from ) id 1UUynw-0004yK-QM; Wed, 24 Apr 2013 15:28:08 +0300 From: Andy Shevchenko To: linux-input@vger.kernel.org, Dmitry Torokhov Cc: Andy Shevchenko Subject: [PATCH] input: egalax_ts: move to devm_* functions Date: Wed, 24 Apr 2013 15:28:07 +0300 Message-Id: <1366806487-19075-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.8.2.rc0.22.gb3600c3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The usage of devm_* functions makes code cleaner and tidier. Signed-off-by: Andy Shevchenko --- drivers/input/touchscreen/egalax_ts.c | 46 +++++++++++------------------------ 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 21584bf..bd6e9d7 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -167,24 +167,22 @@ static int egalax_firmware_version(struct i2c_client *client) } static int egalax_ts_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct egalax_ts *ts; struct input_dev *input_dev; - int ret; int error; - ts = kzalloc(sizeof(struct egalax_ts), GFP_KERNEL); + ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL); if (!ts) { dev_err(&client->dev, "Failed to allocate memory\n"); return -ENOMEM; } - input_dev = input_allocate_device(); + input_dev = devm_input_allocate_device(&client->dev); if (!input_dev) { dev_err(&client->dev, "Failed to allocate memory\n"); - error = -ENOMEM; - goto err_free_ts; + return -ENOMEM; } ts->client = client; @@ -194,14 +192,13 @@ static int egalax_ts_probe(struct i2c_client *client, error = egalax_wake_up_device(client); if (error) { dev_err(&client->dev, "Failed to wake up the controller\n"); - goto err_free_dev; + return error; } - ret = egalax_firmware_version(client); - if (ret < 0) { + error = egalax_firmware_version(client); + if (error < 0) { dev_err(&client->dev, "Failed to read firmware version\n"); - error = -EIO; - goto err_free_dev; + return error; } input_dev->name = "EETI eGalax Touch Screen"; @@ -222,40 +219,25 @@ static int egalax_ts_probe(struct i2c_client *client, input_set_drvdata(input_dev, ts); - error = request_threaded_irq(client->irq, NULL, egalax_ts_interrupt, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "egalax_ts", ts); + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, + egalax_ts_interrupt, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "egalax_ts", ts); if (error < 0) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_free_dev; + return error; } error = input_register_device(ts->input_dev); if (error) - goto err_free_irq; + return error; i2c_set_clientdata(client, ts); return 0; - -err_free_irq: - free_irq(client->irq, ts); -err_free_dev: - input_free_device(input_dev); -err_free_ts: - kfree(ts); - - return error; } static int egalax_ts_remove(struct i2c_client *client) { - struct egalax_ts *ts = i2c_get_clientdata(client); - - free_irq(client->irq, ts); - - input_unregister_device(ts->input_dev); - kfree(ts); - return 0; }