From patchwork Mon May 5 09:04:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 29622 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7721D2055D for ; Mon, 5 May 2014 09:05:04 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id w7sf10517411qcr.8 for ; Mon, 05 May 2014 02:05:04 -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=t7FSsXwJFvpTbx/2GhcggjqdEPEmFhpMDF81zuFfcEs=; b=KagM9FSUf7KeHSOV6FuCPTH4VBpV2fV8/dhwAuyIrO+g6ntZvY6AOP3fEuNgAu/C7Z F+URRIbYYKzVmxJ3v+zimQg8EJPzxXdPx0ActC3tvRP26vzgYbpYTrMNvqhJ5QunhnWp wLRSu7qnakhlCcdLr67dKhj9jRNeefadOqRVSgC+E/Py129FM+ooRnPpf6wui0fN3xTw U6Z+8NVdRUj3q1sScBeJz5mZZQmHB4+MlTAIhVcK1DXPcY40WzVgL16grAuvQH7Wvhgy QXu3kLGRHLGEOuW4KscOLeBk8Fk7g+4iH39Vfp0wJHSqHPwtRCnjtRmcWsC4cIhaXB4f ZbsA== X-Gm-Message-State: ALoCoQkzdL1PzVW/NYGlYU7tTVpnM94hDQpo3Pv3bCd2X5pAO7wKLoKIFefh/DNfKH2bkU3Gn3/V X-Received: by 10.58.105.105 with SMTP id gl9mr15997295veb.17.1399280704231; Mon, 05 May 2014 02:05:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.201 with SMTP id e67ls2520057qgf.94.gmail; Mon, 05 May 2014 02:05:04 -0700 (PDT) X-Received: by 10.220.92.193 with SMTP id s1mr17600vcm.34.1399280704100; Mon, 05 May 2014 02:05:04 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id sa1si29692vdb.214.2014.05.05.02.05.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 02:05:04 -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.179; Received: by mail-vc0-f179.google.com with SMTP id il7so2897938vcb.38 for ; Mon, 05 May 2014 02:05:04 -0700 (PDT) X-Received: by 10.58.154.10 with SMTP id vk10mr27657776veb.18.1399280704026; Mon, 05 May 2014 02:05:04 -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 ib8csp124308vcb; Mon, 5 May 2014 02:05:03 -0700 (PDT) X-Received: by 10.66.140.104 with SMTP id rf8mr69114059pab.107.1399280702739; Mon, 05 May 2014 02:05:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pn4si7765545pac.462.2014.05.05.02.05.01; Mon, 05 May 2014 02:05:01 -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 S1755564AbaEEJEw (ORCPT + 27 others); Mon, 5 May 2014 05:04:52 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:37985 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755095AbaEEJEu (ORCPT ); Mon, 5 May 2014 05:04:50 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4594kWx013009; Mon, 5 May 2014 04:04:46 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4594kek018859; Mon, 5 May 2014 04:04:46 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Mon, 5 May 2014 04:04:46 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4594ep0022901; Mon, 5 May 2014 04:04:43 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v4 1/7] Input: pixcir_i2c_ts: Use devres managed resource allocations Date: Mon, 5 May 2014 12:04:32 +0300 Message-ID: <1399280678-23925-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399280678-23925-1-git-send-email-rogerq@ti.com> References: <1399280678-23925-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 | 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; }