diff options
author | Antti Julku <antti.julku@nokia.com> | 2011-08-25 09:48:02 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-09-21 11:59:15 -0400 |
commit | 5e762444b0d3e56bbd66f5092434c4a1ba698313 (patch) | |
tree | ad54379252e2fa923a3001a1c194ef541a87a686 /net/bluetooth/hci_sock.c | |
parent | c908df362c20be0eeef506fe62e13d835a4633f9 (diff) |
Bluetooth: Add mgmt events for blacklisting
Add management interface events for blocking/unblocking a device.
Sender of the block device command gets cmd complete and other
mgmt sockets get the event. Event is also sent to mgmt sockets when
blocking is done with ioctl, e.g when blocking a device with
hciconfig. This makes it possible for bluetoothd to track status
of blocked devices when a third party block or unblocks a device.
Event sending is handled in mgmt_device_blocked function which gets
called from hci_blacklist_add in hci_core.c. A pending command is
added in mgmt_block_device, so that it can found when sending the
event - the event is not sent to the socket from which the pending
command came. Locks were moved out from hci_core.c to hci_sock.c
and mgmt.c, because locking is needed also for mgmt_pending_add in
mgmt.c.
Signed-off-by: Antti Julku <antti.julku@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_sock.c')
-rw-r--r-- | net/bluetooth/hci_sock.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index ff02cf5e77cc..f6afe3d76a66 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -183,21 +183,35 @@ static int hci_sock_release(struct socket *sock) | |||
183 | static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) | 183 | static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) |
184 | { | 184 | { |
185 | bdaddr_t bdaddr; | 185 | bdaddr_t bdaddr; |
186 | int err; | ||
186 | 187 | ||
187 | if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) | 188 | if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) |
188 | return -EFAULT; | 189 | return -EFAULT; |
189 | 190 | ||
190 | return hci_blacklist_add(hdev, &bdaddr); | 191 | hci_dev_lock_bh(hdev); |
192 | |||
193 | err = hci_blacklist_add(hdev, &bdaddr); | ||
194 | |||
195 | hci_dev_unlock_bh(hdev); | ||
196 | |||
197 | return err; | ||
191 | } | 198 | } |
192 | 199 | ||
193 | static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) | 200 | static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) |
194 | { | 201 | { |
195 | bdaddr_t bdaddr; | 202 | bdaddr_t bdaddr; |
203 | int err; | ||
196 | 204 | ||
197 | if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) | 205 | if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) |
198 | return -EFAULT; | 206 | return -EFAULT; |
199 | 207 | ||
200 | return hci_blacklist_del(hdev, &bdaddr); | 208 | hci_dev_lock_bh(hdev); |
209 | |||
210 | err = hci_blacklist_del(hdev, &bdaddr); | ||
211 | |||
212 | hci_dev_unlock_bh(hdev); | ||
213 | |||
214 | return err; | ||
201 | } | 215 | } |
202 | 216 | ||
203 | /* Ioctls that require bound socket */ | 217 | /* Ioctls that require bound socket */ |