UPSTREAM: extcon: Deduplicate code in extcon_set_state_sync()

Finding the cable index and checking for changed status is also done
in extcon_set_state(). So calling extcon_set_state_sync() will do these
checks twice. Remove them and use these checks from extcon_set_state().

Bug: 253534975
Bug: 260915739
Change-Id: Iaff09f32e237751c2a94fdd6a50dbf20d9c9d321
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Link: https://lore.kernel.org/all/20211123145301.778629-1-alexander.stein@ew.tq-group.com/T/
(cherry picked from commit 2da3db7f498d8b6137566b4869d289938b69de13)
This commit is contained in:
Alexander Stein
2021-11-23 15:53:01 +01:00
committed by Badhri Jagan Sridharan
parent 21f5612164
commit aba68815d5

View File

@@ -576,19 +576,7 @@ EXPORT_SYMBOL_GPL(extcon_set_state);
*/
int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, bool state)
{
int ret, index;
unsigned long flags;
index = find_cable_index_by_id(edev, id);
if (index < 0)
return index;
/* Check whether the external connector's state is changed. */
spin_lock_irqsave(&edev->lock, flags);
ret = is_extcon_changed(edev, index, state);
spin_unlock_irqrestore(&edev->lock, flags);
if (!ret)
return 0;
int ret;
ret = extcon_set_state(edev, id, state);
if (ret < 0)