Remove duplicate device index calculations.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4818 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
pbrook 2008-07-01 21:31:54 +00:00
parent 9656f324d2
commit 18be518729
12 changed files with 21 additions and 44 deletions

View File

@ -140,8 +140,6 @@ static int ads7846_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int ads7846_iid = 0;
struct ads7846_state_s *ads7846_init(qemu_irq penirq)
{
struct ads7846_state_s *s;
@ -162,8 +160,7 @@ struct ads7846_state_s *ads7846_init(qemu_irq penirq)
ads7846_int_update(s);
register_savevm("ads7846", ads7846_iid ++, 0,
ads7846_save, ads7846_load, s);
register_savevm("ads7846", -1, 0, ads7846_save, ads7846_load, s);
return s;
}

View File

@ -3596,8 +3596,6 @@ static int md_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int md_iid = 0;
static const uint8_t dscm1xxxx_cis[0x14a] = {
[0x000] = CISTPL_DEVICE, /* 5V Device Information */
[0x002] = 0x03, /* Tuple length = 4 bytes */
@ -3824,7 +3822,7 @@ struct pcmcia_card_s *dscm1xxxx_init(BlockDriverState *bdrv)
md->ide->mdata_size = METADATA_SIZE;
md->ide->mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
register_savevm("microdrive", md_iid ++, 0, md_save, md_load, md);
register_savevm("microdrive", -1, 0, md_save, md_load, md);
return &md->card;
}

View File

@ -490,8 +490,6 @@ static int lm_kbd_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int lm_kbd_iid = 0;
struct i2c_slave *lm8323_init(i2c_bus *bus, qemu_irq nirq)
{
struct lm_kbd_s *s;
@ -510,8 +508,7 @@ struct i2c_slave *lm8323_init(i2c_bus *bus, qemu_irq nirq)
lm_kbd_reset(s);
qemu_register_reset((void *) lm_kbd_reset, s);
register_savevm("LM8323", lm_kbd_iid ++, 0,
lm_kbd_save, lm_kbd_load, s);
register_savevm("LM8323", -1, 0, lm_kbd_save, lm_kbd_load, s);
return &s->i2c;
}

View File

@ -121,8 +121,6 @@ static int max111x_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int max111x_iid = 0;
static struct max111x_s *max111x_init(qemu_irq cb)
{
struct max111x_s *s;
@ -143,8 +141,7 @@ static struct max111x_s *max111x_init(qemu_irq cb)
s->input[7] = 0x80;
s->com = 0;
register_savevm("max111x", max111x_iid ++, 0,
max111x_save, max111x_load, s);
register_savevm("max111x", -1, 0, max111x_save, max111x_load, s);
return s;
}

View File

@ -177,8 +177,6 @@ static int max7310_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int max7310_iid = 0;
static void max7310_gpio_set(void *opaque, int line, int level)
{
struct max7310_s *s = (struct max7310_s *) opaque;
@ -205,8 +203,7 @@ struct i2c_slave *max7310_init(i2c_bus *bus)
max7310_reset(&s->i2c);
register_savevm("max7310", max7310_iid ++, 0,
max7310_save, max7310_load, s);
register_savevm("max7310", -1, 0, max7310_save, max7310_load, s);
return &s->i2c;
}

View File

