From patchwork Thu Dec 13 15:14:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10728885 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 1586291E for ; Thu, 13 Dec 2018 15:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05D9928742 for ; Thu, 13 Dec 2018 15:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDE0F2C45E; Thu, 13 Dec 2018 15:15:09 +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 8020128742 for ; Thu, 13 Dec 2018 15:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbeLMPPJ (ORCPT ); Thu, 13 Dec 2018 10:15:09 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:33092 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729429AbeLMPPI (ORCPT ); Thu, 13 Dec 2018 10:15:08 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43Fy0T2mqyz1qxRw; Thu, 13 Dec 2018 16:15:05 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43Fy0T2MPrz1qtfL; Thu, 13 Dec 2018 16:15:05 +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 40sz6SbrpvqR; Thu, 13 Dec 2018 16:15:04 +0100 (CET) X-Auth-Info: IseDMC9JOTl79KxaS1LGKAAFuvsnE/uE9UvnUESXseE= 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; Thu, 13 Dec 2018 16:15:04 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie Subject: [PATCH 3/8] input: touchscreen: ili210x: Convert to threaded IRQ Date: Thu, 13 Dec 2018 16:14:37 +0100 Message-Id: <20181213151442.27854-4-marex@denx.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181213151442.27854-1-marex@denx.de> References: <20181213151442.27854-1-marex@denx.de> 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 Get rid of the workqueue, just spawn a threaded IRQ and handle all the touchscreen readouts in the handler thread. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie To: linux-input@vger.kernel.org --- drivers/input/touchscreen/ili210x.c | 51 +++++------------------------ 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 7ba93de712432..1102ee560bf4d 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -5,7 +5,6 @@ #include #include #include -#include #define MAX_TOUCHES 2 #define DEFAULT_POLL_PERIOD 20 @@ -43,9 +42,6 @@ struct firmware_version { struct ili210x { struct i2c_client *client; struct input_dev *input; - bool (*get_pendown_state)(void); - unsigned int poll_period; - struct delayed_work dwork; }; static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, @@ -102,20 +98,9 @@ static void ili210x_report_events(struct input_dev *input, input_sync(input); } -static bool get_pendown_state(const struct ili210x *priv) -{ - bool state = false; - - if (priv->get_pendown_state) - state = priv->get_pendown_state(); - - return state; -} - -static void ili210x_work(struct work_struct *work) +static irqreturn_t ili210x_irq(int irq, void *irq_data) { - struct ili210x *priv = container_of(work, struct ili210x, - dwork.work); + struct ili210x *priv = irq_data; struct i2c_client *client = priv->client; struct touchdata touchdata; int error; @@ -125,21 +110,10 @@ static void ili210x_work(struct work_struct *work) if (error) { dev_err(&client->dev, "Unable to get touchdata, err = %d\n", error); - return; + return IRQ_HANDLED; } - ili210x_report_events(priv->input, &touchdata); - - if ((touchdata.status & 0xf3) || get_pendown_state(priv)) - schedule_delayed_work(&priv->dwork, - msecs_to_jiffies(priv->poll_period)); -} - -static irqreturn_t ili210x_irq(int irq, void *irq_data) -{ - struct ili210x *priv = irq_data; - - schedule_delayed_work(&priv->dwork, 0); + ili210x_report_events(priv, &touchdata); return IRQ_HANDLED; } @@ -224,8 +198,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, priv->client = client; priv->input = input; - priv->poll_period = DEFAULT_POLL_PERIOD; - INIT_DELAYED_WORK(&priv->dwork, ili210x_work); /* Setup input device */ input->name = "ILI210x Touchscreen"; @@ -248,19 +220,19 @@ 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_threaded_irq(dev, client->irq, NULL, ili210x_irq, + IRQF_ONESHOT, client->name, priv); if (error) { dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", error); - goto err_free_mem; + 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); @@ -279,19 +251,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); input_unregister_device(priv->input); return 0;