/* __iio_request_ring_buffer_event_chrdev() allocate ring event chrdev @buf: ring buffer whose event chrdev we are allocating @owner: the module who owns the ring buffer (for ref counting) @dev: device with which the chrdev is associated  */
static int __iio_request_ring_buffer_event_chrdev(struct iio_ring_buffer *buf, int id, struct module *owner, struct device *dev)
/* __iio_request_ring_buffer_event_chrdev() allocate ring event chrdev @buf: ring buffer whose event chrdev we are allocating @owner: the module who owns the ring buffer (for ref counting) @dev: device with which the chrdev is associated  */
static int __iio_request_ring_buffer_event_chrdev(struct iio_ring_buffer *buf, int id, struct module *owner, struct device *dev)
{
	int ret;
	ret = iio_get_new_idr_val(&iio_ring_event_idr);
	if (ret < 0)
		goto error_ret;
	else
		buf->ev_int.id = ret;
	snprintf(buf->ev_int._name, 20,
		 "ring_event_line%d",
		 buf->ev_int.id);
	ret = iio_setup_ev_int(&(buf->ev_int),
			       buf->ev_int._name,
			       owner,
			       dev);
	if (ret)
		goto error_free_id;
	return 0;
error_free_id:
	iio_free_idr_val(&iio_ring_event_idr, buf->ev_int.id);
error_ret:
	return ret;
}