diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2018-01-25 14:14:32 -0300 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-01-26 07:59:33 +0100 |
commit | 80ae865468bde918363a123aa26c6fc4385023ac (patch) | |
tree | 2b00678ecb67754b6c06e1c08da36bf790688826 /hw/usb | |
parent | c7516699fc416ed836639dff12115f9d806bfc82 (diff) | |
download | qemu-80ae865468bde918363a123aa26c6fc4385023ac.zip |
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>
Diffstat (limited to 'hw/usb')
-rw-r--r-- | hw/usb/ccid-card-emulated.c | 4 | ||||
-rw-r--r-- | hw/usb/ccid-card-passthru.c | 1 | ||||
-rw-r--r-- | hw/usb/ccid.h | 4 | ||||
-rw-r--r-- | hw/usb/dev-smartcard-reader.c | 25 |
4 files changed, 17 insertions, 17 deletions
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index daefd9f8f4..ea42e4681d 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -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); diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index b7dd3602dc..085ed2c667 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -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" diff --git a/hw/usb/ccid.h b/hw/usb/ccid.h index 6c6c10188d..3920733f13 100644 --- a/hw/usb/ccid.h +++ b/hw/usb/ccid.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; /* diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 85f5f2247b..e6468057a0 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -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; } |