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

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

Merge "drivers: qcom: ultrasound: Lock async driver calls"

parents 9da51300 c8c16b74
Loading
Loading
Loading
Loading
+59 −7
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/time.h>
#include <linux/kmemleak.h>
#include <linux/wakelock.h>
#include <linux/mutex.h>
#include <sound/apr_audio.h>
#include <linux/qdsp6v2/usf.h>
#include "q6usm.h"
@@ -135,6 +136,8 @@ struct usf_type {
	uint16_t conflicting_event_filters;
	/* The requested buttons bitmap */
	uint16_t req_buttons_bitmap;
	/* Mutex for exclusive operations (all public APIs) */
	struct mutex mutex;
};

struct usf_input_dev_type {
@@ -1403,9 +1406,22 @@ static int __usf_set_stream_param(struct usf_xx_type *usf_xx,
				int dir)
{
	struct us_client *usc = usf_xx->usc;
	struct us_port_data *port = &usc->port[dir];
	struct us_port_data *port;
	int rc = 0;

	if (usc == NULL) {
		pr_err("%s: usc is null\n",
			__func__);
		return -EFAULT;
	}

	port = &usc->port[dir];
	if (port == NULL) {
		pr_err("%s: port is null\n",
			__func__);
		return -EFAULT;
	}

	if (port->param_buf == NULL) {
		pr_err("%s: parameter buffer is null\n",
			__func__);
@@ -1538,10 +1554,12 @@ static int usf_get_stream_param(struct usf_xx_type *usf_xx,
	return __usf_get_stream_param(usf_xx, &get_stream_param, dir);
} /* usf_get_stream_param */

static long usf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
static long __usf_ioctl(struct usf_type *usf,
		unsigned int cmd,
		unsigned long arg)
{

	int rc = 0;
	struct usf_type *usf = file->private_data;
	struct usf_xx_type *usf_xx = NULL;

	switch (cmd) {
@@ -1703,6 +1721,18 @@ static long usf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
	     (cmd == US_SET_RX_INFO)))
		release_xx(usf_xx);

	return rc;
} /* __usf_ioctl */

static long usf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	struct usf_type *usf = file->private_data;
	int rc = 0;

	mutex_lock(&usf->mutex);
	rc = __usf_ioctl(usf, cmd, arg);
	mutex_unlock(&usf->mutex);

	return rc;
} /* usf_ioctl */

@@ -2147,12 +2177,11 @@ static int usf_get_stream_param32(struct usf_xx_type *usf_xx,
	return __usf_get_stream_param(usf_xx, &get_stream_param, dir);
} /* usf_get_stream_param32 */

static long usf_compat_ioctl(struct file *file,
static long __usf_compat_ioctl(struct usf_type *usf,
			     unsigned int cmd,
			     unsigned long arg)
{
	int rc = 0;
	struct usf_type *usf = file->private_data;
	struct usf_xx_type *usf_xx = NULL;

	switch (cmd) {
@@ -2160,7 +2189,7 @@ static long usf_compat_ioctl(struct file *file,
	case US_START_RX:
	case US_STOP_TX:
	case US_STOP_RX: {
		return usf_ioctl(file, cmd, arg);
		return __usf_ioctl(usf, cmd, arg);
	}

	case US_SET_TX_INFO32: {
@@ -2268,6 +2297,20 @@ static long usf_compat_ioctl(struct file *file,
	     (cmd == US_SET_RX_INFO)))
		release_xx(usf_xx);

	return rc;
} /* __usf_compat_ioctl */

static long usf_compat_ioctl(struct file *file,
			     unsigned int cmd,
			     unsigned long arg)
{
	struct usf_type *usf = file->private_data;
	int rc = 0;

	mutex_lock(&usf->mutex);
	rc = __usf_compat_ioctl(usf, cmd, arg);
	mutex_unlock(&usf->mutex);

	return rc;
} /* usf_compat_ioctl */
#endif /* CONFIG_COMPAT */
@@ -2277,13 +2320,17 @@ static int usf_mmap(struct file *file, struct vm_area_struct *vms)
	struct usf_type *usf = file->private_data;
	int dir = OUT;
	struct usf_xx_type *usf_xx = &usf->usf_tx;
	int rc = 0;

	mutex_lock(&usf->mutex);
	if (vms->vm_flags & USF_VM_WRITE) { /* RX buf mapping */
		dir = IN;
		usf_xx = &usf->usf_rx;
	}
	rc = q6usm_get_virtual_address(dir, usf_xx->usc, vms);
	mutex_unlock(&usf->mutex);

	return q6usm_get_virtual_address(dir, usf_xx->usc, vms);
	return rc;
}

static uint16_t add_opened_dev(int minor)
@@ -2336,6 +2383,8 @@ static int usf_open(struct inode *inode, struct file *file)
	usf->usf_tx.us_detect_type = USF_US_DETECT_UNDEF;
	usf->usf_rx.us_detect_type = USF_US_DETECT_UNDEF;

	mutex_init(&usf->mutex);

	pr_debug("%s:usf in open\n", __func__);
	return 0;
}
@@ -2346,6 +2395,7 @@ static int usf_release(struct inode *inode, struct file *file)

	pr_debug("%s: release entry\n", __func__);

	mutex_lock(&usf->mutex);
	usf_release_input(usf);

	usf_disable(&usf->usf_tx);
@@ -2354,6 +2404,8 @@ static int usf_release(struct inode *inode, struct file *file)
	s_opened_devs[usf->dev_ind] = 0;

	wakeup_source_trash(&usf_wakeup_source);
	mutex_unlock(&usf->mutex);
	mutex_destroy(&usf->mutex);
	kfree(usf);
	pr_debug("%s: release exit\n", __func__);
	return 0;