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

Commit d16b63d4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "char: msm_smd_pkt: use open timeout for opening existing channel"

parents 07556be5 d41050f0
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -1069,6 +1069,8 @@ int smd_pkt_open(struct inode *inode, struct file *file)

	mutex_lock(&smd_pkt_devp->ch_lock);
	if (smd_pkt_devp->ch == 0) {
		unsigned open_wait_rem = smd_pkt_devp->open_modem_wait * 1000;

		INIT_COMPLETION(smd_pkt_devp->ch_allocated);

		r = smd_pkt_add_driver(smd_pkt_devp);
@@ -1090,7 +1092,7 @@ int smd_pkt_open(struct inode *inode, struct file *file)
				 * retry by user-space modules and to avoid
				 * possible watchdog bite.
				 */
				msleep((smd_pkt_devp->open_modem_wait * 1000));
				msleep(open_wait_rem);
				goto release_pd;
			}
		}
@@ -1111,12 +1113,12 @@ int smd_pkt_open(struct inode *inode, struct file *file)
		 * Wait for a packet channel to be allocated so we know
		 * the modem is ready enough.
		 */
		if (smd_pkt_devp->open_modem_wait) {
		if (open_wait_rem) {
			r = wait_for_completion_interruptible_timeout(
				&smd_pkt_devp->ch_allocated,
				msecs_to_jiffies(
					smd_pkt_devp->open_modem_wait
						 * 1000));
				msecs_to_jiffies(open_wait_rem));
			if (r >= 0)
				open_wait_rem = jiffies_to_msecs(r);
			if (r == 0)
				r = -ETIMEDOUT;
			if (r < 0) {
@@ -1137,9 +1139,11 @@ int smd_pkt_open(struct inode *inode, struct file *file)
			goto release_pil;
		}

		open_wait_rem = max_t(unsigned, 2000, open_wait_rem);
		r = wait_event_interruptible_timeout(
				smd_pkt_devp->ch_opened_wait_queue,
				smd_pkt_devp->is_open, (2 * HZ));
				smd_pkt_devp->is_open,
				msecs_to_jiffies(open_wait_rem));
		if (r == 0) {
			r = -ETIMEDOUT;
			/* close the ch to sync smd's state with smd_pkt */