• Dmitry Torokhov's avatar
    thermal: rockchip: fix handling of invalid readings · d9a241cb
    Dmitry Torokhov authored
    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: default avatarCaesar Wang <wxt@rock-chips.com>
    Signed-off-by: default avatarDmitry Torokhov <dtor@chromium.org>
    Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
    d9a241cb
rockchip_thermal.c 18.1 KB