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

Commit ab423fe4 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: dev: uci: block file open until MHI remove is complete"

parents 90c19c17 6d8ab04e
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -450,11 +450,10 @@ static int mhi_uci_open(struct inode *inode, struct file *filp)
			break;
		}
	}
	mutex_unlock(&mhi_uci_drv.lock);

	/* could not find a minor node */
	if (ret)
		return ret;
		goto error_exit;

	mutex_lock(&uci_dev->mutex);
	if (!uci_dev->enabled) {
@@ -482,6 +481,7 @@ static int mhi_uci_open(struct inode *inode, struct file *filp)

	filp->private_data = uci_dev;
	mutex_unlock(&uci_dev->mutex);
	mutex_unlock(&mhi_uci_drv.lock);

	return 0;

@@ -496,6 +496,9 @@ static int mhi_uci_open(struct inode *inode, struct file *filp)
 error_open_chan:
	mutex_unlock(&uci_dev->mutex);

error_exit:
	mutex_unlock(&mhi_uci_drv.lock);

	return ret;
}

@@ -514,8 +517,11 @@ static void mhi_uci_remove(struct mhi_device *mhi_dev)

	MSG_LOG("Enter\n");

	/* disable the node */

	mutex_lock(&mhi_uci_drv.lock);
	mutex_lock(&uci_dev->mutex);

	/* disable the node */
	spin_lock_irq(&uci_dev->dl_chan.lock);
	spin_lock_irq(&uci_dev->ul_chan.lock);
	uci_dev->enabled = false;
@@ -527,9 +533,7 @@ static void mhi_uci_remove(struct mhi_device *mhi_dev)
	/* delete the node to prevent new opens */
	device_destroy(mhi_uci_drv.class, uci_dev->devt);
	uci_dev->dev = NULL;
	mutex_lock(&mhi_uci_drv.lock);
	list_del(&uci_dev->node);
	mutex_unlock(&mhi_uci_drv.lock);

	/* safe to free memory only if all file nodes are closed */
	if (!uci_dev->ref_count) {
@@ -537,11 +541,14 @@ static void mhi_uci_remove(struct mhi_device *mhi_dev)
		mutex_destroy(&uci_dev->mutex);
		clear_bit(MINOR(uci_dev->devt), uci_minors);
		kfree(uci_dev);
		mutex_unlock(&mhi_uci_drv.lock);
		return;
	}

	MSG_LOG("Exit\n");
	mutex_unlock(&uci_dev->mutex);
	mutex_unlock(&mhi_uci_drv.lock);

}

static int mhi_uci_probe(struct mhi_device *mhi_dev,