Skip to contentSkip to conversation

hwmon: (gpio-fan) Remove un-necessary speed_index lookup for thermal hook

PATCH Applied Nishanth Menon 2 participants 2 messages Feb 20, 2016 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (gpio-fan) Remove un-necessary speed_index lookup for thermal hook

Thermal hook gpio_fan_get_cur_state is only interested in knowing the current speed index that was setup in the system, this is already available as part of fan_data->speed_index which is always set by set_fan_speed. Using get_fan_speed_index is useful when we have no idea about the fan speed configuration (for example during fan_ctrl_init).

When thermal framework invokes gpio_fan_get_cur_state=>get_fan_speed_index via gpio_fan_get_cur_state especially in a polled configuration for thermal governor, we basically hog the i2c interface to the extent that other functions fail to get any traffic out :(.

Instead, just provide the last state set in the driver - since the gpio fan driver is responsible for the fan state immaterial of override, the fan_data->speed_index should accurately reflect the state.

Fixes b5cf88e46bad ("(gpio-fan): Add thermal control hooks")

---
Test logs from linus master v4.5-rc4-137-g23300f657594 Without fix: http://paste.ubuntu.org.cn/3948618
With Fix: http://paste.ubuntu.org.cn/3948617

 drivers/hwmon/gpio-fan.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/hwmon/gpio-fan.c +1 -6
index 82de3deeb18a..685568b1236d 100644
@@ -406,16 +406,11 @@ static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
 				  unsigned long *state)
 {
 	struct gpio_fan_data *fan_data = cdev->devdata;
-	int r;
 
 	if (!fan_data)
 		return -EINVAL;
 
-	r = get_fan_speed_index(fan_data);
-	if (r < 0)
-		return r;
-
-	*state = r;
+	*state = fan_data->speed_index;
 	return 0;
 }
 
Signature · 1 line
2.7.0
maintainer Applied
#1 lore raw
Quoted 17 lines · Nishanth Menon

Thermal hook gpio_fan_get_cur_state is only interested in knowing the current speed index that was setup in the system, this is already available as part of fan_data->speed_index which is always set by set_fan_speed. Using get_fan_speed_index is useful when we have no idea about the fan speed configuration (for example during fan_ctrl_init).

When thermal framework invokes gpio_fan_get_cur_state=>get_fan_speed_index via gpio_fan_get_cur_state especially in a polled configuration for thermal governor, we basically hog the i2c interface to the extent that other functions fail to get any traffic out :(.

Instead, just provide the last state set in the driver - since the gpio fan driver is responsible for the fan state immaterial of override, the fan_data->speed_index should accurately reflect the state.

Quoted 7 lines
Fixes b5cf88e46bad ("(gpio-fan): Add thermal control hooks")

---

Applied.

Thanks,
Guenter

Quoted 30 lines

Test logs from linus master v4.5-rc4-137-g23300f657594 Without fix: http://paste.ubuntu.org.cn/3948618
With Fix: http://paste.ubuntu.org.cn/3948617

  drivers/hwmon/gpio-fan.c | 7 +------
  1 file changed, 1 insertion(+), 6 deletions(-)
drivers/hwmon/gpio-fan.c +1 -6
index 82de3deeb18a..685568b1236d 100644
@@ -406,16 +406,11 @@ static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
  				  unsigned long *state)
  {
  	struct gpio_fan_data *fan_data = cdev->devdata;
-	int r;
 
  	if (!fan_data)
  		return -EINVAL;
 
-	r = get_fan_speed_index(fan_data);
-	if (r < 0)
-		return r;
-
-	*state = r;
+	*state = fan_data->speed_index;
  	return 0;
  }