Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277736
b: refs/heads/master
c: b24752f
h: refs/heads/master
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo F. Padovan committed Nov 7, 2011
1 parent 3a81316 commit 29d3e57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 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: 08add513caa8930b8f7b9d5837a7dda624741745
refs/heads/master: b24752fe655e9427240a5fe840914b94e5f9c2bc
19 changes: 18 additions & 1 deletion trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static void mgmt_pending_foreach(u16 opcode, int index,

cmd = list_entry(p, struct pending_cmd, list);

if (cmd->opcode != opcode)
if (opcode > 0 && cmd->opcode != opcode)
continue;

if (index >= 0 && cmd->index != index)
Expand Down Expand Up @@ -1949,13 +1949,25 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
return err;
}

static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
{
u8 *status = data;

cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
mgmt_pending_remove(cmd);
}

int mgmt_index_added(u16 index)
{
return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL);
}

int mgmt_index_removed(u16 index)
{
u8 status = ENODEV;

mgmt_pending_foreach(0, index, cmd_status_rsp, &status);

return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL);
}

Expand Down Expand Up @@ -1992,6 +2004,11 @@ int mgmt_powered(u16 index, u8 powered)

mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match);

if (!powered) {
u8 status = ENETDOWN;
mgmt_pending_foreach(0, index, cmd_status_rsp, &status);
}

ev.val = powered;

ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk);
Expand Down

0 comments on commit 29d3e57

Please sign in to comment.