diff options
author | Tedd Ho-Jeong An <tedd.an@intel.com> | 2021-08-04 17:32:08 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2021-08-05 16:03:29 +0200 |
commit | 6ec566131de0e330fffd33753b325fb4d6b2d00e (patch) | |
tree | f72db21e1ce4294d1b484ab5f437b0faffc13f05 /net/bluetooth | |
parent | 713baf3dae8f45dc8ada4ed2f5fdcbf94a5c274d (diff) | |
download | linux-6ec566131de0e330fffd33753b325fb4d6b2d00e.tar.bz2 |
Bluetooth: Add support hdev to allocate private data
This patch adds support hdev to allocate extra size for private data.
The size of private data is specified in the hdev_alloc_size(priv_size)
and the allocated buffer can be accessed with hci_get_priv(hdev).
Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2b78e1336c53..cb2e9e513907 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3751,11 +3751,18 @@ done: } /* Alloc HCI device */ -struct hci_dev *hci_alloc_dev(void) +struct hci_dev *hci_alloc_dev_priv(int sizeof_priv) { struct hci_dev *hdev; + unsigned int alloc_size; - hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); + alloc_size = sizeof(*hdev); + if (sizeof_priv) { + /* Fixme: May need ALIGN-ment? */ + alloc_size += sizeof_priv; + } + + hdev = kzalloc(alloc_size, GFP_KERNEL); if (!hdev) return NULL; @@ -3869,7 +3876,7 @@ struct hci_dev *hci_alloc_dev(void) return hdev; } -EXPORT_SYMBOL(hci_alloc_dev); +EXPORT_SYMBOL(hci_alloc_dev_priv); /* Free HCI device */ void hci_free_dev(struct hci_dev *hdev) |