int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
			void *user_data)
{
	int err;

	if (session->discover)
		return -EBUSY;

	session->discover = g_new0(struct discover_callback, 1);

	if (session->seps) {
		struct avdtp_remote_sep *sep = session->seps->data;

		/* Check that SEP have been discovered as it may be loaded from
		 * cache.
		 */
		if (sep->discovered) {
			session->discover->cb = cb;
			session->discover->user_data = user_data;
			session->discover->id = g_idle_add(process_discover,
								session);
			return 0;
		}
	}

	err = send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0);
	if (err == 0) {
		session->discover->cb = cb;
		session->discover->user_data = user_data;
	}

	return err;
}
int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
			void *user_data)
{
	int err;

	if (session->discover)
		return -EBUSY;

	session->discover = g_new0(struct discover_callback, 1);

	if (session->seps) {
		struct avdtp_remote_sep *sep = session->seps->data;

		 
		if (sep->discovered) {
			session->discover->cb = cb;
			session->discover->user_data = user_data;
			session->discover->id = g_idle_add(process_discover,
								session);
			return 0;
		}
	}

	err = send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0);
	if (err == 0) {
		session->discover->cb = cb;
		session->discover->user_data = user_data;
	}

	return err;
}