static ssize_t afe_debug_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { char *lb_str = filp->private_data; char lbuf[32]; int rc; unsigned long param[5]; if (cnt > sizeof(lbuf) - 1) return -EINVAL; rc = copy_from_user(lbuf, ubuf, cnt); if (rc) return -EFAULT; lbuf[cnt] = '\0'; if (!strcmp(lb_str, "afe_loopback")) { rc = afe_get_parameters(lbuf, param, 3); if (!rc) { pr_info("%s %lu %lu %lu\n", lb_str, param[0], param[1], param[2]); if ((param[0] != AFE_LOOPBACK_ON) && (param[0] != AFE_LOOPBACK_OFF)) { pr_err("%s: Error, parameter 0 incorrect\n", __func__); rc = -EINVAL; goto afe_error; } #ifdef CONFIG_RECINCALL if ((afe_validate_port(param[1]) < 0) || (afe_validate_port(param[2])) < 0) #else if ((param[1] >= AFE_MAX_PORTS) || (param[2] >= AFE_MAX_PORTS)) #endif { pr_err("%s: Error, invalid afe port\n", __func__); } if (this_afe.apr == NULL) { pr_err("%s: Error, AFE not opened\n", __func__); rc = -EINVAL; } else { rc = afe_loopback(param[0], param[1], param[2]); } } else { pr_err("%s: Error, invalid parameters\n", __func__); rc = -EINVAL; } } afe_error: if (rc == 0) rc = cnt; else pr_err("%s: rc = %d\n", __func__, rc); return rc; }
static ssize_t afe_debug_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { char *lb_str = filp->private_data; char lbuf[32]; int rc; unsigned long param[5]; if (cnt > sizeof(lbuf) - 1) return -EINVAL; rc = copy_from_user(lbuf, ubuf, cnt); if (rc) return -EFAULT; lbuf[cnt] = '\0'; if (!strcmp(lb_str, "afe_loopback")) { rc = afe_get_parameters(lbuf, param, 3); if (!rc) { pr_info("%s %lu %lu %lu\n", lb_str, param[0], param[1], param[2]); if ((param[0] != AFE_LOOPBACK_ON) && (param[0] != AFE_LOOPBACK_OFF)) { pr_err("%s: Error, parameter 0 incorrect\n", __func__); rc = -EINVAL; goto afe_error; } if ((afe_validate_port(param[1]) < 0) || (afe_validate_port(param[2])) < 0) { pr_err("%s: Error, invalid afe port\n", __func__); } if (this_afe.apr == NULL) { pr_err("%s: Error, AFE not opened\n", __func__); rc = -EINVAL; } else { rc = afe_loopback(param[0], param[1], param[2]); } } else { pr_err("%s: Error, invalid parameters\n", __func__); rc = -EINVAL; } } else if (!strcmp(lb_str, "afe_loopback_gain")) { rc = afe_get_parameters(lbuf, param, 2); if (!rc) { pr_info("%s %lu %lu\n", lb_str, param[0], param[1]); if (afe_validate_port(param[0]) < 0) { pr_err("%s: Error, invalid afe port\n", __func__); rc = -EINVAL; goto afe_error; } if (param[1] < 0 || param[1] > 100) { pr_err("%s: Error, volume shoud be 0 to 100" " percentage param = %lu\n", __func__, param[1]); rc = -EINVAL; goto afe_error; } param[1] = (Q6AFE_MAX_VOLUME * param[1]) / 100; if (this_afe.apr == NULL) { pr_err("%s: Error, AFE not opened\n", __func__); rc = -EINVAL; } else { rc = afe_loopback_gain(param[0], param[1]); } } else { pr_err("%s: Error, invalid parameters\n", __func__); rc = -EINVAL; } } afe_error: if (rc == 0) rc = cnt; else pr_err("%s: rc = %d\n", __func__, rc); return rc; }