qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [4818] Remove duplicate device index calculations.


From: Paul Brook
Subject: [Qemu-devel] [4818] Remove duplicate device index calculations.
Date: Tue, 01 Jul 2008 21:31:55 +0000

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;
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]