* 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"
return 0;
}
-void tmp105_reset(i2c_slave *i2c)
+static void tmp105_reset(i2c_slave *i2c)
{
TMP105State *s = (TMP105State *) 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)