Commit d88a76d1d359c1e97fb8921288af87f14247c999
Committed by
Paul Brook
1 parent
6806e595
qdev: convert ac97.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Showing
1 changed file
with
22 additions
and
20 deletions
hw/ac97.c
| @@ -1308,29 +1308,13 @@ static void ac97_on_reset (void *opaque) | @@ -1308,29 +1308,13 @@ static void ac97_on_reset (void *opaque) | ||
| 1308 | mixer_reset (s); | 1308 | mixer_reset (s); |
| 1309 | } | 1309 | } |
| 1310 | 1310 | ||
| 1311 | -int ac97_init (PCIBus *bus) | 1311 | +static void ac97_initfn(PCIDevice *dev) |
| 1312 | { | 1312 | { |
| 1313 | - PCIAC97LinkState *d; | ||
| 1314 | - AC97LinkState *s; | ||
| 1315 | - uint8_t *c; | ||
| 1316 | - | ||
| 1317 | - if (!bus) { | ||
| 1318 | - AUD_log ("ac97", "No PCI bus\n"); | ||
| 1319 | - return -1; | ||
| 1320 | - } | ||
| 1321 | - | ||
| 1322 | - d = (PCIAC97LinkState *) pci_register_device (bus, "AC97", | ||
| 1323 | - sizeof (PCIAC97LinkState), | ||
| 1324 | - -1, NULL, NULL); | ||
| 1325 | - | ||
| 1326 | - if (!d) { | ||
| 1327 | - AUD_log ("ac97", "Failed to register PCI device\n"); | ||
| 1328 | - return -1; | ||
| 1329 | - } | 1313 | + PCIAC97LinkState *d = DO_UPCAST(PCIAC97LinkState, dev, dev); |
| 1314 | + AC97LinkState *s = &d->ac97; | ||
| 1315 | + uint8_t *c = d->dev.config; | ||
| 1330 | 1316 | ||
| 1331 | - s = &d->ac97; | ||
| 1332 | s->pci_dev = &d->dev; | 1317 | s->pci_dev = &d->dev; |
| 1333 | - c = d->dev.config; | ||
| 1334 | pci_config_set_vendor_id (c, PCI_VENDOR_ID_INTEL); /* ro */ | 1318 | pci_config_set_vendor_id (c, PCI_VENDOR_ID_INTEL); /* ro */ |
| 1335 | pci_config_set_device_id (c, PCI_DEVICE_ID_INTEL_82801AA_5); /* ro */ | 1319 | pci_config_set_device_id (c, PCI_DEVICE_ID_INTEL_82801AA_5); /* ro */ |
| 1336 | 1320 | ||
| @@ -1372,5 +1356,23 @@ int ac97_init (PCIBus *bus) | @@ -1372,5 +1356,23 @@ int ac97_init (PCIBus *bus) | ||
| 1372 | qemu_register_reset (ac97_on_reset, s); | 1356 | qemu_register_reset (ac97_on_reset, s); |
| 1373 | AUD_register_card ("ac97", &s->card); | 1357 | AUD_register_card ("ac97", &s->card); |
| 1374 | ac97_on_reset (s); | 1358 | ac97_on_reset (s); |
| 1359 | +} | ||
| 1360 | + | ||
| 1361 | +int ac97_init (PCIBus *bus) | ||
| 1362 | +{ | ||
| 1363 | + pci_create_simple(bus, -1, "AC97"); | ||
| 1375 | return 0; | 1364 | return 0; |
| 1376 | } | 1365 | } |
| 1366 | + | ||
| 1367 | +static PCIDeviceInfo ac97_info = { | ||
| 1368 | + .qdev.name = "AC97", | ||
| 1369 | + .qdev.size = sizeof(PCIAC97LinkState), | ||
| 1370 | + .init = ac97_initfn, | ||
| 1371 | +}; | ||
| 1372 | + | ||
| 1373 | +static void ac97_register(void) | ||
| 1374 | +{ | ||
| 1375 | + pci_qdev_register(&ac97_info); | ||
| 1376 | +} | ||
| 1377 | +device_init(ac97_register); | ||
| 1378 | + |