From eaa77f77549b940d92162441a9815069329fa90b Mon Sep 17 00:00:00 2001 From: "munkyu.im" Date: Wed, 4 Dec 2013 17:25:03 +0900 Subject: [PATCH] nfc: check if virtqueue is ready 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 --- tizen/src/hw/maru_virtio_nfc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tizen/src/hw/maru_virtio_nfc.c b/tizen/src/hw/maru_virtio_nfc.c index 332dd4d716..3dc2120a6d 100644 --- a/tizen/src/hw/maru_virtio_nfc.c +++ b/tizen/src/hw/maru_virtio_nfc.c @@ -77,9 +77,15 @@ static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER; 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)); @@ -119,8 +125,9 @@ static void flush_nfc_recv_queue(void) 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); -- 2.34.1