summaryrefslogtreecommitdiffstats
path: root/audio/pcm_bluetooth.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-09-05 14:27:18 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-09-05 14:27:18 +0000
commitc4e21c814832ea94f64821a2360a28074d03be1a (patch)
tree5e0292327179920ca4b7dbc39d4539168a1f3b56 /audio/pcm_bluetooth.c
parent5e4e6d23323b869b36fb02d815dd4b928f94eacb (diff)
Cleanup fd passing a little
Diffstat (limited to 'audio/pcm_bluetooth.c')
-rw-r--r--audio/pcm_bluetooth.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c
index 2c36bed9..da5927d0 100644
--- a/audio/pcm_bluetooth.c
+++ b/audio/pcm_bluetooth.c
@@ -907,22 +907,17 @@ static int bluetooth_a2dp_hw_constraint(snd_pcm_ioplug_t *io)
static int bluetooth_recvmsg_fd(struct bluetooth_data *data)
{
- char cmsg_b[CMSG_SPACE(sizeof(int))];
- struct ipc_packet pkt;
+ char cmsg_b[CMSG_SPACE(sizeof(int))], m;
int err, ret;
- struct iovec iov = {
- .iov_base = &pkt,
- .iov_len = sizeof(pkt)
- };
- struct msghdr msgh = {
- .msg_name = 0,
- .msg_namelen = 0,
- .msg_iov = &iov,
- .msg_iovlen = 1,
- .msg_control = &cmsg_b,
- .msg_controllen = CMSG_LEN(sizeof(int)),
- .msg_flags = 0
- };
+ struct iovec iov = { &m, sizeof(m) };
+ struct msghdr msgh;
+ struct cmsghdr *cmsg;
+
+ memset(&msgh, 0, sizeof(msgh));
+ msgh.msg_iov = &iov;
+ msgh.msg_iovlen = 1;
+ msgh.msg_control = &cmsg_b;
+ msgh.msg_controllen = CMSG_LEN(sizeof(int));
ret = recvmsg(data->sock, &msgh, 0);
if (ret < 0) {
@@ -931,20 +926,16 @@ static int bluetooth_recvmsg_fd(struct bluetooth_data *data)
return -err;
}
- if (pkt.type == PKT_TYPE_CFG_RSP) {
- struct cmsghdr *cmsg;
- /* Receive auxiliary data in msgh */
- for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&msgh,cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET
+ /* Receive auxiliary data in msgh */
+ for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET
&& cmsg->cmsg_type == SCM_RIGHTS) {
- data->stream_fd = (*(int *) CMSG_DATA(cmsg));
- DBG("stream_fd=%d", data->stream_fd);
- return 0;
- }
+ data->stream_fd = (*(int *) CMSG_DATA(cmsg));
+ DBG("stream_fd=%d", data->stream_fd);
+ return 0;
}
- } else
- SNDERR("Unexpected packet type %d received", pkt.type);
+ }
return -EINVAL;
}