linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 6/8] Bluetooth: Move non-critical sections outside of the dev lock
Date: Wed,  9 Jan 2013 15:29:38 +0200	[thread overview]
Message-ID: <1357738180-4128-7-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1357738180-4128-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

This patch fixes sections of code that do not need hci_lock_dev to be
outside of the lock. Such sections include code that do not touch the
hdev at all as well as sections which just read a single byte from the
supported_features value (i.e. all lmp_*_capable() macros).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/mgmt.c |   46 ++++++++++++++++++----------------------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4f60540..69221ce 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1133,13 +1133,11 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 
 	BT_DBG("request for %s", hdev->name);
 
-	hci_dev_lock(hdev);
+	if (!lmp_ssp_capable(hdev))
+		return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
+				  MGMT_STATUS_NOT_SUPPORTED);
 
-	if (!lmp_ssp_capable(hdev)) {
-		err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
-				 MGMT_STATUS_NOT_SUPPORTED);
-		goto failed;
-	}
+	hci_dev_lock(hdev);
 
 	val = !!cp->val;
 
@@ -1217,13 +1215,11 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 
 	BT_DBG("request for %s", hdev->name);
 
-	hci_dev_lock(hdev);
+	if (!lmp_le_capable(hdev))
+		return cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
+				  MGMT_STATUS_NOT_SUPPORTED);
 
-	if (!lmp_le_capable(hdev)) {
-		err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
-				 MGMT_STATUS_NOT_SUPPORTED);
-		goto unlock;
-	}
+	hci_dev_lock(hdev);
 
 	val = !!cp->val;
 	enabled = lmp_host_le_capable(hdev);
@@ -1422,25 +1418,19 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data,
 
 	BT_DBG("request for %s", hdev->name);
 
-	hci_dev_lock(hdev);
+	if (!lmp_bredr_capable(hdev))
+		return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
+				  MGMT_STATUS_NOT_SUPPORTED);
 
-	if (!lmp_bredr_capable(hdev)) {
-		err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
-				 MGMT_STATUS_NOT_SUPPORTED);
-		goto unlock;
-	}
+	if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags))
+		return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
+				  MGMT_STATUS_BUSY);
 
-	if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) {
-		err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
-				 MGMT_STATUS_BUSY);
-		goto unlock;
-	}
+	if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0)
+		return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
+				  MGMT_STATUS_INVALID_PARAMS);
 
-	if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) {
-		err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
-				 MGMT_STATUS_INVALID_PARAMS);
-		goto unlock;
-	}
+	hci_dev_lock(hdev);
 
 	hdev->major_class = cp->major;
 	hdev->minor_class = cp->minor;
-- 
1.7.10.4


  parent reply	other threads:[~2013-01-09 13:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 13:29 [PATCH 0/8] Bluetooth: Various mgmt fixes Johan Hedberg
2013-01-09 13:29 ` [PATCH 1/8] Bluetooth: Fix missing command complete event for mgmt_confirm_name Johan Hedberg
2013-01-09 20:02   ` Marcel Holtmann
2013-01-09 13:29 ` [PATCH 2/8] Bluetooth: Fix missing command complete for mgmt_load_long_term_keys Johan Hedberg
2013-01-09 20:04   ` Marcel Holtmann
2013-01-09 13:29 ` [PATCH 3/8] Bluetooth: Fix checking for valid device class values Johan Hedberg
2013-01-09 20:07   ` Marcel Holtmann
2013-01-09 13:29 ` [PATCH 4/8] Bluetooth: Fix accepting set_dev_class for non-BR/EDR controllers Johan Hedberg
2013-01-09 20:08   ` Marcel Holtmann
2013-01-09 13:29 ` [PATCH 5/8] Bluetooth: Fix returning proper command status for start_discovery Johan Hedberg
2013-01-09 20:10   ` Marcel Holtmann
2013-01-10 12:54   ` [PATCH 5/8 v2] " Johan Hedberg
2013-01-10 16:24     ` Marcel Holtmann
2013-01-10 18:30     ` Gustavo Padovan
2013-01-09 13:29 ` Johan Hedberg [this message]
2013-01-09 20:12   ` [PATCH 6/8] Bluetooth: Move non-critical sections outside of the dev lock Marcel Holtmann
2013-01-09 13:29 ` [PATCH 7/8] Bluetooth: Fix checking for exact values of boolean mgmt parameters Johan Hedberg
2013-01-09 13:45   ` Anderson Lizardo
2013-01-09 13:48     ` Johan Hedberg
2013-01-09 13:53       ` Anderson Lizardo
2013-01-09 14:05   ` [PATCH 7/8 v2] " Johan Hedberg
2013-01-09 20:13     ` Marcel Holtmann
2013-01-10  8:24     ` Gustavo Padovan
2013-01-09 13:29 ` [PATCH 8/8] Bluetooth: Fix sending incorrect new_settings for mgmt_set_powered Johan Hedberg
2013-01-10  8:41   ` Marcel Holtmann
2013-01-10 18:31   ` Gustavo Padovan

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=1357738180-4128-7-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@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;
as well as URLs for NNTP newsgroup(s).