From: Ninad Palsule <ninad@linux.ibm.com>
To: openbmc@lists.ozlabs.org, andrew@codeconstruct.com.au,
joel@jms.id.au, eajames@linux.ibm.com
Cc: ninad@linux.ibm.com
Subject: [PATCH linux dev-6.12 v2 6/6] iio: si7020: Lock root adapter to wait for reset
Date: Wed, 3 Sep 2025 10:58:08 -0500 [thread overview]
Message-ID: <20250903155810.2839634-7-ninad@linux.ibm.com> (raw)
In-Reply-To: <20250903155810.2839634-1-ninad@linux.ibm.com>
From: Eddie James <eajames@linux.ibm.com>
Use the new mux root operations to lock the root adapter while waiting for
the reset to complete. I2C commands issued after the SI7020 is starting up
or after reset can potentially upset the startup sequence. Therefore, the
host needs to wait for the startup sequence to finish before issuing
further I2C commands.
OpenBMC-Staging-Count: 4
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20220906202829.1921114-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/iio/humidity/si7020.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c
index ff2dba50c0a5b..7f24d54beb8d0 100644
--- a/drivers/iio/humidity/si7020.c
+++ b/drivers/iio/humidity/si7020.c
@@ -228,6 +228,7 @@ static const struct iio_info si7020_info = {
static int si7020_probe(struct i2c_client *client)
{
+ struct i2c_adapter *root;
struct iio_dev *indio_dev;
struct si7020_data *data;
int ret;
@@ -237,13 +238,24 @@ static int si7020_probe(struct i2c_client *client)
I2C_FUNC_SMBUS_READ_WORD_DATA))
return -EOPNOTSUPP;
+ root = i2c_lock_select_bus(client->adapter);
+ if (IS_ERR(root))
+ return PTR_ERR(root);
+
/* Reset device, loads default settings. */
- ret = i2c_smbus_write_byte(client, SI7020CMD_RESET);
- if (ret < 0)
+ ret = __i2c_smbus_xfer(root, client->addr, client->flags,
+ I2C_SMBUS_WRITE, SI7020CMD_RESET,
+ I2C_SMBUS_BYTE, NULL);
+ if (ret < 0) {
+ i2c_unlock_deselect_bus(client->adapter);
return ret;
+ }
+
/* Wait the maximum power-up time after software reset. */
msleep(15);
+ i2c_unlock_deselect_bus(client->adapter);
+
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
--
2.48.1
next prev parent reply other threads:[~2025-09-03 15:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 15:58 [PATCH linux dev-6.12 v2 0/6] Port linux fixes from dev-6.6 Ninad Palsule
2025-09-03 15:58 ` [PATCH linux dev-6.12 v2 1/6] soc: aspeed: Add XDMA Engine Driver Ninad Palsule
2025-09-03 15:58 ` [PATCH linux dev-6.12 v2 2/6] soc: aspeed: xdma: Add user interface Ninad Palsule
2025-09-03 15:58 ` [PATCH linux dev-6.12 v2 3/6] soc: aspeed: xdma: Add reset ioctl Ninad Palsule
2025-09-03 15:58 ` [PATCH linux dev-6.12 v2 4/6] soc: aspeed: xdma: Add trace events Ninad Palsule
2025-09-03 15:58 ` [PATCH linux dev-6.12 v2 5/6] i2c: core: Add mux root adapter operations Ninad Palsule
2025-09-03 15:58 ` Ninad Palsule [this message]
2025-09-04 1:55 ` [PATCH linux dev-6.12 v2 0/6] Port linux fixes from dev-6.6 Andrew Jeffery
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=20250903155810.2839634-7-ninad@linux.ibm.com \
--to=ninad@linux.ibm.com \
--cc=andrew@codeconstruct.com.au \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=openbmc@lists.ozlabs.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