Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 291002
b: refs/heads/master
c: 4b34ee7
h: refs/heads/master
v: v3
  • Loading branch information
Johan Hedberg committed Feb 21, 2012
1 parent 1dfbad5 commit b256245
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8ee5654034c85b3915d078147a9d1064cac1852e
refs/heads/master: 4b34ee782164fbaf29b2e7c0e8cb3a898c0986ca
26 changes: 14 additions & 12 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ static const u16 mgmt_events[] = {

#define SERVICE_CACHE_TIMEOUT (5 * 1000)

#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \
!test_bit(HCI_AUTO_OFF, &hdev->dev_flags))

struct pending_cmd {
struct list_head list;
u16 opcode;
Expand Down Expand Up @@ -733,7 +736,7 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len)
struct mgmt_mode *cp = data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
int err, up;
int err;

BT_DBG("request for hci%u", index);

Expand All @@ -758,8 +761,7 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len)
}
}

up = test_bit(HCI_UP, &hdev->flags);
if ((cp->val && up) || (!cp->val && !up)) {
if (!!cp->val == hdev_is_powered(hdev)) {
err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
goto failed;
}
Expand Down Expand Up @@ -810,7 +812,7 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -877,7 +879,7 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -1005,7 +1007,7 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -1064,7 +1066,7 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_SSP,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -1621,7 +1623,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -1690,7 +1692,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, void *data, u16 len)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down Expand Up @@ -1933,7 +1935,7 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, mgmt_op, MGMT_STATUS_NOT_POWERED);
goto done;
}
Expand Down Expand Up @@ -2109,7 +2111,7 @@ static int read_local_oob_data(struct sock *sk, u16 index)

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
MGMT_STATUS_NOT_POWERED);
goto unlock;
Expand Down Expand Up @@ -2280,7 +2282,7 @@ static int start_discovery(struct sock *sk, u16 index,

hci_dev_lock(hdev);

if (!test_bit(HCI_UP, &hdev->flags)) {
if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_NOT_POWERED);
goto failed;
Expand Down

0 comments on commit b256245

Please sign in to comment.