From: Jonathan Cameron <jic23@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
ktsai@capellamicro.com, lars@metafoo.de,
Wahaj <wahajaved@protonmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: light: cm32181: Fix PM support on system with 2 I2C resources
Date: Sat, 21 Jan 2023 17:51:20 +0000 [thread overview]
Message-ID: <20230121175120.526d3d16@jic23-huawei> (raw)
In-Reply-To: <3d51f766-bd80-870d-c939-99660526c654@redhat.com>
On Wed, 18 Jan 2023 18:07:45 +0100
Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 1/18/23 18:04, Kai-Heng Feng wrote:
> > Commit c1e62062ff54 ("iio: light: cm32181: Handle CM3218 ACPI devices
> > with 2 I2C resources") creates a second client for the actual I2C
> > address, but the "struct device" passed to PM ops is the first I2C
> > client that can't talk to the sensor.
> >
> > That means the I2C transfers in both suspend and resume routines can
> > fail and blocking the whole suspend process.
> >
> > Instead of using the first client for I2C transfer, use the I2C client
> > stored in the cm32181 private struct so the PM ops can get the correct
> > I2C client to really talk to the sensor device.
> >
> > Fixes: 68c1b3dd5c48 ("iio: light: cm32181: Add PM support")
> > BugLink: https://bugs.launchpad.net/bugs/1988346
> > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152281
> > Tested-by: Wahaj <wahajaved@protonmail.com>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>
> Thanks, patch looks good to me:
>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>
> Regards,
>
> Hans
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks
Jonathan
>
>
>
> > ---
> > v2:
> > - Removed setting drvdata to the dummy client.
> > - Added bug links.
> > - Wording.
> >
> > drivers/iio/light/cm32181.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
> > index 001055d097509..b1674a5bfa368 100644
> > --- a/drivers/iio/light/cm32181.c
> > +++ b/drivers/iio/light/cm32181.c
> > @@ -440,6 +440,8 @@ static int cm32181_probe(struct i2c_client *client)
> > if (!indio_dev)
> > return -ENOMEM;
> >
> > + i2c_set_clientdata(client, indio_dev);
> > +
> > /*
> > * Some ACPI systems list 2 I2C resources for the CM3218 sensor, the
> > * SMBus Alert Response Address (ARA, 0x0c) and the actual I2C address.
> > @@ -460,8 +462,6 @@ static int cm32181_probe(struct i2c_client *client)
> > return PTR_ERR(client);
> > }
> >
> > - i2c_set_clientdata(client, indio_dev);
> > -
> > cm32181 = iio_priv(indio_dev);
> > cm32181->client = client;
> > cm32181->dev = dev;
> > @@ -490,7 +490,8 @@ static int cm32181_probe(struct i2c_client *client)
> >
> > static int cm32181_suspend(struct device *dev)
> > {
> > - struct i2c_client *client = to_i2c_client(dev);
> > + struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
> > + struct i2c_client *client = cm32181->client;
> >
> > return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
> > CM32181_CMD_ALS_DISABLE);
> > @@ -498,8 +499,8 @@ static int cm32181_suspend(struct device *dev)
> >
> > static int cm32181_resume(struct device *dev)
> > {
> > - struct i2c_client *client = to_i2c_client(dev);
> > struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
> > + struct i2c_client *client = cm32181->client;
> >
> > return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
> > cm32181->conf_regs[CM32181_REG_ADDR_CMD]);
>
prev parent reply other threads:[~2023-01-21 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 17:04 [PATCH v2] iio: light: cm32181: Fix PM support on system with 2 I2C resources Kai-Heng Feng
2023-01-18 17:07 ` Hans de Goede
2023-01-21 17:51 ` Jonathan Cameron [this message]
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=20230121175120.526d3d16@jic23-huawei \
--to=jic23@kernel.org \
--cc=hdegoede@redhat.com \
--cc=kai.heng.feng@canonical.com \
--cc=ktsai@capellamicro.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wahajaved@protonmail.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