@ -319,8 +319,6 @@ static int nand_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int nand_iid = 0;
/*
* Chip inputs are CLE, ALE, CE, WP, GND and eight I/O pins. Chip
* outputs are R/B and eight I/O pins.
@ -495,7 +493,7 @@ struct nand_flash_s *nand_init(int manf_id, int chip_id)
s->storage = (uint8_t *) memset(qemu_malloc(s->pages * pagesize),
0xff, s->pages * pagesize);
register_savevm("nand", nand_iid ++, 0, nand_save, nand_load, s);
register_savevm("nand", -1, 0, nand_save, nand_load, s);
return s;
}

View File

@ -228,8 +228,6 @@ void tmp105_reset(i2c_slave *i2c)
tmp105_interrupt_update(s);
}
static int tmp105_iid = 0;
struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm)
{
struct tmp105_s *s = (struct tmp105_s *)
@ -242,8 +240,7 @@ struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm)
tmp105_reset(&s->i2c);
register_savevm("TMP105", tmp105_iid ++, 0,
tmp105_save, tmp105_load, s);
register_savevm("TMP105", -1, 0, tmp105_save, tmp105_load, s);
return &s->i2c;
}

View File

@ -520,8 +520,6 @@ static int tsc2005_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int tsc2005_iid = 0;
void *tsc2005_init(qemu_irq pintdav)
{
struct tsc2005_state_s *s;
@ -551,8 +549,7 @@ void *tsc2005_init(qemu_irq pintdav)
"QEMU TSC2005-driven Touchscreen");
qemu_register_reset((void *) tsc2005_reset, s);
register_savevm("tsc2005", tsc2005_iid ++, 0,
tsc2005_save, tsc2005_load, s);
register_savevm("tsc2005", -1, 0, tsc2005_save, tsc2005_load, s);
return s;
}

View File

@ -1107,8 +1107,6 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int tsc2102_iid = 0;
struct uwire_slave_s *tsc2102_init(qemu_irq pint, AudioState *audio)
{
struct tsc210x_state_s *s;
@ -1154,7 +1152,7 @@ struct uwire_slave_s *tsc2102_init(qemu_irq pint, AudioState *audio)
AUD_register_card(s->audio, s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);
register_savevm(s->name, tsc2102_iid ++, 0,
register_savevm(s->name, -1, 0,
tsc210x_save, tsc210x_load, s);
return &s->chip;
@ -1208,8 +1206,7 @@ struct uwire_slave_s *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
AUD_register_card(s->audio, s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);
register_savevm(s->name, tsc2102_iid ++, 0,
tsc210x_save, tsc210x_load, s);
register_savevm(s->name, -1, 0, tsc210x_save, tsc210x_load, s);
return &s->chip;
}

View File

@ -876,8 +876,6 @@ static int menelaus_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int menelaus_iid = 0;
i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq)
{
struct menelaus_s *s = (struct menelaus_s *)
@ -894,8 +892,7 @@ i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq)
menelaus_reset(&s->i2c);
register_savevm("menelaus", menelaus_iid ++,
0, menelaus_save, menelaus_load, s);
register_savevm("menelaus", -1, 0, menelaus_save, menelaus_load, s);
return &s->i2c;
}

View File

@ -646,8 +646,6 @@ static int wm8750_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static int wm8750_iid = 0;
i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio)
{
struct wm8750_s *s = (struct wm8750_s *)
@ -659,7 +657,7 @@ i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio)
AUD_register_card(audio, CODEC, &s->card);
wm8750_reset(&s->i2c);
register_savevm(CODEC, wm8750_iid ++, 0, wm8750_save, wm8750_load, s);
register_savevm(CODEC, -1, 0, wm8750_save, wm8750_load, s);
return &s->i2c;
}

11
vl.c
View File

@ -6060,6 +6060,8 @@ typedef struct SaveStateEntry {
static SaveStateEntry *first_se;
/* TODO: Individual devices generally have very little idea about the rest
of the system, so instance_id should be removed/replaced. */
int register_savevm(const char *idstr,
int instance_id,
int version_id,
@ -6073,7 +6075,7 @@ int register_savevm(const char *idstr,
if (!se)
return -1;
pstrcpy(se->idstr, sizeof(se->idstr), idstr);
se->instance_id = instance_id;
se->instance_id = (instance_id == -1) ? 0 : instance_id;
se->version_id = version_id;
se->save_state = save_state;
se->load_state = load_state;
@ -6082,8 +6084,13 @@ int register_savevm(const char *idstr,
/* add at the end of list */
pse = &first_se;
while (*pse != NULL)
while (*pse != NULL) {
if (instance_id == -1
&& strcmp(se->idstr, (*pse)->idstr) == 0
&& se->instance_id <= (*pse)->instance_id)
se->instance_id = (*pse)->instance_id + 1;
pse = &(*pse)->next;
}
*pse = se;
return 0;
}