Bluetooth: RFCOMM: Introduce helper to initialize dlc
This is to avoid code duplication while implementing outgoing connection. Change-Id: I52f882b7be9180f29def59c8ac3ef0a4798b719d Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This commit is contained in:
parent
e3c258e286
commit
5d40ea1d15
1 changed files with 19 additions and 11 deletions
|
@ -351,6 +351,24 @@ static void rfcomm_disconnected(struct bt_l2cap_chan *chan)
|
||||||
session->state = BT_RFCOMM_STATE_IDLE;
|
session->state = BT_RFCOMM_STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rfcomm_dlc_init(struct bt_rfcomm_dlc *dlc,
|
||||||
|
struct bt_rfcomm_session *session,
|
||||||
|
uint8_t dlci,
|
||||||
|
bt_rfcomm_role_t role)
|
||||||
|
{
|
||||||
|
BT_DBG("dlc %p", dlc);
|
||||||
|
|
||||||
|
dlc->dlci = dlci;
|
||||||
|
dlc->session = session;
|
||||||
|
dlc->rx_credit = RFCOMM_DEFAULT_CREDIT;
|
||||||
|
dlc->state = BT_RFCOMM_STATE_INIT;
|
||||||
|
dlc->role = role;
|
||||||
|
nano_sem_init(&dlc->tx_credits);
|
||||||
|
|
||||||
|
dlc->_next = session->dlcs;
|
||||||
|
session->dlcs = dlc;
|
||||||
|
}
|
||||||
|
|
||||||
static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session,
|
static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session,
|
||||||
uint8_t dlci)
|
uint8_t dlci)
|
||||||
{
|
{
|
||||||
|
@ -375,18 +393,8 @@ static struct bt_rfcomm_dlc *rfcomm_dlc_accept(struct bt_rfcomm_session *session
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_DBG("Dlc %p initialized", dlc);
|
rfcomm_dlc_init(dlc, session, dlci, BT_RFCOMM_ROLE_ACCEPTOR);
|
||||||
|
|
||||||
dlc->_next = session->dlcs;
|
|
||||||
session->dlcs = dlc;
|
|
||||||
|
|
||||||
dlc->dlci = dlci;
|
|
||||||
dlc->session = session;
|
|
||||||
dlc->role = BT_RFCOMM_ROLE_ACCEPTOR;
|
|
||||||
dlc->rx_credit = RFCOMM_DEFAULT_CREDIT;
|
|
||||||
dlc->state = BT_RFCOMM_STATE_INIT;
|
|
||||||
dlc->mtu = min(dlc->mtu, session->mtu);
|
dlc->mtu = min(dlc->mtu, session->mtu);
|
||||||
nano_sem_init(&dlc->tx_credits);
|
|
||||||
|
|
||||||
return dlc;
|
return dlc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue