Commit 48db9ca4 authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Use in-kernel sockets API

The kernel provides a new convenient way to access the sockets API for
in-kernel users. It is a good idea to actually use it.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 53c1d4b0
...@@ -622,7 +622,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst ...@@ -622,7 +622,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst
bacpy(&addr.l2_bdaddr, src); bacpy(&addr.l2_bdaddr, src);
addr.l2_family = AF_BLUETOOTH; addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = 0; addr.l2_psm = 0;
*err = sock->ops->bind(sock, (struct sockaddr *) &addr, sizeof(addr)); *err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
if (*err < 0) if (*err < 0)
goto failed; goto failed;
...@@ -643,7 +643,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst ...@@ -643,7 +643,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst
bacpy(&addr.l2_bdaddr, dst); bacpy(&addr.l2_bdaddr, dst);
addr.l2_family = AF_BLUETOOTH; addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = htobs(RFCOMM_PSM); addr.l2_psm = htobs(RFCOMM_PSM);
*err = sock->ops->connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK); *err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
if (*err == 0 || *err == -EINPROGRESS) if (*err == 0 || *err == -EINPROGRESS)
return s; return s;
...@@ -1757,19 +1757,12 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s) ...@@ -1757,19 +1757,12 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s)
BT_DBG("session %p", s); BT_DBG("session %p", s);
if (sock_create_lite(PF_BLUETOOTH, sock->type, BTPROTO_L2CAP, &nsock)) err = kernel_accept(sock, &nsock, O_NONBLOCK);
if (err < 0)
return; return;
nsock->ops = sock->ops;
__module_get(nsock->ops->owner); __module_get(nsock->ops->owner);
err = sock->ops->accept(sock, nsock, O_NONBLOCK);
if (err < 0) {
sock_release(nsock);
return;
}
/* Set our callbacks */ /* Set our callbacks */
nsock->sk->sk_data_ready = rfcomm_l2data_ready; nsock->sk->sk_data_ready = rfcomm_l2data_ready;
nsock->sk->sk_state_change = rfcomm_l2state_change; nsock->sk->sk_state_change = rfcomm_l2state_change;
...@@ -1885,7 +1878,7 @@ static int rfcomm_add_listener(bdaddr_t *ba) ...@@ -1885,7 +1878,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
bacpy(&addr.l2_bdaddr, ba); bacpy(&addr.l2_bdaddr, ba);
addr.l2_family = AF_BLUETOOTH; addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = htobs(RFCOMM_PSM); addr.l2_psm = htobs(RFCOMM_PSM);
err = sock->ops->bind(sock, (struct sockaddr *) &addr, sizeof(addr)); err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
if (err < 0) { if (err < 0) {
BT_ERR("Bind failed %d", err); BT_ERR("Bind failed %d", err);
goto failed; goto failed;
...@@ -1898,7 +1891,7 @@ static int rfcomm_add_listener(bdaddr_t *ba) ...@@ -1898,7 +1891,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
release_sock(sk); release_sock(sk);
/* Start listening on the socket */ /* Start listening on the socket */
err = sock->ops->listen(sock, 10); err = kernel_listen(sock, 10);
if (err) { if (err) {
BT_ERR("Listen failed %d", err); BT_ERR("Listen failed %d", err);
goto failed; goto failed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment