* [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1
@ 2014-01-31 14:34 Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus Andreas Färber
` (12 more replies)
0 siblings, 13 replies; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Anthony Liguori
Hello,
This series prepares for converting I2C to QOM realize.
Didn't finish that so far, but I'd like to apply this to qom-next before it
starts to conflict.
Regards,
Andreas
Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Peter Maydell <peter.maydell@linaro.org>
Andreas Färber (11):
i2c: Rename i2c_bus to I2CBus
pxa2xx: QOM'ify I2C slave
tosa: QOM'ify DAC
z2: QOM'ify AER915
wm8750: QOM'ify
ssd0303: QOM'ify
max7310: QOM'ify
lm832x: QOM'ify
ds1338: QOM'ify
twl92230: QOM'ify
i2c: Drop FROM_I2C_SLAVE() macro
hw/acpi/piix4.c | 6 +++---
hw/arm/exynos4210.c | 2 +-
hw/arm/musicpal.c | 4 ++--
hw/arm/nseries.c | 2 +-
hw/arm/pxa2xx.c | 44 ++++++++++++++++++++++++++++----------------
hw/arm/realview.c | 4 ++--
hw/arm/spitz.c | 2 +-
hw/arm/stellaris.c | 8 ++++----
hw/arm/tosa.c | 18 ++++++++++++------
hw/arm/versatilepb.c | 4 ++--
hw/arm/z2.c | 20 +++++++++++++-------
hw/audio/wm8750.c | 33 ++++++++++++++++++++-------------
hw/display/ssd0303.c | 18 ++++++++++++------
hw/gpio/max7310.c | 23 ++++++++++++++---------
hw/i2c/bitbang_i2c.c | 6 +++---
hw/i2c/bitbang_i2c.h | 2 +-
hw/i2c/core.c | 32 ++++++++++++++++----------------
hw/i2c/exynos4210_i2c.c | 2 +-
hw/i2c/omap_i2c.c | 4 ++--
hw/i2c/pm_smbus.c | 2 +-
hw/i2c/smbus.c | 18 +++++++++---------
hw/i2c/smbus_eeprom.c | 2 +-
hw/i2c/smbus_ich9.c | 2 +-
hw/i2c/versatile_i2c.c | 2 +-
hw/i386/pc_piix.c | 2 +-
hw/input/lm832x.c | 22 +++++++++++++---------
hw/isa/vt82c686.c | 4 ++--
hw/mips/mips_fulong2e.c | 2 +-
hw/mips/mips_malta.c | 2 +-
hw/timer/ds1338.c | 21 +++++++++++++--------
hw/timer/twl92230.c | 35 +++++++++++++++++++++--------------
include/hw/arm/exynos4210.h | 2 +-
include/hw/arm/omap.h | 2 +-
include/hw/arm/pxa.h | 2 +-
include/hw/i2c/i2c.h | 20 +++++++++-----------
include/hw/i2c/pm_smbus.h | 2 +-
include/hw/i2c/smbus.h | 20 ++++++++++----------
include/hw/i386/ich9.h | 2 +-
include/hw/i386/pc.h | 6 +++---
include/hw/isa/vt82c686.h | 4 ++--
include/qemu/typedefs.h | 2 +-
41 files changed, 233 insertions(+), 177 deletions(-)
--
1.8.4.5
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:24 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave Andreas Färber
` (11 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Evgeny Voevodin, Michael S. Tsirkin,
Igor Mitsyanko, Jan Kiszka, Dmitry Solodkiy, Anthony Liguori,
Maksim Kozlov, Andreas Färber, Aurelien Jarno
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/acpi/piix4.c | 6 +++---
hw/arm/exynos4210.c | 2 +-
hw/arm/musicpal.c | 4 ++--
hw/arm/nseries.c | 2 +-
hw/arm/pxa2xx.c | 6 +++---
hw/arm/realview.c | 4 ++--
hw/arm/spitz.c | 2 +-
hw/arm/stellaris.c | 8 ++++----
hw/arm/tosa.c | 2 +-
hw/arm/versatilepb.c | 4 ++--
hw/arm/z2.c | 2 +-
hw/i2c/bitbang_i2c.c | 6 +++---
hw/i2c/bitbang_i2c.h | 2 +-
hw/i2c/core.c | 32 ++++++++++++++++----------------
hw/i2c/exynos4210_i2c.c | 2 +-
hw/i2c/omap_i2c.c | 4 ++--
hw/i2c/pm_smbus.c | 2 +-
hw/i2c/smbus.c | 18 +++++++++---------
hw/i2c/smbus_eeprom.c | 2 +-
hw/i2c/smbus_ich9.c | 2 +-
hw/i2c/versatile_i2c.c | 2 +-
hw/i386/pc_piix.c | 2 +-
hw/isa/vt82c686.c | 4 ++--
hw/mips/mips_fulong2e.c | 2 +-
hw/mips/mips_malta.c | 2 +-
include/hw/arm/exynos4210.h | 2 +-
include/hw/arm/omap.h | 2 +-
include/hw/arm/pxa.h | 2 +-
include/hw/i2c/i2c.h | 16 ++++++++--------
include/hw/i2c/pm_smbus.h | 2 +-
include/hw/i2c/smbus.h | 20 ++++++++++----------
include/hw/i386/ich9.h | 2 +-
include/hw/i386/pc.h | 6 +++---
include/hw/isa/vt82c686.h | 4 ++--
include/qemu/typedefs.h | 2 +-
35 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 5d55a3c..33e812d 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -517,9 +517,9 @@ Object *piix4_pm_find(void)
return o;
}
-i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
- qemu_irq sci_irq, qemu_irq smi_irq,
- int kvm_enabled, FWCfgState *fw_cfg)
+I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+ qemu_irq sci_irq, qemu_irq smi_irq,
+ int kvm_enabled, FWCfgState *fw_cfg)
{
DeviceState *dev;
PIIX4PMState *s;
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 4ebb938..9f137e9 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -326,7 +326,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
busdev = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(busdev, 0, i2c_irq);
sysbus_mmio_map(busdev, 0, addr);
- s->i2c_if[n] = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
+ s->i2c_if[n] = (I2CBus *)qdev_get_child_bus(dev, "i2c");
}
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 023e875..50a3b8f 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1593,7 +1593,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
DeviceState *key_dev;
DeviceState *wm8750_dev;
SysBusDevice *s;
- i2c_bus *i2c;
+ I2CBus *i2c;
int i;
unsigned long flash_size;
DriveInfo *dinfo;
@@ -1687,7 +1687,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
- i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
+ i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple(TYPE_MUSICPAL_KEY, -1, NULL);
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 9ef31ca..c28f895 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -202,7 +202,7 @@ static void n8x0_i2c_setup(struct n800_s *s)
{
DeviceState *dev;
qemu_irq tmp_irq = qdev_get_gpio_in(s->mpu->gpio, N8X0_TMP105_GPIO);
- i2c_bus *i2c = omap_i2c_bus(s->mpu->i2c[0]);
+ I2CBus *i2c = omap_i2c_bus(s->mpu->i2c[0]);
/* Attach a menelaus PM chip */
dev = i2c_create_slave(i2c, "twl92230", N8X0_MENELAUS_ADDR);
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 02b7016..daf60e8 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1238,7 +1238,7 @@ struct PXA2xxI2CState {
MemoryRegion iomem;
PXA2xxI2CSlaveState *slave;
- i2c_bus *bus;
+ I2CBus *bus;
qemu_irq irq;
uint32_t offset;
uint32_t region_size;
@@ -1482,7 +1482,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
DeviceState *dev;
SysBusDevice *i2c_dev;
PXA2xxI2CState *s;
- i2c_bus *i2cbus;
+ I2CBus *i2cbus;
dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
qdev_prop_set_uint32(dev, "size", region_size + 1);
@@ -1518,7 +1518,7 @@ static int pxa2xx_i2c_initfn(SysBusDevice *sbd)
return 0;
}
-i2c_bus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
+I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
{
return s->bus;
}
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 8d845dd..6ef7646 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -60,7 +60,7 @@ static void realview_init(QEMUMachineInitArgs *args,
qemu_irq mmc_irq[2];
PCIBus *pci_bus = NULL;
NICInfo *nd;
- i2c_bus *i2c;
+ I2CBus *i2c;
int n;
int done_nic = 0;
qemu_irq cpu_irq[4];
@@ -255,7 +255,7 @@ static void realview_init(QEMUMachineInitArgs *args,
}
dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
- i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
+ i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
i2c_create_slave(i2c, "ds1338", 0x68);
/* Memory map for RealView Emulation Baseboard: */
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index ba17283..2decff1 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -734,7 +734,7 @@ static void spitz_wm8750_addr(void *opaque, int line, int level)
static void spitz_i2c_setup(PXA2xxState *cpu)
{
/* Attach the CPU on one end of our I2C bus. */
- i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+ I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
DeviceState *wm;
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 3170d69..d6cc77b 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -692,7 +692,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
typedef struct {
SysBusDevice parent_obj;
- i2c_bus *bus;
+ I2CBus *bus;
qemu_irq irq;
MemoryRegion iomem;
uint32_t msa;
@@ -868,7 +868,7 @@ static int stellaris_i2c_init(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
stellaris_i2c_state *s = STELLARIS_I2C(dev);
- i2c_bus *bus;
+ I2CBus *bus;
sysbus_init_irq(sbd, &s->irq);
bus = i2c_init_bus(dev, "i2c");
@@ -1213,7 +1213,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
qemu_irq adc;
int sram_size;
int flash_size;
- i2c_bus *i2c;
+ I2CBus *i2c;
DeviceState *dev;
int i;
int j;
@@ -1256,7 +1256,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
if (board->dc2 & (1 << 12)) {
dev = sysbus_create_simple(TYPE_STELLARIS_I2C, 0x40020000, pic[8]);
- i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
+ i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
if (board->peripherals & BP_OLED_I2C) {
i2c_create_slave(i2c, "ssd0303", 0x3d);
}
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index c00d8c2..dd224d3 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -194,7 +194,7 @@ static int tosa_dac_init(I2CSlave *i2c)
static void tosa_tg_init(PXA2xxState *cpu)
{
- i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+ I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
i2c_create_slave(bus, "tosa_dac", DAC_BASE);
ssi_create_slave(cpu->ssp[1], "tosa-ssp");
}
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index aef2bde..e5493b4 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -185,7 +185,7 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id)
DeviceState *pl041;
PCIBus *pci_bus;
NICInfo *nd;
- i2c_bus *i2c;
+ I2CBus *i2c;
int n;
int done_smc = 0;
DriveInfo *dinfo;
@@ -288,7 +288,7 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id)
sysbus_create_simple("pl031", 0x101e8000, pic[10]);
dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
- i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
+ i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
i2c_create_slave(i2c, "ds1338", 0x68);
/* Add PL041 AACI Interface to the LM4549 codec */
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 97367b1..97ec381 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -308,7 +308,7 @@ static void z2_init(QEMUMachineInitArgs *args)
DriveInfo *dinfo;
int be;
void *z2_lcd;
- i2c_bus *bus;
+ I2CBus *bus;
DeviceState *wm;
if (!cpu_model) {
diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
index ca59456..6d1bb03 100644
--- a/hw/i2c/bitbang_i2c.c
+++ b/hw/i2c/bitbang_i2c.c
@@ -46,7 +46,7 @@ typedef enum bitbang_i2c_state {
} bitbang_i2c_state;
struct bitbang_i2c_interface {
- i2c_bus *bus;
+ I2CBus *bus;
bitbang_i2c_state state;
int last_data;
int last_clock;
@@ -170,7 +170,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
abort();
}
-bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus)
+bitbang_i2c_interface *bitbang_i2c_init(I2CBus *bus)
{
bitbang_i2c_interface *s;
@@ -213,7 +213,7 @@ static int gpio_i2c_init(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
GPIOI2CState *s = GPIO_I2C(dev);
- i2c_bus *bus;
+ I2CBus *bus;
memory_region_init(&s->dummy_iomem, OBJECT(s), "gpio_i2c", 0);
sysbus_init_mmio(sbd, &s->dummy_iomem);
diff --git a/hw/i2c/bitbang_i2c.h b/hw/i2c/bitbang_i2c.h
index 2866ac3..3a7126d 100644
--- a/hw/i2c/bitbang_i2c.h
+++ b/hw/i2c/bitbang_i2c.h
@@ -8,7 +8,7 @@ typedef struct bitbang_i2c_interface bitbang_i2c_interface;
#define BITBANG_I2C_SDA 0
#define BITBANG_I2C_SCL 1
-bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus);
+bitbang_i2c_interface *bitbang_i2c_init(I2CBus *bus);
int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level);
#endif
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index c97e7f7..efd8b4f 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -9,7 +9,7 @@
#include "hw/i2c/i2c.h"
-struct i2c_bus
+struct I2CBus
{
BusState qbus;
I2CSlave *current_dev;
@@ -23,24 +23,24 @@ static Property i2c_props[] = {
};
#define TYPE_I2C_BUS "i2c-bus"
-#define I2C_BUS(obj) OBJECT_CHECK(i2c_bus, (obj), TYPE_I2C_BUS)
+#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
static const TypeInfo i2c_bus_info = {
.name = TYPE_I2C_BUS,
.parent = TYPE_BUS,
- .instance_size = sizeof(i2c_bus),
+ .instance_size = sizeof(I2CBus),
};
static void i2c_bus_pre_save(void *opaque)
{
- i2c_bus *bus = opaque;
+ I2CBus *bus = opaque;
bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
}
static int i2c_bus_post_load(void *opaque, int version_id)
{
- i2c_bus *bus = opaque;
+ I2CBus *bus = opaque;
/* The bus is loaded before attached devices, so load and save the
current device id. Devices will check themselves as loaded. */
@@ -56,15 +56,15 @@ static const VMStateDescription vmstate_i2c_bus = {
.pre_save = i2c_bus_pre_save,
.post_load = i2c_bus_post_load,
.fields = (VMStateField []) {
- VMSTATE_UINT8(saved_address, i2c_bus),
+ VMSTATE_UINT8(saved_address, I2CBus),
VMSTATE_END_OF_LIST()
}
};
/* Create a new I2C bus. */
-i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)
+I2CBus *i2c_init_bus(DeviceState *parent, const char *name)
{
- i2c_bus *bus;
+ I2CBus *bus;
bus = I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name));
vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
@@ -77,14 +77,14 @@ void i2c_set_slave_address(I2CSlave *dev, uint8_t address)
}
/* Return nonzero if bus is busy. */
-int i2c_bus_busy(i2c_bus *bus)
+int i2c_bus_busy(I2CBus *bus)
{
return bus->current_dev != NULL;
}
/* Returns non-zero if the address is not valid. */
/* TODO: Make this handle multiple masters. */
-int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv)
+int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
{
BusChild *kid;
I2CSlave *slave = NULL;
@@ -113,7 +113,7 @@ int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv)
return 0;
}
-void i2c_end_transfer(i2c_bus *bus)
+void i2c_end_transfer(I2CBus *bus)
{
I2CSlave *dev = bus->current_dev;
I2CSlaveClass *sc;
@@ -130,7 +130,7 @@ void i2c_end_transfer(i2c_bus *bus)
bus->current_dev = NULL;
}
-int i2c_send(i2c_bus *bus, uint8_t data)
+int i2c_send(I2CBus *bus, uint8_t data)
{
I2CSlave *dev = bus->current_dev;
I2CSlaveClass *sc;
@@ -147,7 +147,7 @@ int i2c_send(i2c_bus *bus, uint8_t data)
return -1;
}
-int i2c_recv(i2c_bus *bus)
+int i2c_recv(I2CBus *bus)
{
I2CSlave *dev = bus->current_dev;
I2CSlaveClass *sc;
@@ -164,7 +164,7 @@ int i2c_recv(i2c_bus *bus)
return -1;
}
-void i2c_nack(i2c_bus *bus)
+void i2c_nack(I2CBus *bus)
{
I2CSlave *dev = bus->current_dev;
I2CSlaveClass *sc;
@@ -182,7 +182,7 @@ void i2c_nack(i2c_bus *bus)
static int i2c_slave_post_load(void *opaque, int version_id)
{
I2CSlave *dev = opaque;
- i2c_bus *bus;
+ I2CBus *bus;
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if (bus->saved_address == dev->address) {
bus->current_dev = dev;
@@ -210,7 +210,7 @@ static int i2c_slave_qdev_init(DeviceState *dev)
return sc->init(s);
}
-DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
+DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
{
DeviceState *dev;
diff --git a/hw/i2c/exynos4210_i2c.c b/hw/i2c/exynos4210_i2c.c
index ce5f849..fb99dfd 100644
--- a/hw/i2c/exynos4210_i2c.c
+++ b/hw/i2c/exynos4210_i2c.c
@@ -83,7 +83,7 @@ typedef struct Exynos4210I2CState {
SysBusDevice parent_obj;
MemoryRegion iomem;
- i2c_bus *bus;
+ I2CBus *bus;
qemu_irq irq;
uint8_t i2ccon;
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
index 2d8e2b7..d63278d 100644
--- a/hw/i2c/omap_i2c.c
+++ b/hw/i2c/omap_i2c.c
@@ -30,7 +30,7 @@ typedef struct OMAPI2CState {
MemoryRegion iomem;
qemu_irq irq;
qemu_irq drq[2];
- i2c_bus *bus;
+ I2CBus *bus;
uint8_t revision;
void *iclk;
@@ -491,7 +491,7 @@ static void omap_i2c_register_types(void)
type_register_static(&omap_i2c_info);
}
-i2c_bus *omap_i2c_bus(DeviceState *omap_i2c)
+I2CBus *omap_i2c_bus(DeviceState *omap_i2c)
{
OMAPI2CState *s = OMAP_I2C(omap_i2c);
return s->bus;
diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index c98e447..9f50067 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -59,7 +59,7 @@ static void smb_transaction(PMSMBus *s)
uint8_t read = s->smb_addr & 0x01;
uint8_t cmd = s->smb_cmd;
uint8_t addr = s->smb_addr >> 1;
- i2c_bus *bus = s->smbus;
+ I2CBus *bus = s->smbus;
SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot);
/* Transaction isn't exec if STS_DEV_ERR bit set */
diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 25d2d04..3febf3c 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -208,13 +208,13 @@ static int smbus_device_init(I2CSlave *i2c)
}
/* Master device commands. */
-void smbus_quick_command(i2c_bus *bus, uint8_t addr, int read)
+void smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
{
i2c_start_transfer(bus, addr, read);
i2c_end_transfer(bus);
}
-uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr)
+uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr)
{
uint8_t data;
@@ -225,14 +225,14 @@ uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr)
return data;
}
-void smbus_send_byte(i2c_bus *bus, uint8_t addr, uint8_t data)
+void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
{
i2c_start_transfer(bus, addr, 0);
i2c_send(bus, data);
i2c_end_transfer(bus);
}
-uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command)
+uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
{
uint8_t data;
i2c_start_transfer(bus, addr, 0);
@@ -244,7 +244,7 @@ uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command)
return data;
}
-void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data)
+void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
{
i2c_start_transfer(bus, addr, 0);
i2c_send(bus, command);
@@ -252,7 +252,7 @@ void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data)
i2c_end_transfer(bus);
}
-uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command)
+uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
{
uint16_t data;
i2c_start_transfer(bus, addr, 0);
@@ -265,7 +265,7 @@ uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command)
return data;
}
-void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data)
+void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)
{
i2c_start_transfer(bus, addr, 0);
i2c_send(bus, command);
@@ -274,7 +274,7 @@ void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data
i2c_end_transfer(bus);
}
-int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data)
+int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
{
int len;
int i;
@@ -292,7 +292,7 @@ int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data)
return len;
}
-void smbus_write_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data,
+void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
int len)
{
int i;
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 0218f8a..86f35c1 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -139,7 +139,7 @@ static void smbus_eeprom_register_types(void)
type_init(smbus_eeprom_register_types)
-void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
+void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int eeprom_spd_size)
{
int i;
diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index 8d47eaf..295b62e 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -108,7 +108,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
dc->cannot_instantiate_with_device_add_yet = true;
}
-i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
+I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
{
PCIDevice *d =
pci_create_simple_multifunction(bus, devfn, true, TYPE_ICH9_SMB_DEVICE);
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
index 02e9f17..3c0c2c1 100644
--- a/hw/i2c/versatile_i2c.c
+++ b/hw/i2c/versatile_i2c.c
@@ -81,7 +81,7 @@ static int versatile_i2c_init(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
VersatileI2CState *s = VERSATILE_I2C(dev);
- i2c_bus *bus;
+ I2CBus *bus;
bus = i2c_init_bus(dev, "i2c");
s->bitbang = bitbang_i2c_init(bus);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a327d71..3639a6d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -236,7 +236,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
}
if (pci_enabled && acpi_enabled) {
- i2c_bus *smbus;
+ I2CBus *smbus;
smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
/* TODO: Populate SPD eeprom data. */
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index e639357..1a93afd 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -369,8 +369,8 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
return 0;
}
-i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
- qemu_irq sci_irq)
+I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+ qemu_irq sci_irq)
{
PCIDevice *dev;
VT686PMState *s;
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 9ef3a97..e1551aa 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -276,7 +276,7 @@ static void mips_fulong2e_init(QEMUMachineInitArgs *args)
qemu_irq *cpu_exit_irq;
PCIBus *pci_bus;
ISABus *isa_bus;
- i2c_bus *smbus;
+ I2CBus *smbus;
int i;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
MIPSCPU *cpu;
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 05c8771..ac5ec44 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -900,7 +900,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
qemu_irq *isa_irq;
qemu_irq *cpu_exit_irq;
int piix4_devfn;
- i2c_bus *smbus;
+ I2CBus *smbus;
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
index bb9a1dd..5c1820f 100644
--- a/include/hw/arm/exynos4210.h
+++ b/include/hw/arm/exynos4210.h
@@ -97,7 +97,7 @@ typedef struct Exynos4210State {
MemoryRegion dram1_mem;
MemoryRegion boot_secondary;
MemoryRegion bootreg_mem;
- i2c_bus *i2c_if[EXYNOS4210_I2C_NUMBER];
+ I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
} Exynos4210State;
void exynos4210_write_secondary(ARMCPU *cpu,
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index 188cda8..b9655ee 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -765,7 +765,7 @@ void omap_mmc_handlers(struct omap_mmc_s *s, qemu_irq ro, qemu_irq cover);
void omap_mmc_enable(struct omap_mmc_s *s, int enable);
/* omap_i2c.c */
-i2c_bus *omap_i2c_bus(DeviceState *omap_i2c);
+I2CBus *omap_i2c_bus(DeviceState *omap_i2c);
# define cpu_is_omap310(cpu) (cpu->mpu_model == omap310)
# define cpu_is_omap1510(cpu) (cpu->mpu_model == omap1510)
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index 7ca330a..c507906 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -116,7 +116,7 @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp,
typedef struct PXA2xxI2CState PXA2xxI2CState;
PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
qemu_irq irq, uint32_t page_size);
-i2c_bus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
+I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
typedef struct PXA2xxI2SState PXA2xxI2SState;
typedef struct PXA2xxFIrState PXA2xxFIrState;
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 461392f..9df987b 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -50,18 +50,18 @@ struct I2CSlave
uint8_t address;
};
-i2c_bus *i2c_init_bus(DeviceState *parent, const char *name);
+I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
-int i2c_bus_busy(i2c_bus *bus);
-int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv);
-void i2c_end_transfer(i2c_bus *bus);
-void i2c_nack(i2c_bus *bus);
-int i2c_send(i2c_bus *bus, uint8_t data);
-int i2c_recv(i2c_bus *bus);
+int i2c_bus_busy(I2CBus *bus);
+int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv);
+void i2c_end_transfer(I2CBus *bus);
+void i2c_nack(I2CBus *bus);
+int i2c_send(I2CBus *bus, uint8_t data);
+int i2c_recv(I2CBus *bus);
#define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
-DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr);
+DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
/* wm8750.c */
void wm8750_data_req_set(DeviceState *dev,
diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h
index e3069bf..926603f 100644
--- a/include/hw/i2c/pm_smbus.h
+++ b/include/hw/i2c/pm_smbus.h
@@ -2,7 +2,7 @@
#define PM_SMBUS_H
typedef struct PMSMBus {
- i2c_bus *smbus;
+ I2CBus *smbus;
MemoryRegion io;
uint8_t smb_stat;
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index d764d75..63f0cc4 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -66,18 +66,18 @@ struct SMBusDevice {
};
/* Master device commands. */
-void smbus_quick_command(i2c_bus *bus, uint8_t addr, int read);
-uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr);
-void smbus_send_byte(i2c_bus *bus, uint8_t addr, uint8_t data);
-uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command);
-void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data);
-uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command);
-void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data);
-int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data);
-void smbus_write_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data,
+void smbus_quick_command(I2CBus *bus, uint8_t addr, int read);
+uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr);
+void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data);
+uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);
+void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data);
+uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command);
+void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data);
+int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
+void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
int len);
-void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
+void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
const uint8_t *eeprom_spd, int size);
#endif
diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
index 4a68b35..9e4a0e4 100644
--- a/include/hw/i386/ich9.h
+++ b/include/hw/i386/ich9.h
@@ -20,7 +20,7 @@ int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
void ich9_lpc_pm_init(PCIDevice *pci_lpc);
PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus);
-i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
+I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
#define ICH9_CC_SIZE (16 * 1024) /* 16KB */
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3e1e81b..9010246 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -165,9 +165,9 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
/* acpi_piix.c */
-i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
- qemu_irq sci_irq, qemu_irq smi_irq,
- int kvm_enabled, FWCfgState *fw_cfg);
+I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+ qemu_irq sci_irq, qemu_irq smi_irq,
+ int kvm_enabled, FWCfgState *fw_cfg);
void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
/* hpet.c */
diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index 6ef876d..471b5e9 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -5,7 +5,7 @@
ISABus *vt82c686b_init(PCIBus * bus, int devfn);
void vt82c686b_ac97_init(PCIBus *bus, int devfn);
void vt82c686b_mc97_init(PCIBus *bus, int devfn);
-i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
- qemu_irq sci_irq);
+I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+ qemu_irq sci_irq);
#endif
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 4524496..a2eb749 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -42,7 +42,7 @@ typedef struct QemuConsole QemuConsole;
typedef struct CharDriverState CharDriverState;
typedef struct MACAddr MACAddr;
typedef struct NetClientState NetClientState;
-typedef struct i2c_bus i2c_bus;
+typedef struct I2CBus I2CBus;
typedef struct ISABus ISABus;
typedef struct ISADevice ISADevice;
typedef struct SMBusDevice SMBusDevice;
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:35 ` Peter Crosthwaite
2014-02-09 12:56 ` Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC Andreas Färber
` (10 subsequent siblings)
12 siblings, 2 replies; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro and rename parent
field to assure we caught all.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/arm/pxa2xx.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index daf60e8..e5f1e10 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1222,8 +1222,14 @@ static const TypeInfo pxa2xx_rtc_sysbus_info = {
};
/* I2C Interface */
-typedef struct {
- I2CSlave i2c;
+
+#define TYPE_PXA2XX_I2C_SLAVE "pxa2xx-i2c-slave"
+#define PXA2XX_I2C_SLAVE(obj) \
+ OBJECT_CHECK(PXA2xxI2CSlaveState, (obj), TYPE_PXA2XX_I2C_SLAVE)
+
+typedef struct PXA2xxI2CSlaveState {
+ I2CSlave parent_obj;
+
PXA2xxI2CState *host;
} PXA2xxI2CSlaveState;
@@ -1268,7 +1274,7 @@ static void pxa2xx_i2c_update(PXA2xxI2CState *s)
/* These are only stubs now. */
static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
{
- PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+ PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
PXA2xxI2CState *s = slave->host;
switch (event) {
@@ -1292,10 +1298,12 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
static int pxa2xx_i2c_rx(I2CSlave *i2c)
{
- PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+ PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
PXA2xxI2CState *s = slave->host;
- if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
+
+ if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
return 0;
+ }
if (s->status & (1 << 0)) { /* RWM */
s->status |= 1 << 6; /* set ITE */
@@ -1307,10 +1315,12 @@ static int pxa2xx_i2c_rx(I2CSlave *i2c)
static int pxa2xx_i2c_tx(I2CSlave *i2c, uint8_t data)
{
- PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+ PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
PXA2xxI2CState *s = slave->host;
- if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
+
+ if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
return 1;
+ }
if (!(s->status & (1 << 0))) { /* RWM */
s->status |= 1 << 7; /* set IRF */
@@ -1325,6 +1335,7 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxI2CState *s = (PXA2xxI2CState *) opaque;
+ I2CSlave *slave;
addr -= s->offset;
switch (addr) {
@@ -1333,7 +1344,8 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
case ISR:
return s->status | (i2c_bus_busy(s->bus) << 2);
case ISAR:
- return s->slave->i2c.address;
+ slave = I2C_SLAVE(s->slave);
+ return slave->address;
case IDBR:
return s->data;
case IBMR:
@@ -1408,7 +1420,7 @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr,
break;
case ISAR:
- i2c_set_slave_address(&s->slave->i2c, value & 0x7f);
+ i2c_set_slave_address(I2C_SLAVE(s->slave), value & 0x7f);
break;
case IDBR:
@@ -1432,7 +1444,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c_slave = {
.minimum_version_id = 1,
.minimum_version_id_old = 1,
.fields = (VMStateField []) {
- VMSTATE_I2C_SLAVE(i2c, PXA2xxI2CSlaveState),
+ VMSTATE_I2C_SLAVE(parent_obj, PXA2xxI2CSlaveState),
VMSTATE_END_OF_LIST()
}
};
@@ -1470,7 +1482,7 @@ static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo pxa2xx_i2c_slave_info = {
- .name = "pxa2xx-i2c-slave",
+ .name = TYPE_PXA2XX_I2C_SLAVE,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(PXA2xxI2CSlaveState),
.class_init = pxa2xx_i2c_slave_class_init,
@@ -1496,8 +1508,8 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
s = PXA2XX_I2C(i2c_dev);
/* FIXME: Should the slave device really be on a separate bus? */
i2cbus = i2c_init_bus(dev, "dummy");
- dev = i2c_create_slave(i2cbus, "pxa2xx-i2c-slave", 0);
- s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
+ dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
+ s->slave = PXA2XX_I2C_SLAVE(dev);
s->slave->host = s;
return s;
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:37 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915 Andreas Färber
` (9 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/arm/tosa.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index dd224d3..2069f55 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -132,15 +132,20 @@ static int tosa_ssp_init(SSISlave *dev)
return 0;
}
+#define TYPE_TOSA_DAC "tosa_dac"
+#define TOSA_DAC(obj) OBJECT_CHECK(TosaDACState, (obj), TYPE_TOSA_DAC)
+
typedef struct {
- I2CSlave i2c;
+ I2CSlave parent_obj;
+
int len;
char buf[3];
} TosaDACState;
static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
{
- TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+ TosaDACState *s = TOSA_DAC(i2c);
+
s->buf[s->len] = data;
if (s->len ++ > 2) {
#ifdef VERBOSE
@@ -159,7 +164,8 @@ static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
static void tosa_dac_event(I2CSlave *i2c, enum i2c_event event)
{
- TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+ TosaDACState *s = TOSA_DAC(i2c);
+
s->len = 0;
switch (event) {
case I2C_START_SEND:
@@ -195,7 +201,7 @@ static int tosa_dac_init(I2CSlave *i2c)
static void tosa_tg_init(PXA2xxState *cpu)
{
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
- i2c_create_slave(bus, "tosa_dac", DAC_BASE);
+ i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE);
ssi_create_slave(cpu->ssp[1], "tosa-ssp");
}
@@ -271,7 +277,7 @@ static void tosa_dac_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo tosa_dac_info = {
- .name = "tosa_dac",
+ .name = TYPE_TOSA_DAC,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(TosaDACState),
.class_init = tosa_dac_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (2 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:38 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify Andreas Färber
` (8 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/arm/z2.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 97ec381..69c4d38 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -193,15 +193,20 @@ static const TypeInfo zipit_lcd_info = {
.class_init = zipit_lcd_class_init,
};
-typedef struct {
- I2CSlave i2c;
+#define TYPE_AER915 "aer915"
+#define AER915(obj) OBJECT_CHECK(AER915State, (obj), TYPE_AER915)
+
+typedef struct AER915State {
+ I2CSlave parent_obj;
+
int len;
uint8_t buf[3];
} AER915State;
static int aer915_send(I2CSlave *i2c, uint8_t data)
{
- AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+ AER915State *s = AER915(i2c);
+
s->buf[s->len] = data;
if (s->len++ > 2) {
DPRINTF("%s: message too long (%i bytes)\n",
@@ -219,7 +224,8 @@ static int aer915_send(I2CSlave *i2c, uint8_t data)
static void aer915_event(I2CSlave *i2c, enum i2c_event event)
{
- AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+ AER915State *s = AER915(i2c);
+
switch (event) {
case I2C_START_SEND:
s->len = 0;
@@ -238,8 +244,8 @@ static void aer915_event(I2CSlave *i2c, enum i2c_event event)
static int aer915_recv(I2CSlave *slave)
{
+ AER915State *s = AER915(slave);
int retval = 0x00;
- AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
switch (s->buf[0]) {
/* Return hardcoded battery voltage,
@@ -290,7 +296,7 @@ static void aer915_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo aer915_info = {
- .name = "aer915",
+ .name = TYPE_AER915,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(AER915State),
.class_init = aer915_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (3 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915 Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:41 ` Peter Crosthwaite
2014-02-09 13:10 ` Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify Andreas Färber
` (7 subsequent siblings)
12 siblings, 2 replies; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Vassili Karpov (malc), Andreas Färber, Gerd Hoffmann
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/audio/wm8750.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c
index 6b5a349..c18f245 100644
--- a/hw/audio/wm8750.c
+++ b/hw/audio/wm8750.c
@@ -23,8 +23,12 @@ typedef struct {
int dac_hz;
} WMRate;
-typedef struct {
- I2CSlave i2c;
+#define TYPE_WM8750 "wm8750"
+#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
+
+typedef struct WM8750State {
+ I2CSlave parent_obj;
+
uint8_t i2c_data[2];
int i2c_len;
QEMUSoundCard card;
@@ -256,7 +260,8 @@ static void wm8750_clk_update(WM8750State *s, int ext)
static void wm8750_reset(I2CSlave *i2c)
{
- WM8750State *s = (WM8750State *) i2c;
+ WM8750State *s = WM8750(i2c);
+
s->rate = &wm_rate_table[0];
s->enable = 0;
wm8750_clk_update(s, 1);
@@ -299,7 +304,7 @@ static void wm8750_reset(I2CSlave *i2c)
static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
{
- WM8750State *s = (WM8750State *) i2c;
+ WM8750State *s = WM8750(i2c);
switch (event) {
case I2C_START_SEND:
@@ -356,7 +361,7 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
static int wm8750_tx(I2CSlave *i2c, uint8_t data)
{
- WM8750State *s = (WM8750State *) i2c;
+ WM8750State *s = WM8750(i2c);
uint8_t cmd;
uint16_t value;
@@ -542,7 +547,7 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
break;
case WM8750_RESET: /* Reset */
- wm8750_reset(&s->i2c);
+ wm8750_reset(I2C_SLAVE(s));
break;
#ifdef VERBOSE
@@ -604,17 +609,17 @@ static const VMStateDescription vmstate_wm8750 = {
VMSTATE_UINT8(format, WM8750State),
VMSTATE_UINT8(power, WM8750State),
VMSTATE_UINT8(rate_vmstate, WM8750State),
- VMSTATE_I2C_SLAVE(i2c, WM8750State),
+ VMSTATE_I2C_SLAVE(parent_obj, WM8750State),
VMSTATE_END_OF_LIST()
}
};
static int wm8750_init(I2CSlave *i2c)
{
- WM8750State *s = FROM_I2C_SLAVE(WM8750State, i2c);
+ WM8750State *s = WM8750(i2c);
AUD_register_card(CODEC, &s->card);
- wm8750_reset(&s->i2c);
+ wm8750_reset(I2C_SLAVE(s));
return 0;
}
@@ -622,8 +627,9 @@ static int wm8750_init(I2CSlave *i2c)
#if 0
static void wm8750_fini(I2CSlave *i2c)
{
- WM8750State *s = (WM8750State *) i2c;
- wm8750_reset(&s->i2c);
+ WM8750State *s = WM8750(i2c);
+
+ wm8750_reset(I2C_SLAVE(s));
AUD_remove_card(&s->card);
g_free(s);
}
@@ -632,7 +638,8 @@ static void wm8750_fini(I2CSlave *i2c)
void wm8750_data_req_set(DeviceState *dev,
void (*data_req)(void *, int, int), void *opaque)
{
- WM8750State *s = FROM_I2C_SLAVE(WM8750State, I2C_SLAVE(dev));
+ WM8750State *s = WM8750(dev);
+
s->data_req = data_req;
s->opaque = opaque;
}
@@ -702,7 +709,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo wm8750_info = {
- .name = "wm8750",
+ .name = TYPE_WM8750,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(WM8750State),
.class_init = wm8750_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (4 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:42 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 07/11] max7310: QOM'ify Andreas Färber
` (6 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/display/ssd0303.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c
index beea5bf..89804e1 100644
--- a/hw/display/ssd0303.c
+++ b/hw/display/ssd0303.c
@@ -41,8 +41,12 @@ enum ssd0303_cmd {
SSD0303_CMD_SKIP1
};
+#define TYPE_SSD0303 "ssd0303"
+#define SSD0303(obj) OBJECT_CHECK(ssd0303_state, (obj), TYPE_SSD0303)
+
typedef struct {
- I2CSlave i2c;
+ I2CSlave parent_obj;
+
QemuConsole *con;
int row;
int col;
@@ -65,8 +69,9 @@ static int ssd0303_recv(I2CSlave *i2c)
static int ssd0303_send(I2CSlave *i2c, uint8_t data)
{
- ssd0303_state *s = (ssd0303_state *)i2c;
+ ssd0303_state *s = SSD0303(i2c);
enum ssd0303_cmd old_cmd_state;
+
switch (s->mode) {
case SSD0303_IDLE:
DPRINTF("byte 0x%02x\n", data);
@@ -175,7 +180,8 @@ static int ssd0303_send(I2CSlave *i2c, uint8_t data)
static void ssd0303_event(I2CSlave *i2c, enum i2c_event event)
{
- ssd0303_state *s = (ssd0303_state *)i2c;
+ ssd0303_state *s = SSD0303(i2c);
+
switch (event) {
case I2C_FINISH:
s->mode = SSD0303_IDLE;
@@ -279,7 +285,7 @@ static const VMStateDescription vmstate_ssd0303 = {
VMSTATE_UINT32(mode, ssd0303_state),
VMSTATE_UINT32(cmd_state, ssd0303_state),
VMSTATE_BUFFER(framebuffer, ssd0303_state),
- VMSTATE_I2C_SLAVE(i2c, ssd0303_state),
+ VMSTATE_I2C_SLAVE(parent_obj, ssd0303_state),
VMSTATE_END_OF_LIST()
}
};
@@ -291,7 +297,7 @@ static const GraphicHwOps ssd0303_ops = {
static int ssd0303_init(I2CSlave *i2c)
{
- ssd0303_state *s = FROM_I2C_SLAVE(ssd0303_state, i2c);
+ ssd0303_state *s = SSD0303(i2c);
s->con = graphic_console_init(DEVICE(i2c), &ssd0303_ops, s);
qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY);
@@ -311,7 +317,7 @@ static void ssd0303_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo ssd0303_info = {
- .name = "ssd0303",
+ .name = TYPE_SSD0303,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(ssd0303_state),
.class_init = ssd0303_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 07/11] max7310: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (5 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:43 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify Andreas Färber
` (5 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Replace FROM_I2C_SLAVE() usages with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/gpio/max7310.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index 59b2877..cfcd89c 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -9,8 +9,12 @@
#include "hw/i2c/i2c.h"
-typedef struct {
- I2CSlave i2c;
+#define TYPE_MAX7310 "max7310"
+#define MAX7310(obj) OBJECT_CHECK(MAX7310State, (obj), TYPE_MAX7310)
+
+typedef struct MAX7310State {
+ I2CSlave parent_obj;
+
int i2c_command_byte;
int len;
@@ -25,7 +29,8 @@ typedef struct {
static void max7310_reset(DeviceState *dev)
{
- MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, I2C_SLAVE(dev));
+ MAX7310State *s = MAX7310(dev);
+
s->level &= s->direction;
s->direction = 0xff;
s->polarity = 0xf0;
@@ -35,7 +40,7 @@ static void max7310_reset(DeviceState *dev)
static int max7310_rx(I2CSlave *i2c)
{
- MAX7310State *s = (MAX7310State *) i2c;
+ MAX7310State *s = MAX7310(i2c);
switch (s->command) {
case 0x00: /* Input port */
@@ -70,7 +75,7 @@ static int max7310_rx(I2CSlave *i2c)
static int max7310_tx(I2CSlave *i2c, uint8_t data)
{
- MAX7310State *s = (MAX7310State *) i2c;
+ MAX7310State *s = MAX7310(i2c);
uint8_t diff;
int line;
@@ -125,7 +130,7 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
static void max7310_event(I2CSlave *i2c, enum i2c_event event)
{
- MAX7310State *s = (MAX7310State *) i2c;
+ MAX7310State *s = MAX7310(i2c);
s->len = 0;
switch (event) {
@@ -156,7 +161,7 @@ static const VMStateDescription vmstate_max7310 = {
VMSTATE_UINT8(polarity, MAX7310State),
VMSTATE_UINT8(status, MAX7310State),
VMSTATE_UINT8(command, MAX7310State),
- VMSTATE_I2C_SLAVE(i2c, MAX7310State),
+ VMSTATE_I2C_SLAVE(parent_obj, MAX7310State),
VMSTATE_END_OF_LIST()
}
};
@@ -177,7 +182,7 @@ static void max7310_gpio_set(void *opaque, int line, int level)
* but also accepts sequences that are not SMBus so return an I2C device. */
static int max7310_init(I2CSlave *i2c)
{
- MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c);
+ MAX7310State *s = MAX7310(i2c);
qdev_init_gpio_in(&i2c->qdev, max7310_gpio_set, 8);
qdev_init_gpio_out(&i2c->qdev, s->handler, 8);
@@ -199,7 +204,7 @@ static void max7310_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo max7310_info = {
- .name = "max7310",
+ .name = TYPE_MAX7310,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(MAX7310State),
.class_init = max7310_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (6 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 07/11] max7310: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:45 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify Andreas Färber
` (4 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/input/lm832x.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c
index f583cf0..4ae1cd9 100644
--- a/hw/input/lm832x.c
+++ b/hw/input/lm832x.c
@@ -23,8 +23,12 @@
#include "qemu/timer.h"
#include "ui/console.h"
+#define TYPE_LM8323 "lm8323"
+#define LM8323(obj) OBJECT_CHECK(LM823KbdState, (obj), TYPE_LM8323)
+
typedef struct {
- I2CSlave i2c;
+ I2CSlave parent_obj;
+
uint8_t i2c_dir;
uint8_t i2c_cycle;
uint8_t reg;
@@ -380,7 +384,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)
static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)
{
- LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+ LM823KbdState *s = LM8323(i2c);
switch (event) {
case I2C_START_RECV:
@@ -396,14 +400,14 @@ static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)
static int lm_i2c_rx(I2CSlave *i2c)
{
- LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+ LM823KbdState *s = LM8323(i2c);
return lm_kbd_read(s, s->reg, s->i2c_cycle ++);
}
static int lm_i2c_tx(I2CSlave *i2c, uint8_t data)
{
- LM823KbdState *s = (LM823KbdState *) i2c;
+ LM823KbdState *s = LM8323(i2c);
if (!s->i2c_cycle)
s->reg = data;
@@ -431,7 +435,7 @@ static const VMStateDescription vmstate_lm_kbd = {
.minimum_version_id_old = 0,
.post_load = lm_kbd_post_load,
.fields = (VMStateField []) {
- VMSTATE_I2C_SLAVE(i2c, LM823KbdState),
+ VMSTATE_I2C_SLAVE(parent_obj, LM823KbdState),
VMSTATE_UINT8(i2c_dir, LM823KbdState),
VMSTATE_UINT8(i2c_cycle, LM823KbdState),
VMSTATE_UINT8(reg, LM823KbdState),
@@ -460,13 +464,13 @@ static const VMStateDescription vmstate_lm_kbd = {
static int lm8323_init(I2CSlave *i2c)
{
- LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+ LM823KbdState *s = LM8323(i2c);
s->model = 0x8323;
s->pwm.tm[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm0_tick, s);
s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
- qdev_init_gpio_out(&i2c->qdev, &s->nirq, 1);
+ qdev_init_gpio_out(DEVICE(i2c), &s->nirq, 1);
lm_kbd_reset(s);
@@ -476,7 +480,7 @@ static int lm8323_init(I2CSlave *i2c)
void lm832x_key_event(DeviceState *dev, int key, int state)
{
- LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE(dev));
+ LM823KbdState *s = LM8323(dev);
if ((s->status & INT_ERROR) && (s->error & ERR_FIFOOVR))
return;
@@ -507,7 +511,7 @@ static void lm8323_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo lm8323_info = {
- .name = "lm8323",
+ .name = TYPE_LM8323,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(LM823KbdState),
.class_init = lm8323_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (7 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:45 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify Andreas Färber
` (3 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/timer/ds1338.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 8987cdc..bb2f8ee 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -23,8 +23,12 @@
#define HOURS_PM 0x20
#define CTRL_OSF 0x20
-typedef struct {
- I2CSlave i2c;
+#define TYPE_DS1338 "ds1338"
+#define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338)
+
+typedef struct DS1338State {
+ I2CSlave parent_obj;
+
int64_t offset;
uint8_t wday_offset;
uint8_t nvram[NVRAM_SIZE];
@@ -38,7 +42,7 @@ static const VMStateDescription vmstate_ds1338 = {
.minimum_version_id = 1,
.minimum_version_id_old = 1,
.fields = (VMStateField[]) {
- VMSTATE_I2C_SLAVE(i2c, DS1338State),
+ VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
VMSTATE_INT64(offset, DS1338State),
VMSTATE_UINT8_V(wday_offset, DS1338State, 2),
VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE),
@@ -90,7 +94,7 @@ static void inc_regptr(DS1338State *s)
static void ds1338_event(I2CSlave *i2c, enum i2c_event event)
{
- DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+ DS1338State *s = DS1338(i2c);
switch (event) {
case I2C_START_RECV:
@@ -111,7 +115,7 @@ static void ds1338_event(I2CSlave *i2c, enum i2c_event event)
static int ds1338_recv(I2CSlave *i2c)
{
- DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+ DS1338State *s = DS1338(i2c);
uint8_t res;
res = s->nvram[s->ptr];
@@ -121,7 +125,8 @@ static int ds1338_recv(I2CSlave *i2c)
static int ds1338_send(I2CSlave *i2c, uint8_t data)
{
- DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+ DS1338State *s = DS1338(i2c);
+
if (s->addr_byte) {
s->ptr = data & (NVRAM_SIZE - 1);
s->addr_byte = false;
@@ -198,7 +203,7 @@ static int ds1338_init(I2CSlave *i2c)
static void ds1338_reset(DeviceState *dev)
{
- DS1338State *s = FROM_I2C_SLAVE(DS1338State, I2C_SLAVE(dev));
+ DS1338State *s = DS1338(dev);
/* The clock is running and synchronized with the host */
s->offset = 0;
@@ -222,7 +227,7 @@ static void ds1338_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo ds1338_info = {
- .name = "ds1338",
+ .name = TYPE_DS1338,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(DS1338State),
.class_init = ds1338_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (8 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:50 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro Andreas Färber
` (2 subsequent siblings)
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/timer/twl92230.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index f3ea365..85d5990 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -27,8 +27,11 @@
#define VERBOSE 1
-typedef struct {
- I2CSlave i2c;
+#define TYPE_TWL92230 "twl92230"
+#define TWL92230(obj) OBJECT_CHECK(MenelausState, (obj), TYPE_TWL92230)
+
+typedef struct MenelausState {
+ I2CSlave parent_obj;
int firstbyte;
uint8_t reg;
@@ -127,7 +130,8 @@ static void menelaus_rtc_hz(void *opaque)
static void menelaus_reset(I2CSlave *i2c)
{
- MenelausState *s = (MenelausState *) i2c;
+ MenelausState *s = TWL92230(i2c);
+
s->reg = 0x00;
s->vcore[0] = 0x0c; /* XXX: X-loader needs 0x8c? check! */
@@ -492,8 +496,9 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
break;
case MENELAUS_DEVICE_OFF:
- if (value & 1)
- menelaus_reset(&s->i2c);
+ if (value & 1) {
+ menelaus_reset(I2C_SLAVE(s));
+ }
break;
case MENELAUS_OSC_CTRL:
@@ -708,7 +713,7 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
static void menelaus_event(I2CSlave *i2c, enum i2c_event event)
{
- MenelausState *s = (MenelausState *) i2c;
+ MenelausState *s = TWL92230(i2c);
if (event == I2C_START_SEND)
s->firstbyte = 1;
@@ -716,7 +721,8 @@ static void menelaus_event(I2CSlave *i2c, enum i2c_event event)
static int menelaus_tx(I2CSlave *i2c, uint8_t data)
{
- MenelausState *s = (MenelausState *) i2c;
+ MenelausState *s = TWL92230(i2c);
+
/* Interpret register address byte */
if (s->firstbyte) {
s->reg = data;
@@ -729,7 +735,7 @@ static int menelaus_tx(I2CSlave *i2c, uint8_t data)
static int menelaus_rx(I2CSlave *i2c)
{
- MenelausState *s = (MenelausState *) i2c;
+ MenelausState *s = TWL92230(i2c);
return menelaus_read(s, s->reg ++);
}
@@ -834,23 +840,24 @@ static const VMStateDescription vmstate_menelaus = {
VMSTATE_STRUCT(rtc.alm, MenelausState, 0, vmstate_menelaus_tm,
struct tm),
VMSTATE_UINT8(pwrbtn_state, MenelausState),
- VMSTATE_I2C_SLAVE(i2c, MenelausState),
+ VMSTATE_I2C_SLAVE(parent_obj, MenelausState),
VMSTATE_END_OF_LIST()
}
};
static int twl92230_init(I2CSlave *i2c)
{
- MenelausState *s = FROM_I2C_SLAVE(MenelausState, i2c);
+ DeviceState *dev = DEVICE(i2c);
+ MenelausState *s = TWL92230(i2c);
s->rtc.hz_tm = timer_new_ms(rtc_clock, menelaus_rtc_hz, s);
/* Three output pins plus one interrupt pin. */
- qdev_init_gpio_out(&i2c->qdev, s->out, 4);
+ qdev_init_gpio_out(dev, s->out, 4);
/* Three input pins plus one power-button pin. */
- qdev_init_gpio_in(&i2c->qdev, menelaus_gpio_set, 4);
+ qdev_init_gpio_in(dev, menelaus_gpio_set, 4);
- menelaus_reset(&s->i2c);
+ menelaus_reset(i2c);
return 0;
}
@@ -868,7 +875,7 @@ static void twl92230_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo twl92230_info = {
- .name = "twl92230",
+ .name = TYPE_TWL92230,
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(MenelausState),
.class_init = twl92230_class_init,
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (9 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify Andreas Färber
@ 2014-01-31 14:34 ` Andreas Färber
2014-02-09 1:53 ` Peter Crosthwaite
2014-02-08 17:22 ` [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
2014-02-09 1:29 ` Peter Crosthwaite
12 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-01-31 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Use type-specific QOM cast macros instead.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
include/hw/i2c/i2c.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 9df987b..4986ebc 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -59,8 +59,6 @@ void i2c_nack(I2CBus *bus);
int i2c_send(I2CBus *bus, uint8_t data);
int i2c_recv(I2CBus *bus);
-#define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
-
DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
/* wm8750.c */
--
1.8.4.5
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (10 preceding siblings ...)
2014-01-31 14:34 ` [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro Andreas Färber
@ 2014-02-08 17:22 ` Andreas Färber
2014-02-09 1:29 ` Peter Crosthwaite
12 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-08 17:22 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori
Am 31.01.2014 15:34, schrieb Andreas Färber:
> Hello,
>
> This series prepares for converting I2C to QOM realize.
>
> Didn't finish that so far, but I'd like to apply this to qom-next before it
> starts to conflict.
>
> Regards,
> Andreas
>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
> Cc: Peter Maydell <peter.maydell@linaro.org>
>
> Andreas Färber (11):
> i2c: Rename i2c_bus to I2CBus
> pxa2xx: QOM'ify I2C slave
> tosa: QOM'ify DAC
> z2: QOM'ify AER915
> wm8750: QOM'ify
> ssd0303: QOM'ify
> max7310: QOM'ify
> lm832x: QOM'ify
> ds1338: QOM'ify
> twl92230: QOM'ify
> i2c: Drop FROM_I2C_SLAVE() macro
Since there's been no comments and PMM indicated he didn't intend to
review them, I've applied these to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus
2014-01-31 14:34 ` [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus Andreas Färber
@ 2014-02-09 1:24 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:24 UTC (permalink / raw)
To: Andreas Färber
Cc: Peter Maydell, Evgeny Voevodin, Michael S. Tsirkin,
Igor Mitsyanko, qemu-devel@nongnu.org Developers, Jan Kiszka,
Dmitry Solodkiy, Anthony Liguori, Maksim Kozlov, Aurelien Jarno
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/acpi/piix4.c | 6 +++---
> hw/arm/exynos4210.c | 2 +-
> hw/arm/musicpal.c | 4 ++--
> hw/arm/nseries.c | 2 +-
> hw/arm/pxa2xx.c | 6 +++---
> hw/arm/realview.c | 4 ++--
> hw/arm/spitz.c | 2 +-
> hw/arm/stellaris.c | 8 ++++----
> hw/arm/tosa.c | 2 +-
> hw/arm/versatilepb.c | 4 ++--
> hw/arm/z2.c | 2 +-
> hw/i2c/bitbang_i2c.c | 6 +++---
> hw/i2c/bitbang_i2c.h | 2 +-
> hw/i2c/core.c | 32 ++++++++++++++++----------------
> hw/i2c/exynos4210_i2c.c | 2 +-
> hw/i2c/omap_i2c.c | 4 ++--
> hw/i2c/pm_smbus.c | 2 +-
> hw/i2c/smbus.c | 18 +++++++++---------
> hw/i2c/smbus_eeprom.c | 2 +-
> hw/i2c/smbus_ich9.c | 2 +-
> hw/i2c/versatile_i2c.c | 2 +-
> hw/i386/pc_piix.c | 2 +-
> hw/isa/vt82c686.c | 4 ++--
> hw/mips/mips_fulong2e.c | 2 +-
> hw/mips/mips_malta.c | 2 +-
> include/hw/arm/exynos4210.h | 2 +-
> include/hw/arm/omap.h | 2 +-
> include/hw/arm/pxa.h | 2 +-
> include/hw/i2c/i2c.h | 16 ++++++++--------
> include/hw/i2c/pm_smbus.h | 2 +-
> include/hw/i2c/smbus.h | 20 ++++++++++----------
> include/hw/i386/ich9.h | 2 +-
> include/hw/i386/pc.h | 6 +++---
> include/hw/isa/vt82c686.h | 4 ++--
> include/qemu/typedefs.h | 2 +-
> 35 files changed, 91 insertions(+), 91 deletions(-)
>
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index 5d55a3c..33e812d 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -517,9 +517,9 @@ Object *piix4_pm_find(void)
> return o;
> }
>
> -i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> - qemu_irq sci_irq, qemu_irq smi_irq,
> - int kvm_enabled, FWCfgState *fw_cfg)
> +I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> + qemu_irq sci_irq, qemu_irq smi_irq,
> + int kvm_enabled, FWCfgState *fw_cfg)
> {
> DeviceState *dev;
> PIIX4PMState *s;
> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> index 4ebb938..9f137e9 100644
> --- a/hw/arm/exynos4210.c
> +++ b/hw/arm/exynos4210.c
> @@ -326,7 +326,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
> busdev = SYS_BUS_DEVICE(dev);
> sysbus_connect_irq(busdev, 0, i2c_irq);
> sysbus_mmio_map(busdev, 0, addr);
> - s->i2c_if[n] = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
> + s->i2c_if[n] = (I2CBus *)qdev_get_child_bus(dev, "i2c");
> }
>
>
> diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
> index 023e875..50a3b8f 100644
> --- a/hw/arm/musicpal.c
> +++ b/hw/arm/musicpal.c
> @@ -1593,7 +1593,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
> DeviceState *key_dev;
> DeviceState *wm8750_dev;
> SysBusDevice *s;
> - i2c_bus *i2c;
> + I2CBus *i2c;
> int i;
> unsigned long flash_size;
> DriveInfo *dinfo;
> @@ -1687,7 +1687,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
> dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
> pic[MP_GPIO_IRQ]);
> i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
> - i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
> + i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c");
>
> lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL);
> key_dev = sysbus_create_simple(TYPE_MUSICPAL_KEY, -1, NULL);
> diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
> index 9ef31ca..c28f895 100644
> --- a/hw/arm/nseries.c
> +++ b/hw/arm/nseries.c
> @@ -202,7 +202,7 @@ static void n8x0_i2c_setup(struct n800_s *s)
> {
> DeviceState *dev;
> qemu_irq tmp_irq = qdev_get_gpio_in(s->mpu->gpio, N8X0_TMP105_GPIO);
> - i2c_bus *i2c = omap_i2c_bus(s->mpu->i2c[0]);
> + I2CBus *i2c = omap_i2c_bus(s->mpu->i2c[0]);
>
> /* Attach a menelaus PM chip */
> dev = i2c_create_slave(i2c, "twl92230", N8X0_MENELAUS_ADDR);
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index 02b7016..daf60e8 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -1238,7 +1238,7 @@ struct PXA2xxI2CState {
>
> MemoryRegion iomem;
> PXA2xxI2CSlaveState *slave;
> - i2c_bus *bus;
> + I2CBus *bus;
> qemu_irq irq;
> uint32_t offset;
> uint32_t region_size;
> @@ -1482,7 +1482,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
> DeviceState *dev;
> SysBusDevice *i2c_dev;
> PXA2xxI2CState *s;
> - i2c_bus *i2cbus;
> + I2CBus *i2cbus;
>
> dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
> qdev_prop_set_uint32(dev, "size", region_size + 1);
> @@ -1518,7 +1518,7 @@ static int pxa2xx_i2c_initfn(SysBusDevice *sbd)
> return 0;
> }
>
> -i2c_bus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
> +I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
> {
> return s->bus;
> }
> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
> index 8d845dd..6ef7646 100644
> --- a/hw/arm/realview.c
> +++ b/hw/arm/realview.c
> @@ -60,7 +60,7 @@ static void realview_init(QEMUMachineInitArgs *args,
> qemu_irq mmc_irq[2];
> PCIBus *pci_bus = NULL;
> NICInfo *nd;
> - i2c_bus *i2c;
> + I2CBus *i2c;
> int n;
> int done_nic = 0;
> qemu_irq cpu_irq[4];
> @@ -255,7 +255,7 @@ static void realview_init(QEMUMachineInitArgs *args,
> }
>
> dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
> - i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
> + i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
> i2c_create_slave(i2c, "ds1338", 0x68);
>
> /* Memory map for RealView Emulation Baseboard: */
> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
> index ba17283..2decff1 100644
> --- a/hw/arm/spitz.c
> +++ b/hw/arm/spitz.c
> @@ -734,7 +734,7 @@ static void spitz_wm8750_addr(void *opaque, int line, int level)
> static void spitz_i2c_setup(PXA2xxState *cpu)
> {
> /* Attach the CPU on one end of our I2C bus. */
> - i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> + I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
>
> DeviceState *wm;
>
> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> index 3170d69..d6cc77b 100644
> --- a/hw/arm/stellaris.c
> +++ b/hw/arm/stellaris.c
> @@ -692,7 +692,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
> typedef struct {
> SysBusDevice parent_obj;
>
> - i2c_bus *bus;
> + I2CBus *bus;
> qemu_irq irq;
> MemoryRegion iomem;
> uint32_t msa;
> @@ -868,7 +868,7 @@ static int stellaris_i2c_init(SysBusDevice *sbd)
> {
> DeviceState *dev = DEVICE(sbd);
> stellaris_i2c_state *s = STELLARIS_I2C(dev);
> - i2c_bus *bus;
> + I2CBus *bus;
>
> sysbus_init_irq(sbd, &s->irq);
> bus = i2c_init_bus(dev, "i2c");
> @@ -1213,7 +1213,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
> qemu_irq adc;
> int sram_size;
> int flash_size;
> - i2c_bus *i2c;
> + I2CBus *i2c;
> DeviceState *dev;
> int i;
> int j;
> @@ -1256,7 +1256,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
>
> if (board->dc2 & (1 << 12)) {
> dev = sysbus_create_simple(TYPE_STELLARIS_I2C, 0x40020000, pic[8]);
> - i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
> + i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
> if (board->peripherals & BP_OLED_I2C) {
> i2c_create_slave(i2c, "ssd0303", 0x3d);
> }
> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
> index c00d8c2..dd224d3 100644
> --- a/hw/arm/tosa.c
> +++ b/hw/arm/tosa.c
> @@ -194,7 +194,7 @@ static int tosa_dac_init(I2CSlave *i2c)
>
> static void tosa_tg_init(PXA2xxState *cpu)
> {
> - i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> + I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> i2c_create_slave(bus, "tosa_dac", DAC_BASE);
> ssi_create_slave(cpu->ssp[1], "tosa-ssp");
> }
> diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
> index aef2bde..e5493b4 100644
> --- a/hw/arm/versatilepb.c
> +++ b/hw/arm/versatilepb.c
> @@ -185,7 +185,7 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id)
> DeviceState *pl041;
> PCIBus *pci_bus;
> NICInfo *nd;
> - i2c_bus *i2c;
> + I2CBus *i2c;
> int n;
> int done_smc = 0;
> DriveInfo *dinfo;
> @@ -288,7 +288,7 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id)
> sysbus_create_simple("pl031", 0x101e8000, pic[10]);
>
> dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
> - i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
> + i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
> i2c_create_slave(i2c, "ds1338", 0x68);
>
> /* Add PL041 AACI Interface to the LM4549 codec */
> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
> index 97367b1..97ec381 100644
> --- a/hw/arm/z2.c
> +++ b/hw/arm/z2.c
> @@ -308,7 +308,7 @@ static void z2_init(QEMUMachineInitArgs *args)
> DriveInfo *dinfo;
> int be;
> void *z2_lcd;
> - i2c_bus *bus;
> + I2CBus *bus;
> DeviceState *wm;
>
> if (!cpu_model) {
> diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
> index ca59456..6d1bb03 100644
> --- a/hw/i2c/bitbang_i2c.c
> +++ b/hw/i2c/bitbang_i2c.c
> @@ -46,7 +46,7 @@ typedef enum bitbang_i2c_state {
> } bitbang_i2c_state;
>
> struct bitbang_i2c_interface {
> - i2c_bus *bus;
> + I2CBus *bus;
> bitbang_i2c_state state;
> int last_data;
> int last_clock;
> @@ -170,7 +170,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
> abort();
> }
>
> -bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus)
> +bitbang_i2c_interface *bitbang_i2c_init(I2CBus *bus)
> {
> bitbang_i2c_interface *s;
>
> @@ -213,7 +213,7 @@ static int gpio_i2c_init(SysBusDevice *sbd)
> {
> DeviceState *dev = DEVICE(sbd);
> GPIOI2CState *s = GPIO_I2C(dev);
> - i2c_bus *bus;
> + I2CBus *bus;
>
> memory_region_init(&s->dummy_iomem, OBJECT(s), "gpio_i2c", 0);
> sysbus_init_mmio(sbd, &s->dummy_iomem);
> diff --git a/hw/i2c/bitbang_i2c.h b/hw/i2c/bitbang_i2c.h
> index 2866ac3..3a7126d 100644
> --- a/hw/i2c/bitbang_i2c.h
> +++ b/hw/i2c/bitbang_i2c.h
> @@ -8,7 +8,7 @@ typedef struct bitbang_i2c_interface bitbang_i2c_interface;
> #define BITBANG_I2C_SDA 0
> #define BITBANG_I2C_SCL 1
>
> -bitbang_i2c_interface *bitbang_i2c_init(i2c_bus *bus);
> +bitbang_i2c_interface *bitbang_i2c_init(I2CBus *bus);
> int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level);
>
> #endif
> diff --git a/hw/i2c/core.c b/hw/i2c/core.c
> index c97e7f7..efd8b4f 100644
> --- a/hw/i2c/core.c
> +++ b/hw/i2c/core.c
> @@ -9,7 +9,7 @@
>
> #include "hw/i2c/i2c.h"
>
> -struct i2c_bus
> +struct I2CBus
> {
> BusState qbus;
> I2CSlave *current_dev;
> @@ -23,24 +23,24 @@ static Property i2c_props[] = {
> };
>
> #define TYPE_I2C_BUS "i2c-bus"
> -#define I2C_BUS(obj) OBJECT_CHECK(i2c_bus, (obj), TYPE_I2C_BUS)
> +#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
>
> static const TypeInfo i2c_bus_info = {
> .name = TYPE_I2C_BUS,
> .parent = TYPE_BUS,
> - .instance_size = sizeof(i2c_bus),
> + .instance_size = sizeof(I2CBus),
> };
>
> static void i2c_bus_pre_save(void *opaque)
> {
> - i2c_bus *bus = opaque;
> + I2CBus *bus = opaque;
>
> bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
> }
>
> static int i2c_bus_post_load(void *opaque, int version_id)
> {
> - i2c_bus *bus = opaque;
> + I2CBus *bus = opaque;
>
> /* The bus is loaded before attached devices, so load and save the
> current device id. Devices will check themselves as loaded. */
> @@ -56,15 +56,15 @@ static const VMStateDescription vmstate_i2c_bus = {
> .pre_save = i2c_bus_pre_save,
> .post_load = i2c_bus_post_load,
> .fields = (VMStateField []) {
> - VMSTATE_UINT8(saved_address, i2c_bus),
> + VMSTATE_UINT8(saved_address, I2CBus),
> VMSTATE_END_OF_LIST()
> }
> };
>
> /* Create a new I2C bus. */
> -i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)
> +I2CBus *i2c_init_bus(DeviceState *parent, const char *name)
> {
> - i2c_bus *bus;
> + I2CBus *bus;
>
> bus = I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name));
> vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
> @@ -77,14 +77,14 @@ void i2c_set_slave_address(I2CSlave *dev, uint8_t address)
> }
>
> /* Return nonzero if bus is busy. */
> -int i2c_bus_busy(i2c_bus *bus)
> +int i2c_bus_busy(I2CBus *bus)
> {
> return bus->current_dev != NULL;
> }
>
> /* Returns non-zero if the address is not valid. */
> /* TODO: Make this handle multiple masters. */
> -int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv)
> +int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
> {
> BusChild *kid;
> I2CSlave *slave = NULL;
> @@ -113,7 +113,7 @@ int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv)
> return 0;
> }
>
> -void i2c_end_transfer(i2c_bus *bus)
> +void i2c_end_transfer(I2CBus *bus)
> {
> I2CSlave *dev = bus->current_dev;
> I2CSlaveClass *sc;
> @@ -130,7 +130,7 @@ void i2c_end_transfer(i2c_bus *bus)
> bus->current_dev = NULL;
> }
>
> -int i2c_send(i2c_bus *bus, uint8_t data)
> +int i2c_send(I2CBus *bus, uint8_t data)
> {
> I2CSlave *dev = bus->current_dev;
> I2CSlaveClass *sc;
> @@ -147,7 +147,7 @@ int i2c_send(i2c_bus *bus, uint8_t data)
> return -1;
> }
>
> -int i2c_recv(i2c_bus *bus)
> +int i2c_recv(I2CBus *bus)
> {
> I2CSlave *dev = bus->current_dev;
> I2CSlaveClass *sc;
> @@ -164,7 +164,7 @@ int i2c_recv(i2c_bus *bus)
> return -1;
> }
>
> -void i2c_nack(i2c_bus *bus)
> +void i2c_nack(I2CBus *bus)
> {
> I2CSlave *dev = bus->current_dev;
> I2CSlaveClass *sc;
> @@ -182,7 +182,7 @@ void i2c_nack(i2c_bus *bus)
> static int i2c_slave_post_load(void *opaque, int version_id)
> {
> I2CSlave *dev = opaque;
> - i2c_bus *bus;
> + I2CBus *bus;
> bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
> if (bus->saved_address == dev->address) {
> bus->current_dev = dev;
> @@ -210,7 +210,7 @@ static int i2c_slave_qdev_init(DeviceState *dev)
> return sc->init(s);
> }
>
> -DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
> +DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
> {
> DeviceState *dev;
>
> diff --git a/hw/i2c/exynos4210_i2c.c b/hw/i2c/exynos4210_i2c.c
> index ce5f849..fb99dfd 100644
> --- a/hw/i2c/exynos4210_i2c.c
> +++ b/hw/i2c/exynos4210_i2c.c
> @@ -83,7 +83,7 @@ typedef struct Exynos4210I2CState {
> SysBusDevice parent_obj;
>
> MemoryRegion iomem;
> - i2c_bus *bus;
> + I2CBus *bus;
> qemu_irq irq;
>
> uint8_t i2ccon;
> diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
> index 2d8e2b7..d63278d 100644
> --- a/hw/i2c/omap_i2c.c
> +++ b/hw/i2c/omap_i2c.c
> @@ -30,7 +30,7 @@ typedef struct OMAPI2CState {
> MemoryRegion iomem;
> qemu_irq irq;
> qemu_irq drq[2];
> - i2c_bus *bus;
> + I2CBus *bus;
>
> uint8_t revision;
> void *iclk;
> @@ -491,7 +491,7 @@ static void omap_i2c_register_types(void)
> type_register_static(&omap_i2c_info);
> }
>
> -i2c_bus *omap_i2c_bus(DeviceState *omap_i2c)
> +I2CBus *omap_i2c_bus(DeviceState *omap_i2c)
> {
> OMAPI2CState *s = OMAP_I2C(omap_i2c);
> return s->bus;
> diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
> index c98e447..9f50067 100644
> --- a/hw/i2c/pm_smbus.c
> +++ b/hw/i2c/pm_smbus.c
> @@ -59,7 +59,7 @@ static void smb_transaction(PMSMBus *s)
> uint8_t read = s->smb_addr & 0x01;
> uint8_t cmd = s->smb_cmd;
> uint8_t addr = s->smb_addr >> 1;
> - i2c_bus *bus = s->smbus;
> + I2CBus *bus = s->smbus;
>
> SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot);
> /* Transaction isn't exec if STS_DEV_ERR bit set */
> diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
> index 25d2d04..3febf3c 100644
> --- a/hw/i2c/smbus.c
> +++ b/hw/i2c/smbus.c
> @@ -208,13 +208,13 @@ static int smbus_device_init(I2CSlave *i2c)
> }
>
> /* Master device commands. */
> -void smbus_quick_command(i2c_bus *bus, uint8_t addr, int read)
> +void smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
> {
> i2c_start_transfer(bus, addr, read);
> i2c_end_transfer(bus);
> }
>
> -uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr)
> +uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr)
> {
> uint8_t data;
>
> @@ -225,14 +225,14 @@ uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr)
> return data;
> }
>
> -void smbus_send_byte(i2c_bus *bus, uint8_t addr, uint8_t data)
> +void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
> {
> i2c_start_transfer(bus, addr, 0);
> i2c_send(bus, data);
> i2c_end_transfer(bus);
> }
>
> -uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command)
> +uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
> {
> uint8_t data;
> i2c_start_transfer(bus, addr, 0);
> @@ -244,7 +244,7 @@ uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command)
> return data;
> }
>
> -void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data)
> +void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
> {
> i2c_start_transfer(bus, addr, 0);
> i2c_send(bus, command);
> @@ -252,7 +252,7 @@ void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data)
> i2c_end_transfer(bus);
> }
>
> -uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command)
> +uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
> {
> uint16_t data;
> i2c_start_transfer(bus, addr, 0);
> @@ -265,7 +265,7 @@ uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command)
> return data;
> }
>
> -void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data)
> +void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)
> {
> i2c_start_transfer(bus, addr, 0);
> i2c_send(bus, command);
> @@ -274,7 +274,7 @@ void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data
> i2c_end_transfer(bus);
> }
>
> -int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data)
> +int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
> {
> int len;
> int i;
> @@ -292,7 +292,7 @@ int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data)
> return len;
> }
>
> -void smbus_write_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data,
> +void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
> int len)
> {
> int i;
> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> index 0218f8a..86f35c1 100644
> --- a/hw/i2c/smbus_eeprom.c
> +++ b/hw/i2c/smbus_eeprom.c
> @@ -139,7 +139,7 @@ static void smbus_eeprom_register_types(void)
>
> type_init(smbus_eeprom_register_types)
>
> -void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
> +void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
> const uint8_t *eeprom_spd, int eeprom_spd_size)
> {
> int i;
> diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
> index 8d47eaf..295b62e 100644
> --- a/hw/i2c/smbus_ich9.c
> +++ b/hw/i2c/smbus_ich9.c
> @@ -108,7 +108,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
> dc->cannot_instantiate_with_device_add_yet = true;
> }
>
> -i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
> +I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
> {
> PCIDevice *d =
> pci_create_simple_multifunction(bus, devfn, true, TYPE_ICH9_SMB_DEVICE);
> diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
> index 02e9f17..3c0c2c1 100644
> --- a/hw/i2c/versatile_i2c.c
> +++ b/hw/i2c/versatile_i2c.c
> @@ -81,7 +81,7 @@ static int versatile_i2c_init(SysBusDevice *sbd)
> {
> DeviceState *dev = DEVICE(sbd);
> VersatileI2CState *s = VERSATILE_I2C(dev);
> - i2c_bus *bus;
> + I2CBus *bus;
>
> bus = i2c_init_bus(dev, "i2c");
> s->bitbang = bitbang_i2c_init(bus);
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index a327d71..3639a6d 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -236,7 +236,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
> }
>
> if (pci_enabled && acpi_enabled) {
> - i2c_bus *smbus;
> + I2CBus *smbus;
>
> smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
> /* TODO: Populate SPD eeprom data. */
> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> index e639357..1a93afd 100644
> --- a/hw/isa/vt82c686.c
> +++ b/hw/isa/vt82c686.c
> @@ -369,8 +369,8 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
> return 0;
> }
>
> -i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> - qemu_irq sci_irq)
> +I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> + qemu_irq sci_irq)
> {
> PCIDevice *dev;
> VT686PMState *s;
> diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
> index 9ef3a97..e1551aa 100644
> --- a/hw/mips/mips_fulong2e.c
> +++ b/hw/mips/mips_fulong2e.c
> @@ -276,7 +276,7 @@ static void mips_fulong2e_init(QEMUMachineInitArgs *args)
> qemu_irq *cpu_exit_irq;
> PCIBus *pci_bus;
> ISABus *isa_bus;
> - i2c_bus *smbus;
> + I2CBus *smbus;
> int i;
> DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
> MIPSCPU *cpu;
> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> index 05c8771..ac5ec44 100644
> --- a/hw/mips/mips_malta.c
> +++ b/hw/mips/mips_malta.c
> @@ -900,7 +900,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
> qemu_irq *isa_irq;
> qemu_irq *cpu_exit_irq;
> int piix4_devfn;
> - i2c_bus *smbus;
> + I2CBus *smbus;
> int i;
> DriveInfo *dinfo;
> DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
> diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
> index bb9a1dd..5c1820f 100644
> --- a/include/hw/arm/exynos4210.h
> +++ b/include/hw/arm/exynos4210.h
> @@ -97,7 +97,7 @@ typedef struct Exynos4210State {
> MemoryRegion dram1_mem;
> MemoryRegion boot_secondary;
> MemoryRegion bootreg_mem;
> - i2c_bus *i2c_if[EXYNOS4210_I2C_NUMBER];
> + I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
> } Exynos4210State;
>
> void exynos4210_write_secondary(ARMCPU *cpu,
> diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
> index 188cda8..b9655ee 100644
> --- a/include/hw/arm/omap.h
> +++ b/include/hw/arm/omap.h
> @@ -765,7 +765,7 @@ void omap_mmc_handlers(struct omap_mmc_s *s, qemu_irq ro, qemu_irq cover);
> void omap_mmc_enable(struct omap_mmc_s *s, int enable);
>
> /* omap_i2c.c */
> -i2c_bus *omap_i2c_bus(DeviceState *omap_i2c);
> +I2CBus *omap_i2c_bus(DeviceState *omap_i2c);
>
> # define cpu_is_omap310(cpu) (cpu->mpu_model == omap310)
> # define cpu_is_omap1510(cpu) (cpu->mpu_model == omap1510)
> diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
> index 7ca330a..c507906 100644
> --- a/include/hw/arm/pxa.h
> +++ b/include/hw/arm/pxa.h
> @@ -116,7 +116,7 @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp,
> typedef struct PXA2xxI2CState PXA2xxI2CState;
> PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
> qemu_irq irq, uint32_t page_size);
> -i2c_bus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
> +I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
>
> typedef struct PXA2xxI2SState PXA2xxI2SState;
> typedef struct PXA2xxFIrState PXA2xxFIrState;
> diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
> index 461392f..9df987b 100644
> --- a/include/hw/i2c/i2c.h
> +++ b/include/hw/i2c/i2c.h
> @@ -50,18 +50,18 @@ struct I2CSlave
> uint8_t address;
> };
>
> -i2c_bus *i2c_init_bus(DeviceState *parent, const char *name);
> +I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
> void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
> -int i2c_bus_busy(i2c_bus *bus);
> -int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv);
> -void i2c_end_transfer(i2c_bus *bus);
> -void i2c_nack(i2c_bus *bus);
> -int i2c_send(i2c_bus *bus, uint8_t data);
> -int i2c_recv(i2c_bus *bus);
> +int i2c_bus_busy(I2CBus *bus);
> +int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv);
> +void i2c_end_transfer(I2CBus *bus);
> +void i2c_nack(I2CBus *bus);
> +int i2c_send(I2CBus *bus, uint8_t data);
> +int i2c_recv(I2CBus *bus);
>
> #define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
>
> -DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr);
> +DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
>
> /* wm8750.c */
> void wm8750_data_req_set(DeviceState *dev,
> diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h
> index e3069bf..926603f 100644
> --- a/include/hw/i2c/pm_smbus.h
> +++ b/include/hw/i2c/pm_smbus.h
> @@ -2,7 +2,7 @@
> #define PM_SMBUS_H
>
> typedef struct PMSMBus {
> - i2c_bus *smbus;
> + I2CBus *smbus;
> MemoryRegion io;
>
> uint8_t smb_stat;
> diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
> index d764d75..63f0cc4 100644
> --- a/include/hw/i2c/smbus.h
> +++ b/include/hw/i2c/smbus.h
> @@ -66,18 +66,18 @@ struct SMBusDevice {
> };
>
> /* Master device commands. */
> -void smbus_quick_command(i2c_bus *bus, uint8_t addr, int read);
> -uint8_t smbus_receive_byte(i2c_bus *bus, uint8_t addr);
> -void smbus_send_byte(i2c_bus *bus, uint8_t addr, uint8_t data);
> -uint8_t smbus_read_byte(i2c_bus *bus, uint8_t addr, uint8_t command);
> -void smbus_write_byte(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t data);
> -uint16_t smbus_read_word(i2c_bus *bus, uint8_t addr, uint8_t command);
> -void smbus_write_word(i2c_bus *bus, uint8_t addr, uint8_t command, uint16_t data);
> -int smbus_read_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data);
> -void smbus_write_block(i2c_bus *bus, uint8_t addr, uint8_t command, uint8_t *data,
> +void smbus_quick_command(I2CBus *bus, uint8_t addr, int read);
> +uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr);
> +void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data);
> +uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);
> +void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data);
> +uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command);
> +void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data);
> +int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
> +void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
> int len);
>
> -void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
> +void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
> const uint8_t *eeprom_spd, int size);
>
> #endif
> diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
> index 4a68b35..9e4a0e4 100644
> --- a/include/hw/i386/ich9.h
> +++ b/include/hw/i386/ich9.h
> @@ -20,7 +20,7 @@ int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
> PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
> void ich9_lpc_pm_init(PCIDevice *pci_lpc);
> PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus);
> -i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
> +I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
>
> #define ICH9_CC_SIZE (16 * 1024) /* 16KB */
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 3e1e81b..9010246 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -165,9 +165,9 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
>
> /* acpi_piix.c */
>
> -i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> - qemu_irq sci_irq, qemu_irq smi_irq,
> - int kvm_enabled, FWCfgState *fw_cfg);
> +I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> + qemu_irq sci_irq, qemu_irq smi_irq,
> + int kvm_enabled, FWCfgState *fw_cfg);
> void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
>
> /* hpet.c */
> diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
> index 6ef876d..471b5e9 100644
> --- a/include/hw/isa/vt82c686.h
> +++ b/include/hw/isa/vt82c686.h
> @@ -5,7 +5,7 @@
> ISABus *vt82c686b_init(PCIBus * bus, int devfn);
> void vt82c686b_ac97_init(PCIBus *bus, int devfn);
> void vt82c686b_mc97_init(PCIBus *bus, int devfn);
> -i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> - qemu_irq sci_irq);
> +I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> + qemu_irq sci_irq);
>
> #endif
> diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
> index 4524496..a2eb749 100644
> --- a/include/qemu/typedefs.h
> +++ b/include/qemu/typedefs.h
> @@ -42,7 +42,7 @@ typedef struct QemuConsole QemuConsole;
> typedef struct CharDriverState CharDriverState;
> typedef struct MACAddr MACAddr;
> typedef struct NetClientState NetClientState;
> -typedef struct i2c_bus i2c_bus;
> +typedef struct I2CBus I2CBus;
> typedef struct ISABus ISABus;
> typedef struct ISADevice ISADevice;
> typedef struct SMBusDevice SMBusDevice;
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
` (11 preceding siblings ...)
2014-02-08 17:22 ` [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
@ 2014-02-09 1:29 ` Peter Crosthwaite
2014-02-09 1:59 ` Andreas Färber
12 siblings, 1 reply; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:29 UTC (permalink / raw)
To: Andreas Färber
Cc: Peter Maydell, qemu-devel@nongnu.org Developers, Anthony Liguori
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Hello,
>
> This series prepares for converting I2C to QOM realize.
>
Incase you are moving onto SSI next I do have a have half a start on
this change pattern for SSI (In particular, I think Ive removed
FROM_SSI_SLAVE for some re-org reasons). I better post. Ping me if SSI
qomification gets in your way before I get a chance to post.
Regards,
Peter
> Didn't finish that so far, but I'd like to apply this to qom-next before it
> starts to conflict.
>
> Regards,
> Andreas
>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
> Cc: Peter Maydell <peter.maydell@linaro.org>
>
> Andreas Färber (11):
> i2c: Rename i2c_bus to I2CBus
> pxa2xx: QOM'ify I2C slave
> tosa: QOM'ify DAC
> z2: QOM'ify AER915
> wm8750: QOM'ify
> ssd0303: QOM'ify
> max7310: QOM'ify
> lm832x: QOM'ify
> ds1338: QOM'ify
> twl92230: QOM'ify
> i2c: Drop FROM_I2C_SLAVE() macro
>
> hw/acpi/piix4.c | 6 +++---
> hw/arm/exynos4210.c | 2 +-
> hw/arm/musicpal.c | 4 ++--
> hw/arm/nseries.c | 2 +-
> hw/arm/pxa2xx.c | 44 ++++++++++++++++++++++++++++----------------
> hw/arm/realview.c | 4 ++--
> hw/arm/spitz.c | 2 +-
> hw/arm/stellaris.c | 8 ++++----
> hw/arm/tosa.c | 18 ++++++++++++------
> hw/arm/versatilepb.c | 4 ++--
> hw/arm/z2.c | 20 +++++++++++++-------
> hw/audio/wm8750.c | 33 ++++++++++++++++++++-------------
> hw/display/ssd0303.c | 18 ++++++++++++------
> hw/gpio/max7310.c | 23 ++++++++++++++---------
> hw/i2c/bitbang_i2c.c | 6 +++---
> hw/i2c/bitbang_i2c.h | 2 +-
> hw/i2c/core.c | 32 ++++++++++++++++----------------
> hw/i2c/exynos4210_i2c.c | 2 +-
> hw/i2c/omap_i2c.c | 4 ++--
> hw/i2c/pm_smbus.c | 2 +-
> hw/i2c/smbus.c | 18 +++++++++---------
> hw/i2c/smbus_eeprom.c | 2 +-
> hw/i2c/smbus_ich9.c | 2 +-
> hw/i2c/versatile_i2c.c | 2 +-
> hw/i386/pc_piix.c | 2 +-
> hw/input/lm832x.c | 22 +++++++++++++---------
> hw/isa/vt82c686.c | 4 ++--
> hw/mips/mips_fulong2e.c | 2 +-
> hw/mips/mips_malta.c | 2 +-
> hw/timer/ds1338.c | 21 +++++++++++++--------
> hw/timer/twl92230.c | 35 +++++++++++++++++++++--------------
> include/hw/arm/exynos4210.h | 2 +-
> include/hw/arm/omap.h | 2 +-
> include/hw/arm/pxa.h | 2 +-
> include/hw/i2c/i2c.h | 20 +++++++++-----------
> include/hw/i2c/pm_smbus.h | 2 +-
> include/hw/i2c/smbus.h | 20 ++++++++++----------
> include/hw/i386/ich9.h | 2 +-
> include/hw/i386/pc.h | 6 +++---
> include/hw/isa/vt82c686.h | 4 ++--
> include/qemu/typedefs.h | 2 +-
> 41 files changed, 233 insertions(+), 177 deletions(-)
>
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave
2014-01-31 14:34 ` [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave Andreas Färber
@ 2014-02-09 1:35 ` Peter Crosthwaite
2014-02-09 12:24 ` Andreas Färber
2014-02-09 12:56 ` Andreas Färber
1 sibling, 1 reply; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:35 UTC (permalink / raw)
To: Andreas Färber; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro and rename parent
> field to assure we caught all.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/arm/pxa2xx.c | 38 +++++++++++++++++++++++++-------------
> 1 file changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index daf60e8..e5f1e10 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -1222,8 +1222,14 @@ static const TypeInfo pxa2xx_rtc_sysbus_info = {
> };
>
> /* I2C Interface */
> -typedef struct {
> - I2CSlave i2c;
> +
> +#define TYPE_PXA2XX_I2C_SLAVE "pxa2xx-i2c-slave"
> +#define PXA2XX_I2C_SLAVE(obj) \
> + OBJECT_CHECK(PXA2xxI2CSlaveState, (obj), TYPE_PXA2XX_I2C_SLAVE)
> +
> +typedef struct PXA2xxI2CSlaveState {
> + I2CSlave parent_obj;
> +
> PXA2xxI2CState *host;
> } PXA2xxI2CSlaveState;
>
> @@ -1268,7 +1274,7 @@ static void pxa2xx_i2c_update(PXA2xxI2CState *s)
> /* These are only stubs now. */
> static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
> {
> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
> PXA2xxI2CState *s = slave->host;
>
> switch (event) {
> @@ -1292,10 +1298,12 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
>
> static int pxa2xx_i2c_rx(I2CSlave *i2c)
> {
> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
> PXA2xxI2CState *s = slave->host;
> - if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
> +
> + if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
> return 0;
> + }
This will look funny when git-blamed. Should out-of-scope trivials be
separate patch so anyone git-blame will at least see "Fix coding
style" rather than then misleading "QOM'ify I2C"?. With the multiple
instances of this cleanup it should at least feature in the commit
message.
Regards,
Peter
>
> if (s->status & (1 << 0)) { /* RWM */
> s->status |= 1 << 6; /* set ITE */
> @@ -1307,10 +1315,12 @@ static int pxa2xx_i2c_rx(I2CSlave *i2c)
>
> static int pxa2xx_i2c_tx(I2CSlave *i2c, uint8_t data)
> {
> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
> PXA2xxI2CState *s = slave->host;
> - if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
> +
> + if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
> return 1;
> + }
>
> if (!(s->status & (1 << 0))) { /* RWM */
> s->status |= 1 << 7; /* set IRF */
> @@ -1325,6 +1335,7 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
> unsigned size)
> {
> PXA2xxI2CState *s = (PXA2xxI2CState *) opaque;
> + I2CSlave *slave;
>
> addr -= s->offset;
> switch (addr) {
> @@ -1333,7 +1344,8 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
> case ISR:
> return s->status | (i2c_bus_busy(s->bus) << 2);
> case ISAR:
> - return s->slave->i2c.address;
> + slave = I2C_SLAVE(s->slave);
> + return slave->address;
> case IDBR:
> return s->data;
> case IBMR:
> @@ -1408,7 +1420,7 @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr,
> break;
>
> case ISAR:
> - i2c_set_slave_address(&s->slave->i2c, value & 0x7f);
> + i2c_set_slave_address(I2C_SLAVE(s->slave), value & 0x7f);
> break;
>
> case IDBR:
> @@ -1432,7 +1444,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c_slave = {
> .minimum_version_id = 1,
> .minimum_version_id_old = 1,
> .fields = (VMStateField []) {
> - VMSTATE_I2C_SLAVE(i2c, PXA2xxI2CSlaveState),
> + VMSTATE_I2C_SLAVE(parent_obj, PXA2xxI2CSlaveState),
> VMSTATE_END_OF_LIST()
> }
> };
> @@ -1470,7 +1482,7 @@ static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo pxa2xx_i2c_slave_info = {
> - .name = "pxa2xx-i2c-slave",
> + .name = TYPE_PXA2XX_I2C_SLAVE,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(PXA2xxI2CSlaveState),
> .class_init = pxa2xx_i2c_slave_class_init,
> @@ -1496,8 +1508,8 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
> s = PXA2XX_I2C(i2c_dev);
> /* FIXME: Should the slave device really be on a separate bus? */
> i2cbus = i2c_init_bus(dev, "dummy");
> - dev = i2c_create_slave(i2cbus, "pxa2xx-i2c-slave", 0);
> - s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
> + dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
> + s->slave = PXA2XX_I2C_SLAVE(dev);
> s->slave->host = s;
>
> return s;
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC
2014-01-31 14:34 ` [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC Andreas Färber
@ 2014-02-09 1:37 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:37 UTC (permalink / raw)
To: Andreas Färber; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/arm/tosa.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
> index dd224d3..2069f55 100644
> --- a/hw/arm/tosa.c
> +++ b/hw/arm/tosa.c
> @@ -132,15 +132,20 @@ static int tosa_ssp_init(SSISlave *dev)
> return 0;
> }
>
> +#define TYPE_TOSA_DAC "tosa_dac"
> +#define TOSA_DAC(obj) OBJECT_CHECK(TosaDACState, (obj), TYPE_TOSA_DAC)
> +
> typedef struct {
> - I2CSlave i2c;
> + I2CSlave parent_obj;
> +
> int len;
> char buf[3];
> } TosaDACState;
>
> static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
> {
> - TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
> + TosaDACState *s = TOSA_DAC(i2c);
> +
> s->buf[s->len] = data;
> if (s->len ++ > 2) {
> #ifdef VERBOSE
> @@ -159,7 +164,8 @@ static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
>
> static void tosa_dac_event(I2CSlave *i2c, enum i2c_event event)
> {
> - TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
> + TosaDACState *s = TOSA_DAC(i2c);
> +
> s->len = 0;
> switch (event) {
> case I2C_START_SEND:
> @@ -195,7 +201,7 @@ static int tosa_dac_init(I2CSlave *i2c)
> static void tosa_tg_init(PXA2xxState *cpu)
> {
> I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> - i2c_create_slave(bus, "tosa_dac", DAC_BASE);
> + i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE);
> ssi_create_slave(cpu->ssp[1], "tosa-ssp");
> }
>
> @@ -271,7 +277,7 @@ static void tosa_dac_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo tosa_dac_info = {
> - .name = "tosa_dac",
> + .name = TYPE_TOSA_DAC,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(TosaDACState),
> .class_init = tosa_dac_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915
2014-01-31 14:34 ` [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915 Andreas Färber
@ 2014-02-09 1:38 ` Peter Crosthwaite
2014-02-09 13:04 ` Andreas Färber
0 siblings, 1 reply; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:38 UTC (permalink / raw)
To: Andreas Färber; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/arm/z2.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
> index 97ec381..69c4d38 100644
> --- a/hw/arm/z2.c
> +++ b/hw/arm/z2.c
> @@ -193,15 +193,20 @@ static const TypeInfo zipit_lcd_info = {
> .class_init = zipit_lcd_class_init,
> };
>
> -typedef struct {
> - I2CSlave i2c;
> +#define TYPE_AER915 "aer915"
> +#define AER915(obj) OBJECT_CHECK(AER915State, (obj), TYPE_AER915)
> +
> +typedef struct AER915State {
> + I2CSlave parent_obj;
> +
> int len;
> uint8_t buf[3];
> } AER915State;
>
> static int aer915_send(I2CSlave *i2c, uint8_t data)
> {
> - AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> + AER915State *s = AER915(i2c);
> +
> s->buf[s->len] = data;
> if (s->len++ > 2) {
> DPRINTF("%s: message too long (%i bytes)\n",
> @@ -219,7 +224,8 @@ static int aer915_send(I2CSlave *i2c, uint8_t data)
>
> static void aer915_event(I2CSlave *i2c, enum i2c_event event)
> {
> - AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> + AER915State *s = AER915(i2c);
> +
> switch (event) {
> case I2C_START_SEND:
> s->len = 0;
> @@ -238,8 +244,8 @@ static void aer915_event(I2CSlave *i2c, enum i2c_event event)
>
> static int aer915_recv(I2CSlave *slave)
> {
> + AER915State *s = AER915(slave);
> int retval = 0x00;
> - AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
>
> switch (s->buf[0]) {
> /* Return hardcoded battery voltage,
> @@ -290,7 +296,7 @@ static void aer915_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo aer915_info = {
> - .name = "aer915",
> + .name = TYPE_AER915,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(AER915State),
> .class_init = aer915_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify Andreas Färber
@ 2014-02-09 1:41 ` Peter Crosthwaite
2014-02-09 13:10 ` Andreas Färber
1 sibling, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:41 UTC (permalink / raw)
To: Andreas Färber
Cc: Vassili Karpov (malc), qemu-devel@nongnu.org Developers,
Gerd Hoffmann
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
A nit, but you are also "removing direct pointer derefence casts" [1] ...
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/audio/wm8750.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c
> index 6b5a349..c18f245 100644
> --- a/hw/audio/wm8750.c
> +++ b/hw/audio/wm8750.c
> @@ -23,8 +23,12 @@ typedef struct {
> int dac_hz;
> } WMRate;
>
> -typedef struct {
> - I2CSlave i2c;
> +#define TYPE_WM8750 "wm8750"
> +#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
> +
> +typedef struct WM8750State {
> + I2CSlave parent_obj;
> +
> uint8_t i2c_data[2];
> int i2c_len;
> QEMUSoundCard card;
> @@ -256,7 +260,8 @@ static void wm8750_clk_update(WM8750State *s, int ext)
>
> static void wm8750_reset(I2CSlave *i2c)
> {
> - WM8750State *s = (WM8750State *) i2c;
> + WM8750State *s = WM8750(i2c);
> +
> s->rate = &wm_rate_table[0];
> s->enable = 0;
> wm8750_clk_update(s, 1);
> @@ -299,7 +304,7 @@ static void wm8750_reset(I2CSlave *i2c)
>
> static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
> {
> - WM8750State *s = (WM8750State *) i2c;
> + WM8750State *s = WM8750(i2c);
>
> switch (event) {
> case I2C_START_SEND:
> @@ -356,7 +361,7 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
>
> static int wm8750_tx(I2CSlave *i2c, uint8_t data)
> {
> - WM8750State *s = (WM8750State *) i2c;
> + WM8750State *s = WM8750(i2c);
> uint8_t cmd;
> uint16_t value;
>
> @@ -542,7 +547,7 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
> break;
>
> case WM8750_RESET: /* Reset */
> - wm8750_reset(&s->i2c);
> + wm8750_reset(I2C_SLAVE(s));
> break;
>
> #ifdef VERBOSE
> @@ -604,17 +609,17 @@ static const VMStateDescription vmstate_wm8750 = {
> VMSTATE_UINT8(format, WM8750State),
> VMSTATE_UINT8(power, WM8750State),
> VMSTATE_UINT8(rate_vmstate, WM8750State),
> - VMSTATE_I2C_SLAVE(i2c, WM8750State),
> + VMSTATE_I2C_SLAVE(parent_obj, WM8750State),
> VMSTATE_END_OF_LIST()
> }
> };
>
> static int wm8750_init(I2CSlave *i2c)
> {
> - WM8750State *s = FROM_I2C_SLAVE(WM8750State, i2c);
> + WM8750State *s = WM8750(i2c);
>
> AUD_register_card(CODEC, &s->card);
> - wm8750_reset(&s->i2c);
> + wm8750_reset(I2C_SLAVE(s));
... [1] here. Change is good though.
Otherwise
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> return 0;
> }
> @@ -622,8 +627,9 @@ static int wm8750_init(I2CSlave *i2c)
> #if 0
> static void wm8750_fini(I2CSlave *i2c)
> {
> - WM8750State *s = (WM8750State *) i2c;
> - wm8750_reset(&s->i2c);
> + WM8750State *s = WM8750(i2c);
> +
> + wm8750_reset(I2C_SLAVE(s));
> AUD_remove_card(&s->card);
> g_free(s);
> }
> @@ -632,7 +638,8 @@ static void wm8750_fini(I2CSlave *i2c)
> void wm8750_data_req_set(DeviceState *dev,
> void (*data_req)(void *, int, int), void *opaque)
> {
> - WM8750State *s = FROM_I2C_SLAVE(WM8750State, I2C_SLAVE(dev));
> + WM8750State *s = WM8750(dev);
> +
> s->data_req = data_req;
> s->opaque = opaque;
> }
> @@ -702,7 +709,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo wm8750_info = {
> - .name = "wm8750",
> + .name = TYPE_WM8750,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(WM8750State),
> .class_init = wm8750_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify Andreas Färber
@ 2014-02-09 1:42 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:42 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/display/ssd0303.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c
> index beea5bf..89804e1 100644
> --- a/hw/display/ssd0303.c
> +++ b/hw/display/ssd0303.c
> @@ -41,8 +41,12 @@ enum ssd0303_cmd {
> SSD0303_CMD_SKIP1
> };
>
> +#define TYPE_SSD0303 "ssd0303"
> +#define SSD0303(obj) OBJECT_CHECK(ssd0303_state, (obj), TYPE_SSD0303)
> +
> typedef struct {
> - I2CSlave i2c;
> + I2CSlave parent_obj;
> +
> QemuConsole *con;
> int row;
> int col;
> @@ -65,8 +69,9 @@ static int ssd0303_recv(I2CSlave *i2c)
>
> static int ssd0303_send(I2CSlave *i2c, uint8_t data)
> {
> - ssd0303_state *s = (ssd0303_state *)i2c;
> + ssd0303_state *s = SSD0303(i2c);
> enum ssd0303_cmd old_cmd_state;
> +
> switch (s->mode) {
> case SSD0303_IDLE:
> DPRINTF("byte 0x%02x\n", data);
> @@ -175,7 +180,8 @@ static int ssd0303_send(I2CSlave *i2c, uint8_t data)
>
> static void ssd0303_event(I2CSlave *i2c, enum i2c_event event)
> {
> - ssd0303_state *s = (ssd0303_state *)i2c;
> + ssd0303_state *s = SSD0303(i2c);
> +
> switch (event) {
> case I2C_FINISH:
> s->mode = SSD0303_IDLE;
> @@ -279,7 +285,7 @@ static const VMStateDescription vmstate_ssd0303 = {
> VMSTATE_UINT32(mode, ssd0303_state),
> VMSTATE_UINT32(cmd_state, ssd0303_state),
> VMSTATE_BUFFER(framebuffer, ssd0303_state),
> - VMSTATE_I2C_SLAVE(i2c, ssd0303_state),
> + VMSTATE_I2C_SLAVE(parent_obj, ssd0303_state),
> VMSTATE_END_OF_LIST()
> }
> };
> @@ -291,7 +297,7 @@ static const GraphicHwOps ssd0303_ops = {
>
> static int ssd0303_init(I2CSlave *i2c)
> {
> - ssd0303_state *s = FROM_I2C_SLAVE(ssd0303_state, i2c);
> + ssd0303_state *s = SSD0303(i2c);
>
> s->con = graphic_console_init(DEVICE(i2c), &ssd0303_ops, s);
> qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY);
> @@ -311,7 +317,7 @@ static void ssd0303_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo ssd0303_info = {
> - .name = "ssd0303",
> + .name = TYPE_SSD0303,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(ssd0303_state),
> .class_init = ssd0303_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 07/11] max7310: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 07/11] max7310: QOM'ify Andreas Färber
@ 2014-02-09 1:43 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:43 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace FROM_I2C_SLAVE() usages with QOM cast macro.
> Rename parent field.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/gpio/max7310.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
> index 59b2877..cfcd89c 100644
> --- a/hw/gpio/max7310.c
> +++ b/hw/gpio/max7310.c
> @@ -9,8 +9,12 @@
>
> #include "hw/i2c/i2c.h"
>
> -typedef struct {
> - I2CSlave i2c;
> +#define TYPE_MAX7310 "max7310"
> +#define MAX7310(obj) OBJECT_CHECK(MAX7310State, (obj), TYPE_MAX7310)
> +
> +typedef struct MAX7310State {
> + I2CSlave parent_obj;
> +
> int i2c_command_byte;
> int len;
>
> @@ -25,7 +29,8 @@ typedef struct {
>
> static void max7310_reset(DeviceState *dev)
> {
> - MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, I2C_SLAVE(dev));
> + MAX7310State *s = MAX7310(dev);
> +
> s->level &= s->direction;
> s->direction = 0xff;
> s->polarity = 0xf0;
> @@ -35,7 +40,7 @@ static void max7310_reset(DeviceState *dev)
>
> static int max7310_rx(I2CSlave *i2c)
> {
> - MAX7310State *s = (MAX7310State *) i2c;
> + MAX7310State *s = MAX7310(i2c);
>
> switch (s->command) {
> case 0x00: /* Input port */
> @@ -70,7 +75,7 @@ static int max7310_rx(I2CSlave *i2c)
>
> static int max7310_tx(I2CSlave *i2c, uint8_t data)
> {
> - MAX7310State *s = (MAX7310State *) i2c;
> + MAX7310State *s = MAX7310(i2c);
> uint8_t diff;
> int line;
>
> @@ -125,7 +130,7 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
>
> static void max7310_event(I2CSlave *i2c, enum i2c_event event)
> {
> - MAX7310State *s = (MAX7310State *) i2c;
> + MAX7310State *s = MAX7310(i2c);
> s->len = 0;
>
> switch (event) {
> @@ -156,7 +161,7 @@ static const VMStateDescription vmstate_max7310 = {
> VMSTATE_UINT8(polarity, MAX7310State),
> VMSTATE_UINT8(status, MAX7310State),
> VMSTATE_UINT8(command, MAX7310State),
> - VMSTATE_I2C_SLAVE(i2c, MAX7310State),
> + VMSTATE_I2C_SLAVE(parent_obj, MAX7310State),
> VMSTATE_END_OF_LIST()
> }
> };
> @@ -177,7 +182,7 @@ static void max7310_gpio_set(void *opaque, int line, int level)
> * but also accepts sequences that are not SMBus so return an I2C device. */
> static int max7310_init(I2CSlave *i2c)
> {
> - MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c);
> + MAX7310State *s = MAX7310(i2c);
>
> qdev_init_gpio_in(&i2c->qdev, max7310_gpio_set, 8);
> qdev_init_gpio_out(&i2c->qdev, s->handler, 8);
> @@ -199,7 +204,7 @@ static void max7310_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo max7310_info = {
> - .name = "max7310",
> + .name = TYPE_MAX7310,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(MAX7310State),
> .class_init = max7310_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify Andreas Färber
@ 2014-02-09 1:45 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:45 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
Same as before, "removal of pointer casts" or something like.
Otherwise:
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/input/lm832x.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c
> index f583cf0..4ae1cd9 100644
> --- a/hw/input/lm832x.c
> +++ b/hw/input/lm832x.c
> @@ -23,8 +23,12 @@
> #include "qemu/timer.h"
> #include "ui/console.h"
>
> +#define TYPE_LM8323 "lm8323"
> +#define LM8323(obj) OBJECT_CHECK(LM823KbdState, (obj), TYPE_LM8323)
> +
> typedef struct {
> - I2CSlave i2c;
> + I2CSlave parent_obj;
> +
> uint8_t i2c_dir;
> uint8_t i2c_cycle;
> uint8_t reg;
> @@ -380,7 +384,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)
>
> static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)
> {
> - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
> + LM823KbdState *s = LM8323(i2c);
>
> switch (event) {
> case I2C_START_RECV:
> @@ -396,14 +400,14 @@ static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)
>
> static int lm_i2c_rx(I2CSlave *i2c)
> {
> - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
> + LM823KbdState *s = LM8323(i2c);
>
> return lm_kbd_read(s, s->reg, s->i2c_cycle ++);
> }
>
> static int lm_i2c_tx(I2CSlave *i2c, uint8_t data)
> {
> - LM823KbdState *s = (LM823KbdState *) i2c;
> + LM823KbdState *s = LM8323(i2c);
>
> if (!s->i2c_cycle)
> s->reg = data;
> @@ -431,7 +435,7 @@ static const VMStateDescription vmstate_lm_kbd = {
> .minimum_version_id_old = 0,
> .post_load = lm_kbd_post_load,
> .fields = (VMStateField []) {
> - VMSTATE_I2C_SLAVE(i2c, LM823KbdState),
> + VMSTATE_I2C_SLAVE(parent_obj, LM823KbdState),
> VMSTATE_UINT8(i2c_dir, LM823KbdState),
> VMSTATE_UINT8(i2c_cycle, LM823KbdState),
> VMSTATE_UINT8(reg, LM823KbdState),
> @@ -460,13 +464,13 @@ static const VMStateDescription vmstate_lm_kbd = {
>
> static int lm8323_init(I2CSlave *i2c)
> {
> - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
> + LM823KbdState *s = LM8323(i2c);
>
> s->model = 0x8323;
> s->pwm.tm[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm0_tick, s);
> s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
> s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
> - qdev_init_gpio_out(&i2c->qdev, &s->nirq, 1);
> + qdev_init_gpio_out(DEVICE(i2c), &s->nirq, 1);
>
> lm_kbd_reset(s);
>
> @@ -476,7 +480,7 @@ static int lm8323_init(I2CSlave *i2c)
>
> void lm832x_key_event(DeviceState *dev, int key, int state)
> {
> - LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE(dev));
> + LM823KbdState *s = LM8323(dev);
>
> if ((s->status & INT_ERROR) && (s->error & ERR_FIFOOVR))
> return;
> @@ -507,7 +511,7 @@ static void lm8323_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo lm8323_info = {
> - .name = "lm8323",
> + .name = TYPE_LM8323,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(LM823KbdState),
> .class_init = lm8323_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify Andreas Färber
@ 2014-02-09 1:45 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:45 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/timer/ds1338.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
> index 8987cdc..bb2f8ee 100644
> --- a/hw/timer/ds1338.c
> +++ b/hw/timer/ds1338.c
> @@ -23,8 +23,12 @@
> #define HOURS_PM 0x20
> #define CTRL_OSF 0x20
>
> -typedef struct {
> - I2CSlave i2c;
> +#define TYPE_DS1338 "ds1338"
> +#define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338)
> +
> +typedef struct DS1338State {
> + I2CSlave parent_obj;
> +
> int64_t offset;
> uint8_t wday_offset;
> uint8_t nvram[NVRAM_SIZE];
> @@ -38,7 +42,7 @@ static const VMStateDescription vmstate_ds1338 = {
> .minimum_version_id = 1,
> .minimum_version_id_old = 1,
> .fields = (VMStateField[]) {
> - VMSTATE_I2C_SLAVE(i2c, DS1338State),
> + VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
> VMSTATE_INT64(offset, DS1338State),
> VMSTATE_UINT8_V(wday_offset, DS1338State, 2),
> VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE),
> @@ -90,7 +94,7 @@ static void inc_regptr(DS1338State *s)
>
> static void ds1338_event(I2CSlave *i2c, enum i2c_event event)
> {
> - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
> + DS1338State *s = DS1338(i2c);
>
> switch (event) {
> case I2C_START_RECV:
> @@ -111,7 +115,7 @@ static void ds1338_event(I2CSlave *i2c, enum i2c_event event)
>
> static int ds1338_recv(I2CSlave *i2c)
> {
> - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
> + DS1338State *s = DS1338(i2c);
> uint8_t res;
>
> res = s->nvram[s->ptr];
> @@ -121,7 +125,8 @@ static int ds1338_recv(I2CSlave *i2c)
>
> static int ds1338_send(I2CSlave *i2c, uint8_t data)
> {
> - DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
> + DS1338State *s = DS1338(i2c);
> +
> if (s->addr_byte) {
> s->ptr = data & (NVRAM_SIZE - 1);
> s->addr_byte = false;
> @@ -198,7 +203,7 @@ static int ds1338_init(I2CSlave *i2c)
>
> static void ds1338_reset(DeviceState *dev)
> {
> - DS1338State *s = FROM_I2C_SLAVE(DS1338State, I2C_SLAVE(dev));
> + DS1338State *s = DS1338(dev);
>
> /* The clock is running and synchronized with the host */
> s->offset = 0;
> @@ -222,7 +227,7 @@ static void ds1338_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo ds1338_info = {
> - .name = "ds1338",
> + .name = TYPE_DS1338,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(DS1338State),
> .class_init = ds1338_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify Andreas Färber
@ 2014-02-09 1:50 ` Peter Crosthwaite
0 siblings, 0 replies; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:50 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
"-> cast removed" &&
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/timer/twl92230.c | 35 +++++++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
> index f3ea365..85d5990 100644
> --- a/hw/timer/twl92230.c
> +++ b/hw/timer/twl92230.c
> @@ -27,8 +27,11 @@
>
> #define VERBOSE 1
>
> -typedef struct {
> - I2CSlave i2c;
> +#define TYPE_TWL92230 "twl92230"
> +#define TWL92230(obj) OBJECT_CHECK(MenelausState, (obj), TYPE_TWL92230)
> +
> +typedef struct MenelausState {
> + I2CSlave parent_obj;
>
> int firstbyte;
> uint8_t reg;
> @@ -127,7 +130,8 @@ static void menelaus_rtc_hz(void *opaque)
>
> static void menelaus_reset(I2CSlave *i2c)
> {
> - MenelausState *s = (MenelausState *) i2c;
> + MenelausState *s = TWL92230(i2c);
> +
> s->reg = 0x00;
>
> s->vcore[0] = 0x0c; /* XXX: X-loader needs 0x8c? check! */
> @@ -492,8 +496,9 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
> break;
>
> case MENELAUS_DEVICE_OFF:
> - if (value & 1)
> - menelaus_reset(&s->i2c);
> + if (value & 1) {
> + menelaus_reset(I2C_SLAVE(s));
> + }
> break;
>
> case MENELAUS_OSC_CTRL:
> @@ -708,7 +713,7 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
>
> static void menelaus_event(I2CSlave *i2c, enum i2c_event event)
> {
> - MenelausState *s = (MenelausState *) i2c;
> + MenelausState *s = TWL92230(i2c);
>
> if (event == I2C_START_SEND)
> s->firstbyte = 1;
> @@ -716,7 +721,8 @@ static void menelaus_event(I2CSlave *i2c, enum i2c_event event)
>
> static int menelaus_tx(I2CSlave *i2c, uint8_t data)
> {
> - MenelausState *s = (MenelausState *) i2c;
> + MenelausState *s = TWL92230(i2c);
> +
> /* Interpret register address byte */
> if (s->firstbyte) {
> s->reg = data;
> @@ -729,7 +735,7 @@ static int menelaus_tx(I2CSlave *i2c, uint8_t data)
>
> static int menelaus_rx(I2CSlave *i2c)
> {
> - MenelausState *s = (MenelausState *) i2c;
> + MenelausState *s = TWL92230(i2c);
>
> return menelaus_read(s, s->reg ++);
> }
> @@ -834,23 +840,24 @@ static const VMStateDescription vmstate_menelaus = {
> VMSTATE_STRUCT(rtc.alm, MenelausState, 0, vmstate_menelaus_tm,
> struct tm),
> VMSTATE_UINT8(pwrbtn_state, MenelausState),
> - VMSTATE_I2C_SLAVE(i2c, MenelausState),
> + VMSTATE_I2C_SLAVE(parent_obj, MenelausState),
> VMSTATE_END_OF_LIST()
> }
> };
>
> static int twl92230_init(I2CSlave *i2c)
> {
> - MenelausState *s = FROM_I2C_SLAVE(MenelausState, i2c);
> + DeviceState *dev = DEVICE(i2c);
> + MenelausState *s = TWL92230(i2c);
>
> s->rtc.hz_tm = timer_new_ms(rtc_clock, menelaus_rtc_hz, s);
> /* Three output pins plus one interrupt pin. */
> - qdev_init_gpio_out(&i2c->qdev, s->out, 4);
> + qdev_init_gpio_out(dev, s->out, 4);
>
> /* Three input pins plus one power-button pin. */
> - qdev_init_gpio_in(&i2c->qdev, menelaus_gpio_set, 4);
> + qdev_init_gpio_in(dev, menelaus_gpio_set, 4);
>
> - menelaus_reset(&s->i2c);
> + menelaus_reset(i2c);
>
> return 0;
> }
> @@ -868,7 +875,7 @@ static void twl92230_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo twl92230_info = {
> - .name = "twl92230",
> + .name = TYPE_TWL92230,
> .parent = TYPE_I2C_SLAVE,
> .instance_size = sizeof(MenelausState),
> .class_init = twl92230_class_init,
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro
2014-01-31 14:34 ` [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro Andreas Färber
@ 2014-02-09 1:53 ` Peter Crosthwaite
2014-02-09 12:49 ` Andreas Färber
0 siblings, 1 reply; 32+ messages in thread
From: Peter Crosthwaite @ 2014-02-09 1:53 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-devel@nongnu.org Developers
On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
> Use type-specific QOM cast macros instead.
>
Should be past tense - "We now use type-specific ...". The imperative
form of "use" suggests you are making the change in this patch but you
have already done it.
> Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> include/hw/i2c/i2c.h | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
> index 9df987b..4986ebc 100644
> --- a/include/hw/i2c/i2c.h
> +++ b/include/hw/i2c/i2c.h
> @@ -59,8 +59,6 @@ void i2c_nack(I2CBus *bus);
> int i2c_send(I2CBus *bus, uint8_t data);
> int i2c_recv(I2CBus *bus);
>
> -#define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
> -
> DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
>
> /* wm8750.c */
> --
> 1.8.4.5
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1
2014-02-09 1:29 ` Peter Crosthwaite
@ 2014-02-09 1:59 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 1:59 UTC (permalink / raw)
To: Peter Crosthwaite
Cc: Peter Maydell, qemu-devel@nongnu.org Developers, Anthony Liguori
Am 09.02.2014 02:29, schrieb Peter Crosthwaite:
> On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Hello,
>>
>> This series prepares for converting I2C to QOM realize.
>>
>
> Incase you are moving onto SSI next I do have a have half a start on
> this change pattern for SSI (In particular, I think Ive removed
> FROM_SSI_SLAVE for some re-org reasons). I better post. Ping me if SSI
> qomification gets in your way before I get a chance to post.
Thanks for your review!
I don't think I have SSI changes queued and I don't have much time to
work on new big series for 2.0 myself, I'm rather going through and
flushing my local branches here. But if you have something cleaned up
and ready, feel free to post.
The "removal of pointer casts" was a direct consequence of renaming the
parent field, but I'll add it to the commit messages, thanks for
pointing it out - better too verbose than too brief.
Cheers,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave
2014-02-09 1:35 ` Peter Crosthwaite
@ 2014-02-09 12:24 ` Andreas Färber
2014-02-09 12:36 ` Peter Maydell
0 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 12:24 UTC (permalink / raw)
To: Peter Crosthwaite; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers
Am 09.02.2014 02:35, schrieb Peter Crosthwaite:
> On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Replace usages of FROM_I2C_SLAVE() with QOM cast macro and rename parent
>> field to assure we caught all.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> hw/arm/pxa2xx.c | 38 +++++++++++++++++++++++++-------------
>> 1 file changed, 25 insertions(+), 13 deletions(-)
>>
>> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
>> index daf60e8..e5f1e10 100644
>> --- a/hw/arm/pxa2xx.c
>> +++ b/hw/arm/pxa2xx.c
>> @@ -1222,8 +1222,14 @@ static const TypeInfo pxa2xx_rtc_sysbus_info = {
>> };
>>
>> /* I2C Interface */
>> -typedef struct {
>> - I2CSlave i2c;
>> +
>> +#define TYPE_PXA2XX_I2C_SLAVE "pxa2xx-i2c-slave"
>> +#define PXA2XX_I2C_SLAVE(obj) \
>> + OBJECT_CHECK(PXA2xxI2CSlaveState, (obj), TYPE_PXA2XX_I2C_SLAVE)
>> +
>> +typedef struct PXA2xxI2CSlaveState {
>> + I2CSlave parent_obj;
>> +
>> PXA2xxI2CState *host;
>> } PXA2xxI2CSlaveState;
>>
>> @@ -1268,7 +1274,7 @@ static void pxa2xx_i2c_update(PXA2xxI2CState *s)
>> /* These are only stubs now. */
>> static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
>> {
>> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
>> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
>> PXA2xxI2CState *s = slave->host;
>>
>> switch (event) {
>> @@ -1292,10 +1298,12 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
>>
>> static int pxa2xx_i2c_rx(I2CSlave *i2c)
>> {
>> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
>> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
>> PXA2xxI2CState *s = slave->host;
>> - if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
>> +
>> + if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
>> return 0;
>> + }
>
> This will look funny when git-blamed. Should out-of-scope trivials be
> separate patch so anyone git-blame will at least see "Fix coding
> style" rather than then misleading "QOM'ify I2C"?.
We've had the policy of fixing Coding Style on lines touched or adjacent
to those touched, to gradually get rid of them - this one was within 3
lines of context. I'm sure PXA code will have many more Coding Style
faults, so placing 2 out of X in their own patch seems silly. Should I
rather drop them?
> With the multiple
> instances of this cleanup it should at least feature in the commit
> message.
You're right that I should've mentioned it. Same for replacing parent
field accesses. Fixed.
Regards,
Andreas
>>
>> if (s->status & (1 << 0)) { /* RWM */
>> s->status |= 1 << 6; /* set ITE */
>> @@ -1307,10 +1315,12 @@ static int pxa2xx_i2c_rx(I2CSlave *i2c)
>>
>> static int pxa2xx_i2c_tx(I2CSlave *i2c, uint8_t data)
>> {
>> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
>> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
>> PXA2xxI2CState *s = slave->host;
>> - if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
>> +
>> + if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
>> return 1;
>> + }
>>
>> if (!(s->status & (1 << 0))) { /* RWM */
>> s->status |= 1 << 7; /* set IRF */
>> @@ -1325,6 +1335,7 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
>> unsigned size)
>> {
>> PXA2xxI2CState *s = (PXA2xxI2CState *) opaque;
>> + I2CSlave *slave;
>>
>> addr -= s->offset;
>> switch (addr) {
>> @@ -1333,7 +1344,8 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
>> case ISR:
>> return s->status | (i2c_bus_busy(s->bus) << 2);
>> case ISAR:
>> - return s->slave->i2c.address;
>> + slave = I2C_SLAVE(s->slave);
>> + return slave->address;
>> case IDBR:
>> return s->data;
>> case IBMR:
>> @@ -1408,7 +1420,7 @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr,
>> break;
>>
>> case ISAR:
>> - i2c_set_slave_address(&s->slave->i2c, value & 0x7f);
>> + i2c_set_slave_address(I2C_SLAVE(s->slave), value & 0x7f);
>> break;
>>
>> case IDBR:
>> @@ -1432,7 +1444,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c_slave = {
>> .minimum_version_id = 1,
>> .minimum_version_id_old = 1,
>> .fields = (VMStateField []) {
>> - VMSTATE_I2C_SLAVE(i2c, PXA2xxI2CSlaveState),
>> + VMSTATE_I2C_SLAVE(parent_obj, PXA2xxI2CSlaveState),
>> VMSTATE_END_OF_LIST()
>> }
>> };
>> @@ -1470,7 +1482,7 @@ static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)
>> }
>>
>> static const TypeInfo pxa2xx_i2c_slave_info = {
>> - .name = "pxa2xx-i2c-slave",
>> + .name = TYPE_PXA2XX_I2C_SLAVE,
>> .parent = TYPE_I2C_SLAVE,
>> .instance_size = sizeof(PXA2xxI2CSlaveState),
>> .class_init = pxa2xx_i2c_slave_class_init,
>> @@ -1496,8 +1508,8 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
>> s = PXA2XX_I2C(i2c_dev);
>> /* FIXME: Should the slave device really be on a separate bus? */
>> i2cbus = i2c_init_bus(dev, "dummy");
>> - dev = i2c_create_slave(i2cbus, "pxa2xx-i2c-slave", 0);
>> - s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
>> + dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
>> + s->slave = PXA2XX_I2C_SLAVE(dev);
>> s->slave->host = s;
>>
>> return s;
>> --
>> 1.8.4.5
>>
>>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave
2014-02-09 12:24 ` Andreas Färber
@ 2014-02-09 12:36 ` Peter Maydell
0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2014-02-09 12:36 UTC (permalink / raw)
To: Andreas Färber; +Cc: Peter Crosthwaite, qemu-devel@nongnu.org Developers
On 9 February 2014 12:24, Andreas Färber <afaerber@suse.de> wrote:
> Am 09.02.2014 02:35, schrieb Peter Crosthwaite:
>> On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
>>> @@ -1292,10 +1298,12 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
>>>
>>> static int pxa2xx_i2c_rx(I2CSlave *i2c)
>>> {
>>> - PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
>>> + PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
>>> PXA2xxI2CState *s = slave->host;
>>> - if ((s->control & (1 << 14)) || !(s->control & (1 << 6)))
>>> +
>>> + if ((s->control & (1 << 14)) || !(s->control & (1 << 6))) {
>>> return 0;
>>> + }
>>
>> This will look funny when git-blamed. Should out-of-scope trivials be
>> separate patch so anyone git-blame will at least see "Fix coding
>> style" rather than then misleading "QOM'ify I2C"?.
>
> We've had the policy of fixing Coding Style on lines touched or adjacent
> to those touched, to gradually get rid of them - this one was within 3
> lines of context. I'm sure PXA code will have many more Coding Style
> faults, so placing 2 out of X in their own patch seems silly. Should I
> rather drop them?
I'll weigh in here since in some sense pxa2xx is my department,
I guess. I would probably not have personally bothered with this
style fix (my usual personal approach is "if checkpatch complains"),
but as Andreas says it's within our usual practice, so I don't have
a problem with it.
thanks
-- PMM
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro
2014-02-09 1:53 ` Peter Crosthwaite
@ 2014-02-09 12:49 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 12:49 UTC (permalink / raw)
To: Peter Crosthwaite; +Cc: qemu-devel@nongnu.org Developers
Am 09.02.2014 02:53, schrieb Peter Crosthwaite:
> On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Use type-specific QOM cast macros instead.
>>
>
> Should be past tense - "We now use type-specific ...". The imperative
> form of "use" suggests you are making the change in this patch but you
> have already done it.
It was meant as a guidance for resolving conflicts due to lack of that
macro, not as a description of past patches. I've adopted your wording.
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Thanks,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave
2014-01-31 14:34 ` [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave Andreas Färber
2014-02-09 1:35 ` Peter Crosthwaite
@ 2014-02-09 12:56 ` Andreas Färber
1 sibling, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 12:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Peter Crosthwaite
Am 31.01.2014 15:34, schrieb Andreas Färber:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro and rename parent
> field to assure we caught all.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/arm/pxa2xx.c | 38 +++++++++++++++++++++++++-------------
> 1 file changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index daf60e8..e5f1e10 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
[...]
> @@ -1496,8 +1508,8 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
> s = PXA2XX_I2C(i2c_dev);
> /* FIXME: Should the slave device really be on a separate bus? */
> i2cbus = i2c_init_bus(dev, "dummy");
> - dev = i2c_create_slave(i2cbus, "pxa2xx-i2c-slave", 0);
> - s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
> + dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
> + s->slave = PXA2XX_I2C_SLAVE(dev);
> s->slave->host = s;
>
> return s;
In line with Peter C.'s other comments, I've added mention that I'm
reusing the type constant here. Will go through others to do the same.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915
2014-02-09 1:38 ` Peter Crosthwaite
@ 2014-02-09 13:04 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 13:04 UTC (permalink / raw)
To: Peter Crosthwaite; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers
Am 09.02.2014 02:38, schrieb Peter Crosthwaite:
> On Sat, Feb 1, 2014 at 12:34 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Thanks, adding and mentioning the following on top:
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 69c4d38..67c1be8 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -357,7 +357,7 @@ static void z2_init(QEMUMachineInitArgs *args)
type_register_static(&aer915_info);
z2_lcd = ssi_create_slave(mpu->ssp[1], "zipit-lcd");
bus = pxa2xx_i2c_bus(mpu->i2c[0]);
- i2c_create_slave(bus, "aer915", 0x55);
+ i2c_create_slave(bus, TYPE_AER915, 0x55);
wm = i2c_create_slave(bus, "wm8750", 0x1b);
mpu->i2s->opaque = wm;
mpu->i2s->codec_out = wm8750_dac_dat;
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify
2014-01-31 14:34 ` [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify Andreas Färber
2014-02-09 1:41 ` Peter Crosthwaite
@ 2014-02-09 13:10 ` Andreas Färber
1 sibling, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2014-02-09 13:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Vassili Karpov (malc), Gerd Hoffmann
Am 31.01.2014 15:34, schrieb Andreas Färber:
> Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
> Rename parent field.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/audio/wm8750.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
Follow-up TODO: Move wm8750_*() prototypes out of include/hw/i2c/i2c.h
a) as header cleanup, b) to place TYPE_WM8750 in an
include/hw/audio/wm8750.h for reuse in z2.c, spitz.c, musicpal.c.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2014-02-09 13:11 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-31 14:34 [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus Andreas Färber
2014-02-09 1:24 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave Andreas Färber
2014-02-09 1:35 ` Peter Crosthwaite
2014-02-09 12:24 ` Andreas Färber
2014-02-09 12:36 ` Peter Maydell
2014-02-09 12:56 ` Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC Andreas Färber
2014-02-09 1:37 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915 Andreas Färber
2014-02-09 1:38 ` Peter Crosthwaite
2014-02-09 13:04 ` Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 05/11] wm8750: QOM'ify Andreas Färber
2014-02-09 1:41 ` Peter Crosthwaite
2014-02-09 13:10 ` Andreas Färber
2014-01-31 14:34 ` [Qemu-devel] [PATCH 06/11] ssd0303: QOM'ify Andreas Färber
2014-02-09 1:42 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 07/11] max7310: QOM'ify Andreas Färber
2014-02-09 1:43 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 08/11] lm832x: QOM'ify Andreas Färber
2014-02-09 1:45 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 09/11] ds1338: QOM'ify Andreas Färber
2014-02-09 1:45 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 10/11] twl92230: QOM'ify Andreas Färber
2014-02-09 1:50 ` Peter Crosthwaite
2014-01-31 14:34 ` [Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro Andreas Färber
2014-02-09 1:53 ` Peter Crosthwaite
2014-02-09 12:49 ` Andreas Färber
2014-02-08 17:22 ` [Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1 Andreas Färber
2014-02-09 1:29 ` Peter Crosthwaite
2014-02-09 1:59 ` Andreas Färber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).