/* Adjust an existing IO region allocation, but making sure that we don't encroach outside the resources which the user supplied.  */
static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_start, unsigned long r_end, struct pcmcia_socket *s)
/* Adjust an existing IO region allocation, but making sure that we don't encroach outside the resources which the user supplied.  */
static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_start, unsigned long r_end, struct pcmcia_socket *s)
{
	struct resource_map *m;
	struct socket_data *s_data = s->resource_data;
	int ret = -ENOMEM;
	mutex_lock(&rsrc_mutex);
	for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) {
		unsigned long start = m->base;
		unsigned long end = m->base + m->num - 1;
		if (start > r_start || r_end > end)
			continue;
		ret = adjust_resource(res, r_start, r_end - r_start + 1);
		break;
	}
	mutex_unlock(&rsrc_mutex);
	return ret;
}