Patchwork Remove useless device dependency of HAS_AUDIO

login
register
mail settings
Submitter Blue Swirl
Date June 20, 2010, 7:13 p.m.
Message ID <AANLkTinDTEslJTmvyPD3-3yXcF3CuFyqv5P27OJ2Zqx8@mail.gmail.com>
Download mbox | patch
Permalink /patch/56270/
State New
Headers show

Comments

Blue Swirl - June 20, 2010, 7:13 p.m.
System architecture dictates whether HAS_AUDIO is defined. It's then
useless to check for HAS_AUDIO in files which are only used on those
architectures which always have audio.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/marvell_88w8618_audio.c |    4 ----
 hw/mips_jazz.c             |    4 ----
 hw/mips_malta.c            |    4 ----
 hw/musicpal.c              |    4 ----
 hw/omap2.c                 |    2 --
 hw/pc.c                    |    2 --
 hw/pc_piix.c               |    2 --
 hw/spitz.c                 |    4 ----
 8 files changed, 0 insertions(+), 26 deletions(-)

     i2c_slave *wm = (i2c_slave *) opaque;
@@ -777,14 +776,12 @@ static void spitz_wm8750_addr(void *opaque, int
line, int level)
     else
         i2c_set_slave_address(wm, SPITZ_WM_ADDRL);
 }
-#endif

 static void spitz_i2c_setup(PXA2xxState *cpu)
 {
     /* Attach the CPU on one end of our I2C bus.  */
     i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);

-#ifdef HAS_AUDIO
     DeviceState *wm;

     /* Attach a WM8750 to the bus */
@@ -798,7 +795,6 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
     cpu->i2s->codec_out = wm8750_dac_dat;
     cpu->i2s->codec_in = wm8750_adc_dat;
     wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
-#endif
 }

 static void spitz_akita_i2c_setup(PXA2xxState *cpu)
malc - June 20, 2010, 9:06 p.m.
On Sun, 20 Jun 2010, Blue Swirl wrote:

> System architecture dictates whether HAS_AUDIO is defined. It's then
> useless to check for HAS_AUDIO in files which are only used on those
> architectures which always have audio.

It wasn't me who came up with HAS_AUDIO guard, so i can't comment much
on the impact, but on the surface the patch looks fine.

[..snip..]

Patch

diff --git a/hw/marvell_88w8618_audio.c b/hw/marvell_88w8618_audio.c
index 57c3d5a..307b584 100644
--- a/hw/marvell_88w8618_audio.c
+++ b/hw/marvell_88w8618_audio.c
@@ -34,7 +34,6 @@ 
 #define MP_AUDIO_CLOCK_24MHZ    (1 << 9)
 #define MP_AUDIO_MONO           (1 << 14)

-#ifdef HAS_AUDIO
 typedef struct mv88w8618_audio_state {
     SysBusDevice busdev;
     qemu_irq irq;
@@ -290,13 +289,10 @@  static SysBusDeviceInfo mv88w8618_audio_info = {
         {/* end of list */}
     }
 };
-#endif

 static void mv88w8618_register_devices(void)
 {
-#ifdef HAS_AUDIO
     sysbus_register_withprop(&mv88w8618_audio_info);
-#endif
 }

 device_init(mv88w8618_register_devices)
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 22db7a2..606cd23 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -89,7 +89,6 @@  static CPUWriteMemoryFunc * const dma_dummy_write[3] = {
     dma_dummy_writeb,
 };

-#ifdef HAS_AUDIO
 static void audio_init(qemu_irq *pic)
 {
     struct soundhw *c;
@@ -109,7 +108,6 @@  static void audio_init(qemu_irq *pic)
         }
     }
 }
-#endif

 #define MAGNUM_BIOS_SIZE_MAX 0x7e000
 #define MAGNUM_BIOS_SIZE (BIOS_SIZE < MAGNUM_BIOS_SIZE_MAX ?
