diff options
Diffstat (limited to 'hw/tmp105.c')
-rw-r--r-- | hw/tmp105.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/hw/tmp105.c b/hw/tmp105.c index d6ab2c35b0..0877e126fc 100644 --- a/hw/tmp105.c +++ b/hw/tmp105.c @@ -22,7 +22,7 @@ #include "hw.h" #include "i2c.h" -struct tmp105_s { +typedef struct { i2c_slave i2c; int len; uint8_t buf[2]; @@ -34,14 +34,14 @@ struct tmp105_s { int16_t limit[2]; int faults; int alarm; -}; +} TMP105State; -static void tmp105_interrupt_update(struct tmp105_s *s) +static void tmp105_interrupt_update(TMP105State *s) { qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */ } -static void tmp105_alarm_update(struct tmp105_s *s) +static void tmp105_alarm_update(TMP105State *s) { if ((s->config >> 0) & 1) { /* SD */ if ((s->config >> 7) & 1) /* OS */ @@ -68,7 +68,7 @@ static void tmp105_alarm_update(struct tmp105_s *s) /* Units are 0.001 centigrades relative to 0 C. */ void tmp105_set(i2c_slave *i2c, int temp) { - struct tmp105_s *s = (struct tmp105_s *) i2c; + TMP105State *s = (TMP105State *) i2c; if (temp >= 128000 || temp < -128000) { fprintf(stderr, "%s: values is out of range (%i.%03i C)\n", @@ -83,7 +83,7 @@ void tmp105_set(i2c_slave *i2c, int temp) static const int tmp105_faultq[4] = { 1, 2, 4, 6 }; -static void tmp105_read(struct tmp105_s *s) +static void tmp105_read(TMP105State *s) { s->len = 0; @@ -115,7 +115,7 @@ static void tmp105_read(struct tmp105_s *s) } } -static void tmp105_write(struct tmp105_s *s) +static void tmp105_write(TMP105State *s) { switch (s->pointer & 3) { case 0: /* Temperature */ @@ -141,7 +141,7 @@ static void tmp105_write(struct tmp105_s *s) static int tmp105_rx(i2c_slave *i2c) { - struct tmp105_s *s = (struct tmp105_s *) i2c; + TMP105State *s = (TMP105State *) i2c; if (s->len < 2) return s->buf[s->len ++]; @@ -151,7 +151,7 @@ static int tmp105_rx(i2c_slave *i2c) static int tmp105_tx(i2c_slave *i2c, uint8_t data) { - struct tmp105_s *s = (struct tmp105_s *) i2c; + TMP105State *s = (TMP105State *) i2c; if (!s->len ++) s->pointer = data; @@ -166,7 +166,7 @@ static int tmp105_tx(i2c_slave *i2c, uint8_t data) static void tmp105_event(i2c_slave *i2c, enum i2c_event event) { - struct tmp105_s *s = (struct tmp105_s *) i2c; + TMP105State *s = (TMP105State *) i2c; if (event == I2C_START_RECV) tmp105_read(s); @@ -176,7 +176,7 @@ static void tmp105_event(i2c_slave *i2c, enum i2c_event event) static void tmp105_save(QEMUFile *f, void *opaque) { - struct tmp105_s *s = (struct tmp105_s *) opaque; + TMP105State *s = (TMP105State *) opaque; qemu_put_byte(f, s->len); qemu_put_8s(f, &s->buf[0]); @@ -195,7 +195,7 @@ static void tmp105_save(QEMUFile *f, void *opaque) static int tmp105_load(QEMUFile *f, void *opaque, int version_id) { - struct tmp105_s *s = (struct tmp105_s *) opaque; + TMP105State *s = (TMP105State *) opaque; s->len = qemu_get_byte(f); qemu_get_8s(f, &s->buf[0]); @@ -216,7 +216,7 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id) void tmp105_reset(i2c_slave *i2c) { - struct tmp105_s *s = (struct tmp105_s *) i2c; + TMP105State *s = (TMP105State *) i2c; s->temperature = 0; s->pointer = 0; @@ -229,8 +229,8 @@ void tmp105_reset(i2c_slave *i2c) struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm) { - struct tmp105_s *s = (struct tmp105_s *) - i2c_slave_init(bus, 0, sizeof(struct tmp105_s)); + TMP105State *s = (TMP105State *) + i2c_slave_init(bus, 0, sizeof(TMP105State)); s->i2c.event = tmp105_event; s->i2c.recv = tmp105_rx; |