mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Akshay Jindal <akshayaj.lkd@gmail.com>
Cc: anshulusr@gmail.com, dlechner@baylibre.com, nuno.sa@analog.com,
	andy@kernel.org, shuah@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] iio: light: ltr390: Implement runtime PM support
Date: Sun, 7 Sep 2025 10:55:57 +0100	[thread overview]
Message-ID: <20250907105557.7bab8bfe@jic23-huawei> (raw)
In-Reply-To: <20250906034225.12401-1-akshayaj.lkd@gmail.com>

On Sat,  6 Sep 2025 09:12:19 +0530
Akshay Jindal <akshayaj.lkd@gmail.com> wrote:

> Implement runtime power management for the LTR390 sensor. The device
> autosuspends after 1s of idle time, reducing current consumption from
> 100 µA in active mode to 1 µA in standby mode as per the datasheet.
> 
> Ensure that interrupts continue to be delivered with runtime PM.
> Since the LTR390 cannot be used as a wakeup source during runtime
> suspend, therefore increment the runtime PM refcount when enabling
> events and decrement it when disabling events or powering down.
> This prevents event loss while still allowing power savings when IRQs
> are unused.
> 
> Signed-off-by: Akshay Jindal <akshayaj.lkd@gmail.com>

One missing bit of error handling. Otherwise looks fine to me.
Wait a while though for other reviews before posting v7.

Thanks

Jonathan



> +static int ltr390_pm_init(struct ltr390_data *data)
> +{
> +	int ret;
> +	struct device *dev = &data->client->dev;
> +
> +	ret = devm_pm_runtime_set_active_enabled(dev);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to enable runtime PM\n");
> +
> +	pm_runtime_set_autosuspend_delay(dev, 1000);
> +	pm_runtime_use_autosuspend(dev);
> +	return 0;
>  }
>  
>  static int ltr390_probe(struct i2c_client *client)
> @@ -708,6 +783,8 @@ static int ltr390_probe(struct i2c_client *client)
>  	if (!indio_dev)
>  		return -ENOMEM;
>  
> +	i2c_set_clientdata(client, indio_dev);
> +
>  	data = iio_priv(indio_dev);
>  	data->regmap = devm_regmap_init_i2c(client, &ltr390_regmap_config);
>  	if (IS_ERR(data->regmap))
> @@ -721,6 +798,8 @@ static int ltr390_probe(struct i2c_client *client)
>  	data->gain = 3;
>  	/* default mode for ltr390 is ALS mode */
>  	data->mode = LTR390_SET_ALS_MODE;
> +	/* default value of irq_enabled is false */
> +	data->irq_enabled = false;
>  
>  	mutex_init(&data->lock);
>  
> @@ -763,6 +842,7 @@ static int ltr390_probe(struct i2c_client *client)
>  					     "request irq (%d) failed\n", client->irq);
>  	}
>  
> +	ltr390_pm_init(data);

This can return an error so you need to check that and fail probe if it does.


>  	return devm_iio_device_register(dev, indio_dev);
>  }
>  
> @@ -784,7 +864,26 @@ static int ltr390_resume(struct device *dev)
>  				LTR390_SENSOR_ENABLE);
>  }
>  


  reply	other threads:[~2025-09-07  9:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-06  3:42 Akshay Jindal
2025-09-07  9:55 ` Jonathan Cameron [this message]
2025-09-09 19:50   ` Akshay Jindal

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=20250907105557.7bab8bfe@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=akshayaj.lkd@gmail.com \
    --cc=andy@kernel.org \
    --cc=anshulusr@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=shuah@kernel.org \
    /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

all inboxes | Powered by JetHome®