From patchwork Thu Jan 21 19:21:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreste Salerno X-Patchwork-Id: 8084571 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7954BEEE5 for ; Thu, 21 Jan 2016 19:21:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCD0920445 for ; Thu, 21 Jan 2016 19:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F208620434 for ; Thu, 21 Jan 2016 19:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752537AbcAUTVb (ORCPT ); Thu, 21 Jan 2016 14:21:31 -0500 Received: from mail3.tomtom.com ([85.90.76.132]:34439 "EHLO mail3.tomtom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760025AbcAUTV1 (ORCPT ); Thu, 21 Jan 2016 14:21:27 -0500 Received: from NLSRVWP-EXC01.ttg.global (10.96.72.11) by nlsrvwp-tmg02.ttg.global (10.96.64.22) with Microsoft SMTP Server (TLS) id 14.3.169.1; Fri, 22 Jan 2016 03:06:02 +0100 Received: from NLSRVWP-EXN11.ttg.global (10.98.64.12) by NLSRVWP-EXC01.ttg.global (10.96.72.11) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 21 Jan 2016 20:21:21 +0100 Received: from nl1lxl-107192.tomtomgroup.com (10.98.250.94) by NLSRVWP-EXN11.ttg.global (10.98.64.12) with Microsoft SMTP Server (TLS) id 15.0.1076.9; Thu, 21 Jan 2016 20:21:21 +0100 From: Oreste Salerno To: CC: , , , , , , , , , Subject: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations Date: Thu, 21 Jan 2016 20:21:13 +0100 Message-ID: <20e9f0188f07fc420912b3defa747303be3cf290.1453403916.git.oreste.salerno@tomtom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.98.250.94] X-ClientProxiedBy: NLSRVWP-EXN10.ttg.global (10.98.64.11) To NLSRVWP-EXN11.ttg.global (10.98.64.12) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_() functions for allocating memory, input device and IRQ. Signed-off-by: Oreste Salerno --- drivers/input/touchscreen/cyttsp_core.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index 5b74e8b..3c2ee84 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c @@ -541,11 +541,11 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, goto err_out; } - ts = kzalloc(sizeof(*ts) + xfer_buf_size, GFP_KERNEL); - input_dev = input_allocate_device(); + ts = devm_kzalloc(dev, sizeof(*ts) + xfer_buf_size, GFP_KERNEL); + input_dev = devm_input_allocate_device(dev); if (!ts || !input_dev) { error = -ENOMEM; - goto err_free_mem; + goto err_out; } ts->dev = dev; @@ -562,7 +562,7 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, if (error) { dev_err(ts->dev, "platform init failed, err: %d\n", error); - goto err_free_mem; + goto err_out; } } @@ -586,9 +586,9 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, input_mt_init_slots(input_dev, CY_MAX_ID, 0); - error = request_threaded_irq(ts->irq, NULL, cyttsp_irq, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - pdata->name, ts); + error = devm_request_threaded_irq(dev, ts->irq, NULL, cyttsp_irq, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + pdata->name, ts); if (error) { dev_err(ts->dev, "failed to request IRQ %d, err: %d\n", ts->irq, error); @@ -599,25 +599,20 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, error = cyttsp_power_on(ts); if (error) - goto err_free_irq; + goto err_platform_exit; error = input_register_device(input_dev); if (error) { dev_err(ts->dev, "failed to register input device: %d\n", error); - goto err_free_irq; + goto err_platform_exit; } return ts; -err_free_irq: - free_irq(ts->irq, ts); err_platform_exit: if (pdata->exit) pdata->exit(); -err_free_mem: - input_free_device(input_dev); - kfree(ts); err_out: return ERR_PTR(error); } @@ -625,11 +620,8 @@ EXPORT_SYMBOL_GPL(cyttsp_probe); void cyttsp_remove(struct cyttsp *ts) { - free_irq(ts->irq, ts); - input_unregister_device(ts->input); if (ts->pdata->exit) ts->pdata->exit(); - kfree(ts); } EXPORT_SYMBOL_GPL(cyttsp_remove);