From patchwork Wed Apr 30 12:36:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 29421 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89BB0203F3 for ; Wed, 30 Apr 2014 12:38:59 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id x3sf679390qcv.10 for ; Wed, 30 Apr 2014 05:38:59 -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=pg07eVJCS7Btm57ewfXdu18pjbTcjTYEeRhFB0Rn5hM=; b=JQc/O0Y+iUPuNyBdzhMmC+4kVKNj5RWtBCXxp4EB3VN8bAPj4vw67sBQuqFQW+IU3P ldV8KVRmeVSEt/RDcIq0nu/o7HXKmtcj/0zXQabkYbCPhLrkazWVyUMCy4t3RtQ5O3iV L6cOqhYm9ujir3yW8irhhs7k5alEG7VUCdNW37+okMwF2iOOOJMf2sPpsJ6zRszNHZ74 42uupCoNpLMydZKEXQP5qZ6rChrFSr5ZQeR9WiWu06JvFZP5dtYF9wfnt0xsc5FDDTrs 90oPwb8VdQHkZfJjNw/PMUuVkfeOenHMMIhVsngrVp0+Pq101kSa8NqK0iFG233FI7z7 3CAQ== X-Gm-Message-State: ALoCoQlzDfrNA4+Wpop3YxPgF/cLNZHeCmOV4nits2QlN6JzuXhRhYxuC7Ksftv4FTBfAxlXi8bS X-Received: by 10.58.141.200 with SMTP id rq8mr2214303veb.31.1398861539195; Wed, 30 Apr 2014 05:38:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.210 with SMTP id o76ls485436qga.66.gmail; Wed, 30 Apr 2014 05:38:59 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr3802702vcx.4.1398861539048; Wed, 30 Apr 2014 05:38:59 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id u5si5261746vdo.184.2014.04.30.05.38.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Apr 2014 05:38:59 -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.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so2088541veb.10 for ; Wed, 30 Apr 2014 05:38:59 -0700 (PDT) X-Received: by 10.220.69.72 with SMTP id y8mr3744876vci.21.1398861538952; Wed, 30 Apr 2014 05:38:58 -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 ib8csp275515vcb; Wed, 30 Apr 2014 05:38:58 -0700 (PDT) X-Received: by 10.67.5.233 with SMTP id cp9mr7815852pad.147.1398861538218; Wed, 30 Apr 2014 05:38:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sf3si16851353pac.370.2014.04.30.05.38.56 for ; Wed, 30 Apr 2014 05:38:56 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1758942AbaD3Miq (ORCPT + 28 others); Wed, 30 Apr 2014 08:38:46 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:52552 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758893AbaD3Mgq (ORCPT ); Wed, 30 Apr 2014 08:36:46 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3UCafUg006546; Wed, 30 Apr 2014 07:36:41 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3UCafZ4031434; Wed, 30 Apr 2014 07:36:41 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 30 Apr 2014 07:36:41 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3UCaZTB018190; Wed, 30 Apr 2014 07:36:39 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v3 1/7] Input: pixcir_i2c_ts: Use devres managed resource allocations Date: Wed, 30 Apr 2014 15:36:26 +0300 Message-ID: <1398861392-8959-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398861392-8959-1-git-send-email-rogerq@ti.com> References: <1398861392-8959-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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 | 36 +++++++++++++------------------ 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 02392d2..45bc2d1 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,8 @@ 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; }