/* Read data out of VME space into a buffer.  */
ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count, loff_t offset)
/* Read data out of VME space into a buffer.  */
ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count, loff_t offset)
{
	struct vme_bridge *bridge = find_bridge(resource);
	struct vme_master_resource *image;
	size_t length;
	if (bridge->master_read == NULL) {
		printk("Reading from resource not supported\n");
		return -EINVAL;
	}
	if (resource->type != VME_MASTER) {
		printk("Not a master resource\n");
		return -EINVAL;
	}
	image = list_entry(resource->entry, struct vme_master_resource, list);
	length = vme_get_size(resource);
	if (offset > length) {
		printk("Invalid Offset\n");
		return -EFAULT;
	}
	if ((offset + count) > length)
		count = length - offset;
	return bridge->master_read(image, buf, count, offset);
}