Before sending event,
virtio device needs to check if virtqueue is ready.
Otherwise when emulator reset,
device operation may have problem to send message.
Change-Id: Ia715e314d0c1f65098eb7f1c612dc79c039bcdbe
Signed-off-by: munkyu.im <munkyu.im@samsung.com>
bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len)
{
+ if (unlikely(!virtio_queue_ready(vio_nfc->rvq))) {
+ ERR("virtio queue is not ready\n");
+ return false;
+ }
+
MsgInfo* _msg = (MsgInfo*) malloc(sizeof(MsgInfo));
- if (!_msg)
+ if (!_msg) {
return false;
+ }
memset(&_msg->info, 0, sizeof(nfc_msg_info));
while (!QTAILQ_EMPTY(&nfc_recv_msg_queue))
{
MsgInfo* msginfo = QTAILQ_FIRST(&nfc_recv_msg_queue);
- if (!msginfo)
+ if (!msginfo) {
break;
+ }
VirtQueueElement elem;
index = virtqueue_pop(vio_nfc->rvq, &elem);