#define TSL2583_CHIP_ID 0x90
#define TSL2583_CHIP_ID_MASK 0xf0
-enum {
- TSL258X_CHIP_UNKNOWN = 0,
- TSL258X_CHIP_WORKING = 1,
- TSL258X_CHIP_SUSPENDED = 2
-};
-
/* Per-device data */
struct taos_als_info {
u16 als_ch0;
struct taos_settings taos_settings;
int als_time_scale;
int als_saturation;
- int taos_chip_status;
+ bool suspended;
};
struct taos_lux {
if (ret < 0)
return ret;
- chip->taos_chip_status = TSL258X_CHIP_WORKING;
+ chip->suspended = false;
return ret;
}
mutex_lock(&chip->als_mutex);
- if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+ if (chip->suspended) {
ret = -EBUSY;
goto done;
}
mutex_lock(&chip->als_mutex);
- if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+ if (chip->suspended) {
ret = -EBUSY;
goto read_done;
}
mutex_lock(&chip->als_mutex);
- if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+ if (chip->suspended) {
ret = -EBUSY;
goto write_done;
}
i2c_set_clientdata(clientp, indio_dev);
mutex_init(&chip->als_mutex);
- chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
+ chip->suspended = true;
ret = i2c_smbus_read_byte_data(clientp,
TSL258X_CMD_REG | TSL258X_CHIPID);
mutex_lock(&chip->als_mutex);
ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
- chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
+ chip->suspended = true;
mutex_unlock(&chip->als_mutex);
return ret;