]> git.karo-electronics.de Git - karo-tx-linux.git/commit
Bluetooth: Move device initialization to hci_alloc_dev()
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 22 Apr 2012 12:39:58 +0000 (14:39 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 22 Apr 2012 13:46:43 +0000 (15:46 +0200)
commit0351848a95c4b43e93a6b78d99da0cea38ba5414
treebffe1bba2cc66fb90c3ebc73e8aee96466d6e3d9
parent3947b5d57befde7408d6cda42c7101e7c6c56d73
Bluetooth: Move device initialization to hci_alloc_dev()

We currently initialize locks, lists, works, etc. in hci_register_dev()
(hci_alloc_dev() was added later) which is bogus because an hdev is in an
invalid state if it is not registered.
This patch moves all memory initialization to hci_alloc_dev(). Device
registering and registration of sub-modules is still left in
hci_register_dev() as it belongs there.

The benefit is (despite cleaning up the code-base) we can now always be
sure that an hdev is a valid object and can be locked and worked on even
though it may not be registered.

This patch also reorders the initialization to be easier to understand.
First the memory is initialized, then all generic structures and as last
step the sub-init functions are called. This guarantees that all
dependencies are initialized in the right order and makes it also easier
to find a specific line. We previously initialized it in the same order as
the "struct hci_dev" is declared which seems pretty random.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c