fan: Use u8 for array access
The index will never be negative and will never exceed 255. Change them from i16 to u8 so SDCC will generate more efficient code. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
99af8a35f5
commit
784202383e
@ -26,7 +26,7 @@ void fan_reset(void) {
|
||||
// Get duty cycle based on temperature, adapted from
|
||||
// https://github.com/pop-os/system76-power/blob/master/src/fan.rs
|
||||
uint8_t fan_duty(const struct Fan * fan, int16_t temp) __reentrant {
|
||||
for (int16_t i = 0; i < fan->points_size; i++) {
|
||||
for (uint8_t i = 0; i < fan->points_size; i++) {
|
||||
const struct FanPoint * cur = &fan->points[i];
|
||||
|
||||
// If exactly the current temp, return the current duty
|
||||
@ -86,7 +86,7 @@ void fan_duty_set(uint8_t peci_fan_duty, uint8_t dgpu_fan_duty) __reentrant {
|
||||
uint8_t fan_heatup(const struct Fan * fan, uint8_t duty) __reentrant {
|
||||
uint8_t lowest = duty;
|
||||
|
||||
int16_t i;
|
||||
uint8_t i;
|
||||
for (i = 0; (i + 1) < fan->heatup_size; i++) {
|
||||
uint8_t value = fan->heatup[i + 1];
|
||||
if (value < lowest) {
|
||||
@ -102,7 +102,7 @@ uint8_t fan_heatup(const struct Fan * fan, uint8_t duty) __reentrant {
|
||||
uint8_t fan_cooldown(const struct Fan * fan, uint8_t duty) __reentrant {
|
||||
uint8_t highest = duty;
|
||||
|
||||
int16_t i;
|
||||
uint8_t i;
|
||||
for (i = 0; (i + 1) < fan->cooldown_size; i++) {
|
||||
uint8_t value = fan->cooldown[i + 1];
|
||||
if (value > highest) {
|
||||
|
Reference in New Issue
Block a user