aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2011-11-11 09:18:52 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-11-16 13:05:50 -0500
commit8680570b0cae8f66ad28c8de227aab1894428ee5 (patch)
treebf8bbda1b5b32125b81a76e069f85ae745cc768c /net/bluetooth
parent1425acb74b6d58690d78027021ce1d8f3068c66f (diff)
Bluetooth: Return success instead of EALREADY for mgmt commands
When the adapter state is already what is requested it's more friendly to user-space to simply report success than to send a EALREADY error message. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/mgmt.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 3958cbdd258f..d0b1a49a66fb 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -290,6 +290,15 @@ static void mgmt_pending_remove(struct pending_cmd *cmd)
290 mgmt_pending_free(cmd); 290 mgmt_pending_free(cmd);
291} 291}
292 292
293static int send_mode_rsp(struct sock *sk, u16 opcode, u16 index, u8 val)
294{
295 struct mgmt_mode rp;
296
297 rp.val = val;
298
299 return cmd_complete(sk, index, opcode, &rp, sizeof(rp));
300}
301
293static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len) 302static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
294{ 303{
295 struct mgmt_mode *cp; 304 struct mgmt_mode *cp;
@@ -312,7 +321,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
312 321
313 up = test_bit(HCI_UP, &hdev->flags); 322 up = test_bit(HCI_UP, &hdev->flags);
314 if ((cp->val && up) || (!cp->val && !up)) { 323 if ((cp->val && up) || (!cp->val && !up)) {
315 err = cmd_status(sk, index, MGMT_OP_SET_POWERED, EALREADY); 324 err = send_mode_rsp(sk, index, MGMT_OP_SET_POWERED, cp->val);
316 goto failed; 325 goto failed;
317 } 326 }
318 327
@@ -375,7 +384,8 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
375 384
376 if (cp->val == test_bit(HCI_ISCAN, &hdev->flags) && 385 if (cp->val == test_bit(HCI_ISCAN, &hdev->flags) &&
377 test_bit(HCI_PSCAN, &hdev->flags)) { 386 test_bit(HCI_PSCAN, &hdev->flags)) {
378 err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, EALREADY); 387 err = send_mode_rsp(sk, index, MGMT_OP_SET_DISCOVERABLE,
388 cp->val);
379 goto failed; 389 goto failed;
380 } 390 }
381 391
@@ -440,7 +450,8 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
440 } 450 }
441 451
442 if (cp->val == test_bit(HCI_PSCAN, &hdev->flags)) { 452 if (cp->val == test_bit(HCI_PSCAN, &hdev->flags)) {
443 err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, EALREADY); 453 err = send_mode_rsp(sk, index, MGMT_OP_SET_CONNECTABLE,
454 cp->val);
444 goto failed; 455 goto failed;
445 } 456 }
446 457
@@ -495,15 +506,6 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data,
495 return 0; 506 return 0;
496} 507}
497 508
498static int send_mode_rsp(struct sock *sk, u16 opcode, u16 index, u8 val)
499{
500 struct mgmt_mode rp;
501
502 rp.val = val;
503
504 return cmd_complete(sk, index, opcode, &rp, sizeof(rp));
505}
506
507static int set_pairable(struct sock *sk, u16 index, unsigned char *data, 509static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
508 u16 len) 510 u16 len)
509{ 511{