From patchwork Wed Feb 26 15:27:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 25355 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A406F203C4 for ; Wed, 26 Feb 2014 15:28:27 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id o6sf3599007oag.6 for ; Wed, 26 Feb 2014 07:28:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=BxmyctvlT4u6Ym1p4Bkaq+Kp2Rnm9vLFLOd5a8S5dUU=; b=bInxpudPYVgseD54h6tFNNh6H42A5JeVGseicQNvF+nvSYQPkqrQ+uCgbTl9HR7y57 RXHckGiVldmNgnwUfWnj2MaUASrr+BsN/oP2KOYcKz3BhZlnpx4Ho1nUcHNwPJOTkip0 QxzScmjCpKSJbfOmldPg50zVkZ4DQJ8+YDmdEYdd9rHpu6hMt5gqAZ1CWZx0xZQROBK5 X2Vyr4Bqd35vqDYFvRDzJrFdigATvVsC4LMDnoJE6nkeRiar+UrDqmjW+BM5pdUjyPWd aQaF6OQ9I3NJ3GFBRGrrzumGGkoxnQzTdmwHl+obOZLsh85HiC507JlO3LFxqxbcmp3W 0i6g== X-Gm-Message-State: ALoCoQnbn6jKGe8QrD8Xne8wdMrdeFeXFmvMXJJjl5e41VgnBgXPzZ0/dm3bRiML1P5ZQ4w4FROY X-Received: by 10.50.114.105 with SMTP id jf9mr14925346igb.1.1393428507015; Wed, 26 Feb 2014 07:28:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.119 with SMTP id d110ls265212qga.32.gmail; Wed, 26 Feb 2014 07:28:26 -0800 (PST) X-Received: by 10.220.200.6 with SMTP id eu6mr424164vcb.35.1393428506831; Wed, 26 Feb 2014 07:28:26 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id l4si290688vch.129.2014.02.26.07.28.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 07:28:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jy13so2362913veb.9 for ; Wed, 26 Feb 2014 07:28:26 -0800 (PST) X-Received: by 10.52.117.115 with SMTP id kd19mr5338235vdb.15.1393428506733; Wed, 26 Feb 2014 07:28:26 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp34013vcz; Wed, 26 Feb 2014 07:28:26 -0800 (PST) X-Received: by 10.68.0.35 with SMTP id 3mr7456311pbb.52.1393428505800; Wed, 26 Feb 2014 07:28:25 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk9si1346523pac.296.2014.02.26.07.28.24; Wed, 26 Feb 2014 07:28:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751170AbaBZP2Y (ORCPT + 9 others); Wed, 26 Feb 2014 10:28:24 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:54288 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbaBZP2X (ORCPT ); Wed, 26 Feb 2014 10:28:23 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1QFSGa6002431; Wed, 26 Feb 2014 09:28:16 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1QFSGUs014251; Wed, 26 Feb 2014 09:28:16 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 26 Feb 2014 09:28:15 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1QFSAC3027272; Wed, 26 Feb 2014 09:28:13 -0600 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v2 1/8] Input: pixcir_i2c_ts: Use devres managed resource allocations Date: Wed, 26 Feb 2014 17:27:59 +0200 Message-ID: <1393428486-15001-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393428486-15001-1-git-send-email-rogerq@ti.com> References: <1393428486-15001-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use devm_() and friends for allocating memory, input device and IRQ. Signed-off-by: Roger Quadros Acked-by: Mugunthan V N --- drivers/input/touchscreen/pixcir_i2c_ts.c | 34 ++++++++++++------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 02392d2..38e83a2 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -130,6 +130,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, { const struct pixcir_ts_platform_data *pdata = dev_get_platdata(&client->dev); + struct device *dev = &client->dev; struct pixcir_i2c_ts_data *tsdata; struct input_dev *input; int error; @@ -139,12 +140,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, return -EINVAL; } - tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL); - input = input_allocate_device(); - if (!tsdata || !input) { - dev_err(&client->dev, "Failed to allocate driver data!\n"); - error = -ENOMEM; - goto err_free_mem; + tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(&client->dev, "Failed to allocate input device\n"); + return -ENOMEM; } tsdata->client = client; @@ -165,29 +168,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, input_set_drvdata(input, tsdata); - error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr, + error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, client->name, tsdata); if (error) { - dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); - goto err_free_mem; + dev_err(dev, "failed to request irq %d\n", client->irq); + return error; } error = input_register_device(input); if (error) - goto err_free_irq; + return error; i2c_set_clientdata(client, tsdata); device_init_wakeup(&client->dev, 1); return 0; - -err_free_irq: - free_irq(client->irq, tsdata); -err_free_mem: - input_free_device(input); - kfree(tsdata); - return error; } static int pixcir_i2c_ts_remove(struct i2c_client *client) @@ -198,10 +194,6 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client) tsdata->exiting = true; mb(); - free_irq(client->irq, tsdata); - - input_unregister_device(tsdata->input); - kfree(tsdata); return 0; }