Revision 39257515 hw/net/rtl8139.c

b/hw/net/rtl8139.c
92 92
}
93 93
#endif
94 94

  
95
#define TYPE_RTL8139 "rtl8139"
96

  
97
#define RTL8139(obj) \
98
     OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139)
99

  
95 100
/* Symbolic offsets to registers. */
96 101
enum RTL8139_registers {
97 102
    MAC0 = 0,        /* Ethernet hardware address. */
......
1197 1202

  
1198 1203
static void rtl8139_reset(DeviceState *d)
1199 1204
{
1200
    RTL8139State *s = container_of(d, RTL8139State, dev.qdev);
1205
    RTL8139State *s = RTL8139(d);
1201 1206
    int i;
1202 1207

  
1203 1208
    /* restore MAC address */
......
1364 1369

  
1365 1370
static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)
1366 1371
{
1372
    DeviceState *d = DEVICE(s);
1373

  
1367 1374
    val &= 0xff;
1368 1375

  
1369 1376
    DPRINTF("ChipCmd write val=0x%08x\n", val);
......
1371 1378
    if (val & CmdReset)
1372 1379
    {
1373 1380
        DPRINTF("ChipCmd reset\n");
1374
        rtl8139_reset(&s->dev.qdev);
1381
        rtl8139_reset(d);
1375 1382
    }
1376 1383
    if (val & CmdRxEnb)
1377 1384
    {
......
1525 1532

  
1526 1533
static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val)
1527 1534
{
1535
    DeviceState *d = DEVICE(s);
1536

  
1528 1537
    val &= 0xff;
1529 1538

  
1530 1539
    DPRINTF("Cfg9346 write val=0x%02x\n", val);
......
1544 1553
    } else if (opmode == 0x40) {
1545 1554
        /* Reset.  */
1546 1555
        val = 0;
1547
        rtl8139_reset(&s->dev.qdev);
1556
        rtl8139_reset(d);
1548 1557
    }
1549 1558

  
1550 1559
    s->Cfg9346 = val;
......
3439 3448

  
3440 3449
static void pci_rtl8139_uninit(PCIDevice *dev)
3441 3450
{
3442
    RTL8139State *s = DO_UPCAST(RTL8139State, dev, dev);
3451
    RTL8139State *s = RTL8139(dev);
3443 3452

  
3444 3453
    memory_region_destroy(&s->bar_io);
3445 3454
    memory_region_destroy(&s->bar_mem);
......
3477 3486

  
3478 3487
static int pci_rtl8139_init(PCIDevice *dev)
3479 3488
{
3480
    RTL8139State * s = DO_UPCAST(RTL8139State, dev, dev);
3489
    RTL8139State *s = RTL8139(dev);
3490
    DeviceState *d = DEVICE(dev);
3481 3491
    uint8_t *pci_conf;
3482 3492

  
3483 3493
    pci_conf = s->dev.config;
......
3507 3517
    s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8;
3508 3518

  
3509 3519
    s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf,
3510
                          object_get_typename(OBJECT(dev)), dev->qdev.id, s);
3520
                          object_get_typename(OBJECT(dev)), d->id, s);
3511 3521
    qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
3512 3522

  
3513 3523
    s->cplus_txbuffer = NULL;
......
3518 3528
    s->timer = qemu_new_timer_ns(vm_clock, rtl8139_timer, s);
3519 3529
    rtl8139_set_next_tctr_time(s, qemu_get_clock_ns(vm_clock));
3520 3530

  
3521
    add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet-phy@0");
3531
    add_boot_device_path(s->conf.bootindex, d, "/ethernet-phy@0");
3522 3532

  
3523 3533
    return 0;
3524 3534
}
......
3546 3556
}
3547 3557

  
3548 3558
static const TypeInfo rtl8139_info = {
3549
    .name          = "rtl8139",
3559
    .name          = TYPE_RTL8139,
3550 3560
    .parent        = TYPE_PCI_DEVICE,
3551 3561
    .instance_size = sizeof(RTL8139State),
3552 3562
    .class_init    = rtl8139_class_init,

Also available in: Unified diff