Return-Path: From: Andrei Emeltchenko To: linux-bluetooth@vger.kernel.org Subject: [PATCHv3 08/12] android/health: Create mdep for ECHO channel Date: Fri, 27 Jun 2014 14:24:59 +0300 Message-Id: <1403868303-8129-8-git-send-email-Andrei.Emeltchenko.news@gmail.com> In-Reply-To: <1403868303-8129-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> References: <1403855994-29262-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> <1403868303-8129-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Andrei Emeltchenko --- android/health.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/android/health.c b/android/health.c index d9731fd..4f15f93 100644 --- a/android/health.c +++ b/android/health.c @@ -1146,7 +1146,6 @@ static struct health_channel *create_channel(struct health_app *app, { struct mdep_cfg *mdep; struct health_channel *channel; - uint8_t index; static unsigned int channel_id = 1; DBG("mdep %u", mdep_index); @@ -1154,10 +1153,23 @@ static struct health_channel *create_channel(struct health_app *app, if (!dev || !app) return NULL; - index = mdep_index + 1; - mdep = queue_find(app->mdeps, match_mdep_by_id, INT_TO_PTR(index)); - if (!mdep) - return NULL; + mdep = queue_find(app->mdeps, match_mdep_by_id, INT_TO_PTR(mdep_index)); + if (!mdep) { + if (mdep_index == HDP_MDEP_ECHO) { + mdep = new0(struct mdep_cfg, 1); + if (!mdep) + return NULL; + + /* Leave other configuration zeroes */ + mdep->id = HDP_MDEP_ECHO; + + if (!queue_push_tail(app->mdeps, mdep)) { + free_mdep_cfg(mdep); + return NULL; + } + } else + return NULL; + } /* create channel and push it to device */ channel = new0(struct health_channel, 1); -- 1.8.3.2