/* If one neighbor fails during initial discovery (determining if it is a neighbor or not), we fail all - note that interaction with neighbor has not occured at this point so if a failure occurs we know something went wrong locally. We thus undo everything.  */
ssize_t wlp_discover(struct wlp *wlp)
/* If one neighbor fails during initial discovery (determining if it is a neighbor or not), we fail all - note that interaction with neighbor has not occured at this point so if a failure occurs we know something went wrong locally. We thus undo everything.  */
ssize_t wlp_discover(struct wlp *wlp)
{
	int result = 0;
	struct device *dev = &wlp->rc->uwb_dev.dev;
	mutex_lock(&wlp->nbmutex);
	__wlp_neighbors_release(wlp);
	result = uwb_dev_for_each(wlp->rc, wlp_add_neighbor_helper, wlp);
	if (result < 0) {
		__wlp_neighbors_release(wlp);
		goto error_dev_for_each;
	}
	result = wlp_discover_all_neighbors(wlp);
	if (result < 0) {
		dev_err(dev, "Unable to fully discover neighborhood. \n");
		result = 0;
	}
error_dev_for_each:
	mutex_unlock(&wlp->nbmutex);
	return result;
}