/* With page-unaligned ioremaps, one or two armed pages may contain addresses from outside the intended mapping. Events for these addresses are currently silently dropped. The events may result only from programming mistakes by accessing addresses before the beginning or past the end of a mapping.  */
int register_kmmio_probe(struct kmmio_probe *p)
/* With page-unaligned ioremaps, one or two armed pages may contain addresses from outside the intended mapping. Events for these addresses are currently silently dropped. The events may result only from programming mistakes by accessing addresses before the beginning or past the end of a mapping.  */
int register_kmmio_probe(struct kmmio_probe *p)
{
	unsigned long flags;
	int ret = 0;
	unsigned long size = 0;
	const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK);
	spin_lock_irqsave(&kmmio_lock, flags);
	if (get_kmmio_probe(p->addr)) {
		ret = -EEXIST;
		goto out;
	}
	kmmio_count++;
	list_add_rcu(&p->list, &kmmio_probes);
	while (size < size_lim) {
		if (add_kmmio_fault_page(p->addr + size))
			pr_err("Unable to set page fault.\n");
		size += PAGE_SIZE;
	}
out:
	spin_unlock_irqrestore(&kmmio_lock, flags);
	return ret;
}