From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KDnSA-00045c-Hb for qemu-devel@nongnu.org; Tue, 01 Jul 2008 17:31:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KDnS9-00044Z-NV for qemu-devel@nongnu.org; Tue, 01 Jul 2008 17:31:58 -0400 Received: from [199.232.76.173] (port=57153 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KDnS9-00044M-GC for qemu-devel@nongnu.org; Tue, 01 Jul 2008 17:31:57 -0400 Received: from savannah.gnu.org ([199.232.41.3]:55076 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KDnS9-0005En-4d for qemu-devel@nongnu.org; Tue, 01 Jul 2008 17:31:57 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KDnS8-00041q-CF for qemu-devel@nongnu.org; Tue, 01 Jul 2008 21:31:56 +0000 Received: from pbrook by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KDnS7-00041V-NK for qemu-devel@nongnu.org; Tue, 01 Jul 2008 21:31:56 +0000 MIME-Version: 1.0 Errors-To: pbrook Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Paul Brook Message-Id: Date: Tue, 01 Jul 2008 21:31:55 +0000 Subject: [Qemu-devel] [4818] Remove duplicate device index calculations. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4818 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4818 Author: pbrook Date: 2008-07-01 21:31:54 +0000 (Tue, 01 Jul 2008) Log Message: ----------- Remove duplicate device index calculations. Modified Paths: -------------- trunk/hw/ads7846.c trunk/hw/ide.c trunk/hw/lm832x.c trunk/hw/max111x.c trunk/hw/max7310.c trunk/hw/nand.c trunk/hw/tmp105.c trunk/hw/tsc2005.c trunk/hw/tsc210x.c trunk/hw/twl92230.c trunk/hw/wm8750.c trunk/vl.c Modified: trunk/hw/ads7846.c =================================================================== --- trunk/hw/ads7846.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/ads7846.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -140,8 +140,6 @@ 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 @@ 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; } Modified: trunk/hw/ide.c =================================================================== --- trunk/hw/ide.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/ide.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -3596,8 +3596,6 @@ 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 @@ 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; } Modified: trunk/hw/lm832x.c =================================================================== --- trunk/hw/lm832x.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/lm832x.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -490,8 +490,6 @@ 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 @@ 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; } Modified: trunk/hw/max111x.c =================================================================== --- trunk/hw/max111x.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/max111x.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -121,8 +121,6 @@ return 0; } -static int max111x_iid = 0; - static struct max111x_s *max111x_init(qemu_irq cb) { struct max111x_s *s; @@ -143,8 +141,7 @@ 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; } Modified: trunk/hw/max7310.c =================================================================== --- trunk/hw/max7310.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/max7310.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -177,8 +177,6 @@ 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 @@ 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; } Modified: trunk/hw/nand.c =================================================================== --- trunk/hw/nand.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/nand.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -319,8 +319,6 @@ 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 @@ 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; } Modified: trunk/hw/tmp105.c =================================================================== --- trunk/hw/tmp105.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/tmp105.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -228,8 +228,6 @@ 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 @@ 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; } Modified: trunk/hw/tsc2005.c =================================================================== --- trunk/hw/tsc2005.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/tsc2005.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -520,8 +520,6 @@ return 0; } -static int tsc2005_iid = 0; - void *tsc2005_init(qemu_irq pintdav) { struct tsc2005_state_s *s; @@ -551,8 +549,7 @@ "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; } Modified: trunk/hw/tsc210x.c =================================================================== --- trunk/hw/tsc210x.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/tsc210x.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -1107,8 +1107,6 @@ 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 @@ 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 @@ 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; } Modified: trunk/hw/twl92230.c =================================================================== --- trunk/hw/twl92230.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/twl92230.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -876,8 +876,6 @@ 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 @@ 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; } Modified: trunk/hw/wm8750.c =================================================================== --- trunk/hw/wm8750.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/hw/wm8750.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -646,8 +646,6 @@ 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 @@ 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; } Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-07-01 20:01:19 UTC (rev 4817) +++ trunk/vl.c 2008-07-01 21:31:54 UTC (rev 4818) @@ -6060,6 +6060,8 @@ 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 @@ 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 @@ /* 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; }