/* This function parses a name such as "tty/driver/serial", and returns the struct proc_dir_entry for "/proc/tty/driver", and returns "serial" in residual.  */
static int xlate_proc_name(const char *name, struct proc_dir_entry **ret, const char **residual)
/* This function parses a name such as "tty/driver/serial", and returns the struct proc_dir_entry for "/proc/tty/driver", and returns "serial" in residual.  */
static int xlate_proc_name(const char *name, struct proc_dir_entry **ret, const char **residual)
{
	const char     		*cp = name, *next;
	struct proc_dir_entry	*de;
	int			len;
	int 			rtn = 0;
	de = *ret;
	if (!de)
		de = &proc_root;
	spin_lock(&proc_subdir_lock);
	while (1) {
		next = strchr(cp, '/');
		if (!next)
			break;
		len = next - cp;
		for (de = de->subdir; de ; de = de->next) {
			if (proc_match(len, cp, de))
				break;
		}
		if (!de) {
			rtn = -ENOENT;
			goto out;
		}
		cp += len + 1;
	}
	*residual = cp;
	*ret = de;
out:
	spin_unlock(&proc_subdir_lock);
	return rtn;
}