diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-08-22 17:19:26 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-08-22 17:19:26 -0400 |
commit | 9eba32b86d17ef87131fa0bce43c614904ab5781 (patch) | |
tree | cd7e40a026475b7e4ddb8bdc944e75bc5a18c250 /include/net/bluetooth | |
parent | 364f63519d94442ed373ac7da79033c8282df46a (diff) |
Bluetooth: Add extra device reference counting for connections
The device model itself has no real usable reference counting at the
moment and this causes problems if parents are deleted before their
children. The device model itself handles the memory details of this
correctly, but the uevent order is not consistent. This causes various
problems for systems like HAL or even X.
So until device_put() does a proper cleanup, the device for Bluetooth
connection will be protected with an extra reference counting to ensure
the correct order of uevents when connections are terminated.
This is not an automatic feature. Higher Bluetooth layers like HIDP or
BNEP should grab this new reference to ensure that their uevents are
send before the ones from the parent device.
Based on a report by Brian Rogers <brian@xyzw.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net/bluetooth')
-rw-r--r-- | include/net/bluetooth/hci_core.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c4ca4228b083..25b8a0345a6a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -187,6 +187,7 @@ struct hci_conn { | |||
187 | struct work_struct work_del; | 187 | struct work_struct work_del; |
188 | 188 | ||
189 | struct device dev; | 189 | struct device dev; |
190 | atomic_t devref; | ||
190 | 191 | ||
191 | struct hci_dev *hdev; | 192 | struct hci_dev *hdev; |
192 | void *l2cap_data; | 193 | void *l2cap_data; |
@@ -339,6 +340,9 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | |||
339 | void hci_conn_enter_active_mode(struct hci_conn *conn); | 340 | void hci_conn_enter_active_mode(struct hci_conn *conn); |
340 | void hci_conn_enter_sniff_mode(struct hci_conn *conn); | 341 | void hci_conn_enter_sniff_mode(struct hci_conn *conn); |
341 | 342 | ||
343 | void hci_conn_hold_device(struct hci_conn *conn); | ||
344 | void hci_conn_put_device(struct hci_conn *conn); | ||
345 | |||
342 | static inline void hci_conn_hold(struct hci_conn *conn) | 346 | static inline void hci_conn_hold(struct hci_conn *conn) |
343 | { | 347 | { |
344 | atomic_inc(&conn->refcnt); | 348 | atomic_inc(&conn->refcnt); |