Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3588933ybb; Tue, 31 Mar 2020 08:10:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtJiDd4Mb3WeDjQ2qYkbKZzuvWda4yNc/TpYD4UfNypbDIcnFnctqMncXjhCTjJMONMM5V2 X-Received: by 2002:a9d:69d8:: with SMTP id v24mr13305936oto.148.1585667424737; Tue, 31 Mar 2020 08:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585667424; cv=none; d=google.com; s=arc-20160816; b=xKCANfTvpUAcJwCj4ppFMarojEKCStoPaWsGlpIeeUgnFte+riSBMoZBk19QReT/Uh EQVsMMOMeK/eVkiN3ByPwne43UWgiRVxz/GtcfPCAc6RP/KGN3joiH7EYdnhpUkMK1eq AAtTg1t+FEfF//1Ui6lg19UeOViPP1zoPTJYXy7k5c1wa095It/pp09IkxG3CL8R4VHz aPtscDcvZBURqJT7AYzcRplUq3UnAAkE9KYRYYuqK0BlMCVEpCqi/BB0yV/ixed7NpRX FWJ/49mkBifTckqG8MrLy3xz7YOhNYlRRrMPtmw+5XD5aStibtguSyCbU2SqvsCw1LcJ vb3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=PwB0D934cQb5SQBA8Gssrx/QqfXAhQTzkTrY8dLc730=; b=hQ9bro2YTP4X+271iNBtFbah+bFWdBTafTx2X/zPCOMmxzlkNAlS5kevxoACMhAEOg Hz58ZYKWkFc3bpFBa+aAJYoR758bCtTieJjw+eVzxv9EuVUOnipfN3UZkDRkpCVvJDVY LG+zngKzWAO7NPkZm2ipLgdMmtNNNojlgwAymtjB53avluCI/52Os8yCG3p6xWQZfDMx KV5mf/nvRdiqzouCsu9eXYq5P3TkXzYapZdqlk3gjxirAy/r67rbcFmPEI9Nf/Kz5dHo vd6vp+vK1SO/JiFI//3Awb7ftxR9uT9mgsTyDzFM+safbktDZt+q8xCR0OTdcwT/W2pg eiTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rEzm2CTK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n62si7335329oig.196.2020.03.31.08.09.37; Tue, 31 Mar 2020 08:10:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rEzm2CTK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730646AbgCaPIy (ORCPT + 99 others); Tue, 31 Mar 2020 11:08:54 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46311 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgCaPIx (ORCPT ); Tue, 31 Mar 2020 11:08:53 -0400 Received: by mail-lf1-f67.google.com with SMTP id q5so17576250lfb.13; Tue, 31 Mar 2020 08:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PwB0D934cQb5SQBA8Gssrx/QqfXAhQTzkTrY8dLc730=; b=rEzm2CTKyebjiOFIvL9oF95lC8hpwBApMoUjxpdJMcRMlrMaEnaWxeCHVSvpVYrPPs PVOovTtr/8XoluW1Ppmvsg+WxY/TFaftwdn9r/KhsDWVnRv/uP5TMOgBFHQwkW0eR0mr YzEhrkhJpRIiVt7ZT2+JaZjYqqhG4uBpgGyeAUeiypfI5SKy6Z/+lPtDlBYdQIpa6MQr umknyNjeTo4eprNsgtQ2VxguDGmyKYOULpWwEqHbyTCgBFqSs5NC8uvSjmSqO3cZ+Zb7 +o111W3VjCH9w7njSZrk8BlgdZnvqqXCkU43mYtqCMQ43gvKlXTr4lCUbOVEEP+nJDta BWLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PwB0D934cQb5SQBA8Gssrx/QqfXAhQTzkTrY8dLc730=; b=spSxySnQceUyPWdDkEfmW7SYyIFEAE0pEYDw7C1XtRDzuj125lTlv27H2osDznv8ay gTDFo9ITzLFCN2y3tPkynt+RQCprz8h/BQ1yjx+3OepPLSpv2QyWxuNv1lwPQaRbSi4n FQHboMyC3NgYlEPp2xErFBVGmwqlQVG0Ye66lsWdGDtaSyvW5fT483hfy6tDAbjPVmlS aMc9MZU3W4ucqWs4vPsYenAP+f3r1ZVJcmun8SBP5h1KEk2ZNnQVRGAmnpEdvmf+vBLQ lDUl9eS4oV6zEDEBUVDJ61VqNMhOk3a0gZ+dQh+otkPfGIUZWeJrqL7oCg5LBFmpMPJP Ki3A== X-Gm-Message-State: AGi0Pua5Kh530Zt5AbizHMCFX5BDV8FrsQ34xVHUKCWGPf/4Ibg2k8ki eXVVX9Vmgv1HWCjrhnYzs1Q= X-Received: by 2002:a19:c197:: with SMTP id r145mr11841290lff.8.1585667331116; Tue, 31 Mar 2020 08:08:51 -0700 (PDT) Received: from [192.168.2.145] (ppp91-78-208-152.pppoe.mtu-net.ru. [91.78.208.152]) by smtp.googlemail.com with ESMTPSA id b17sm3100929lfa.15.2020.03.31.08.08.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2020 08:08:50 -0700 (PDT) Subject: Re: [PATCH v10 52/55] input: touchscreen: atmel_mxt_ts: Added sysfs entry for touchscreen status To: Jiada Wang , nick@shmanahar.org, dmitry.torokhov@gmail.com, jikos@kernel.org, benjamin.tissoires@redhat.com, bsz@semihalf.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, erosca@de.adit-jv.com, Andrew_Gabbasov@mentor.com References: <20200331105051.58896-1-jiada_wang@mentor.com> <20200331105051.58896-53-jiada_wang@mentor.com> From: Dmitry Osipenko Message-ID: <63336277-8ed2-a097-a983-6e8ac48d776e@gmail.com> Date: Tue, 31 Mar 2020 18:08:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200331105051.58896-53-jiada_wang@mentor.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 31.03.2020 13:50, Jiada Wang пишет: ... > +static void mxt_watchdog_work(struct work_struct *work) > +{ > + struct mxt_data *data = > + container_of(work, struct mxt_data, watchdog_work.work); > + u16 info_buf; > + int ret; > + > + if (data->suspended || data->in_bootloader || > + data->mxt_status.intp_triggered) > + goto sched_work; Won't it become a problem if other thread puts device into suspended / bootloader state in the same time? > + ret = __mxt_read_reg(data->client, 0, sizeof(info_buf), &info_buf); > + > + if (ret) { > + data->mxt_status.error_count++; > + data->mxt_status.dev_status = false; > + } else { > + data->mxt_status.dev_status = true; > + } > + > +sched_work: > + schedule_delayed_work(&data->watchdog_work, > + msecs_to_jiffies(MXT_WATCHDOG_TIMEOUT)); > +} ... > @@ -4329,6 +4390,12 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) > msleep(MXT_RESET_TIME); > } > > + if (debug_state) { > + INIT_DELAYED_WORK(&data->watchdog_work, mxt_watchdog_work); > + schedule_delayed_work(&data->watchdog_work, > + msecs_to_jiffies(MXT_WATCHDOG_TIMEOUT)); > + } > + > error = mxt_initialize(data); > if (error) > goto err_free_object; > @@ -4343,6 +4410,8 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) > return 0; > > err_free_object: > + if (debug_state) > + cancel_delayed_work_sync(&data->watchdog_work); > mxt_free_input_device(data); > mxt_free_object_table(data); > if (data->reset_gpio) { > @@ -4367,6 +4436,9 @@ static int mxt_remove(struct i2c_client *client) > mxt_free_input_device(data); > mxt_free_object_table(data); > > + if (debug_state) > + cancel_delayed_work_sync(&data->watchdog_work); What will happen if debug_state was false during of mxt_probe() and then the debug_state parameter was changed to true via sysfs? I think the INIT_DELAYED_WORK() and cancel_delayed_work_sync() should be invoked unconditionally. > return 0; > } > > @@ -4463,3 +4535,7 @@ module_i2c_driver(mxt_driver); > MODULE_AUTHOR("Joonyoung Shim "); > MODULE_DESCRIPTION("Atmel maXTouch Touchscreen driver"); > MODULE_LICENSE("GPL"); > + > +module_param(debug_state, bool, 0); > +MODULE_PARM_DESC(debug_state, "Enable/Disable watchdog work to check device state (default=" > + __MODULE_STRING(MXT_DEBUG_STATE) ")"); > The "default=..." part of MODULE_PARM_DESC() probably isn't really useful and could be omitted, don't you think so?