diff options
Diffstat (limited to 'drivers/iio/chemical/ccs811.c')
-rw-r--r-- | drivers/iio/chemical/ccs811.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c index fbe2431f5b81..b4a46eb45789 100644 --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -32,7 +32,7 @@ #define CCS811_ALG_RESULT_DATA 0x02 #define CCS811_RAW_DATA 0x03 #define CCS811_HW_ID 0x20 -#define CCS881_HW_ID_VALUE 0x81 +#define CCS811_HW_ID_VALUE 0x81 #define CCS811_HW_VERSION 0x21 #define CCS811_HW_VERSION_VALUE 0x10 #define CCS811_HW_VERSION_MASK 0xF0 @@ -69,7 +69,7 @@ struct ccs811_reading { __be16 voc; u8 status; u8 error; - __be16 resistance; + __be16 raw_data; } __attribute__((__packed__)); struct ccs811_data { @@ -133,6 +133,9 @@ static int ccs811_start_sensor_application(struct i2c_client *client) if (ret < 0) return ret; + if ((ret & CCS811_STATUS_FW_MODE_APPLICATION)) + return 0; + if ((ret & CCS811_STATUS_APP_VALID_MASK) != CCS811_STATUS_APP_VALID_LOADED) return -EIO; @@ -210,12 +213,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_VOLTAGE: - *val = be16_to_cpu(data->buffer.resistance) & + *val = be16_to_cpu(data->buffer.raw_data) & CCS811_VOLTAGE_MASK; ret = IIO_VAL_INT; break; case IIO_CURRENT: - *val = be16_to_cpu(data->buffer.resistance) >> 10; + *val = be16_to_cpu(data->buffer.raw_data) >> 10; ret = IIO_VAL_INT; break; case IIO_CONCENTRATION: @@ -353,7 +356,7 @@ static int ccs811_probe(struct i2c_client *client, if (ret < 0) return ret; - if (ret != CCS881_HW_ID_VALUE) { + if (ret != CCS811_HW_ID_VALUE) { dev_err(&client->dev, "hardware id doesn't match CCS81x\n"); return -ENODEV; } |