Skip to content

Commit

Permalink
Bluetooth: hci_sync: Introduce PTR_UINT/UINT_PTR macros
Browse files Browse the repository at this point in the history
This introduces PTR_UINT/UINT_PTR macros and replace the use of
PTR_ERR/ERR_PTR.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Luiz Augusto von Dentz committed Aug 11, 2023
1 parent a091289 commit a1f6c3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions include/net/bluetooth/hci_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Copyright (C) 2021 Intel Corporation
*/

#define UINT_PTR(_handle) ((void *)((uintptr_t)_handle))
#define PTR_UINT(_ptr) ((uintptr_t)((void *)_ptr))

typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data);
typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data,
int err);
Expand Down
19 changes: 10 additions & 9 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ static void bis_cleanup(struct hci_conn *conn)

static int remove_cig_sync(struct hci_dev *hdev, void *data)
{
u8 handle = PTR_ERR(data);
u8 handle = PTR_UINT(data);

return hci_le_remove_cig_sync(hdev, handle);
}
Expand All @@ -881,7 +881,8 @@ static int hci_le_remove_cig(struct hci_dev *hdev, u8 handle)
{
bt_dev_dbg(hdev, "handle 0x%2.2x", handle);

return hci_cmd_sync_queue(hdev, remove_cig_sync, ERR_PTR(handle), NULL);
return hci_cmd_sync_queue(hdev, remove_cig_sync, UINT_PTR(handle),
NULL);
}

static void find_cis(struct hci_conn *conn, void *data)
Expand Down Expand Up @@ -1260,7 +1261,7 @@ u8 hci_conn_set_handle(struct hci_conn *conn, u16 handle)
static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
{
struct hci_conn *conn;
u16 handle = PTR_ERR(data);
u16 handle = PTR_UINT(data);

conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn)
Expand Down Expand Up @@ -1290,7 +1291,7 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
static int hci_connect_le_sync(struct hci_dev *hdev, void *data)
{
struct hci_conn *conn;
u16 handle = PTR_ERR(data);
u16 handle = PTR_UINT(data);

conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn)
Expand Down Expand Up @@ -1372,7 +1373,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
clear_bit(HCI_CONN_SCANNING, &conn->flags);

err = hci_cmd_sync_queue(hdev, hci_connect_le_sync,
ERR_PTR(conn->handle),
UINT_PTR(conn->handle),
create_le_conn_complete);
if (err) {
hci_conn_del(conn);
Expand Down Expand Up @@ -1736,7 +1737,7 @@ static int hci_le_create_big(struct hci_conn *conn, struct bt_iso_qos *qos)

static int set_cig_params_sync(struct hci_dev *hdev, void *data)
{
u8 cig_id = PTR_ERR(data);
u8 cig_id = PTR_UINT(data);
struct hci_conn *conn;
struct bt_iso_qos *qos;
struct iso_cig_params pdu;
Expand Down Expand Up @@ -1846,7 +1847,7 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)

done:
if (hci_cmd_sync_queue(hdev, set_cig_params_sync,
ERR_PTR(qos->ucast.cig), NULL) < 0)
UINT_PTR(qos->ucast.cig), NULL) < 0)
return false;

return true;
Expand Down Expand Up @@ -2858,7 +2859,7 @@ u32 hci_conn_get_phy(struct hci_conn *conn)
static int abort_conn_sync(struct hci_dev *hdev, void *data)
{
struct hci_conn *conn;
u16 handle = PTR_ERR(data);
u16 handle = PTR_UINT(data);

conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn)
Expand Down Expand Up @@ -2898,6 +2899,6 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
}
}

return hci_cmd_sync_queue(hdev, abort_conn_sync, ERR_PTR(conn->handle),
return hci_cmd_sync_queue(hdev, abort_conn_sync, UINT_PTR(conn->handle),
NULL);
}
4 changes: 2 additions & 2 deletions net/bluetooth/hci_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -6528,13 +6528,13 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,

static int _update_adv_data_sync(struct hci_dev *hdev, void *data)
{
u8 instance = PTR_ERR(data);
u8 instance = PTR_UINT(data);

return hci_update_adv_data_sync(hdev, instance);
}

int hci_update_adv_data(struct hci_dev *hdev, u8 instance)
{
return hci_cmd_sync_queue(hdev, _update_adv_data_sync,
ERR_PTR(instance), NULL);
UINT_PTR(instance), NULL);
}

0 comments on commit a1f6c3a

Please sign in to comment.