lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 6 Sep 2022 15:28:29 -0500 From: Eddie James <eajames@...ux.ibm.com> To: linux-i2c@...r.kernel.org Cc: linux-iio@...r.kernel.org, wsa@...nel.org, peda@...ntia.se, jic23@...nel.org, lars@...afoo.de, miltonm@...ibm.com, joel@....id.au, eajames@...ux.ibm.com, linux-kernel@...r.kernel.org Subject: [PATCH v2 2/2] iio: si7020: Lock root adapter to wait for reset 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. Signed-off-by: Eddie James <eajames@...ux.ibm.com> --- 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 ab6537f136ba..76ca7863f35b 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c @@ -106,6 +106,7 @@ static const struct iio_info si7020_info = { static int si7020_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct i2c_adapter *root; struct iio_dev *indio_dev; struct i2c_client **data; int ret; @@ -115,13 +116,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.31.1
Powered by blists - more mailing lists