@@ -230,21 +230,18 @@ static void bt_iso_chan_add(struct bt_conn *iso, struct bt_iso_chan *chan)
230230 BT_DBG ("iso %p chan %p" , iso , chan );
231231}
232232
233- static int bt_iso_setup_data_path (struct bt_conn * iso )
233+ static int bt_iso_setup_data_path (struct bt_iso_chan * chan )
234234{
235235 int err ;
236- struct bt_iso_chan * chan ;
237236 struct bt_iso_chan_path default_hci_path = { .pid = BT_ISO_DATA_PATH_HCI };
238237 struct bt_iso_chan_path * out_path = NULL ;
239238 struct bt_iso_chan_path * in_path = NULL ;
240239 struct bt_iso_chan_io_qos * tx_qos ;
241240 struct bt_iso_chan_io_qos * rx_qos ;
241+ struct bt_conn * iso ;
242242 uint8_t dir ;
243243
244- chan = iso_chan (iso );
245- if (chan == NULL ) {
246- return - EINVAL ;
247- }
244+ iso = chan -> iso ;
248245
249246 tx_qos = chan -> qos -> tx ;
250247 rx_qos = chan -> qos -> rx ;
@@ -258,33 +255,49 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
258255 * in the controller.
259256 */
260257
261- if (tx_qos != NULL && chan -> iso -> iso .can_send ) {
258+ if (tx_qos != NULL && iso -> iso . info .can_send ) {
262259 if (tx_qos -> path != NULL ) { /* Use application path */
263260 in_path = tx_qos -> path ;
264261 } else { /* else fallback to HCI path */
265262 in_path = & default_hci_path ;
266263 }
267264 }
268265
269- if (rx_qos != NULL && chan -> iso -> iso .can_recv ) {
266+ if (rx_qos != NULL && iso -> iso . info .can_recv ) {
270267 if (rx_qos -> path != NULL ) { /* Use application path */
271268 out_path = rx_qos -> path ;
272269 } else { /* else fallback to HCI path */
273270 out_path = & default_hci_path ;
274271 }
275272 }
276273
274+ __ASSERT (in_path || out_path ,
275+ "At least one path shall be shell: in %p out %p" ,
276+ in_path , out_path );
277+
277278 if (IS_ENABLED (CONFIG_BT_ISO_BROADCASTER ) &&
278279 iso -> iso .info .type == BT_ISO_CHAN_TYPE_BROADCASTER && in_path ) {
279280 dir = BT_HCI_DATAPATH_DIR_HOST_TO_CTLR ;
280- return hci_le_setup_iso_data_path (iso , dir , in_path );
281+ err = hci_le_setup_iso_data_path (iso , dir , in_path );
282+ if (err != 0 ) {
283+ BT_DBG ("Failed to set broadcaster data path: %d" , err );
284+ }
285+
286+ return err ;
281287 } else if (IS_ENABLED (CONFIG_BT_ISO_SYNC_RECEIVER ) &&
282- iso -> iso .info .type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER && out_path ) {
288+ iso -> iso .info .type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER &&
289+ out_path ) {
283290 dir = BT_HCI_DATAPATH_DIR_CTLR_TO_HOST ;
284- return hci_le_setup_iso_data_path (iso , dir , out_path );
291+ err = hci_le_setup_iso_data_path (iso , dir , out_path );
292+ if (err != 0 ) {
293+ BT_DBG ("Failed to set sync receiver data path: %d" ,
294+ err );
295+ }
296+
297+ return err ;
285298 } else if (IS_ENABLED (CONFIG_BT_ISO_UNICAST ) &&
286299 iso -> iso .info .type == BT_ISO_CHAN_TYPE_CONNECTED ) {
287- if (in_path != NULL && tx_qos -> sdu > 0 ) {
300+ if (in_path != NULL ) {
288301 /* Enable TX */
289302 dir = BT_HCI_DATAPATH_DIR_HOST_TO_CTLR ;
290303 err = hci_le_setup_iso_data_path (iso , dir , in_path );
@@ -293,7 +306,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
293306 }
294307 }
295308
296- if (out_path != NULL && rx_qos -> sdu > 0 ) {
309+ if (out_path != NULL ) {
297310 /* Enable RX */
298311 dir = BT_HCI_DATAPATH_DIR_CTLR_TO_HOST ;
299312 err = hci_le_setup_iso_data_path (iso , dir , out_path );
@@ -313,6 +326,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
313326void bt_iso_connected (struct bt_conn * iso )
314327{
315328 struct bt_iso_chan * chan ;
329+ int err ;
316330
317331 if (iso == NULL || iso -> type != BT_CONN_TYPE_ISO ) {
318332 BT_DBG ("Invalid parameters: iso %p iso->type %u" , iso ,
@@ -322,8 +336,15 @@ void bt_iso_connected(struct bt_conn *iso)
322336
323337 BT_DBG ("%p" , iso );
324338
325- if (bt_iso_setup_data_path (iso )) {
326- BT_ERR ("Unable to setup data path" );
339+ chan = iso_chan (iso );
340+ if (chan == NULL ) {
341+ BT_ERR ("Could not lookup chan from connected ISO" );
342+ return ;
343+ }
344+
345+ err = bt_iso_setup_data_path (chan );
346+ if (err != 0 ) {
347+ BT_ERR ("Unable to setup data path: %d" , err );
327348#if defined(CONFIG_BT_ISO_BROADCAST )
328349 if (iso -> iso .info .type == BT_ISO_CHAN_TYPE_BROADCASTER ||
329350 iso -> iso .info .type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER ) {
@@ -349,12 +370,6 @@ void bt_iso_connected(struct bt_conn *iso)
349370 return ;
350371 }
351372
352- chan = iso_chan (iso );
353- if (chan == NULL ) {
354- BT_ERR ("Could not lookup chan from connected ISO" );
355- return ;
356- }
357-
358373 bt_iso_chan_set_state (chan , BT_ISO_STATE_CONNECTED );
359374
360375 if (chan -> ops -> connected ) {
@@ -696,7 +711,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
696711 }
697712
698713 iso_conn = chan -> iso ;
699- if (!iso_conn -> iso .can_send ) {
714+ if (!iso_conn -> iso .info . can_send ) {
700715 BT_DBG ("Channel not able to send" );
701716 return - EINVAL ;
702717 }
0 commit comments