Esempio n. 1
0
struct us_client *q6usm_us_client_alloc(
	void (*cb)(uint32_t, uint32_t, uint32_t *, void *),
	void *priv)
{
	struct us_client *usc;
	int n;
	int lcnt = 0;

	usc = kzalloc(sizeof(struct us_client), GFP_KERNEL);
	if (usc == NULL)
		return NULL;
	n = q6usm_session_alloc(usc);
	if (n <= 0)
		goto fail_session;
	usc->session = n;
	usc->cb = cb;
	usc->priv = priv;
	usc->apr = apr_register("ADSP", "USM", \
				(apr_fn)q6usm_callback,\
				((usc->session) << 8 | 0x0001),\
				usc);

	if (usc->apr == NULL) {
		pr_err("%s: Registration with APR failed\n", __func__);
		goto fail;
	}
	pr_debug("%s: Registering the common port with APR\n", __func__);
	if (atomic_read(&this_mmap.ref_cnt) == 0) {
		this_mmap.apr = apr_register("ADSP", "USM",
					     (apr_fn)q6usm_mmapcallback,
					     0x0FFFFFFFF, &this_mmap);
		if (this_mmap.apr == NULL) {
			pr_err("%s: USM port registration failed\n",
			       __func__);
			goto fail;
		}
	}

	atomic_inc(&this_mmap.ref_cnt);
	init_waitqueue_head(&usc->cmd_wait);
	mutex_init(&usc->cmd_lock);
	for (lcnt = 0; lcnt <= OUT; ++lcnt) {
		mutex_init(&usc->port[lcnt].lock);
		spin_lock_init(&usc->port[lcnt].dsp_lock);
	}
	atomic_set(&usc->cmd_state, 0);

	return usc;
fail:
	q6usm_us_client_free(usc);
	return NULL;
fail_session:
	kfree(usc);
	return NULL;
}
Esempio n. 2
0
static void release_xx(struct usf_xx_type *usf_xx)
{
    if (usf_xx != NULL) {
        if (usf_xx->usc) {
            q6usm_us_client_free(usf_xx->usc);
            usf_xx->usc = NULL;
        }

        if (usf_xx->encdec_cfg.params != NULL) {
            kfree(usf_xx->encdec_cfg.params);
            usf_xx->encdec_cfg.params = NULL;
        }
    }
}