The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Biren Pandya <birenpandya@gmail.com>
Cc: "Linus Walleij" <linusw@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: gyro: mpu3050: Fix runtime PM leak and refactor trigger state
Date: Sun, 21 Jun 2026 18:45:02 +0100	[thread overview]
Message-ID: <20260621184502.7c99616b@jic23-huawei> (raw)
In-Reply-To: <20260615214504.38979-1-birenpandya@gmail.com>

On Tue, 16 Jun 2026 03:15:04 +0530
Biren Pandya <birenpandya@gmail.com> wrote:

> mpu3050_drdy_trigger_set_state() calls pm_runtime_get_sync() when the
> trigger is enabled, but several error paths in the enable branch return
> directly without dropping the usage counter again. pm_runtime_get_sync()
> increments the usage counter, so every failed enable leaks a runtime PM
> reference and the device can no longer autosuspend. The driver state flag
> hw_irq_trigger is also left set after a failed enable.
> 
> To fix the error unwind clearly and avoid an asymmetric goto block inside a
> monolithic function, this patch breaks the trigger state handler into two
> distinct helpers: mpu3050_drdy_trigger_enable() and
> mpu3050_drdy_trigger_disable(). The enable helper correctly implements the
> error unwind path to drop the PM reference and clear the flag.
> 
> Additionally, pm_runtime_get_sync() is replaced with
> pm_runtime_resume_and_get() for robust error checking.
> 
> Fixes: 3904b28efb2c ("iio: gyro: Add core driver for the MPU-3050")
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
> 
>  drivers/iio/gyro/mpu3050-core.c | 156 ++++++++++++++++++--------------
>  1 file changed, 87 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
> index d84e04e4b431..7dea7ab6b2d6 100644
> --- a/drivers/iio/gyro/mpu3050-core.c
> +++ b/drivers/iio/gyro/mpu3050-core.c
> @@ -950,97 +950,115 @@ static irqreturn_t mpu3050_irq_thread(int irq, void *p)
>   * @trig: trigger instance
>   * @enable: true if trigger should be enabled, false to disable
>   */

As the bot called out.  There are docs here that need to move
with the function.

> -static int mpu3050_drdy_trigger_set_state(struct iio_trigger *trig,
> -					  bool enable)


  parent reply	other threads:[~2026-06-21 17:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 21:45 [PATCH v2] iio: gyro: mpu3050: Fix runtime PM leak and refactor trigger state Biren Pandya
2026-06-16  6:44 ` kernel test robot
2026-06-21 17:45 ` Jonathan Cameron [this message]
2026-07-14 13:14 ` [PATCH v3] " Biren Pandya
2026-07-20  2:09   ` 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=20260621184502.7c99616b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=birenpandya@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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