hw/usb: Use lock guard macros
Use qemu LOCK_GUARD macros from "qemu/lockable.h" in hw/usb/ccid-card-emulated.c, saves manual unlock calls. Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200923134327.576139-1-ameynarkhede03@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f00ff136ee
commit
5c43b603a2
@ -30,6 +30,7 @@
|
||||
#include <libcacard.h>
|
||||
|
||||
#include "qemu/thread.h"
|
||||
#include "qemu/lockable.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/module.h"
|
||||
#include "ccid.h"
|
||||
@ -244,7 +245,7 @@ static void *handle_apdu_thread(void* arg)
|
||||
card->quit_apdu_thread = 0; /* debugging */
|
||||
break;
|
||||
}
|
||||
qemu_mutex_lock(&card->vreader_mutex);
|
||||
WITH_QEMU_LOCK_GUARD(&card->vreader_mutex) {
|
||||
while (!QSIMPLEQ_EMPTY(&card->guest_apdu_list)) {
|
||||
event = QSIMPLEQ_FIRST(&card->guest_apdu_list);
|
||||
assert((unsigned long)event > 1000);
|
||||
@ -271,7 +272,7 @@ static void *handle_apdu_thread(void* arg)
|
||||
}
|
||||
g_free(event);
|
||||
}
|
||||
qemu_mutex_unlock(&card->vreader_mutex);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -365,7 +366,7 @@ static void card_event_handler(EventNotifier *notifier)
|
||||
EmulEvent *event, *next;
|
||||
|
||||
event_notifier_test_and_clear(&card->notifier);
|
||||
qemu_mutex_lock(&card->event_list_mutex);
|
||||
QEMU_LOCK_GUARD(&card->event_list_mutex);
|
||||
QSIMPLEQ_FOREACH_SAFE(event, &card->event_list, entry, next) {
|
||||
DPRINTF(card, 2, "event %s\n", emul_event_to_string(event->p.gen.type));
|
||||
switch (event->p.gen.type) {
|
||||
@ -398,7 +399,6 @@ static void card_event_handler(EventNotifier *notifier)
|
||||
g_free(event);
|
||||
}
|
||||
QSIMPLEQ_INIT(&card->event_list);
|
||||
qemu_mutex_unlock(&card->event_list_mutex);
|
||||
}
|
||||
|
||||
static int init_event_notifier(EmulatedState *card, Error **errp)
|
||||
|
Loading…
Reference in New Issue
Block a user