From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 10/11] android/health: Refactor create_device
Date: Tue, 24 Jun 2014 15:12:01 +0300 [thread overview]
Message-ID: <1403611922-26901-10-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1403611922-26901-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
create_device() should not search for apps again since we have searched
already, and we do not have always app_id.
---
android/health.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/android/health.c b/android/health.c
index 2613ca6..df97848 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1352,12 +1352,11 @@ static int connect_mcl(struct health_channel *channel)
search_cb, channel, NULL, 0);
}
-static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
+static struct health_device *create_device(struct health_app *app,
+ const uint8_t *addr)
{
- struct health_app *app;
struct health_device *dev;
- app = queue_find(apps, app_by_app_id, INT_TO_PTR(app_id));
if (!app)
return NULL;
@@ -1367,7 +1366,6 @@ static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
return NULL;
android2bdaddr(addr, &dev->dst);
- dev->app_id = app_id;
dev->channels = queue_new();
if (!dev->channels) {
free_health_device(dev);
@@ -1397,7 +1395,11 @@ static struct health_device *get_device(uint16_t app_id, const uint8_t *addr)
if (dev)
return dev;
- return create_device(app_id, addr);
+ dev = create_device(app, addr);
+ if (dev)
+ dev->app_id = app_id;
+
+ return dev;
}
static struct health_channel *create_channel(uint16_t app_id,
--
1.8.3.2
next prev parent reply other threads:[~2014-06-24 12:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 12:11 [PATCH 01/11] android/hal-health: trivial: Correct coding style Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 02/11] android/health: Remove unneeded check Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 03/11] android/health: Fix possible overflow Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 04/11] android/health: Fix missing error check Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 05/11] android/health: trivial: Remove empty line Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 06/11] android/health: Remove extra check Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 07/11] android/health: trivial: Fix missing space Andrei Emeltchenko
2014-06-24 12:11 ` [PATCH 08/11] android/health: Refactor setting mcl callbacks to function Andrei Emeltchenko
2014-06-24 12:12 ` [PATCH 09/11] android/health: Add actual error message to error print Andrei Emeltchenko
2014-06-24 12:12 ` Andrei Emeltchenko [this message]
2014-06-24 12:12 ` [PATCH 11/11] android/health: Add setting mcl callbacks for incoming connection Andrei Emeltchenko
2014-06-25 15:30 ` [PATCH 01/11] android/hal-health: trivial: Correct coding style Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403611922-26901-10-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox