From patchwork Tue May 6 11:06:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 29690 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D99B20534 for ; Tue, 6 May 2014 11:06:40 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kx10sf33812760pab.10 for ; Tue, 06 May 2014 04:06:40 -0700 (PDT) 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=sVxhdV+ufVsIprEuUZABE4GpUm6i17/J/h9Mzquie70=; b=Hxn8Z183wc6REjKhvSUsWv0XHH29i32f6ZAwmylD2oT9E86VRoz4lcYR7175agUUPl IW1/DcMlUl9RO9kKcYW9I7FTQxZPV6nZUstX+21x2GGb283m3Wv+fBb+dPriXeKNhAUg NTqdm2drNg8C8pk//SgjNVoQzCGeCVrARi/dZZG44dgBoTLnAV9cTT7TBkl476aHBOgg tdgaOwgxLZR1C7+AHVKoCoBzyRhBBWHj7dd2JvoYM1qZjWETSnZQQlXVTHuFjg5lOiV1 DXkGDoji3ZBawy2TrK384iHKH78fBKwHnxGv9B9c+V8gAdi+syauejJZkQLNO2r8ehrj yg2g== X-Gm-Message-State: ALoCoQkjCoSghH7oGT3+W3nATNcMpsBbRf+9Ty0KO6Ka2LQKI540d7POds4+Et5NSUi/2q8mz3gr X-Received: by 10.67.5.165 with SMTP id cn5mr920665pad.9.1399374400137; Tue, 06 May 2014 04:06:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.107 with SMTP id b98ls2851273qgd.64.gmail; Tue, 06 May 2014 04:06:40 -0700 (PDT) X-Received: by 10.52.166.18 with SMTP id zc18mr355954vdb.65.1399374400001; Tue, 06 May 2014 04:06:40 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id sg6si1051418vdc.117.2014.05.06.04.06.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 May 2014 04:06:39 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id hy4so695472vcb.26 for ; Tue, 06 May 2014 04:06:39 -0700 (PDT) X-Received: by 10.58.243.39 with SMTP id wv7mr17806vec.51.1399374399925; Tue, 06 May 2014 04:06:39 -0700 (PDT) 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.221.72 with SMTP id ib8csp213636vcb; Tue, 6 May 2014 04:06:39 -0700 (PDT) X-Received: by 10.66.253.170 with SMTP id ab10mr5114021pad.53.1399374398979; Tue, 06 May 2014 04:06:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yb4si11716327pab.308.2014.05.06.04.06.38; Tue, 06 May 2014 04:06:38 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934885AbaEFLGd (ORCPT + 8 others); Tue, 6 May 2014 07:06:33 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:47659 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934579AbaEFLG3 (ORCPT ); Tue, 6 May 2014 07:06:29 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s46B6Q27007836; Tue, 6 May 2014 06:06:26 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s46B6Q37019141; Tue, 6 May 2014 06:06:26 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Tue, 6 May 2014 06:06:26 -0500 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 s46B6Kf6021055; Tue, 6 May 2014 06:06:23 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v5 1/7] Input: pixcir_i2c_ts: Use devres managed resource allocations Date: Tue, 6 May 2014 14:06:06 +0300 Message-ID: <1399374372-29123-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399374372-29123-1-git-send-email-rogerq@ti.com> References: <1399374372-29123-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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 | 38 ++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 02392d2..8a083bd 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, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - client->name, tsdata); + 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; }