usb-ccid: convert CCIDCardClass::exitfn() -> unrealize()
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20180125171432.13554-4-f4bug@amsat.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
c7516699fc
commit
80ae865468
@ -547,7 +547,7 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
|
||||
card, QEMU_THREAD_JOINABLE);
|
||||
}
|
||||
|
||||
static void emulated_exitfn(CCIDCardState *base)
|
||||
static void emulated_unrealize(CCIDCardState *base, Error **errp)
|
||||
{
|
||||
EmulatedState *card = EMULATED_CCID_CARD(base);
|
||||
VEvent *vevent = vevent_new(VEVENT_LAST, NULL, NULL);
|
||||
@ -582,7 +582,7 @@ static void emulated_class_initfn(ObjectClass *klass, void *data)
|
||||
CCIDCardClass *cc = CCID_CARD_CLASS(klass);
|
||||
|
||||
cc->realize = emulated_realize;
|
||||
cc->exitfn = emulated_exitfn;
|
||||
cc->unrealize = emulated_unrealize;
|
||||
cc->get_atr = emulated_get_atr;
|
||||
cc->apdu_from_guest = emulated_apdu_from_guest;
|
||||
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include <cacard/vscard_common.h>
|
||||
#include "chardev/char-fe.h"
|
||||
#include "qemu/error-report.h"
|
||||
|
@ -28,13 +28,15 @@ typedef struct CCIDCardInfo CCIDCardInfo;
|
||||
* into the smartcard device (hw/ccid-card-*.c)
|
||||
*/
|
||||
typedef struct CCIDCardClass {
|
||||
/*< private >*/
|
||||
DeviceClass parent_class;
|
||||
/*< public >*/
|
||||
const uint8_t *(*get_atr)(CCIDCardState *card, uint32_t *len);
|
||||
void (*apdu_from_guest)(CCIDCardState *card,
|
||||
const uint8_t *apdu,
|
||||
uint32_t len);
|
||||
void (*exitfn)(CCIDCardState *card);
|
||||
void (*realize)(CCIDCardState *card, Error **errp);
|
||||
void (*unrealize)(CCIDCardState *card, Error **errp);
|
||||
} CCIDCardClass;
|
||||
|
||||
/*
|
||||
|
@ -500,16 +500,6 @@ static void ccid_card_apdu_from_guest(CCIDCardState *card,
|
||||
}
|
||||
}
|
||||
|
||||
static void ccid_card_exitfn(CCIDCardState *card)
|
||||
{
|
||||
CCIDCardClass *cc = CCID_CARD_GET_CLASS(card);
|
||||
|
||||
if (cc->exitfn) {
|
||||
cc->exitfn(card);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool ccid_has_pending_answers(USBCCIDState *s)
|
||||
{
|
||||
return s->pending_answers_num > 0;
|
||||
@ -1271,18 +1261,25 @@ void ccid_card_card_inserted(CCIDCardState *card)
|
||||
ccid_on_slot_change(s, true);
|
||||
}
|
||||
|
||||
static int ccid_card_exit(DeviceState *qdev)
|
||||
static void ccid_card_unrealize(DeviceState *qdev, Error **errp)
|
||||
{
|
||||
CCIDCardState *card = CCID_CARD(qdev);
|
||||
CCIDCardClass *cc = CCID_CARD_GET_CLASS(card);
|
||||
USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
|
||||
USBCCIDState *s = USB_CCID_DEV(dev);
|
||||
Error *local_err = NULL;
|
||||
|
||||
if (ccid_card_inserted(s)) {
|
||||
ccid_card_card_removed(card);
|
||||
}
|
||||
ccid_card_exitfn(card);
|
||||
if (cc->unrealize) {
|
||||
cc->unrealize(card, &local_err);
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
s->card = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ccid_card_realize(DeviceState *qdev, Error **errp)
|
||||
@ -1472,7 +1469,7 @@ static void ccid_card_class_init(ObjectClass *klass, void *data)
|
||||
DeviceClass *k = DEVICE_CLASS(klass);
|
||||
k->bus_type = TYPE_CCID_BUS;
|
||||
k->realize = ccid_card_realize;
|
||||
k->exit = ccid_card_exit;
|
||||
k->unrealize = ccid_card_unrealize;
|
||||
k->props = ccid_props;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user