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

Commit 1a77e412 authored by Eric Holmberg's avatar Eric Holmberg
Browse files

char: msm_smd_pkt: flush pending work on release



If an SMD device is closed while the device is active and then
immediately re-opened, then a delayed work item may get processed while
data structures are in the process of being re-initialized.

Move initialization of data structures to device creation which happens
once during module initialization.

CRs-Fixed: 698603
Change-Id: Ida85d8452f32b62fd848c706ba046f1a9a08bc85
Signed-off-by: default avatarEric Holmberg <eholmber@codeaurora.org>
parent f19ef0f6
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -1072,11 +1072,7 @@ int smd_pkt_open(struct inode *inode, struct file *file)

	mutex_lock(&smd_pkt_devp->ch_lock);
	if (smd_pkt_devp->ch == 0) {
		wakeup_source_init(&smd_pkt_devp->pa_ws,
							smd_pkt_devp->dev_name);
		INIT_WORK(&smd_pkt_devp->packet_arrival_work,
				packet_arrival_worker);
		init_completion(&smd_pkt_devp->ch_allocated);
		INIT_COMPLETION(smd_pkt_devp->ch_allocated);

		r = smd_pkt_add_driver(smd_pkt_devp);
		if (r) {
@@ -1181,9 +1177,6 @@ release_pd:
	if (r < 0)
		smd_pkt_remove_driver(smd_pkt_devp);
out:
	if (!smd_pkt_devp->ch)
		wakeup_source_trash(&smd_pkt_devp->pa_ws);

	mutex_unlock(&smd_pkt_devp->ch_lock);


@@ -1220,12 +1213,15 @@ int smd_pkt_release(struct inode *inode, struct file *file)
		smd_pkt_devp->has_reset = 0;
		smd_pkt_devp->do_reset_notification = 0;
		smd_pkt_devp->ws_locked = 0;
		wakeup_source_trash(&smd_pkt_devp->pa_ws);
	}
	mutex_unlock(&smd_pkt_devp->tx_lock);
	mutex_unlock(&smd_pkt_devp->rx_lock);
	mutex_unlock(&smd_pkt_devp->ch_lock);

	if (flush_work(&smd_pkt_devp->packet_arrival_work))
		D_STATUS("%s: Flushed work for smd_pkt_dev id:%d\n", __func__,
				smd_pkt_devp->i);

	D_STATUS("Finished %s on smd_pkt_dev id:%d\n",
		 __func__, smd_pkt_devp->i);

@@ -1260,6 +1256,9 @@ static int smd_pkt_init_add_device(struct smd_pkt_dev *smd_pkt_devp, int i)
	mutex_init(&smd_pkt_devp->ch_lock);
	mutex_init(&smd_pkt_devp->rx_lock);
	mutex_init(&smd_pkt_devp->tx_lock);
	wakeup_source_init(&smd_pkt_devp->pa_ws, smd_pkt_devp->dev_name);
	INIT_WORK(&smd_pkt_devp->packet_arrival_work, packet_arrival_worker);
	init_completion(&smd_pkt_devp->ch_allocated);

	cdev_init(&smd_pkt_devp->cdev, &smd_pkt_fops);
	smd_pkt_devp->cdev.owner = THIS_MODULE;
@@ -1283,6 +1282,7 @@ static int smd_pkt_init_add_device(struct smd_pkt_dev *smd_pkt_devp, int i)
			__func__, i);
		r = -ENOMEM;
		cdev_del(&smd_pkt_devp->cdev);
		wakeup_source_trash(&smd_pkt_devp->pa_ws);
		return r;
	}
	if (device_create_file(smd_pkt_devp->devicep,