public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Miao Li <limiao870622@163.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	waqar.hameed@axis.com, dixitparmar19@gmail.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Miao Li <limiao@kylinos.cn>
Subject: Re: [PATCH] iio: light: stk3310: Deal with the ps interrupt issue in PM
Date: Tue, 28 Apr 2026 19:22:13 +0100	[thread overview]
Message-ID: <20260428192213.7c5c80e5@jic23-huawei> (raw)
In-Reply-To: <20260427094313.81460-1-limiao870622@163.com>

On Mon, 27 Apr 2026 17:43:13 +0800
Miao Li <limiao870622@163.com> wrote:

> From: Miao Li <limiao@kylinos.cn>
Hi Miao Li

A few (possibly additional) things inline.

> 
> On the Huawei hisi platform, if the STK3311-X chip's PS interrupt

I'm curious. What HiSilicon platform is this?
Good to have that recorded as part of the description for anyone
else who encounters this bug.

> is configured in "Recommended interrupt mode", the interrupt cannot
> be triggered normally after waking from suspend or hibernation.
> 
> In this case, neither disabling and re-enabling the interrupt nor
> resetting the PS threshold register can restore the interrupt to
> normal operation.
> 
> if we disable the interrupt in suspend(), then reset the PS threshold
> register and enable the interrupt in resume(), this issue can be fixed.
Switch text to imperative. 

  If the interrupt is disabled in suspend() then rest the PS threshold
  register and enable the interrupt in resume(). This resolves the issue.

Or something like that.


> 
> Signed-off-by: Miao Li <limiao@kylinos.cn>

> @@ -504,8 +523,13 @@ static int stk3310_init(struct iio_dev *indio_dev)
>  
>  	/* Enable PS interrupts */
>  	ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
> -	if (ret < 0)
> +	if (ret < 0) {
>  		dev_err(&client->dev, "failed to enable interrupts!\n");
> +		return ret;
> +	}
> +
> +	data->ps_int_enabled = true;
> +	data->ps_thdh = STK3310_PS_MAX_VAL;
>  
>  	return ret;

return 0;


...

> @@ -681,6 +714,8 @@ static int stk3310_resume(struct device *dev)
>  {
>  	u8 state = 0;
>  	struct stk3310_data *data;
> +	__be16 buf;
> +	int ret;
>  
>  	data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
>  	if (data->ps_enabled)
> @@ -688,7 +723,35 @@ static int stk3310_resume(struct device *dev)
>  	if (data->als_enabled)
>  		state |= STK3310_STATE_EN_ALS;
>  
> -	return stk3310_set_state(data, state);
> +	ret = stk3310_set_state(data, state);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (data->ps_thdl != 0x0) {
> +		buf = cpu_to_be16(data->ps_thdl);
> +		ret = regmap_bulk_write(data->regmap, STK3310_REG_THDL_PS, &buf, 2);

sizeof(buf) rather than 2. here and below.

> +		if (ret < 0) {
> +			dev_err(dev, "failed to set reg THDL_PS at resume.\n");
> +			return ret;
> +		}
> +	}
> +
> +	if (data->ps_thdh != STK3310_PS_MAX_VAL) {
> +		buf = cpu_to_be16(data->ps_thdh);
> +		ret = regmap_bulk_write(data->regmap, STK3310_REG_THDH_PS, &buf, 2);
> +		if (ret < 0) {
> +			dev_err(dev, "failed to set reg THDH_PS at resume.\n");
> +			return ret;
> +		}
> +	}
> +
> +	if (data->ps_int_enabled) {
> +		ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
> +		if (ret < 0)
> +			dev_err(dev, "failed to enable ps int at resume.\n");
Keep return ret in here so we have consistent pattern with the above .
> +	}
> +
> +	return ret;
Then
	return 0;

>  }
>  
>  static DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend,


  parent reply	other threads:[~2026-04-28 18:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  9:43 [PATCH] iio: light: stk3310: Deal with the ps interrupt issue in PM Miao Li
2026-04-27  9:56 ` Andy Shevchenko
2026-04-27 10:13 ` Joshua Crofts
2026-04-28 18:22 ` Jonathan Cameron [this message]
2026-04-29  6:18   ` Miao Li
2026-04-29  6:45   ` Miao Li
2026-04-29  6:51   ` [PATCH v2] " Miao Li
2026-04-29  6:59     ` Andy Shevchenko
2026-04-29  7:50       ` Miao Li
2026-04-29  7:14   ` [PATCH v3] " Miao Li
2026-04-29  9:03     ` Andy Shevchenko
2026-04-29  9:19     ` Jonathan Cameron

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=20260428192213.7c5c80e5@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dixitparmar19@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=limiao870622@163.com \
    --cc=limiao@kylinos.cn \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=waqar.hameed@axis.com \
    /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