diff options
author | Jongpil Jung <jongpil19.jung@samsung.com> | 2019-12-26 13:46:39 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-27 12:57:08 +0000 |
commit | c45fb208e0646d6e42566d969d467b7eceaccde4 (patch) | |
tree | c778b6310496a19319f3c1f0630750f1cb454ea8 /driver/als_tcs3400.c | |
parent | 8893119c6fab824abef7e38a2a902fbf5f6f353f (diff) | |
download | chrome-ec-c45fb208e0646d6e42566d969d467b7eceaccde4.tar.gz |
drivers/tcs3400: don't apply zero scale.
EC will be broken with scale zero. So, we need to check scale value
before we apply value.
BUG=b:146868237
TEST=emerge-hatch chromeos-ec and flash ec on device.
apply zero scale into rgb sensor. (clear, red, green and blue)
echo "0" > /sys/bus/iio/devices/iio\:device6/in_illuminance_calibscale
BRANCH=none
Change-Id: I716ae805ff1742ddd45dbbdfd956beb1c22d5a6c
Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1982294
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Diffstat (limited to 'driver/als_tcs3400.c')
-rw-r--r-- | driver/als_tcs3400.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 6deb584976..10e33b755c 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -573,6 +573,8 @@ static int tcs3400_rgb_set_scale(const struct motion_sensor_t *s, struct rgb_channel_calibration_t *rgb_cal = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; + if (scale[X] == 0 || scale[Y] == 0 || scale[Z] == 0) + return EC_ERROR_INVAL; rgb_cal[RED_RGB_IDX].scale.k_channel_scale = scale[X]; rgb_cal[GREEN_RGB_IDX].scale.k_channel_scale = scale[Y]; rgb_cal[BLUE_RGB_IDX].scale.k_channel_scale = scale[Z]; @@ -648,6 +650,8 @@ static int tcs3400_set_scale(const struct motion_sensor_t *s, const uint16_t *scale, int16_t temp) { + if (scale[X] == 0) + return EC_ERROR_INVAL; TCS3400_DRV_DATA(s)->als_cal.channel_scale.k_channel_scale = scale[X]; return EC_SUCCESS; } |