Bluetooth: host: Make bt_conn_ref return NULL if the ref count is zero

Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-11-30 13:38:49 +01:00 committed by Carles Cufí
commit fae964c008
2 changed files with 19 additions and 4 deletions

View file

@ -197,9 +197,12 @@ struct bt_conn_le_data_len_param {
*
* Increment the reference count of a connection object.
*
* @note Will return NULL if the reference count is zero.
*
* @param conn Connection object.
*
* @return Connection object with incremented reference count.
* @return Connection object with incremented reference count, or NULL if the
* reference count is zero.
*/
struct bt_conn *bt_conn_ref(struct bt_conn *conn);