static ssize_t perf_write()

in kernel/perf.c [288:341]


static ssize_t perf_write(struct file *file, const char __user *buf,
	size_t count, loff_t *ppos)
{
	size_t image_size;
	uint32_t image_type;
	uint32_t interface_type;
	uint32_t test;

	if (perf_processor_interface == ONYX_INTF)
		image_size = PCXU_IMAGE_SIZE;
	else if (perf_processor_interface == CUDA_INTF)
		image_size = PCXW_IMAGE_SIZE;
	else
		return -EFAULT;

	if (!perfmon_capable())
		return -EACCES;

	if (count != sizeof(uint32_t))
		return -EIO;

	if (copy_from_user(&image_type, buf, sizeof(uint32_t)))
		return -EFAULT;

	/* Get the interface type and test type */
   	interface_type = (image_type >> 16) & 0xffff;
	test           = (image_type & 0xffff);

	/* Make sure everything makes sense */

	/* First check the machine type is correct for
	   the requested image */
	if (((perf_processor_interface == CUDA_INTF) &&
			(interface_type != CUDA_INTF)) ||
		((perf_processor_interface == ONYX_INTF) &&
			(interface_type != ONYX_INTF)))
		return -EINVAL;

	/* Next check to make sure the requested image
	   is valid */
	if (((interface_type == CUDA_INTF) &&
		       (test >= MAX_CUDA_IMAGES)) ||
	    ((interface_type == ONYX_INTF) &&
		       (test >= MAX_ONYX_IMAGES)))
		return -EINVAL;

	/* Copy the image into the processor */
	if (interface_type == CUDA_INTF)
		return perf_config(cuda_images[test]);
	else
		return perf_config(onyx_images[test]);

	return count;
}