static int snddev_icodec_close(struct msm_snddev_info *dev_info) { int rc = 0; struct snddev_icodec_state *icodec; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; if (icodec->data->capability & SNDDEV_CAP_RX) { mutex_lock(&drv->rx_lock); if (!drv->rx_active) { mutex_unlock(&drv->rx_lock); pr_err("%s: rx_active not set, return\n", __func__); rc = -EPERM; goto error; } rc = snddev_icodec_close_rx(icodec); if (!IS_ERR_VALUE(rc)) drv->rx_active = 0; else pr_err("%s: close rx failed, rc = %d\n", __func__, rc); mutex_unlock(&drv->rx_lock); } else if (icodec->data->capability & SNDDEV_CAP_LB) { mutex_lock(&drv->lb_lock); rc = snddev_icodec_close_lb(icodec); mutex_unlock(&drv->lb_lock); } else { mutex_lock(&drv->tx_lock); if (!drv->tx_active) { mutex_unlock(&drv->tx_lock); pr_err("%s: tx_active not set, return\n", __func__); rc = -EPERM; goto error; } rc = snddev_icodec_close_tx(icodec); if (!IS_ERR_VALUE(rc)) drv->tx_active = 0; else pr_err("%s: close tx failed, rc = %d\n", __func__, rc); mutex_unlock(&drv->tx_lock); } error: return rc; }
static int snddev_icodec_close(struct msm_snddev_info *dev_info) { int rc = 0; struct snddev_icodec_state *icodec; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; MM_AUD_INFO("snddev_icodec_close: device %s\n", dev_info->name); if (icodec->data->capability & SNDDEV_CAP_RX) { mutex_lock(&drv->rx_lock); if (!drv->rx_active) { mutex_unlock(&drv->rx_lock); rc = -EPERM; goto error; } rc = snddev_icodec_close_rx(icodec); if (!IS_ERR_VALUE(rc)) drv->rx_active = 0; mutex_unlock(&drv->rx_lock); } else { mutex_lock(&drv->tx_lock); if (!drv->tx_active) { mutex_unlock(&drv->tx_lock); rc = -EPERM; goto error; } rc = snddev_icodec_close_tx(icodec); if (!IS_ERR_VALUE(rc)) drv->tx_active = 0; mutex_unlock(&drv->tx_lock); } error: return rc; }