Skip to content

Commit 9985a09

Browse files
sjanckartben
authored andcommitted
bluetooth: hci: userchan: Implement close callback
This allows to use bt_disable() also in native_sim build. Signed-off-by: Szymon Janc <[email protected]>
1 parent dcc61ae commit 9985a09

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/bluetooth/hci/userchan.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,28 @@ static int uc_open(const struct device *dev, bt_hci_recv_t recv)
360360
return 0;
361361
}
362362

363+
static int uc_close(const struct device *dev)
364+
{
365+
struct uc_data *uc = dev->data;
366+
int rc;
367+
368+
if (uc->fd < 0) {
369+
return -ENETDOWN;
370+
}
371+
372+
rc = nsi_host_close(uc->fd);
373+
if (rc < 0) {
374+
return -nsi_errno_from_mid(-rc);
375+
}
376+
377+
uc->fd = -1;
378+
379+
return 0;
380+
}
381+
363382
static DEVICE_API(bt_hci, uc_drv_api) = {
364383
.open = uc_open,
384+
.close = uc_close,
365385
.send = uc_send,
366386
};
367387

0 commit comments

Comments
 (0)