static bool fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
{
	long size;
	char *buf;

	size = fw_file_size(file);
	if (size <= 0)
		return false;
	if (fw_buf->dest_size > 0 && fw_buf->dest_size < size)
		return false;

	if (fw_buf->dest_addr)
		buf = fw_buf->map_fw_mem(fw_buf->dest_addr,
					   fw_buf->dest_size, fw_buf->map_data);
	else
		buf = vmalloc(size);
	if (!buf)
		return false;
	if (kernel_read(file, 0, buf, size) != size) {
		if (fw_buf->dest_addr)
			fw_buf->unmap_fw_mem(buf, fw_buf->dest_size,
							fw_buf->map_data);
		else
			vfree(buf);
		return false;
	}
	fw_buf->data = buf;
	fw_buf->size = size;
	if (fw_buf->dest_addr)
		fw_buf->unmap_fw_mem(buf, fw_buf->size, fw_buf->map_data);
	return true;
}
示例#2
0
static bool fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
{
	long size;
	char *buf;

	size = fw_file_size(file);
	if (size <= 0)
		return false;
	buf = vmalloc(size);
	if (!buf)
		return false;
	if (kernel_read(file, 0, buf, size) != size) {
		vfree(buf);
		return false;
	}
	fw_buf->data = buf;
	fw_buf->size = size;
	return true;
}