linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Guedes <aguedespe@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: andre.guedes@openbossa.org
Subject: [PATCH 2/3] Bluetooth: Create thread-safe advertising cache functions
Date: Tue,  7 Feb 2012 01:29:56 -0300	[thread overview]
Message-ID: <1328588997-25029-3-git-send-email-aguedespe@gmail.com> (raw)
In-Reply-To: <1328588997-25029-1-git-send-email-aguedespe@gmail.com>

This patch creates thread-safe versions of advertising cache add/
find/clear functions.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
---
 include/net/bluetooth/hci_core.h |    4 ++++
 net/bluetooth/hci_core.c         |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index a6fccca..ca52a88 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -677,6 +677,10 @@ int __hci_adv_entries_clear(struct hci_dev *hdev);
 struct adv_entry *__hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
 int __hci_add_adv_entry(struct hci_dev *hdev,
 					struct hci_ev_le_advertising_info *ev);
+int hci_adv_entries_clear(struct hci_dev *hdev);
+struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_add_adv_entry(struct hci_dev *hdev,
+					struct hci_ev_le_advertising_info *ev);
 
 void hci_del_off_timer(struct hci_dev *hdev);
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 362b1ab..536248d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1603,6 +1603,40 @@ int __hci_add_adv_entry(struct hci_dev *hdev,
 	return 0;
 }
 
+struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
+{
+	struct adv_entry *entry;
+
+	hci_dev_lock(hdev);
+	entry = __hci_find_adv_entry(hdev, bdaddr);
+	hci_dev_unlock(hdev);
+
+	return entry;
+}
+
+int hci_adv_entries_clear(struct hci_dev *hdev)
+{
+	int res;
+
+	hci_dev_lock(hdev);
+	res = __hci_adv_entries_clear(hdev);
+	hci_dev_unlock(hdev);
+
+	return res;
+}
+
+int hci_add_adv_entry(struct hci_dev *hdev,
+					struct hci_ev_le_advertising_info *ev)
+{
+	int res;
+
+	hci_dev_lock(hdev);
+	res = __hci_add_adv_entry(hdev, ev);
+	hci_dev_unlock(hdev);
+
+	return res;
+}
+
 static void le_scan_param_req(struct hci_dev *hdev, unsigned long opt)
 {
 	struct le_scan_params *param =  (struct le_scan_params *) opt;
-- 
1.7.9


  parent reply	other threads:[~2012-02-07  4:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07  4:29 [PATCH 0/3] Advertising cache locking code refactoring Andre Guedes
2012-02-07  4:29 ` [PATCH 1/3] Bluetooth: Add prefix "__" to advertising cache functions Andre Guedes
2012-02-07  4:29 ` Andre Guedes [this message]
2012-02-07  4:29 ` [PATCH 3/3] Bluetooth: Use advertising cache thread-safe functions Andre Guedes
2012-02-07 10:48   ` Anderson Lizardo
2012-02-07 12:20     ` Andre Guedes
2012-02-07 13:26       ` Ulisses Furquim
2012-02-07 14:46         ` Andre Guedes
2012-02-07 15:20           ` Ulisses Furquim
2012-02-07 17:41             ` Andre Guedes
2012-02-07 17:47               ` Ulisses Furquim
2012-02-09 13:49 ` [PATCH 0/3] Advertising cache locking code refactoring Marcel Holtmann
2012-02-09 17:23   ` Ulisses Furquim
2012-02-09 19:18     ` Marcel Holtmann

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=1328588997-25029-3-git-send-email-aguedespe@gmail.com \
    --to=aguedespe@gmail.com \
    --cc=andre.guedes@openbossa.org \
    --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;
as well as URLs for NNTP newsgroup(s).