Commit 000e0949 authored by Nishanth Menon's avatar Nishanth Menon Committed by Guenter Roeck

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: b5cf88e4 ("(gpio-fan): Add thermal control hooks")
Reported-by: default avatarTony Lindgren <tony@atomide.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent acc14694
...@@ -406,16 +406,11 @@ static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev, ...@@ -406,16 +406,11 @@ static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
unsigned long *state) unsigned long *state)
{ {
struct gpio_fan_data *fan_data = cdev->devdata; struct gpio_fan_data *fan_data = cdev->devdata;
int r;
if (!fan_data) if (!fan_data)
return -EINVAL; return -EINVAL;
r = get_fan_speed_index(fan_data); *state = fan_data->speed_index;
if (r < 0)
return r;
*state = r;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment