static char nfc_data [NFC_MAX_BUF_SIZE] = {'0',};
-static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER;
+static QemuMutex recv_buf_mutex;
static void send_nfc_data_to_ecs(const char* data)
{
_msg->info.client_id = id;
_msg->info.client_type = type;
- pthread_mutex_lock(&recv_buf_mutex);
+ qemu_mutex_lock(&recv_buf_mutex);
strcpy(nfc_data, data);
QTAILQ_INSERT_TAIL(&nfc_recv_msg_queue, _msg, next);
- pthread_mutex_unlock(&recv_buf_mutex);
+ qemu_mutex_unlock(&recv_buf_mutex);
qemu_bh_schedule(vio_nfc->bh);
}
- pthread_mutex_lock(&recv_buf_mutex);
+ qemu_mutex_lock(&recv_buf_mutex);
while (!QTAILQ_EMPTY(&nfc_recv_msg_queue))
{
free(msginfo);
}
- pthread_mutex_unlock(&recv_buf_mutex);
+ qemu_mutex_unlock(&recv_buf_mutex);
}
vio_nfc->svq = virtio_add_queue(&vio_nfc->vdev, 256, virtio_nfc_send);
vio_nfc->bh = qemu_bh_new(maru_nfc_bh, vio_nfc);
+
+ qemu_mutex_init(&recv_buf_mutex);
}
static void virtio_nfc_unrealize(DeviceState* dev, Error **errp)
INFO("destroy nfc device\n");
+ qemu_mutex_destroy(&recv_buf_mutex);
+
if (vio_nfc->bh) {
qemu_bh_delete(vio_nfc->bh);
}