Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1115610rwl; Fri, 7 Apr 2023 10:08:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2hAHQUly8c76MjMLT4BLC7WjvirwxB0DB4LwCZUuut8uvkzf67XUVFvlel0F+Qwu8hOJm X-Received: by 2002:a17:906:1b07:b0:948:6e9c:273e with SMTP id o7-20020a1709061b0700b009486e9c273emr151621ejg.62.1680887282054; Fri, 07 Apr 2023 10:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680887282; cv=none; d=google.com; s=arc-20160816; b=DZYt9f1rL48mUl9TAVXOdunBLb/9Pqx3VPqSxAZXPaA2aoRUCwj6QD06CNxil8iq2j vSsZR0DnM5Rzd7dfoXEO2N5cv0i2vI7sPvy1o//nuWCYznz1NTsQ0XQt+v9NG3Ck+CP0 2wHEpK0EbyU/by3/Bi0jbAUir1jnii1OLNU+gSguK+SzdOSzEY5H7pOkUK2pFEQ5J2XM KEVPvtd5PwkQD+5NZu65y8hbbGNUUXyp8Ngyiaq+wpLZ11iKks+GVZ46SuFpBFo3WqfJ ZCS1gYLsmkan3+2fb19c+wOL6OOd4WgJDdDBNEWc/OmYN2pMhQV83NPkZ9XsOdJgtw6p h+VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=o+EC9oSqo+HSTysdaLl9MdTGNN+XyvYFDHraMGNwzHo=; b=gJVWNi9n6Md7upqFJFqHAQOKA1WdzBeoiPHt27IGSBx5sq+y9bTdBjAgKPtAekn21s bYU+SW4kKYctleEBd1IksfJGI08QoUY+5O+CJw+WJmzebXcQD9ZZt9ZtJiaUmqX3tLwH CVSfDIWETDudXc4x8F3IJ2VjNFoQD4lOfhq/7UeM5cZDPFWRtL0mcK8MXX1d/UQ+BnA3 ux0QXzbfr+xuKMUjhM68hoToWSpBCYryPhZKTwEM4TMuktJcLveBqFUi4glRGx5rp/Pp mBU9AEySbo/o1cs2ZklMxu31+4r44dTHQyIz7jfJTdT+IIfYbCKliu3u31BBRdCyFyqH K7mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KAFsJ88K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c22-20020a1709060fd600b00944a52dd3b9si1623142ejk.452.2023.04.07.10.07.36; Fri, 07 Apr 2023 10:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KAFsJ88K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229753AbjDGQ5w (ORCPT + 99 others); Fri, 7 Apr 2023 12:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjDGQ5v (ORCPT ); Fri, 7 Apr 2023 12:57:51 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4AE61A5; Fri, 7 Apr 2023 09:57:50 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id ld14so1520218qvb.13; Fri, 07 Apr 2023 09:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680886669; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=o+EC9oSqo+HSTysdaLl9MdTGNN+XyvYFDHraMGNwzHo=; b=KAFsJ88KqYSuxae/wmpNfoMXlas7mSPVg8du6CvORQjqNZSSfmg/gJmR0aSHYNqOej xUCyV7ghNU/pu5rKHl5CK7JAzupwOhro1oHui6dXT8nv5iBvJNuPiX2XCe/u0C1Sfwt+ Dmtz1MrBIFdBpodPvmmapP1SAwb5Xlb2XJzmr0aLMfqq3z4z9DvfVNRtpfrN0trsOavb nmBeKzzO9MEr1boanB4ojnuNJDi9E+NgAqIlWXnm5YxmuUeUxOurftf8+aLXzwk4tuNZ JgtT/B1BxH0uKKmC/mYjb/wY4PhBDw+silSWAAdiNn4Q+XKpGOZjUbWWZzge1nhvS2EE 6S7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680886669; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=o+EC9oSqo+HSTysdaLl9MdTGNN+XyvYFDHraMGNwzHo=; b=XcwKqtQ+WFEH6BbqIlj07dZoAhY86y4dxI3LjJv/gKIGCOvAI5dukIZ0mJ5nrKfffn LJ4xrcYxTFK6f5GQ2LGJbVpQ5kBUD9nni7QFIeLlCvlkglklxw1HyDT/tnKI+6x5SvQe EganWA4/NMA0MJpOLcSvO177pve8PzV+hN492g4qd9NEynmuslI2eip19y7A1aXzBH/q 9fRWQMqZUA2GGKRFpNq2oLhRe5DOY+m5bmlQ52s24rlHLp8j/jABCU6YRr5EWtb9lN+/ 29mqSo2LLN81v7l5pHh+E2pJkgYAIkBqfH90pegbhRIVkv0UTI3T5eRdulyBdf2KbuIP kN3g== X-Gm-Message-State: AAQBX9cYhtrm/riMDj+Utt7leOhZa7cNX2ipakUIxCPp8iMNq2udf1wL LaUMLxJTtj2CX24wWu2j713JhWSFpmk= X-Received: by 2002:a05:6214:2a49:b0:5bf:370e:f446 with SMTP id jf9-20020a0562142a4900b005bf370ef446mr6635631qvb.17.1680886669126; Fri, 07 Apr 2023 09:57:49 -0700 (PDT) Received: from penguin ([205.220.129.30]) by smtp.gmail.com with ESMTPSA id kl14-20020a056214518e00b005dd8b9345absm1454622qvb.67.2023.04.07.09.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 09:57:48 -0700 (PDT) Date: Fri, 7 Apr 2023 09:57:12 -0700 From: Dmitry Torokhov To: "jingle.wu" Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, phoenix@emc.com.tw, josh.chen@emc.com.tw, dave.wang@emc.com.tw Subject: Re: [PATCH] Input: elan_i2c - Implement inhibit/uninhibit functions. Message-ID: References: <20230320011456.986321-1-jingle.wu@emc.com.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230320011456.986321-1-jingle.wu@emc.com.tw> X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jingle, On Mon, Mar 20, 2023 at 09:14:56AM +0800, jingle.wu wrote: > Add inhibit/uninhibit functions. > > Signed-off-by: Jingle.wu > --- > drivers/input/mouse/elan_i2c_core.c | 86 +++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > > diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c > index 5f0d75a45c80..b7100945c9cc 100644 > --- a/drivers/input/mouse/elan_i2c_core.c > +++ b/drivers/input/mouse/elan_i2c_core.c > @@ -329,6 +329,89 @@ static int elan_initialize(struct elan_tp_data *data, bool skip_reset) > return error; > } > > +static int elan_reactivate(struct elan_tp_data *data) > +{ > + struct device *dev = &data->client->dev; > + int ret; Please call this variable and other similar ones "error". > + > + ret = elan_set_power(data, true); > + if (ret) > + dev_err(dev, "failed to restore power: %d\n", ret); > + > + ret = data->ops->sleep_control(data->client, false); > + if (ret) { > + dev_err(dev, > + "failed to wake device up: %d\n", ret); > + return ret; > + } > + > + return ret; return 0; > +} > + > +static void elan_inhibit(struct input_dev *input_dev) > +{ > + struct elan_tp_data *data = input_get_drvdata(input_dev); > + struct i2c_client *client = data->client; > + int ret; > + > + if (data->in_fw_update) > + return; Simply and silently ignoring inhibit request is not great. Can we wait for firmware update to complete? > + > + dev_dbg(&client->dev, "inhibiting\n"); > + /* > + * We are taking the mutex to make sure sysfs operations are > + * complete before we attempt to bring the device into low[er] > + * power mode. > + */ > + ret = mutex_lock_interruptible(&data->sysfs_mutex); > + if (ret) > + return; > + > + disable_irq(client->irq); > + > + ret = elan_set_power(data, false); > + if (ret) > + enable_irq(client->irq); > + > + mutex_unlock(&data->sysfs_mutex); > + > +} > + > +static void elan_close(struct input_dev *input_dev) > +{ > + if ((input_dev->users) && (!input_dev->inhibited)) > + elan_inhibit(input_dev); I am not sure why you need these checks. Input core will only call input_dev->close() when device is powered up st (i.e. it is not inhibited and there are users of it) and when either: - there is inhibit request or - the last user is letting go of the device Similarly elan_open() will be called when first user opens device if device is not inhibited, or when request to uninhibit comes for inhibited device that has users. But you need to make sure you start in a low power state. Thanks. -- Dmitry