sm6250-common: light: avoid uint32_t underflow

Change-Id: If4f9360cc301ee8ba9f432dbbe3379c2c634c574
This commit is contained in:
Demon000 2019-09-06 13:47:29 +02:00
parent f98970f590
commit 46157d8b5b

View File

@ -74,6 +74,10 @@ static uint32_t getBrightness(const LightState& state) {
} }
static inline uint32_t scaleBrightness(uint32_t brightness, uint32_t maxBrightness) { static inline uint32_t scaleBrightness(uint32_t brightness, uint32_t maxBrightness) {
if (brightness == 0) {
return 0;
}
return (brightness - 1) * (maxBrightness - 1) / (0xFF - 1) + 1; return (brightness - 1) * (maxBrightness - 1) / (0xFF - 1) + 1;
} }