/*----------------------------------------------------------------------------- * Function: hdcp_ioctl *----------------------------------------------------------------------------- */ long hdcp_ioctl(struct file *fd, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; switch (cmd) { case HDCP_ENABLE: return hdcp_enable_ctl(argp); case HDCP_DISABLE: return hdcp_disable_ctl(); case HDCP_ENCRYPT_KEY: return hdcp_encrypt_key_ctl(argp); case HDCP_QUERY_STATUS: return hdcp_query_status_ctl(argp); case HDCP_WAIT_EVENT: return hdcp_wait_event_ctl(argp); case HDCP_DONE: return hdcp_done_ctl(argp); default: return -ENOTTY; } /* End switch */ }
static long hdcp_ioctl(struct file *fd, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; struct hdcp_wait_control ctrl; uint32_t status; if (!fd) { HDCP_ERR("%s null pointer\n", __func__); return -EINVAL; } HDCP_DBG("%s\n", __func__); switch (cmd) { case HDCP_WAIT_EVENT: if (copy_from_user(&ctrl, argp, sizeof(struct hdcp_wait_control))) { HDCP_ERR("HDCP: Error copying from user space" " - wait ioctl"); return -EFAULT; } /* Do not allow re-entrance for this ioctl */ mutex_lock(&hdcp.re_entrant_lock); if (hdcp.re_entrance_flag == false) { hdcp.re_entrance_flag = true; mutex_unlock(&hdcp.re_entrant_lock); hdcp_auth_wait_event_ctl(&ctrl); mutex_lock(&hdcp.re_entrant_lock); hdcp.re_entrance_flag = false; mutex_unlock(&hdcp.re_entrant_lock); } else { mutex_unlock(&hdcp.re_entrant_lock); ctrl.event = HDCP_EVENT_EXIT; } /* Store output data to output pointer */ if (copy_to_user(argp, &ctrl, sizeof(struct hdcp_wait_control))) { HDCP_ERR("HDCP: Error copying to user space -" " wait ioctl"); return -EFAULT; } break; case HDCP_QUERY_STATUS: hdcp_query_status_ctl(&status); /* Store output data to output pointer */ if (copy_to_user(argp, &status, sizeof(uint32_t))) { HDCP_ERR("HDCP: Error copying to user space -" "query status ioctl"); return -EFAULT; } break; case HDCP_DONE: if (copy_from_user(&status, argp, sizeof(uint32_t))) { HDCP_ERR("HDCP: Error copying from user space" " - done ioctl"); return -EFAULT; } return hdcp_user_space_done_ctl(&status); default: return -ENOTTY; } /* End switch */ return 0; }