Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2396922ybg; Fri, 5 Jun 2020 12:53:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEU9m/1rv6CSRH8mJdJ6xoD/qkJy0ZoQGPHGcWqN2ZdNM5SzOhSDYA1x5mmJWuJkEZch8w X-Received: by 2002:a50:b5c3:: with SMTP id a61mr11060459ede.80.1591386813437; Fri, 05 Jun 2020 12:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591386813; cv=none; d=google.com; s=arc-20160816; b=jvw4QtpOBWBKXwiKDJfnEROCKO5OvIvbELWtIAoMNxWtFWCT/a7h04YkYlPHJ/Wsqx 48wJNvMYY3pWVXRjk8Z1ogtC1H7kQGUYz8mmJ6cozTmo4HpIfBNPJzK/WTMc6LPUdCbc 4HcYv3oQgB5kfbqma0TyIvyGLq0tY/TW/z05w0A43uHCUikgcvT82xN9oZB5LsqSQqov WqEzhFNJagBdolLXuHJk4K7+qJ8DRGYQv6bc+fKdT/4+F0r58o5g9zSeG5jxl3hh3Vve sMyJsT9lwrA7RCphogVlqMX42B8v55fwDRvbhOs+ullcyow7QyvOFUMvc0EQ0zLiei/R dUTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RiDRWGOpQX8bZgwvRWDC+SV+pnc8QB4WO4PcbJe+gpI=; b=nT4CZrJhWtKoubNX17pcstRvm0bxQpGfQrq+Css/tngewFS97eKNKmDOg/yQL9CWVi JysmPT/aSvyqdTtSLsprvK6Cu4XNS7SSdbIViq31dWakoBP5RWDMWYeqKHm4qQXRuSXU fBODhr5o8kS7E5KDStgDwuzlVmk803MidtKRG6zlRKmQEZhieyASBYMW3Hgt3j48tbUM E4LUPps7tBUZB/nilJ2f6aYnAzGiWgaStIjVKAAniS4fC7psOU2o0Kco5eyaQjvGnc8O A7rUTphqpR7W8e74eTP7mo7AuZlQGvDXpruUsh1eVNjSDUSetH6SGe05CaE+mUqU7F/R RKHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="ZQGk/Wcm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se20si3975876ejb.165.2020.06.05.12.53.10; Fri, 05 Jun 2020 12:53:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="ZQGk/Wcm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbgFETuJ (ORCPT + 99 others); Fri, 5 Jun 2020 15:50:09 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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