From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 439AFC433DF for ; Fri, 5 Jun 2020 19:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 119722074B for ; Fri, 5 Jun 2020 19:50:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="ZQGk/Wcm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbgFETuI (ORCPT ); Fri, 5 Jun 2020 15:50:08 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:41599 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbgFETuH (ORCPT ); Fri, 5 Jun 2020 15:50:07 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49dtXG0LfBz4D; Fri, 5 Jun 2020 21:49:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1591386603; bh=nw6ZPbzMEGEU3ympvmvF/EBnKh28J/TObnDHFEogcNM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZQGk/WcmQdG+yyITewmCzwmMOtBeMJF66LJXev36YPIF5HrC5ZHZ2yLz3vJylFOY2 WT3VOkjF3kAcjfTkMR4gxIzFUE/sY5FqXj8AFOnZJ4Tr6DOXWsqghWyoTnW+bmLd7W jwf7lDWpwE9H61I5VhaqXwCJeCG+3Lg1TEqxk1KZ6vhl2INRouIoCb0udoubFJKGQI IsEim/o9vF8TNZ0H+HPzCDx+zT08J5O7Oou9dsj0/dTuOSTcvd1399RdkvL5g6/Eot j+wtjmvTFf8Ae7wTPa5xvRXyXIACc/X1FvT/PQI7a7lj4fzSUFS7z0POvlS/mwXhVU JIdjeHtEOaibA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Fri, 5 Jun 2020 21:49:48 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Andrzej Pietrasiewicz Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-input@vger.kernel.org, linux-tegra@vger.kernel.org, patches@opensource.cirrus.com, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Kukjin Kim , Krzysztof Kozlowski , Dmitry Torokhov , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Vladimir Zapolskiy , Sylvain Lemieux , Laxman Dewangan , Thierry Reding , Jonathan Hunter , Barry Song , Michael Hennerich , Nick Dyer , Hans de Goede , Ferruh Yigit , Sangwon Jee , Peter Hutterer , Henrique de Moraes Holschuh , kernel@collabora.com Subject: Re: [PATCH v3 5/7] iio: adc: exynos: Use input_device_enabled() Message-ID: <20200605194948.GC9553@qmqm.qmqm.pl> References: <20200604072853.GP89269@dtor-ws> <20200605173335.13753-1-andrzej.p@collabora.com> <20200605173335.13753-6-andrzej.p@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200605173335.13753-6-andrzej.p@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Fri, Jun 05, 2020 at 07:33:33PM +0200, Andrzej Pietrasiewicz wrote: > A new helper is available, so use it. Inspecting 'users' member of > input_dev requires taking device's mutex. > > Signed-off-by: Andrzej Pietrasiewicz > --- > drivers/iio/adc/exynos_adc.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c > index 22131a677445..294715bafe25 100644 > --- a/drivers/iio/adc/exynos_adc.c > +++ b/drivers/iio/adc/exynos_adc.c > @@ -630,10 +630,13 @@ static irqreturn_t exynos_ts_isr(int irq, void *dev_id) > struct exynos_adc *info = dev_id; > struct iio_dev *dev = dev_get_drvdata(info->dev); > u32 x, y; > - bool pressed; > + bool pressed, cont; > int ret; > > - while (info->input->users) { > + mutex_lock(&info->input->mutex); > + cont = input_device_enabled(info->input); > + mutex_unlock(&info->input->mutex); > + while (cont) { > ret = exynos_read_s3c64xx_ts(dev, &x, &y); > if (ret == -ETIMEDOUT) > break; > @@ -651,6 +654,10 @@ static irqreturn_t exynos_ts_isr(int irq, void *dev_id) > input_sync(info->input); > > usleep_range(1000, 1100); > + > + mutex_lock(&info->input->mutex); > + cont = input_device_enabled(info->input); > + mutex_unlock(&info->input->mutex); > } The mutex doesn't really protect anything here, but I would nevertheless suggest this sequence instead: lock() while (test) { unlock() ... lock() } unlock() Best Regards, Michał Mirosław