Bluetooth: Refactor deferred setup test in rfcomm_dlc_close()
authorPeter Hurley <peter@hurleysoftware.com>
Mon, 10 Feb 2014 01:59:12 +0000 (20:59 -0500)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 14 Feb 2014 21:39:30 +0000 (13:39 -0800)
Prepare for directly closing dlc if the RFCOMM session has not
yet been started; refactor the deferred setup test for only those
dlc states to which the test applies. Retains functional
equivalence.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Tested-By: Alexander Holler <holler@ahsoftware.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/rfcomm/core.c

index e8898624cbaf2d6339e9f8ae4a149ce6c93058db..3ce5ae493d1dcd77441a3cd7d123124ed02a6fff 100644 (file)
@@ -443,11 +443,18 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
        switch (d->state) {
        case BT_CONNECT:
        case BT_CONFIG:
+       case BT_OPEN:
+       case BT_CONNECT2:
                if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) {
                        set_bit(RFCOMM_AUTH_REJECT, &d->flags);
                        rfcomm_schedule();
-                       break;
+                       return 0;
                }
+       }
+
+       switch (d->state) {
+       case BT_CONNECT:
+       case BT_CONFIG:
                /* Fall through */
 
        case BT_CONNECTED:
@@ -461,15 +468,6 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
                }
                break;
 
-       case BT_OPEN:
-       case BT_CONNECT2:
-               if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) {
-                       set_bit(RFCOMM_AUTH_REJECT, &d->flags);
-                       rfcomm_schedule();
-                       break;
-               }
-               /* Fall through */
-
        default:
                rfcomm_dlc_clear_timer(d);