Bluetooth: Uses test_and_clear_bit() when possible
authorGustavo F. Padovan <padovan@profusion.mobi>
Fri, 7 Oct 2011 01:05:37 +0000 (22:05 -0300)
committerGustavo F. Padovan <padovan@profusion.mobi>
Fri, 7 Oct 2011 02:15:06 +0000 (23:15 -0300)
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/hidp/core.c

index 7722d8346684f2426163f5a95c49dcfd2e47a5ce..f2bec4981b76939f17da2042f02acd4b6c629dfb 100644 (file)
@@ -496,10 +496,9 @@ static void hidp_process_handshake(struct hidp_session *session,
        case HIDP_HSHK_ERR_INVALID_REPORT_ID:
        case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST:
        case HIDP_HSHK_ERR_INVALID_PARAMETER:
-               if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) {
-                       clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
+               if (test_and_clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags))
                        wake_up_interruptible(&session->report_queue);
-               }
+
                /* FIXME: Call into SET_ GET_ handlers here */
                break;
 
@@ -520,10 +519,8 @@ static void hidp_process_handshake(struct hidp_session *session,
        }
 
        /* Wake up the waiting thread. */
-       if (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) {
-               clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags);
+       if (test_and_clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags))
                wake_up_interruptible(&session->report_queue);
-       }
 }
 
 static void hidp_process_hid_control(struct hidp_session *session,