aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/ac97.c4
-rw-r--r--hw/dma.c6
-rw-r--r--hw/e1000.c8
-rw-r--r--hw/fdc.c2
-rw-r--r--hw/max7310.c6
-rw-r--r--hw/nseries.c4
-rw-r--r--hw/rc4030.c4
-rw-r--r--hw/sb16.c6
-rw-r--r--hw/sh_intc.c9
-rw-r--r--hw/sh_intc.h2
-rw-r--r--hw/sm501.c2
-rw-r--r--hw/usb-net.c5
-rw-r--r--hw/vmware_vga.c2
13 files changed, 27 insertions, 33 deletions
diff --git a/hw/ac97.c b/hw/ac97.c
index c30e894074..dc9a165a31 100644
--- a/hw/ac97.c
+++ b/hw/ac97.c
@@ -1196,7 +1196,7 @@ static void ac97_save (QEMUFile *f, void *opaque)
qemu_put_be32s (f, &s->glob_sta);
qemu_put_be32s (f, &s->cas);
- for (i = 0; i < sizeof (s->bm_regs) / sizeof (s->bm_regs[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) {
AC97BusMasterRegs *r = &s->bm_regs[i];
qemu_put_be32s (f, &r->bdbar);
qemu_put_8s (f, &r->civ);
@@ -1235,7 +1235,7 @@ static int ac97_load (QEMUFile *f, void *opaque, int version_id)
qemu_get_be32s (f, &s->glob_sta);
qemu_get_be32s (f, &s->cas);
- for (i = 0; i < sizeof (s->bm_regs) / sizeof (s->bm_regs[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) {
AC97BusMasterRegs *r = &s->bm_regs[i];
qemu_get_be32s (f, &r->bdbar);
qemu_get_8s (f, &r->civ);
diff --git a/hw/dma.c b/hw/dma.c
index b247a0cd89..e58ab6dd23 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -37,8 +37,6 @@
#define ldebug(...)
#endif
-#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
-
struct dma_regs {
int now[2];
uint16_t base[2];
@@ -479,7 +477,7 @@ static void dma_init2(struct dma_cont *d, int base, int dshift,
register_ioport_write (base + (i << dshift), 1, 1, write_chan, d);
register_ioport_read (base + (i << dshift), 1, 1, read_chan, d);
}
- for (i = 0; i < LENOFA (page_port_list); i++) {
+ for (i = 0; i < ARRAY_SIZE (page_port_list); i++) {
register_ioport_write (page_base + page_port_list[i], 1, 1,
write_page, d);
register_ioport_read (page_base + page_port_list[i], 1, 1,
@@ -499,7 +497,7 @@ static void dma_init2(struct dma_cont *d, int base, int dshift,
}
qemu_register_reset(dma_reset, d);
dma_reset(d);
- for (i = 0; i < LENOFA (d->regs); ++i) {
+ for (i = 0; i < ARRAY_SIZE (d->regs); ++i) {
d->regs[i].transfer_handler = dma_phony_handler;
}
}
diff --git a/hw/e1000.c b/hw/e1000.c
index 67a062a318..c326671b0e 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -763,7 +763,7 @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
[MTA ... MTA+127] = &mac_readreg,
[VFTA ... VFTA+127] = &mac_readreg,
};
-enum { NREADOPS = sizeof(macreg_readops) / sizeof(*macreg_readops) };
+enum { NREADOPS = ARRAY_SIZE(macreg_readops) };
#define putreg(x) [x] = mac_writereg
static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
@@ -779,7 +779,7 @@ static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
[MTA ... MTA+127] = &mac_writereg,
[VFTA ... VFTA+127] = &mac_writereg,
};
-enum { NWRITEOPS = sizeof(macreg_writeops) / sizeof(*macreg_writeops) };
+enum { NWRITEOPS = ARRAY_SIZE(macreg_writeops) };
static void
e1000_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
@@ -854,13 +854,13 @@ static const int mac_regtosave[] = {
TDT, TORH, TORL, TOTH, TOTL, TPR, TPT, TXDCTL, WUFC,
VET,
};
-enum { MAC_NSAVE = sizeof mac_regtosave/sizeof *mac_regtosave };
+enum { MAC_NSAVE = ARRAY_SIZE(mac_regtosave) };
static const struct {
int size;
int array0;
} mac_regarraystosave[] = { {32, RA}, {128, MTA}, {128, VFTA} };
-enum { MAC_NARRAYS = sizeof mac_regarraystosave/sizeof *mac_regarraystosave };
+enum { MAC_NARRAYS = ARRAY_SIZE(mac_regarraystosave) };
static void
nic_save(QEMUFile *f, void *opaque)
diff --git a/hw/fdc.c b/hw/fdc.c
index 26ff184250..b1b4bc7d07 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1851,7 +1851,7 @@ static fdctrl_t *fdctrl_init_common (qemu_irq irq, int dma_chann,
int i, j;
/* Fill 'command_to_handler' lookup table */
- for (i = sizeof(handlers)/sizeof(handlers[0]) - 1; i >= 0; i--) {
+ for (i = ARRAY_SIZE(handlers) - 1; i >= 0; i--) {
for (j = 0; j < sizeof(command_to_handler); j++) {
if ((j & handlers[i].mask) == handlers[i].value)
command_to_handler[j] = i;
diff --git a/hw/max7310.c b/hw/max7310.c
index 2816611a80..ee57581030 100644
--- a/hw/max7310.c
+++ b/hw/max7310.c
@@ -180,7 +180,7 @@ static int max7310_load(QEMUFile *f, void *opaque, int version_id)
static void max7310_gpio_set(void *opaque, int line, int level)
{
struct max7310_s *s = (struct max7310_s *) opaque;
- if (line >= sizeof(s->handler) / sizeof(*s->handler) || line < 0)
+ if (line >= ARRAY_SIZE(s->handler) || line < 0)
hw_error("bad GPIO line");
if (level)
@@ -199,7 +199,7 @@ struct i2c_slave *max7310_init(i2c_bus *bus)
s->i2c.recv = max7310_rx;
s->i2c.send = max7310_tx;
s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s,
- sizeof(s->handler) / sizeof(*s->handler));
+ ARRAY_SIZE(s->handler));
max7310_reset(&s->i2c);
@@ -217,7 +217,7 @@ qemu_irq *max7310_gpio_in_get(i2c_slave *i2c)
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
{
struct max7310_s *s = (struct max7310_s *) i2c;
- if (line >= sizeof(s->handler) / sizeof(*s->handler) || line < 0)
+ if (line >= ARRAY_SIZE(s->handler) || line < 0)
hw_error("bad GPIO line");
s->handler[line] = handler;
diff --git a/hw/nseries.c b/hw/nseries.c
index 80fd9e81df..925e89cf53 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -432,7 +432,7 @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len)
cpu_abort(cpu_single_env, "%s: FIXME: bad SPI word width %i\n",
__FUNCTION__, len);
- if (s->p >= sizeof(s->resp) / sizeof(*s->resp))
+ if (s->p >= ARRAY_SIZE(s->resp))
ret = 0;
else
ret = s->resp[s->p ++];
@@ -840,7 +840,7 @@ static void n800_setup_nolo_tags(void *sram_base)
/* OMAP STI console? Pin out settings? */
ADD_TAG(0x6e01, 414);
- for (i = 0; i < sizeof(n800_pinout) / 4; i ++)
+ for (i = 0; i < ARRAY_SIZE(n800_pinout); i ++)
stl_raw(v ++, n800_pinout[i]);
/* Kernel memsize? */
diff --git a/hw/rc4030.c b/hw/rc4030.c
index 54f9adfa3e..89cec6e3bb 100644
--- a/hw/rc4030.c
+++ b/hw/rc4030.c
@@ -269,7 +269,7 @@ static void rc4030_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
static int current = 0;
target_phys_addr_t dest = 0 + dests[current];
uint8_t buf;
- current = (current + 1) % (sizeof(dests)/sizeof(dests[0]));
+ current = (current + 1) % (ARRAY_SIZE(dests));
buf = s->cache_bwin - 1;
cpu_physical_memory_rw(dest, &buf, 1, 1);
}
@@ -403,7 +403,7 @@ static void update_jazz_irq(rc4030State *s)
if (s->isr_jazz != 0) {
uint32_t irq = 0;
printf("jazz pending:");
- for (irq = 0; irq < sizeof(irq_names)/sizeof(irq_names[0]); irq++) {
+ for (irq = 0; irq < ARRAY_SIZE(irq_names); irq++) {
if (s->isr_jazz & (1 << irq)) {
printf(" %s", irq_names[irq]);
if (!(s->imr_jazz & (1 << irq))) {
diff --git a/hw/sb16.c b/hw/sb16.c
index 8a0fafe63f..ad246ea3c9 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -27,8 +27,6 @@
#include "isa.h"
#include "qemu-timer.h"
-#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
-
#define dolog(...) AUD_log ("sb16", __VA_ARGS__)
/* #define DEBUG */
@@ -1440,11 +1438,11 @@ int SB16_init (AudioState *audio, qemu_irq *pic)
dolog ("warning: Could not create auxiliary timer\n");
}
- for (i = 0; i < LENOFA (dsp_write_ports); i++) {
+ for (i = 0; i < ARRAY_SIZE (dsp_write_ports); i++) {
register_ioport_write (s->port + dsp_write_ports[i], 1, 1, dsp_write, s);
}
- for (i = 0; i < LENOFA (dsp_read_ports); i++) {
+ for (i = 0; i < ARRAY_SIZE (dsp_read_ports); i++) {
register_ioport_read (s->port + dsp_read_ports[i], 1, 1, dsp_read, s);
}
diff --git a/hw/sh_intc.c b/hw/sh_intc.c
index 136e7dd216..9039e555d5 100644
--- a/hw/sh_intc.c
+++ b/hw/sh_intc.c
@@ -17,7 +17,6 @@
//#define DEBUG_INTC_SOURCES
#define INTC_A7(x) ((x) & 0x1fffffff)
-#define INTC_ARRAY(x) (sizeof(x) / sizeof(x[0]))
void sh_intc_toggle_source(struct intc_source *source,
int enable_adj, int assert_adj)
@@ -327,7 +326,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
for (i = 0; i < desc->nr_mask_regs; i++) {
struct intc_mask_reg *mr = desc->mask_regs + i;
- for (k = 0; k < INTC_ARRAY(mr->enum_ids); k++) {
+ for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) {
if (mr->enum_ids[k] != source)
continue;
@@ -342,7 +341,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
for (i = 0; i < desc->nr_prio_regs; i++) {
struct intc_prio_reg *pr = desc->prio_regs + i;
- for (k = 0; k < INTC_ARRAY(pr->enum_ids); k++) {
+ for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) {
if (pr->enum_ids[k] != source)
continue;
@@ -357,7 +356,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
for (i = 0; i < nr_groups; i++) {
struct intc_group *gr = groups + i;
- for (k = 0; k < INTC_ARRAY(gr->enum_ids); k++) {
+ for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) {
if (gr->enum_ids[k] != source)
continue;
@@ -400,7 +399,7 @@ void sh_intc_register_sources(struct intc_desc *desc,
s = sh_intc_source(desc, gr->enum_id);
s->next_enum_id = gr->enum_ids[0];
- for (k = 1; k < INTC_ARRAY(gr->enum_ids); k++) {
+ for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) {
if (!gr->enum_ids[k])
continue;
diff --git a/hw/sh_intc.h b/hw/sh_intc.h
index 4e36f007d7..a9750ae9b1 100644
--- a/hw/sh_intc.h
+++ b/hw/sh_intc.h
@@ -32,7 +32,7 @@ struct intc_prio_reg {
unsigned long value;
};
-#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
+#define _INTC_ARRAY(a) a, ARRAY_SIZE(a)
struct intc_source {
unsigned short vect;
diff --git a/hw/sm501.c b/hw/sm501.c
index 54d176b83f..0d6b08b84c 100644
--- a/hw/sm501.c
+++ b/hw/sm501.c
@@ -514,7 +514,7 @@ static uint32_t get_local_mem_size_index(uint32_t size)
uint32_t norm_size = 0;
int i, index = 0;
- for (i = 0; i < sizeof(sm501_mem_local_size)/sizeof(uint32_t); i++) {
+ for (i = 0; i < ARRAY_SIZE(sm501_mem_local_size); i++) {
uint32_t new_size = sm501_mem_local_size[i];
if (new_size >= size) {
if (norm_size == 0 || norm_size > new_size) {
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 82005af568..f16a0a5404 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -628,14 +628,13 @@ static int ndis_query(USBNetState *s, uint32_t oid,
uint8_t *inbuf, unsigned int inlen, uint8_t *outbuf,
size_t outlen)
{
- unsigned int i, count;
+ unsigned int i;
switch (oid) {
/* general oids (table 4-1) */
/* mandatory */
case OID_GEN_SUPPORTED_LIST:
- count = sizeof(oid_supported_list) / sizeof(uint32_t);
- for (i = 0; i < count; i++)
+ for (i = 0; i < ARRAY_SIZE(oid_supported_list); i++)
((le32 *) outbuf)[i] = cpu_to_le32(oid_supported_list[i]);
return sizeof(oid_supported_list);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index f7be907a3e..e30d03fde0 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -817,7 +817,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
s->guest = value;
#ifdef VERBOSE
if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE +
- sizeof(vmsvga_guest_id) / sizeof(*vmsvga_guest_id))
+ ARRAY_SIZE(vmsvga_guest_id))
printf("%s: guest runs %s.\n", __FUNCTION__,
vmsvga_guest_id[value - GUEST_OS_BASE]);
#endif