From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Akshay Jindal <akshayaj.lkd@gmail.com>, <anshulusr@gmail.com>,
<jic23@kernel.org>, <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 v7] iio: light: ltr390: Implement runtime PM support
Date: Wed, 10 Sep 2025 12:02:45 +0100 [thread overview]
Message-ID: <20250910120245.000033e8@huawei.com> (raw)
In-Reply-To: <CAHp75VfpQ9c4cptnNGzFYakQxY7JjtUEMDsysS9KJ60xrzaE4g@mail.gmail.com>
On Wed, 10 Sep 2025 10:17:00 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Tue, Sep 9, 2025 at 10:47 PM 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.
>
> ...
>
> > +static int ltr390_read_raw(struct iio_dev *iio_device,
> > + struct iio_chan_spec const *chan, int *val,
> > + int *val2, long mask)
>
> Isn't the mask unsigned long? Jonathan, do we get this fixed already?
Whilst it could (and probably should) be unsigned, it's not actually a mask.
That naming is a historical mess up / evolution thing - long ago it was a bitmap.
It is now the index of a bit in the mask. So this is unrelated(ish) to the
recent fixes around the actual bitmaps/bitmasks.
Changing this one is a lot more painful than the recent fix to the infomask
as it means changing the signature in every driver.
I'm doubtful on whether this one is worth the churn.
>
> Also logical split might be better, i.e. putting val and val2 on the
> same line. Then mask will be on the next one
>
> ...
>
> > static void ltr390_powerdown(void *priv)
> > {
> > struct ltr390_data *data = priv;
> > + struct device *dev = &data->client->dev;
> > + int ret;
> >
> > guard(mutex)(&data->lock);
> >
> > /* Ensure that power off and interrupts are disabled */
> > - if (regmap_clear_bits(data->regmap, LTR390_INT_CFG,
> > - LTR390_LS_INT_EN) < 0)
> > - dev_err(&data->client->dev, "failed to disable interrupts\n");
> > + if (data->irq_enabled) {
> > + ret = regmap_clear_bits(data->regmap, LTR390_INT_CFG, LTR390_LS_INT_EN);
> > + if (ret < 0)
> > + dev_err(dev, "failed to disable interrupts\n");
>
> In event_config we assure that IRQ is enabled.
>
> > + data->irq_enabled = false;
>
> Here we may lie about the facts. What will the driver do, if the IRQ
> is triggered just before this line?
>
> > + pm_runtime_put_autosuspend(&data->client->dev);
>
> You have dev, use it.
>
> But where is the symmetrical pm_runtime_get*()?
>
> > + }
> > +
> > + ret = regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SENSOR_ENABLE);
> > + if (ret < 0)
> > + dev_err(dev, "failed to disable sensor\n");
> > +}
>
>
next prev parent reply other threads:[~2025-09-10 11:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 19:46 [PATCH v7] iio: light: ltr390: Implement runtime PM support Akshay Jindal
2025-09-10 7:17 ` Andy Shevchenko
2025-09-10 11:02 ` Jonathan Cameron [this message]
2025-09-10 18:00 ` Akshay Jindal
2025-09-10 18:52 ` Jonathan Cameron
2025-09-10 12:36 ` Akshay Jindal
2025-09-10 19:12 ` Jonathan Cameron
2025-09-10 20:24 ` Andy Shevchenko
2025-09-13 12:17 ` Jonathan Cameron
2025-09-13 15:58 ` 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=20250910120245.000033e8@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=akshayaj.lkd@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=anshulusr@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--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