thermal: rockchip: fix handling of invalid readings
authorDmitry Torokhov <dtor@chromium.org>
Fri, 7 Aug 2015 20:59:23 +0000 (13:59 -0700)
committerEduardo Valentin <edubezval@gmail.com>
Fri, 30 Oct 2015 18:07:32 +0000 (11:07 -0700)
commitd9a241cbbdca9ead3322c073dbb9dbf61ac76ef0
tree34b749f70f2d80bead0e86c8f0f69288e33a5e14
parent9876b1a4431a3f0959c70e1d817ecab6440cb2e6
thermal: rockchip: fix handling of invalid readings

We attempted to signal invalid code by returning -EAGAIN from
rk_tsadcv2_code_to_temp(), unfortunately the return value was stuffed
directly into the temperature pointer, potentially confusing upper
layers with temperature of -EINVAL.

Let's split temperature from error/success indicator to avoid such
confusion.

Also change the way we scan the temperature table to start with the 2nd
element so that we do not need to worry that we may reference out of
bounds element while doing binary search and keep checking that we end
up with 'mid' equal to 0 (since we are looking for the temperature that
would fall into interval between the 'mid' and 'mid - 1') .

Tested-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/rockchip_thermal.c