Am 24.07.2013 09:48, schrieb Andreas Färber:
> Signed-off-by: Andreas Färber <afaer...@suse.de>
> ---
>  hw/arm/pxa2xx.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index 6548338..ab145ee 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -1224,8 +1224,15 @@ typedef struct {
>      PXA2xxI2CState *host;
>  } PXA2xxI2CSlaveState;
>  
> +#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
> +#define PXA2XX_I2C(obj) \
> +    OBJECT_CHECK(PXA2xxI2CState, (obj), TYPE_PXA2XX_I2C)
> +
>  struct PXA2xxI2CState {
> -    SysBusDevice busdev;
> +    /*< private >*/
> +    SysBusDevice parent_obj;
> +    /*< public >*/
> +
>      MemoryRegion iomem;
>      PXA2xxI2CSlaveState *slave;
>      i2c_bus *bus;
> @@ -1473,7 +1480,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
>      SysBusDevice *i2c_dev;
>      PXA2xxI2CState *s;
>  
> -    i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, "pxa2xx_i2c"));
> +    i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, TYPE_PXA2XX_I2C));
>      qdev_prop_set_uint32(&i2c_dev->qdev, "size", region_size + 1);
>      qdev_prop_set_uint32(&i2c_dev->qdev, "offset", base & region_size);
>  
> @@ -1482,7 +1489,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
>      sysbus_mmio_map(i2c_dev, 0, base & ~region_size);
>      sysbus_connect_irq(i2c_dev, 0, irq);
>  
> -    s = FROM_SYSBUS(PXA2xxI2CState, i2c_dev);
> +    s = PXA2XX_I2C(i2c_dev);
>      /* FIXME: Should the slave device really be on a separate bus?  */
>      dev = i2c_create_slave(i2c_init_bus(NULL, "dummy"), "pxa2xx-i2c-slave", 
> 0);
>      s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
[snip]

Needs the following addition.

Andreas

diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index ab145ee..ec3ac58 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1480,11 +1480,12 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
     SysBusDevice *i2c_dev;
     PXA2xxI2CState *s;

-    i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, TYPE_PXA2XX_I2C));
-    qdev_prop_set_uint32(&i2c_dev->qdev, "size", region_size + 1);
-    qdev_prop_set_uint32(&i2c_dev->qdev, "offset", base & region_size);
+    dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
+    i2c_dev = SYS_BUS_DEVICE(dev);
+    qdev_prop_set_uint32(dev, "size", region_size + 1);
+    qdev_prop_set_uint32(dev, "offset", base & region_size);

-    qdev_init_nofail(&i2c_dev->qdev);
+    qdev_init_nofail(dev);

     sysbus_mmio_map(i2c_dev, 0, base & ~region_size);
     sysbus_connect_irq(i2c_dev, 0, irq);


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

Reply via email to