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

Commit 03043a92 authored by Amit Pundir's avatar Amit Pundir
Browse files

ANDROID: hid: uhid: use ll_open_count for refcounting



Upstream commit 283a21da ("HID: remove no longer used hid->open field"),
removed obsolete hid->open, so use hid->ll_open_count to track refcount.
Also use existing hid->ll_open_lock mutex instead.

Fixes: Change-Id: I57413e42ec961a960a8ddc4942228df22c730d80
       ("ANDROID: hid: uhid: implement refcount for open and close")
Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
parent 0f3edc49
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@
#define UHID_NAME	"uhid"
#define UHID_BUFSIZE	32

static DEFINE_MUTEX(uhid_open_mutex);

struct uhid_device {
	struct mutex devlock;
	bool running;
@@ -146,13 +144,13 @@ static int uhid_hid_open(struct hid_device *hid)
	struct uhid_device *uhid = hid->driver_data;
	int retval = 0;

	mutex_lock(&uhid_open_mutex);
	if (!hid->open++) {
	mutex_lock(&hid->ll_open_lock);
	if (!hid->ll_open_count++) {
		retval = uhid_queue_event(uhid, UHID_OPEN);
		if (retval)
			hid->open--;
			hid->ll_open_count--;
	}
	mutex_unlock(&uhid_open_mutex);
	mutex_unlock(&hid->ll_open_lock);
	return retval;
}

@@ -160,10 +158,10 @@ static void uhid_hid_close(struct hid_device *hid)
{
	struct uhid_device *uhid = hid->driver_data;

	mutex_lock(&uhid_open_mutex);
	if (!--hid->open)
	mutex_lock(&hid->ll_open_lock);
	if (!--hid->ll_open_count)
		uhid_queue_event(uhid, UHID_CLOSE);
	mutex_unlock(&uhid_open_mutex);
	mutex_unlock(&hid->ll_open_lock);
}

static int uhid_hid_parse(struct hid_device *hid)