return ret;
}
/* read the data */
- *val = i2c_smbus_read_byte(client);
+ ret = i2c_smbus_read_byte(client);
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "%s failed to read byte after writing to register %x\n",
+ __func__, reg);
+ return ret;
+ }
+ *val = ret;
val++;
reg++;
}
}
reg_val = i2c_smbus_read_byte(chip->client);
+ if (reg_val < 0) {
+ dev_err(&chip->client->dev,
+ "%s failed to read after writing to the CNTRL register\n",
+ __func__);
+ return ret;
+ }
+
if ((reg_val & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON))
!= (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) {
dev_err(&chip->client->dev,
return ret;
}
reg_val = i2c_smbus_read_byte(chip->client);
+ if (reg_val < 0) {
+ dev_err(&chip->client->dev,
+ "%s failed to read after writing to the STATUS register\n",
+ __func__);
+ return ret;
+ }
if ((reg_val & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) {
dev_err(&chip->client->dev,