static int usf_set_rx_info(struct usf_type *usf, unsigned long arg) { struct us_rx_info_type config_rx; struct usf_xx_type *usf_xx = &usf->usf_rx; int rc = copy_from_user(&config_rx, (void *) arg, sizeof(config_rx)); if (rc) { pr_err("%s: copy config_rx from user; rc=%d\n", __func__, rc); return -EFAULT; } usf_xx->new_region = USM_UNDEF_TOKEN; usf_xx->prev_region = USM_UNDEF_TOKEN; usf_xx->cb = usf_rx_cb; rc = config_xx(usf_xx, &config_rx.us_xx_info); if (rc) return rc; rc = q6usm_open_write(usf_xx->usc, usf_xx->encdec_cfg.format_id); if (rc) return rc; rc = q6usm_us_client_buf_alloc( IN, usf_xx->usc, usf_xx->buffer_size, usf_xx->buffer_count); if (rc) { (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); return rc; } rc = q6usm_us_param_buf_alloc(IN, usf_xx->usc, config_rx.us_xx_info.max_get_set_param_buf_size); if (rc) { (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); return rc; } rc = q6usm_dec_cfg_blk(usf_xx->usc, &usf_xx->encdec_cfg); if (rc) (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); else { init_waitqueue_head(&usf_xx->wait); usf_xx->usf_state = USF_CONFIGURED_STATE; } return rc; } /* usf_set_rx_info */
static void usf_disable(struct usf_xx_type *usf_xx) { if (usf_xx != NULL) { if ((usf_xx->usf_state != USF_IDLE_STATE) && (usf_xx->usf_state != USF_OPENED_STATE)) { (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); usf_xx->usf_state = USF_OPENED_STATE; wake_up(&usf_xx->wait); } release_xx(usf_xx); } }
static int usf_set_tx_info(struct usf_type *usf, unsigned long arg) { struct us_tx_info_type config_tx; const char *name = NULL; struct usf_xx_type *usf_xx = &usf->usf_tx; int rc = copy_from_user(&config_tx, (void *) arg, sizeof(config_tx)); if (rc) { pr_err("%s: copy config_tx from user; rc=%d\n", __func__, rc); return -EFAULT; } name = config_tx.us_xx_info.client_name; usf_xx->new_region = USM_UNDEF_TOKEN; usf_xx->prev_region = USM_UNDEF_TOKEN; usf_xx->cb = usf_tx_cb; init_waitqueue_head(&usf_xx->wait); if (name != NULL) { int res = strncpy_from_user( usf_xx->client_name, name, sizeof(usf_xx->client_name)-1); if (res < 0) { pr_err("%s: get client name failed\n", __func__); return -EINVAL; } } rc = config_xx(usf_xx, &config_tx.us_xx_info); if (rc) return rc; rc = q6usm_open_read(usf_xx->usc, usf_xx->encdec_cfg.format_id); if (rc) return rc; rc = q6usm_us_client_buf_alloc(OUT, usf_xx->usc, usf_xx->buffer_size, usf_xx->buffer_count); if (rc) { (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); return rc; } rc = q6usm_enc_cfg_blk(usf_xx->usc, &usf_xx->encdec_cfg); if (!rc && (config_tx.input_info.event_types != USF_NO_EVENT)) { rc = register_input_device(usf, &config_tx.input_info); } if (rc) (void)q6usm_cmd(usf_xx->usc, CMD_CLOSE); else usf_xx->usf_state = USF_CONFIGURED_STATE; return rc; } /* usf_set_tx_info */