Commit 7a6d793e authored by Andrey Skvortsov's avatar Andrey Skvortsov Committed by Luiz Augusto von Dentz

Bluetooth: hci_h5: Add ability to allocate memory for private data

In some cases uart-base drivers may need to use priv data. For
example, to store information needed for devcoredump.

Fixes: 044014ce ("Bluetooth: btrtl: Add Realtek devcoredump support")
Signed-off-by: default avatarAndrey Skvortsov <andrej.skvortzov@gmail.com>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 2615fd9a
...@@ -113,6 +113,7 @@ struct h5_vnd { ...@@ -113,6 +113,7 @@ struct h5_vnd {
int (*suspend)(struct h5 *h5); int (*suspend)(struct h5 *h5);
int (*resume)(struct h5 *h5); int (*resume)(struct h5 *h5);
const struct acpi_gpio_mapping *acpi_gpio_map; const struct acpi_gpio_mapping *acpi_gpio_map;
int sizeof_priv;
}; };
struct h5_device_data { struct h5_device_data {
...@@ -863,7 +864,8 @@ static int h5_serdev_probe(struct serdev_device *serdev) ...@@ -863,7 +864,8 @@ static int h5_serdev_probe(struct serdev_device *serdev)
if (IS_ERR(h5->device_wake_gpio)) if (IS_ERR(h5->device_wake_gpio))
return PTR_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) static void h5_serdev_remove(struct serdev_device *serdev)
......
...@@ -300,8 +300,9 @@ static const struct serdev_device_ops hci_serdev_client_ops = { ...@@ -300,8 +300,9 @@ static const struct serdev_device_ops hci_serdev_client_ops = {
.write_wakeup = hci_uart_write_wakeup, .write_wakeup = hci_uart_write_wakeup,
}; };
int hci_uart_register_device(struct hci_uart *hu, int hci_uart_register_device_priv(struct hci_uart *hu,
const struct hci_uart_proto *p) const struct hci_uart_proto *p,
int sizeof_priv)
{ {
int err; int err;
struct hci_dev *hdev; struct hci_dev *hdev;
...@@ -325,7 +326,7 @@ int hci_uart_register_device(struct hci_uart *hu, ...@@ -325,7 +326,7 @@ int hci_uart_register_device(struct hci_uart *hu,
set_bit(HCI_UART_PROTO_READY, &hu->flags); set_bit(HCI_UART_PROTO_READY, &hu->flags);
/* Initialize and register HCI device */ /* Initialize and register HCI device */
hdev = hci_alloc_dev(); hdev = hci_alloc_dev_priv(sizeof_priv);
if (!hdev) { if (!hdev) {
BT_ERR("Can't allocate HCI device"); BT_ERR("Can't allocate HCI device");
err = -ENOMEM; err = -ENOMEM;
...@@ -394,7 +395,7 @@ int hci_uart_register_device(struct hci_uart *hu, ...@@ -394,7 +395,7 @@ int hci_uart_register_device(struct hci_uart *hu,
percpu_free_rwsem(&hu->proto_lock); percpu_free_rwsem(&hu->proto_lock);
return err; 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) void hci_uart_unregister_device(struct hci_uart *hu)
{ {
......
...@@ -97,7 +97,17 @@ struct hci_uart { ...@@ -97,7 +97,17 @@ struct hci_uart {
int hci_uart_register_proto(const struct hci_uart_proto *p); 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_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); void hci_uart_unregister_device(struct hci_uart *hu);
int hci_uart_tx_wakeup(struct hci_uart *hu); int hci_uart_tx_wakeup(struct hci_uart *hu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment