/* Look up a completion event file by FD. If lookup is successful, takes a ref to the event file struct that it returns; if unsuccessful, returns NULL.  */
struct ib_uverbs_event_file* ib_uverbs_lookup_comp_file(int fd)
/* Look up a completion event file by FD. If lookup is successful, takes a ref to the event file struct that it returns; if unsuccessful, returns NULL.  */
struct ib_uverbs_event_file* ib_uverbs_lookup_comp_file(int fd)
{
	struct ib_uverbs_event_file *ev_file = NULL;
	struct file *filp;
	filp = fget(fd);
	if (!filp)
		return NULL;
	if (filp->f_op != &uverbs_event_fops)
		goto out;
	ev_file = filp->private_data;
	if (ev_file->is_async) {
		ev_file = NULL;
		goto out;
	}
	kref_get(&ev_file->ref);
out:
	fput(filp);
	return ev_file;
}