Hi On Sat, Sep 9, 2017 at 10:33 AM Mao Zhongyi <maozy.f...@cn.fujitsu.com> wrote:
> Convert CCID Device to realize and rename the ccid_card_init() > to ccid_card_realize(). > > Cc: Gerd Hoffmann <kra...@redhat.com> > Signed-off-by: Mao Zhongyi <maozy.f...@cn.fujitsu.com> > --- > hw/usb/dev-smartcard-reader.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c > index bef1f03..27cd48d 100644 > --- a/hw/usb/dev-smartcard-reader.c > +++ b/hw/usb/dev-smartcard-reader.c > @@ -1306,27 +1306,25 @@ static int ccid_card_exit(DeviceState *qdev) > return 0; > } > > -static int ccid_card_init(DeviceState *qdev) > +static void ccid_card_realize(DeviceState *qdev, Error **errp) > { > CCIDCardState *card = CCID_CARD(qdev); > USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent); > USBCCIDState *s = USB_CCID_DEV(dev); > - int ret = 0; > > if (card->slot != 0) { > - warn_report("usb-ccid supports one slot, can't add %d", > + error_setg(errp, "usb-ccid supports one slot, can't add %d", > card->slot); > - return -1; > + return; > } > if (s->card != NULL) { > - warn_report("usb-ccid card already full, not adding"); > - return -1; > + error_setg(errp, "usb-ccid card already full, not adding"); > + return; > } > - ret = ccid_card_initfn(card); > - if (ret == 0) { > + > + if (!ccid_card_initfn(card)) { > s->card = card; > } > You should set an error here, or the caller won't be aware of card init error anymore. Best would be to convert ccid_card_initfn() and callbacks to take an Error **. - return ret; > } > > static void ccid_realize(USBDevice *dev, Error **errp) > @@ -1496,7 +1494,7 @@ static void ccid_card_class_init(ObjectClass *klass, > void *data) > { > DeviceClass *k = DEVICE_CLASS(klass); > k->bus_type = TYPE_CCID_BUS; > - k->init = ccid_card_init; > + k->realize = ccid_card_realize; > k->exit = ccid_card_exit; > k->props = ccid_props; > } > -- > 2.9.4 > > > > > -- Marc-André Lureau