Patch "iio: humidity: hdc100x: fix sensor data reads of temp and humidity" has been added to the 4.7-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: humidity: hdc100x: fix sensor data reads of temp and humidity
to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
iio-humidity-hdc100x-fix-sensor-data-reads-of-temp-and-humidity.patch
and it can be found in the queue-4.7 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
0d9dcf852334b796bacc7020364afba3122db81eMon Sep 17 00:00:00 2001
From: Alison Schofield <[email protected]>
Date: Mon, 8 Aug 2016 11:14:36 -0700
Subject: iio: humidity: hdc100x: fix sensor data reads of temp and humidity
From: Alison Schofield <[email protected]>
commit 0d9dcf852334b796bacc7020364afba3122db81e upstream.
Replace the i2c_smbus_read_byte commmands used to retrieve the sensor data with an i2c_master_recv command.
The smbus read byte method fails because the device does not expect a stop condition after sending the first byte. When we issue the second read, we are getting the first byte again. Net effect is that of the 14 bits used for the measurement, the 8 most significant bits are correct, the lower 6 are not.
None of the smbus read protocols follow the pattern this device requires (S Addr Rd [A] Data [A] Data NA P), hence the switch to an i2c receive transaction.
Applicable from original introduction of this driver, but will require backporting due to churn in the code.
--- drivers/iio/humidity/hdc100x.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/iio/humidity/hdc100x.c +7 -20
@@ -142,7 +142,7 @@ static int hdc100x_get_measurement(strucstruct i2c_client *client = data->client;int delay = data->adc_int_us[chan->address];int ret; -int val; +__be16 val;/* start measurement */ ret =i2c_smbus_write_byte (client, chan->address);
@@ -154,26 +154,13 @@ static int hdc100x_get_measurement(struc/* wait for integration time to pass */ usleep_range (delay, delay +1000 ); -/* -* i2c_smbus_read_word_data cannot() be used here due to the command -* value not being understood and causes NAKs preventing any reading -* from being accessed. -*/ - ret =i2c_smbus_read_byte (client); +/* read measurement */ + ret =i2c_master_recv (data->client, (char *)&val,sizeof (val));if (ret <0 ) { -dev_err (&client->dev,"cannot read high byte measurement" ); +dev_err (&client->dev,"cannot read sensor data\n" );return ret; } - val = ret <<8 ; - - ret =i2c_smbus_read_byte (client); -if (ret <0 ) { -dev_err (&client->dev,"cannot read low byte measurement" ); -return ret; - } - val |= ret; - -return val; +return be16_to_cpu (val); }static int hdc100x_get_heater_status (struct hdc100x_data *data)
@@ -272,8 +259,8 @@ static int hdc100x_probe(struct i2c_cliestruct iio_dev *indio_dev;struct hdc100x_data *data; -if (!i2c_check_functionality (client->adapter, -I2C_FUNC_SMBUS_WORD_DATA |I2C_FUNC_SMBUS_BYTE )) +if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_WORD_DATA | +I2C_FUNC_SMBUS_BYTE |I2C_FUNC_I2C ))return -EOPNOTSUPP ; indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data));
Patches currently in stable-queue which might be from [email protected] are
queue-4.7/iio-proximity-as3935-set-up-buffer-timestamps-for-non-zero-values.patch queue-4.7/iio-humidity-am2315-set-up-buffer-timestamps-for-non-zero-values.patch queue-4.7/iio-humidity-hdc100x-fix-sensor-data-reads-of-temp-and-humidity.patch