Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4513b06 authored by Hans de Goede's avatar Hans de Goede Committed by Chanwoo Choi
Browse files

extcon: Fix attached value returned by is_extcon_changed



is_extcon_changed should only check the idx-th bit of new, not
the entirety of new when setting attached.

This fixes extcon sending notifications that a cable was inserted when
it gets removed while another cable is still connected.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
parent 1f93e4a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -159,7 +159,7 @@ static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached)
static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached)
{
{
	if (((prev >> idx) & 0x1) != ((new >> idx) & 0x1)) {
	if (((prev >> idx) & 0x1) != ((new >> idx) & 0x1)) {
		*attached = new ? true : false;
		*attached = ((new >> idx) & 0x1) ? true : false;
		return true;
		return true;
	}
	}