/* mipsmt_sys_sched_getaffinity - get the cpu affinity of a process  */
asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long __user *user_mask_ptr)
/* mipsmt_sys_sched_getaffinity - get the cpu affinity of a process  */
asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long __user *user_mask_ptr)
{
	unsigned int real_len;
	cpumask_t mask;
	int retval;
	struct task_struct *p;
	real_len = sizeof(mask);
	if (len < real_len)
		return -EINVAL;
	get_online_cpus();
	read_lock(&tasklist_lock);
	retval = -ESRCH;
	p = find_process_by_pid(pid);
	if (!p)
		goto out_unlock;
	retval = security_task_getscheduler(p);
	if (retval)
		goto out_unlock;
	cpus_and(mask, p->thread.user_cpus_allowed, cpu_possible_map);
out_unlock:
	read_unlock(&tasklist_lock);
	put_online_cpus();
	if (retval)
		return retval;
	if (copy_to_user(user_mask_ptr, &mask, real_len))
		return -EFAULT;
	return real_len;
}