• Roger Quadros's avatar
    extcon: Fix hang and extcon_get/set_cable_state(). · be052cc8
    Roger Quadros authored
    Users of find_cable_index_by_name() will cause a kernel hang
    as the while loop counter is never incremented and end condition
    is never reached.
    
    extcon_get_cable_state() and extcon_set_cable_state() are broken
    because they use cable index instead of cable id. This causes
    the first cable state (cable.0) to be always invalid in sysfs
    or extcon_get_cable_state() users.
    
    Introduce a new function find_cable_id_by_name() that fixes
    both of the above issues.
    
    Fixes: commit 73b6ecdb ("extcon: Redefine the unique id of supported external connectors without 'enum extcon' type")
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
    Tested-by: default avatarIvan T. Ivanov <ivan.ivanov@linaro.org>
    [cw00.choi: Fix minor coding style]
    Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
    be052cc8
extcon.c 29.1 KB