Revision fd506b4f

b/hw/char/spapr_vty.c
12 12
    uint8_t buf[VTERM_BUFSIZE];
13 13
} VIOsPAPRVTYDevice;
14 14

  
15
#define TYPE_VIO_SPAPR_VTY_DEVICE "spapr-vty"
16
#define VIO_SPAPR_VTY_DEVICE(obj) \
17
     OBJECT_CHECK(VIOsPAPRVTYDevice, (obj), TYPE_VIO_SPAPR_VTY_DEVICE)
18

  
15 19
static int vty_can_receive(void *opaque)
16 20
{
17
    VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque;
21
    VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(opaque);
18 22

  
19 23
    return (dev->in - dev->out) < VTERM_BUFSIZE;
20 24
}
21 25

  
22 26
static void vty_receive(void *opaque, const uint8_t *buf, int size)
23 27
{
24
    VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)opaque;
28
    VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(opaque);
25 29
    int i;
26 30

  
27 31
    if ((dev->in == dev->out) && size) {
......
36 40

  
37 41
static int vty_getchars(VIOsPAPRDevice *sdev, uint8_t *buf, int max)
38 42
{
39
    VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
43
    VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev);
40 44
    int n = 0;
41 45

  
42 46
    while ((n < max) && (dev->out != dev->in)) {
......
48 52

  
49 53
void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len)
50 54
{
51
    VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
55
    VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev);
52 56

  
53 57
    /* FIXME: should check the qemu_chr_fe_write() return value */
54 58
    qemu_chr_fe_write(dev->chardev, buf, len);
......
56 60

  
57 61
static int spapr_vty_init(VIOsPAPRDevice *sdev)
58 62
{
59
    VIOsPAPRVTYDevice *dev = (VIOsPAPRVTYDevice *)sdev;
63
    VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev);
60 64

  
61 65
    if (!dev->chardev) {
62 66
        fprintf(stderr, "spapr-vty: Can't create vty without a chardev!\n");
......
151 155
}
152 156

  
153 157
static const TypeInfo spapr_vty_info = {
154
    .name          = "spapr-vty",
158
    .name          = TYPE_VIO_SPAPR_VTY_DEVICE,
155 159
    .parent        = TYPE_VIO_SPAPR_DEVICE,
156 160
    .instance_size = sizeof(VIOsPAPRVTYDevice),
157 161
    .class_init    = spapr_vty_class_init,
......
177 181
            continue;
178 182
        }
179 183

  
180
        sdev = DO_UPCAST(VIOsPAPRDevice, qdev, iter);
184
        sdev = VIO_SPAPR_DEVICE(iter);
181 185

  
182 186
        /* First VTY we've found, so it is selected for now */
183 187
        if (!selected) {
b/hw/net/spapr_llan.c
73 73
#define VLAN_RX_BDS_OFF      16
74 74
#define VLAN_MAX_BUFS        ((SPAPR_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF) / 8)
75 75

  
76
#define TYPE_VIO_SPAPR_VLAN_DEVICE "spapr-vlan"
77
#define VIO_SPAPR_VLAN_DEVICE(obj) \
78
     OBJECT_CHECK(VIOsPAPRVLANDevice, (obj), TYPE_VIO_SPAPR_VLAN_DEVICE)
79

  
76 80
typedef struct VIOsPAPRVLANDevice {
77 81
    VIOsPAPRDevice sdev;
78 82
    NICConf nicconf;
......
93 97
static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf,
94 98
                                  size_t size)
95 99
{
96
    VIOsPAPRDevice *sdev = qemu_get_nic_opaque(nc);
97
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
100
    VIOsPAPRVLANDevice *dev = qemu_get_nic_opaque(nc);
101
    VIOsPAPRDevice *sdev = VIO_SPAPR_DEVICE(dev);
98 102
    vlan_bd_t rxq_bd = vio_ldq(sdev, dev->buf_list + VLAN_RXQ_BD_OFF);
99 103
    vlan_bd_t bd;
100 104
    int buf_ptr = dev->use_buf_ptr;
......
192 196

  
193 197
static void spapr_vlan_reset(VIOsPAPRDevice *sdev)
194 198
{
195
    VIOsPAPRVLANDevice *dev = DO_UPCAST(VIOsPAPRVLANDevice, sdev, sdev);
199
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
196 200

  
197 201
    dev->buf_list = 0;
198 202
    dev->rx_bufs = 0;
......
201 205

  
202 206
static int spapr_vlan_init(VIOsPAPRDevice *sdev)
203 207
{
204
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
208
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
205 209

  
206 210
    qemu_macaddr_default_if_unset(&dev->nicconf.macaddr);
207 211

  
......
225 229

  
226 230
static int spapr_vlan_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off)
227 231
{
228
    VIOsPAPRVLANDevice *vdev = (VIOsPAPRVLANDevice *)dev;
232
    VIOsPAPRVLANDevice *vdev = VIO_SPAPR_VLAN_DEVICE(dev);
229 233
    uint8_t padded_mac[8] = {0, 0};
230 234
    int ret;
231 235

  
......
282 286
    target_ulong rec_queue = args[2];
283 287
    target_ulong filter_list = args[3];
284 288
    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
285
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
289
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
286 290
    vlan_bd_t filter_list_bd;
287 291

  
288 292
    if (!dev) {
......
341 345
{
342 346
    target_ulong reg = args[0];
343 347
    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
344
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
348
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
345 349

  
346 350
    if (!dev) {
347 351
        return H_PARAMETER;
......
365 369
    target_ulong reg = args[0];
366 370
    target_ulong buf = args[1];
367 371
    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
368
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
372
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
369 373
    vlan_bd_t bd;
370 374

  
371 375
    dprintf("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
......
413 417
    target_ulong *bufs = args + 1;
414 418
    target_ulong continue_token = args[7];
415 419
    VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
416
    VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
420
    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
417 421
    unsigned total_len;
418 422
    uint8_t *lbuf, *p;
419 423
    int i, nbufs;
......
511 515
}
512 516

  
513 517
static const TypeInfo spapr_vlan_info = {
514
    .name          = "spapr-vlan",
518
    .name          = TYPE_VIO_SPAPR_VLAN_DEVICE,
515 519
    .parent        = TYPE_VIO_SPAPR_DEVICE,
516 520
    .instance_size = sizeof(VIOsPAPRVLANDevice),
517 521
    .class_init    = spapr_vlan_class_init,
b/hw/nvram/spapr_nvram.c
36 36
    BlockDriverState *drive;
37 37
} sPAPRNVRAM;
38 38

  
39
#define TYPE_VIO_SPAPR_NVRAM "spapr-nvram"
40
#define VIO_SPAPR_NVRAM(obj) \
41
     OBJECT_CHECK(sPAPRNVRAM, (obj), TYPE_VIO_SPAPR_NVRAM)
42

  
39 43
#define MIN_NVRAM_SIZE 8192
40 44
#define DEFAULT_NVRAM_SIZE 65536
41 45
#define MAX_NVRAM_SIZE (UINT16_MAX * 16)
......
134 138

  
135 139
static int spapr_nvram_init(VIOsPAPRDevice *dev)
136 140
{
137
    sPAPRNVRAM *nvram = (sPAPRNVRAM *)dev;
141
    sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);
138 142

  
139 143
    if (nvram->drive) {
140 144
        nvram->size = bdrv_getlength(nvram->drive);
......
157 161

  
158 162
static int spapr_nvram_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off)
159 163
{
160
    sPAPRNVRAM *nvram = (sPAPRNVRAM *)dev;
164
    sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);
161 165

  
162 166
    return fdt_setprop_cell(fdt, node_off, "#bytes", nvram->size);
163 167
}
......
182 186
}
183 187

  
184 188
static const TypeInfo spapr_nvram_type_info = {
185
    .name          = "spapr-nvram",
189
    .name          = TYPE_VIO_SPAPR_NVRAM,
186 190
    .parent        = TYPE_VIO_SPAPR_DEVICE,
187 191
    .instance_size = sizeof(sPAPRNVRAM),
188 192
    .class_init    = spapr_nvram_class_init,
b/hw/ppc/spapr_vio.c
379 379
     * the given dev might already be in the list.
380 380
     */
381 381
    QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
382
        other = DO_UPCAST(VIOsPAPRDevice, qdev, kid->child);
382
        other = VIO_SPAPR_DEVICE(kid->child);
383 383

  
384 384
        if (other != dev && other->reg == dev->reg) {
385 385
            return other;
......
391 391

  
392 392
static void spapr_vio_busdev_reset(DeviceState *qdev)
393 393
{
394
    VIOsPAPRDevice *dev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
394
    VIOsPAPRDevice *dev = VIO_SPAPR_DEVICE(qdev);
395 395
    VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
396 396

  
397 397
    /* Shut down the request queue and TCEs if necessary */
b/hw/scsi/spapr_vscsi.c
91 91
    int                     total_desc;
92 92
} vscsi_req;
93 93

  
94
#define TYPE_VIO_SPAPR_VSCSI_DEVICE "spapr-vscsi"
95
#define VIO_SPAPR_VSCSI_DEVICE(obj) \
96
     OBJECT_CHECK(VSCSIState, (obj), TYPE_VIO_SPAPR_VSCSI_DEVICE)
94 97

  
95 98
typedef struct {
96 99
    VIOsPAPRDevice vdev;
......
461 464
/* Callback to indicate that the SCSI layer has completed a transfer.  */
462 465
static void vscsi_transfer_data(SCSIRequest *sreq, uint32_t len)
463 466
{
464
    VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, sreq->bus->qbus.parent);
467
    VSCSIState *s = VIO_SPAPR_VSCSI_DEVICE(sreq->bus->qbus.parent);
465 468
    vscsi_req *req = sreq->hba_private;
466 469
    uint8_t *buf;
467 470
    int rc = 0;
......
492 495
/* Callback to indicate that the SCSI layer has completed a transfer.  */
493 496
static void vscsi_command_complete(SCSIRequest *sreq, uint32_t status, size_t resid)
494 497
{
495
    VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, sreq->bus->qbus.parent);
498
    VSCSIState *s = VIO_SPAPR_VSCSI_DEVICE(sreq->bus->qbus.parent);
496 499
    vscsi_req *req = sreq->hba_private;
497 500
    int32_t res_in = 0, res_out = 0;
498 501

  
......
827 830

  
828 831
static int vscsi_do_crq(struct VIOsPAPRDevice *dev, uint8_t *crq_data)
829 832
{
830
    VSCSIState *s = DO_UPCAST(VSCSIState, vdev, dev);
833
    VSCSIState *s = VIO_SPAPR_VSCSI_DEVICE(dev);
831 834
    vscsi_crq crq;
832 835

  
833 836
    memcpy(crq.raw, crq_data, 16);
......
897 900

  
898 901
static void spapr_vscsi_reset(VIOsPAPRDevice *dev)
899 902
{
900
    VSCSIState *s = DO_UPCAST(VSCSIState, vdev, dev);
903
    VSCSIState *s = VIO_SPAPR_VSCSI_DEVICE(dev);
901 904
    int i;
902 905

  
903 906
    memset(s->reqs, 0, sizeof(s->reqs));
......
908 911

  
909 912
static int spapr_vscsi_init(VIOsPAPRDevice *dev)
910 913
{
911
    VSCSIState *s = DO_UPCAST(VSCSIState, vdev, dev);
914
    VSCSIState *s = VIO_SPAPR_VSCSI_DEVICE(dev);
912 915

  
913 916
    dev->crq.SendFunc = vscsi_do_crq;
914 917

  
......
968 971
}
969 972

  
970 973
static const TypeInfo spapr_vscsi_info = {
971
    .name          = "spapr-vscsi",
974
    .name          = TYPE_VIO_SPAPR_VSCSI_DEVICE,
972 975
    .parent        = TYPE_VIO_SPAPR_DEVICE,
973 976
    .instance_size = sizeof(VSCSIState),
974 977
    .class_init    = spapr_vscsi_class_init,

Also available in: Unified diff