Skip to content

Commit ee3c5b6

Browse files
khfengjic23
authored andcommitted
iio: light: cm32181: Fix PM support on system with 2 I2C resources
Commit c1e6206 ("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: 68c1b3d ("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 <[email protected]> Signed-off-by: Kai-Heng Feng <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent eb50cd5 commit ee3c5b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/iio/light/cm32181.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ static int cm32181_probe(struct i2c_client *client)
440440
if (!indio_dev)
441441
return -ENOMEM;
442442

443+
i2c_set_clientdata(client, indio_dev);
444+
443445
/*
444446
* Some ACPI systems list 2 I2C resources for the CM3218 sensor, the
445447
* SMBus Alert Response Address (ARA, 0x0c) and the actual I2C address.
@@ -460,8 +462,6 @@ static int cm32181_probe(struct i2c_client *client)
460462
return PTR_ERR(client);
461463
}
462464

463-
i2c_set_clientdata(client, indio_dev);
464-
465465
cm32181 = iio_priv(indio_dev);
466466
cm32181->client = client;
467467
cm32181->dev = dev;
@@ -490,16 +490,17 @@ static int cm32181_probe(struct i2c_client *client)
490490

491491
static int cm32181_suspend(struct device *dev)
492492
{
493-
struct i2c_client *client = to_i2c_client(dev);
493+
struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
494+
struct i2c_client *client = cm32181->client;
494495

495496
return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
496497
CM32181_CMD_ALS_DISABLE);
497498
}
498499

499500
static int cm32181_resume(struct device *dev)
500501
{
501-
struct i2c_client *client = to_i2c_client(dev);
502502
struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
503+
struct i2c_client *client = cm32181->client;
503504

504505
return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD,
505506
cm32181->conf_regs[CM32181_REG_ADDR_CMD]);

0 commit comments

Comments
 (0)