From patchwork Wed Jan 30 06:48:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10787753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 918E4184E for ; Wed, 30 Jan 2019 06:48:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F8FC2CA0E for ; Wed, 30 Jan 2019 06:48:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70DAC2C1CA; Wed, 30 Jan 2019 06:48:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A812C9A6 for ; Wed, 30 Jan 2019 06:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbfA3Gsv (ORCPT ); Wed, 30 Jan 2019 01:48:51 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:56614 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfA3Gsu (ORCPT ); Wed, 30 Jan 2019 01:48:50 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43qDV85h0Zz1qvvq; Wed, 30 Jan 2019 07:48:48 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43qDV85G1Qz1rVwb; Wed, 30 Jan 2019 07:48:48 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 3t2m96vyWmNt; Wed, 30 Jan 2019 07:48:47 +0100 (CET) X-Auth-Info: BytJugluQO8jM1st9spvnvneocRErj6M2Pf12l77ooU= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 30 Jan 2019 07:48:47 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V4 06/10] input: touchscreen: ili210x: Convert to devm IRQ Date: Wed, 30 Jan 2019 07:48:31 +0100 Message-Id: <20190130064835.8418-7-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190130064835.8418-1-marex@denx.de> References: <20190130064835.8418-1-marex@denx.de> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert the driver to devm_request_irq(), drop the related unmanaged deregistration code and add ili210x_irq_teardown() to tear the IRQ down and cancel possible touchscreen pending work. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: Retain workqueue V3: Reword the commit message V4: Use devm_request_irq() instead of the threaded variant, add custom devm action to tear the IRQ down. --- drivers/input/touchscreen/ili210x.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index f8b20d302384..cd4ce0bef948 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -177,6 +177,13 @@ static void ili210x_power_down(void *data) gpiod_set_value_cansleep(reset_gpio, 1); } +static void ili210x_irq_teardown(void *data) +{ + struct ili210x *priv = data; + + cancel_delayed_work_sync(&priv->dwork); +} + static int ili210x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -266,19 +273,23 @@ static int ili210x_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, priv); - error = request_irq(client->irq, ili210x_irq, 0, - client->name, priv); + error = devm_request_irq(dev, client->irq, ili210x_irq, 0, + client->name, priv); if (error) { dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", error); - goto err_free_mem; + return error; } + error = devm_add_action(dev, ili210x_irq_teardown, priv); + if (error) + return error; + error = sysfs_create_group(&dev->kobj, &ili210x_attr_group); if (error) { dev_err(dev, "Unable to create sysfs attributes, err: %d\n", error); - goto err_free_irq; + return error; } error = input_register_device(priv->input); @@ -297,19 +308,12 @@ static int ili210x_i2c_probe(struct i2c_client *client, err_remove_sysfs: sysfs_remove_group(&dev->kobj, &ili210x_attr_group); -err_free_irq: - free_irq(client->irq, priv); -err_free_mem: return error; } static int ili210x_i2c_remove(struct i2c_client *client) { - struct ili210x *priv = i2c_get_clientdata(client); - sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group); - free_irq(priv->client->irq, priv); - cancel_delayed_work_sync(&priv->dwork); return 0; }