/* Copy an openpromio structure into kernel space from user space. This routine does error checking to make sure that all memory accesses are within bounds. A pointer to the allocated openpromio structure will be placed in "*opp_p". Return value is the length of the user supplied buffer.  */
static int copyin(struct openpromio __user *info, struct openpromio **opp_p)
/* Copy an openpromio structure into kernel space from user space. This routine does error checking to make sure that all memory accesses are within bounds. A pointer to the allocated openpromio structure will be placed in "*opp_p". Return value is the length of the user supplied buffer.  */
static int copyin(struct openpromio __user *info, struct openpromio **opp_p)
{
	unsigned int bufsize;
	if (!info || !opp_p)
		return -EFAULT;
	if (get_user(bufsize, &info->oprom_size))
		return -EFAULT;
	if (bufsize == 0)
		return -EINVAL;
	if (bufsize > OPROMMAXPARAM)
		bufsize = OPROMMAXPARAM;
	if (!(*opp_p = kzalloc(sizeof(int) + bufsize + 1, GFP_KERNEL)))
		return -ENOMEM;
	if (copy_from_user(&(*opp_p)->oprom_array,
			   &info->oprom_array, bufsize)) {
		kfree(*opp_p);
		return -EFAULT;
	}
	return bufsize;
}