static int check_devices(struct crypt_device *cd, const char *name, const char *iname, uint32_t *flags)
{
	int r;

	if (!flags || !name)
		return -EINVAL;

	if (iname) {
		r = dm_status_device(cd, iname);
		if (r >= 0 && !(*flags & CRYPT_ACTIVATE_REFRESH))
			return -EBUSY;
		if (r < 0 && r != -ENODEV)
			return r;
		if (r == -ENODEV)
			*flags &= ~CRYPT_ACTIVATE_REFRESH;
	}

	r = dm_status_device(cd, name);
	if (r >= 0 && !(*flags & CRYPT_ACTIVATE_REFRESH))
		return -EBUSY;
	if (r < 0 && r != -ENODEV)
		return r;
	if (r == -ENODEV)
		*flags &= ~CRYPT_ACTIVATE_REFRESH;

	return 0;
}
static int check_devices(struct crypt_device *cd, const char *name, const char *iname, uint32_t *flags)
{
	int r;

	if (!flags || !name)
		return -EINVAL;

	if (iname) {
		r = dm_status_device(cd, iname);
		if (r >= 0 && !(*flags & CRYPT_ACTIVATE_REFRESH))
			return -EBUSY;
		if (r < 0 && r != -ENODEV)
			return r;
		if (r == -ENODEV)
			*flags &= ~CRYPT_ACTIVATE_REFRESH;
	}

	r = dm_status_device(cd, name);
	if (r >= 0 && !(*flags & CRYPT_ACTIVATE_REFRESH))
		return -EBUSY;
	if (r < 0 && r != -ENODEV)
		return r;
	if (r == -ENODEV)
		*flags &= ~CRYPT_ACTIVATE_REFRESH;

	return 0;
}