Skip to content

Commit 1432d05

Browse files
MariuszSkamracarlescufi
authored andcommitted
Bluetooth: audio: pacs: Remove redundant code
Avoid unnecessary memcmp of UUID's. Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 9ecbee2 commit 1432d05

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

subsys/bluetooth/audio/pacs.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,6 @@ static void get_pac_records(struct bt_conn *conn, enum bt_audio_dir dir,
109109
}
110110
}
111111

112-
static ssize_t pac_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
113-
void *buf, uint16_t len, uint16_t offset)
114-
{
115-
enum bt_audio_dir dir;
116-
117-
if (!bt_uuid_cmp(attr->uuid, BT_UUID_PACS_SNK)) {
118-
dir = BT_AUDIO_DIR_SINK;
119-
} else {
120-
dir = BT_AUDIO_DIR_SOURCE;
121-
}
122-
123-
get_pac_records(conn, dir, &read_buf);
124-
125-
return bt_gatt_attr_read(conn, attr, buf, len, offset, read_buf.data,
126-
read_buf.len);
127-
}
128-
129112
static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
130113
{
131114
BT_DBG("attr %p value 0x%04x", attr, value);
@@ -257,7 +240,10 @@ static ssize_t snk_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
257240
BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len,
258241
offset);
259242

260-
return pac_read(conn, attr, buf, len, offset);
243+
get_pac_records(conn, BT_AUDIO_DIR_SINK, &read_buf);
244+
245+
return bt_gatt_attr_read(conn, attr, buf, len, offset, read_buf.data,
246+
read_buf.len);
261247
}
262248

263249
static void snk_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
@@ -353,7 +339,10 @@ static ssize_t src_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
353339
BT_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len,
354340
offset);
355341

356-
return pac_read(conn, attr, buf, len, offset);
342+
get_pac_records(conn, BT_AUDIO_DIR_SOURCE, &read_buf);
343+
344+
return bt_gatt_attr_read(conn, attr, buf, len, offset, read_buf.data,
345+
read_buf.len);
357346
}
358347

359348
static void src_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)

0 commit comments

Comments
 (0)