/* Wait for a device to report an event  */
static int dev_wait(struct dm_ioctl *param, size_t param_size)
/* Wait for a device to report an event  */
static int dev_wait(struct dm_ioctl *param, size_t param_size)
{
	int r;
	struct mapped_device *md;
	struct dm_table *table;
	md = find_device(param);
	if (!md)
		return -ENXIO;
	if (dm_wait_event(md, param->event_nr)) {
		r = -ERESTARTSYS;
		goto out;
	}
	r = __dev_status(md, param);
	if (r)
		goto out;
	table = dm_get_live_or_inactive_table(md, param);
	if (table) {
		retrieve_status(table, param, param_size);
		dm_table_put(table);
	}
 out:
	dm_put(md);
	return r;
}