From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "jingle.wu" <jingle.wu@emc.com.tw>
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.
Date: Fri, 7 Apr 2023 09:57:12 -0700 [thread overview]
Message-ID: <ZDBKwo4UMUm+TSnj@penguin> (raw)
In-Reply-To: <20230320011456.986321-1-jingle.wu@emc.com.tw>
Hi Jingle,
On Mon, Mar 20, 2023 at 09:14:56AM +0800, jingle.wu wrote:
> Add inhibit/uninhibit functions.
>
> Signed-off-by: Jingle.wu <jingle.wu@emc.com.tw>
> ---
> 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
next prev parent reply other threads:[~2023-04-07 16:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 1:14 [PATCH] Input: elan_i2c - Implement inhibit/uninhibit functions jingle.wu
2023-03-28 8:54 ` phoenix
2023-04-07 16:57 ` Dmitry Torokhov [this message]
2023-04-10 1:26 ` Jingle.Wu
2023-04-26 22:57 ` 'Dmitry Torokhov'
2023-04-28 2:21 ` Jingle.Wu
2023-05-12 0:07 ` 'Dmitry Torokhov'
-- strict thread matches above, loose matches on Subject: below --
2023-07-03 1:34 jingle.wu
2023-05-31 9:03 jingle.wu
2023-06-29 22:57 ` Dmitry Torokhov
2023-07-05 6:09 ` Jingle.Wu
2023-07-31 5:47 ` 'Dmitry Torokhov'
2023-07-07 5:56 ` Jingle.Wu
2023-04-10 10:51 jingle.wu
2023-03-17 7:16 jingle.wu
2023-03-19 2:17 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZDBKwo4UMUm+TSnj@penguin \
--to=dmitry.torokhov@gmail.com \
--cc=dave.wang@emc.com.tw \
--cc=jingle.wu@emc.com.tw \
--cc=josh.chen@emc.com.tw \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phoenix@emc.com.tw \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).