qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Cao jin <caoj.fnst@cn.fujitsu.com>,
	Michael Tokarev <mjt@tls.msk.ru>
Subject: [Qemu-devel] [PULL 11/14] Passthru CCID card: QOMify
Date: Thu, 11 Feb 2016 15:19:00 +0300	[thread overview]
Message-ID: <059db2041954766d2f9fd83f51a732a372076937.1455192968.git.mjt@msgid.tls.msk.ru> (raw)
In-Reply-To: <cover.1455192968.git.mjt@msgid.tls.msk.ru>

From: Cao jin <caoj.fnst@cn.fujitsu.com>

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/usb/ccid-card-passthru.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 2e4d95f..c0e90e5 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -39,8 +39,6 @@ static const uint8_t DEFAULT_ATR[] = {
  0x13, 0x08
 };
 
-
-#define PASSTHRU_DEV_NAME "ccid-card-passthru"
 #define VSCARD_IN_SIZE 65536
 
 /* maximum size of ATR - from 7816-3 */
@@ -59,6 +57,10 @@ struct PassthruState {
     uint8_t  debug;
 };
 
+#define TYPE_CCID_PASSTHRU "ccid-card-passthru"
+#define PASSTHRU_CCID_CARD(obj) \
+    OBJECT_CHECK(PassthruState, (obj), TYPE_CCID_PASSTHRU)
+
 /*
  * VSCard protocol over chardev
  * This code should not depend on the card type.
@@ -317,7 +319,7 @@ static void ccid_card_vscard_event(void *opaque, int event)
 static void passthru_apdu_from_guest(
     CCIDCardState *base, const uint8_t *apdu, uint32_t len)
 {
-    PassthruState *card = DO_UPCAST(PassthruState, base, base);
+    PassthruState *card = PASSTHRU_CCID_CARD(base);
 
     if (!card->cs) {
         printf("ccid-passthru: no chardev, discarding apdu length %d\n", len);
@@ -328,7 +330,7 @@ static void passthru_apdu_from_guest(
 
 static const uint8_t *passthru_get_atr(CCIDCardState *base, uint32_t *len)
 {
-    PassthruState *card = DO_UPCAST(PassthruState, base, base);
+    PassthruState *card = PASSTHRU_CCID_CARD(base);
 
     *len = card->atr_length;
     return card->atr;
@@ -336,7 +338,7 @@ static const uint8_t *passthru_get_atr(CCIDCardState *base, uint32_t *len)
 
 static int passthru_initfn(CCIDCardState *base)
 {
-    PassthruState *card = DO_UPCAST(PassthruState, base, base);
+    PassthruState *card = PASSTHRU_CCID_CARD(base);
 
     card->vscard_in_pos = 0;
     card->vscard_in_hdr = 0;
@@ -400,7 +402,7 @@ static void passthru_class_initfn(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo passthru_card_info = {
-    .name          = PASSTHRU_DEV_NAME,
+    .name          = TYPE_CCID_PASSTHRU,
     .parent        = TYPE_CCID_CARD,
     .instance_size = sizeof(PassthruState),
     .class_init    = passthru_class_initfn,
-- 
2.1.4

  parent reply	other threads:[~2016-02-11 12:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11 12:18 [Qemu-devel] [PULL 00/14] Trivial patches for 2016-02-11 Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 01/14] remove libtool support Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 02/14] man: virtfs-proxy-helper: Rework awkward sentence Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 03/14] qom: Correct object_property_get_int() description Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 04/14] cpu: cpu_save/cpu_load is no more Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 05/14] qemu-sockets: simplify error handling Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 06/14] rdma: remove check on time_spent when calculating mbs Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 07/14] qmp-spec: fix index in doc Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 08/14] char: fix parameter name / type in BSD codepath Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 09/14] ES1370: QOMify Michael Tokarev
2016-02-11 12:18 ` [Qemu-devel] [PULL 10/14] Emulated CCID card: QOMify Michael Tokarev
2016-02-11 12:19 ` Michael Tokarev [this message]
2016-02-11 12:19 ` [Qemu-devel] [PULL 12/14] s390x: remove s390-zipl.rom Michael Tokarev
2016-02-11 12:19 ` [Qemu-devel] [PULL 13/14] Adds keycode 86 to the hid_usage_keys translation table Michael Tokarev
2016-02-11 12:19 ` [Qemu-devel] [PULL 14/14] w32: include winsock2.h before windows.h Michael Tokarev
2016-02-11 17:08 ` [Qemu-devel] [PULL 00/14] Trivial patches for 2016-02-11 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=059db2041954766d2f9fd83f51a732a372076937.1455192968.git.mjt@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).