hwmon: (gpio-fan) Remove un-necessary speed_index lookup for thermal hook
authorNishanth Menon <nm@ti.com>
Sat, 20 Feb 2016 00:09:51 +0000 (18:09 -0600)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 7 Mar 2016 17:33:13 +0000 (12:33 -0500)
commite0a8bcb7cd5e71dfb3d8d5ed3e2db6d9a7c2b0df
tree994fd402ce26faaa14dc77027aad4a79e65e14dc
parent9077dc77a92526b028111db2943a26ff8e475d03
hwmon: (gpio-fan) Remove un-necessary speed_index lookup for thermal hook

[ Upstream commit 000e0949148382c4962489593a2f05504c2a6771 ]

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")
Reported-by: Tony Lindgren <tony@atomide.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/hwmon/gpio-fan.c