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

Commit dd11a247 authored by Ajay Agarwal's avatar Ajay Agarwal Committed by Chandana Kishori Chiluveru
Browse files

usb: gadget: ffs: Fix runtime PM usage count for multiple set_alt



In some scenarios such as USBCV tests, multiple set_alt
could be issued with same interface and alternate
setting. In that case, EPs are disabled and enabled,
we get the usage count but do not put it. This causes
a mismatch and DWC3 LPM does not work anymore. Fix
this issue by moving put_usage_count to ffs_func_set_alt.

Change-Id: Ic85db09820d2c18b67bd463fe27e2c1ef41e8c74
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
parent 513494c8
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -1388,7 +1388,7 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to)
		*to = p->data;
	}

	ffs_log("enter");
	ffs_log("exit");

	return res;
}
@@ -3602,6 +3602,8 @@ static int ffs_func_set_alt(struct usb_function *f,
	if (ffs->func) {
		ffs_func_eps_disable(ffs->func);
		ffs->func = NULL;
		/* matching put to allow LPM on disconnect */
		usb_gadget_autopm_put_async(ffs->gadget);
	}

	if (ffs->state == FFS_DEACTIVATED) {
@@ -3634,13 +3636,9 @@ static int ffs_func_set_alt(struct usb_function *f,

static void ffs_func_disable(struct usb_function *f)
{
	struct ffs_function *func = ffs_func_from_usb(f);
	struct ffs_data *ffs = func->ffs;

	ffs_log("enter");
	ffs_func_set_alt(f, 0, (unsigned)-1);
	/* matching put to allow LPM on disconnect */
	usb_gadget_autopm_put_async(ffs->gadget);

	ffs_log("exit");
}