/* iio_trigger_register_id() - get a unique id for this trigger @trig_info: the trigger  */
static int iio_trigger_register_id(struct iio_trigger *trig_info)
/* iio_trigger_register_id() - get a unique id for this trigger @trig_info: the trigger  */
static int iio_trigger_register_id(struct iio_trigger *trig_info)
{
	int ret = 0;
idr_again:
	if (unlikely(idr_pre_get(&iio_trigger_idr, GFP_KERNEL) == 0))
		return -ENOMEM;
	spin_lock(&iio_trigger_idr_lock);
	ret = idr_get_new(&iio_trigger_idr, NULL, &trig_info->id);
	spin_unlock(&iio_trigger_idr_lock);
	if (unlikely(ret == -EAGAIN))
		goto idr_again;
	else if (likely(!ret))
		trig_info->id = trig_info->id & MAX_ID_MASK;
	return ret;
}