linux-user: fix ppc target_stat64 st_blocks layout
[qemu] / hw / tmp105.c
index 0877e12..0113f8d 100644 (file)
@@ -15,8 +15,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "hw.h"
@@ -214,7 +213,7 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-void tmp105_reset(i2c_slave *i2c)
+static void tmp105_reset(i2c_slave *i2c)
 {
     TMP105State *s = (TMP105State *) i2c;
 
@@ -227,19 +226,30 @@ void tmp105_reset(i2c_slave *i2c)
     tmp105_interrupt_update(s);
 }
 
-struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm)
+static int tmp105_init(i2c_slave *i2c)
 {
-    TMP105State *s = (TMP105State *)
-            i2c_slave_init(bus, 0, sizeof(TMP105State));
+    TMP105State *s = FROM_I2C_SLAVE(TMP105State, i2c);
 
-    s->i2c.event = tmp105_event;
-    s->i2c.recv = tmp105_rx;
-    s->i2c.send = tmp105_tx;
-    s->pin = alarm;
+    qdev_init_gpio_out(&i2c->qdev, &s->pin, 1);
 
     tmp105_reset(&s->i2c);
 
     register_savevm("TMP105", -1, 0, tmp105_save, tmp105_load, s);
+    return 0;
+}
+
+static I2CSlaveInfo tmp105_info = {
+    .qdev.name = "tmp105",
+    .qdev.size = sizeof(TMP105State),
+    .init = tmp105_init,
+    .event = tmp105_event,
+    .recv = tmp105_rx,
+    .send = tmp105_tx
+};
 
-    return &s->i2c;
+static void tmp105_register_devices(void)
+{
+    i2c_register_slave(&tmp105_info);
 }
+
+device_init(tmp105_register_devices)