Skip to content

Commit

Permalink
hw/audio/pcspk: Inline pcspk_init()
Browse files Browse the repository at this point in the history
pcspk_init() is a legacy init function, inline and remove it.

Since the device is realized using &error_fatal, use the same
error for setting the "pit" link.

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20231019073307.99608-1-philmd@linaro.org>
  • Loading branch information
philmd committed Oct 19, 2023
1 parent 6c9dcd8 commit 40f8214
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 3 additions & 1 deletion hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,9 @@ void pc_basic_device_init(struct PCMachineState *pcms,
/* connect PIT to output control line of the HPET */
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(pcms->pcspk, isa_bus, pit);
object_property_set_link(OBJECT(pcms->pcspk), "pit",
OBJECT(pit), &error_fatal);
isa_realize_and_unref(pcms->pcspk, isa_bus, &error_fatal);
}

/* Super I/O */
Expand Down
5 changes: 4 additions & 1 deletion hw/isa/i82378.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
uint8_t *pci_conf;
ISABus *isabus;
ISADevice *pit;
ISADevice *pcspk;

pci_conf = pci->config;
pci_set_word(pci_conf + PCI_COMMAND,
Expand Down Expand Up @@ -102,7 +103,9 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
pit = i8254_pit_init(isabus, 0x40, 0, NULL);

/* speaker */
pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
pcspk = isa_new(TYPE_PC_SPEAKER);
object_property_set_link(OBJECT(pcspk), "pit", OBJECT(pit), &error_fatal);
isa_realize_and_unref(pcspk, isabus, &error_fatal);

/* 2 82C37 (dma) */
isa_create_simple(isabus, "i82374");
Expand Down
5 changes: 4 additions & 1 deletion hw/mips/jazz.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ static void mips_jazz_init(MachineState *machine,
SysBusDevice *sysbus;
ISABus *isa_bus;
ISADevice *pit;
ISADevice *pcspk;
DriveInfo *fds[MAX_FD];
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
Expand Down Expand Up @@ -278,7 +279,9 @@ static void mips_jazz_init(MachineState *machine,
isa_bus_register_input_irqs(isa_bus, i8259);
i8257_dma_init(isa_bus, 0);
pit = i8254_pit_init(isa_bus, 0x40, 0, NULL);
pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
pcspk = isa_new(TYPE_PC_SPEAKER);
object_property_set_link(OBJECT(pcspk), "pit", OBJECT(pit), &error_fatal);
isa_realize_and_unref(pcspk, isa_bus, &error_fatal);

/* Video card */
switch (jazz_model) {
Expand Down
10 changes: 0 additions & 10 deletions include/hw/audio/pcspk.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
#ifndef HW_PCSPK_H
#define HW_PCSPK_H

#include "hw/isa/isa.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"

#define TYPE_PC_SPEAKER "isa-pcspk"

static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
{
object_property_set_link(OBJECT(isadev), "pit", OBJECT(pit), NULL);
isa_realize_and_unref(isadev, bus, &error_fatal);
}

#endif /* HW_PCSPK_H */

0 comments on commit 40f8214

Please sign in to comment.