[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250907105557.7bab8bfe@jic23-huawei>
Date: Sun, 7 Sep 2025 10:55:57 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Akshay Jindal <akshayaj.lkd@...il.com>
Cc: anshulusr@...il.com, dlechner@...libre.com, nuno.sa@...log.com,
andy@...nel.org, shuah@...nel.org, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6] iio: light: ltr390: Implement runtime PM support
On Sat, 6 Sep 2025 09:12:19 +0530
Akshay Jindal <akshayaj.lkd@...il.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@...il.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, <r390_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);
> }
>
Powered by blists - more mailing lists