/* This function returns %1 if the reference has been done, %0 if not, otherwise a negative error code is returned.  */
static int done_already(struct rb_root *done_tree, int lnum)
/* This function returns %1 if the reference has been done, %0 if not, otherwise a negative error code is returned.  */
static int done_already(struct rb_root *done_tree, int lnum)
{
	struct rb_node **p = &done_tree->rb_node, *parent = NULL;
	struct done_ref *dr;
	while (*p) {
		parent = *p;
		dr = rb_entry(parent, struct done_ref, rb);
		if (lnum < dr->lnum)
			p = &(*p)->rb_left;
		else if (lnum > dr->lnum)
			p = &(*p)->rb_right;
		else
			return 1;
	}
	dr = kzalloc(sizeof(struct done_ref), GFP_NOFS);
	if (!dr)
		return -ENOMEM;
	dr->lnum = lnum;
	rb_link_node(&dr->rb, parent, p);
	rb_insert_color(&dr->rb, done_tree);
	return 0;
}