Skip to content

Commit

Permalink
usb-ccid: convert CCIDCardClass::exitfn() -> unrealize()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
philmd authored and kraxel committed Jan 26, 2018
1 parent c751669 commit 80ae865
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions hw/usb/ccid-card-emulated.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions hw/usb/ccid-card-passthru.c
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion hw/usb/ccid.h
Expand Up @@ -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;

/*
Expand Down
25 changes: 11 additions & 14 deletions hw/usb/dev-smartcard-reader.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 80ae865

Please sign in to comment.