BIOS_SIZE : MAGNUM_BIOS_SIZE_MAX)
@@ -288,9 +286,7 @@  void mips_jazz_init (ram_addr_t ram_size,

     /* Sound card */
     /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
-#ifdef HAS_AUDIO
     audio_init(i8259);
-#endif

     /* NVRAM: Unprotected at 0x9000, Protected at 0xa000, Read only
at 0xb000 */
     ds1225y_init(0x80009000, "nvram");
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 23de7f0..9042b57 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -456,7 +456,6 @@  static MaltaFPGAState
*malta_fpga_init(target_phys_addr_t base, qemu_irq uart_ir
 }

 /* Audio support */
-#ifdef HAS_AUDIO
 static void audio_init (PCIBus *pci_bus)
 {
     struct soundhw *c;
@@ -474,7 +473,6 @@  static void audio_init (PCIBus *pci_bus)
         }
     }
 }
-#endif

 /* Network support */
 static void network_init(void)
@@ -970,9 +968,7 @@  void mips_malta_init (ram_addr_t ram_size,
     floppy_controller = fdctrl_init_isa(fd);

     /* Sound card */
-#ifdef HAS_AUDIO
     audio_init(pci_bus);
-#endif

     /* Network card */
     network_init();
diff --git a/hw/musicpal.c b/hw/musicpal.c
index d44c5a0..95ef2c6 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1486,10 +1486,8 @@  static void musicpal_init(ram_addr_t ram_size,
     DeviceState *i2c_dev;
     DeviceState *lcd_dev;
     DeviceState *key_dev;
-#ifdef HAS_AUDIO
     DeviceState *wm8750_dev;
     SysBusDevice *s;
-#endif
     i2c_bus *i2c;
     int i;
     unsigned long flash_size;
@@ -1611,7 +1609,6 @@  static void musicpal_init(ram_addr_t ram_size,
         qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
     }

-#ifdef HAS_AUDIO
     wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
     dev = qdev_create(NULL, "mv88w8618_audio");
     s = sysbus_from_qdev(dev);
@@ -1619,7 +1616,6 @@  static void musicpal_init(ram_addr_t ram_size,
     qdev_init_nofail(dev);
     sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
     sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
-#endif

     musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
     musicpal_binfo.kernel_filename = kernel_filename;
diff --git a/hw/omap2.c b/hw/omap2.c
index 666c15a..f2c47fe 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -1973,13 +1973,11 @@  struct omap_eac_s *omap_eac_init(struct
omap_target_agent_s *ta,
     s->codec.txdrq = *drq;
     omap_eac_reset(s);

-#ifdef HAS_AUDIO
     AUD_register_card("OMAP EAC", &s->codec.card);

     iomemtype = cpu_register_io_memory(omap_eac_readfn,
                     omap_eac_writefn, s);
     omap_l4_attach(ta, 0, iomemtype);
-#endif

     return s;
 }
diff --git a/hw/pc.c b/hw/pc.c
index 1848151..e67eeb4 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -721,7 +721,6 @@  static const int ne2000_irq[NE2000_NB_MAX] = { 9,
10, 11, 3, 4, 5 };
 static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };

-#ifdef HAS_AUDIO
 void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic)
 {
     struct soundhw *c;
@@ -738,7 +737,6 @@  void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic)
         }
     }
 }
-#endif

 void pc_init_ne2k_isa(NICInfo *nd)
 {
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 68040b7..f670fd7 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -140,9 +140,7 @@  static void pc_init1(ram_addr_t ram_size,
         }
     }

-#ifdef HAS_AUDIO
     pc_audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
-#endif

     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd,
                  floppy_controller, rtc_state);
diff --git a/hw/spitz.c b/hw/spitz.c
index 4f82e24..b3e5318 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -768,7 +768,6 @@  static void spitz_microdrive_attach(PXA2xxState
*cpu, int slot)

 #define SPITZ_GPIO_WM	5

-#ifdef HAS_AUDIO
 static void spitz_wm8750_addr(void *opaque, int line, int level)
 {