]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: hci_h5: Add ability to allocate memory for private data
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 23 Feb 2024 21:37:03 +0000 (00:37 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 6 Mar 2024 22:26:21 +0000 (17:26 -0500)
In some cases uart-base drivers may need to use priv data. For
example, to store information needed for devcoredump.

Fixes: 044014ce85a1 ("Bluetooth: btrtl: Add Realtek devcoredump support")
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/hci_h5.c
drivers/bluetooth/hci_serdev.c
drivers/bluetooth/hci_uart.h

index 71e748a9477e449ed358b5c6b54561bdd19aadb7..b66136348bd6455da603f8715b10c82da0465d59 100644 (file)
@@ -113,6 +113,7 @@ struct h5_vnd {
        int (*suspend)(struct h5 *h5);
        int (*resume)(struct h5 *h5);
        const struct acpi_gpio_mapping *acpi_gpio_map;
+       int sizeof_priv;
 };
 
 struct h5_device_data {
@@ -863,7 +864,8 @@ static int h5_serdev_probe(struct serdev_device *serdev)
        if (IS_ERR(h5->device_wake_gpio))
                return PTR_ERR(h5->device_wake_gpio);
 
-       return hci_uart_register_device(&h5->serdev_hu, &h5p);
+       return hci_uart_register_device_priv(&h5->serdev_hu, &h5p,
+                                            h5->vnd->sizeof_priv);
 }
 
 static void h5_serdev_remove(struct serdev_device *serdev)
index 39c8b567da3c0e82d7ec3707db6fb909ea05f8ff..214fff876eae50e8ef88b7a4df44a3c76fdff240 100644 (file)
@@ -300,8 +300,9 @@ static const struct serdev_device_ops hci_serdev_client_ops = {
        .write_wakeup = hci_uart_write_wakeup,
 };
 
-int hci_uart_register_device(struct hci_uart *hu,
-                            const struct hci_uart_proto *p)
+int hci_uart_register_device_priv(struct hci_uart *hu,
+                            const struct hci_uart_proto *p,
+                            int sizeof_priv)
 {
        int err;
        struct hci_dev *hdev;
@@ -325,7 +326,7 @@ int hci_uart_register_device(struct hci_uart *hu,
        set_bit(HCI_UART_PROTO_READY, &hu->flags);
 
        /* Initialize and register HCI device */
-       hdev = hci_alloc_dev();
+       hdev = hci_alloc_dev_priv(sizeof_priv);
        if (!hdev) {
                BT_ERR("Can't allocate HCI device");
                err = -ENOMEM;
@@ -394,7 +395,7 @@ err_rwsem:
        percpu_free_rwsem(&hu->proto_lock);
        return err;
 }
-EXPORT_SYMBOL_GPL(hci_uart_register_device);
+EXPORT_SYMBOL_GPL(hci_uart_register_device_priv);
 
 void hci_uart_unregister_device(struct hci_uart *hu)
 {
index fb4a2d0d8cc802d918948bd4392926e4c372bd6a..68c8c7e95d64dc6007f276b29cf2992815726baa 100644 (file)
@@ -97,7 +97,17 @@ struct hci_uart {
 
 int hci_uart_register_proto(const struct hci_uart_proto *p);
 int hci_uart_unregister_proto(const struct hci_uart_proto *p);
-int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
+
+int hci_uart_register_device_priv(struct hci_uart *hu,
+                                 const struct hci_uart_proto *p,
+                                 int sizeof_priv);
+
+static inline int hci_uart_register_device(struct hci_uart *hu,
+                                          const struct hci_uart_proto *p)
+{
+       return hci_uart_register_device_priv(hu, p, 0);
+}
+
 void hci_uart_unregister_device(struct hci_uart *hu);
 
 int hci_uart_tx_wakeup(struct hci_uart *hu);