OSDN Git Service

extcon: Fix hang and extcon_get/set_cable_state().
authorRoger Quadros <rogerq@ti.com>
Tue, 7 Jul 2015 13:06:15 +0000 (16:06 +0300)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 31 Jul 2015 01:08:47 +0000 (10:08 +0900)
commitbe052cc87745e01846fb036eb81567c784439078
treea730360e39f24ab9b75fb930eecc615d21e0baca
parente350f8045f642dfc4c28a81c57d2103e1f7ceead
extcon: Fix hang and extcon_get/set_cable_state().

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 73b6ecdb93e8 ("extcon: Redefine the unique id of supported external connectors without 'enum extcon' type")
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Tested-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
[cw00.choi: Fix minor coding style]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/extcon/extcon.c