static int fake_slave_set()

in bridges/vme_fake.c [154:218]


static int fake_slave_set(struct vme_slave_resource *image, int enabled,
		unsigned long long vme_base, unsigned long long size,
		dma_addr_t buf_base, u32 aspace, u32 cycle)
{
	unsigned int i, granularity = 0;
	unsigned long long vme_bound;
	struct vme_bridge *fake_bridge;
	struct fake_driver *bridge;

	fake_bridge = image->parent;
	bridge = fake_bridge->driver_priv;

	i = image->number;

	switch (aspace) {
	case VME_A16:
		granularity = 0x10;
		break;
	case VME_A24:
		granularity = 0x1000;
		break;
	case VME_A32:
		granularity = 0x10000;
		break;
	case VME_A64:
		granularity = 0x10000;
		break;
	case VME_CRCSR:
	case VME_USER1:
	case VME_USER2:
	case VME_USER3:
	case VME_USER4:
	default:
		pr_err("Invalid address space\n");
		return -EINVAL;
	}

	/*
	 * Bound address is a valid address for the window, adjust
	 * accordingly
	 */
	vme_bound = vme_base + size - granularity;

	if (vme_base & (granularity - 1)) {
		pr_err("Invalid VME base alignment\n");
		return -EINVAL;
	}
	if (vme_bound & (granularity - 1)) {
		pr_err("Invalid VME bound alignment\n");
		return -EINVAL;
	}

	mutex_lock(&image->mtx);

	bridge->slaves[i].enabled = enabled;
	bridge->slaves[i].vme_base = vme_base;
	bridge->slaves[i].size = size;
	bridge->slaves[i].buf_base = fake_pci_to_ptr(buf_base);
	bridge->slaves[i].aspace = aspace;
	bridge->slaves[i].cycle = cycle;

	mutex_unlock(&image->mtx);

	return 0;
}