From: munkyu.im Date: Wed, 4 Dec 2013 08:25:03 +0000 (+0900) Subject: nfc: check if virtqueue is ready X-Git-Tag: TizenStudio_2.0_p2.3~433^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eaa77f77549b940d92162441a9815069329fa90b;p=sdk%2Femulator%2Fqemu.git 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 --- diff --git a/tizen/src/hw/maru_virtio_nfc.c b/tizen/src/hw/maru_virtio_nfc.c index 332dd4d..3dc2120 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);