Skip to contentSkip to conversation

SSI QOM cleanups

PATCH Applied Peter Crosthwaite 2 participants 16 messages Feb 12, 2014 – Mar 4, 2014

lore
Share & tools
lore
#0 lore raw

cover SSI QOM cleanups

Hi Andreas,

Here is a mixed bag of QOM cleanups, moving us slightly closer to QOMification of SSI.

This prepares support for some major refactoring around SSI (in particular some QSPI patches).

Regards,
Peter

Peter Crosthwaite (6):
ssi: Convert legacy casts from SSI_SLAVE->DEVICE
ssi: Remove legacy SSI_BUS->BUS cast
misc: max111x: Create abstract max111x class
misc: max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV macro block/m25p80: Remove FROM_SSI_SLAVE usages

 hw/arm/spitz.c       |  9 +++++----
 hw/block/m25p80.c    |  6 +++---
 hw/display/ads7846.c |  2 +-
 hw/display/ssd0323.c |  4 ++--
 hw/misc/max111x.c    | 46 +++++++++++++++++++++++++++++++++-------------
 hw/sd/ssi-sd.c       |  2 +-
 hw/ssi/ssi.c         |  4 ++--
 include/hw/ssi.h     |  1 -
 8 files changed, 47 insertions(+), 27 deletions(-)
Signature · 1 line
1.8.5.4
#1 lore raw

PATCH 1/6 ssi: Convert legacy casts from SSI_SLAVE->DEVICE

Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE.

---

 hw/arm/spitz.c       | 9 +++++----
 hw/display/ads7846.c | 2 +-
 hw/display/ssd0323.c | 4 ++--
 hw/misc/max111x.c    | 4 ++--
 hw/sd/ssi-sd.c       | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
hw/arm/spitz.c +5 -4
index ba17283..c7b3a94 100644
@@ -660,12 +660,13 @@ static void spitz_adc_temp_on(void *opaque, int line, int level)
 
 static int corgi_ssp_init(SSISlave *dev)
 {
+    DeviceState *d = DEVICE(dev);
     CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev);
 
-    qdev_init_gpio_in(&dev->qdev, corgi_ssp_gpio_cs, 3);
-    s->bus[0] = ssi_create_bus(&dev->qdev, "ssi0");
-    s->bus[1] = ssi_create_bus(&dev->qdev, "ssi1");
-    s->bus[2] = ssi_create_bus(&dev->qdev, "ssi2");
+    qdev_init_gpio_in(d, corgi_ssp_gpio_cs, 3);
+    s->bus[0] = ssi_create_bus(d, "ssi0");
+    s->bus[1] = ssi_create_bus(d, "ssi1");
+    s->bus[2] = ssi_create_bus(d, "ssi2");
 
     return 0;
 }
hw/display/ads7846.c +1 -1
index 5da3dc5..87beefe 100644
@@ -137,7 +137,7 @@ static int ads7846_init(SSISlave *dev)
 {
     ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, dev);
 
-    qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1);
+    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 
     s->input[0] = ADS_TEMP0;	/* TEMP0 */
     s->input[2] = ADS_VBAT;	/* VBAT */
hw/display/ssd0323.c +2 -2
index c3231c6..c463bd8 100644
@@ -345,9 +345,9 @@ static int ssd0323_init(SSISlave *dev)
     s->con = graphic_console_init(DEVICE(dev), &ssd0323_ops, s);
     qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY);
 
-    qdev_init_gpio_in(&dev->qdev, ssd0323_cd, 1);
+    qdev_init_gpio_in(DEVICE(dev), ssd0323_cd, 1);
 
-    register_savevm(&dev->qdev, "ssd0323_oled", -1, 1,
+    register_savevm(DEVICE(dev), "ssd0323_oled", -1, 1,
                     ssd0323_save, ssd0323_load, s);
     return 0;
 }
hw/misc/max111x.c +2 -2
index d477ecd..fcf2a4d 100644
@@ -119,7 +119,7 @@ static int max111x_init(SSISlave *dev, int inputs)
 {
     MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
 
-    qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1);
+    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 
     s->inputs = inputs;
     /* TODO: add a user interface for setting these */
@@ -133,7 +133,7 @@ static int max111x_init(SSISlave *dev, int inputs)
     s->input[7] = 0x80;
     s->com = 0;
 
-    vmstate_register(&dev->qdev, -1, &vmstate_max111x, s);
+    vmstate_register(DEVICE(dev), -1, &vmstate_max111x, s);
     return 0;
 }
 
hw/sd/ssi-sd.c +1 -1
index 1bb56c4..2f34dc6 100644
@@ -249,7 +249,7 @@ static int ssi_sd_init(SSISlave *dev)
     if (s->sd == NULL) {
         return -1;
     }
-    register_savevm(&dev->qdev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
+    register_savevm(DEVICE(dev), "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
     return 0;
 }
 
Signature · 1 line
1.8.5.4
#2 lore raw

Re: [Qemu-devel] [PATCH qom-next v1 1/6] ssi: Convert legacy casts from SSI_SLAVE->DEVICE

Am 12.02.2014 01:27, schrieb Peter Crosthwaite:

Quoted 24 lines

Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE.

---

 hw/arm/spitz.c       | 9 +++++----
 hw/display/ads7846.c | 2 +-
 hw/display/ssd0323.c | 4 ++--
 hw/misc/max111x.c    | 4 ++--
 hw/sd/ssi-sd.c       | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
hw/arm/spitz.c +1 -1
index ba17283..c7b3a94 100644
@@ -660,12 +660,13 @@ static void spitz_adc_temp_on(void *opaque, int line, int level)
 
 static int corgi_ssp_init(SSISlave *dev)
 {
+    DeviceState *d = DEVICE(dev);
     CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev);
 
-    qdev_init_gpio_in(&dev->qdev, corgi_ssp_gpio_cs, 3);

hw/arm/spitz.c static void spitz_adc_temp_on(void *opaque, int line, int level) · line 672

Quoted 10 lines
hw/arm/spitz.c +4 -3
-    s->bus[0] = ssi_create_bus(&dev->qdev, "ssi0");
-    s->bus[1] = ssi_create_bus(&dev->qdev, "ssi1");
-    s->bus[2] = ssi_create_bus(&dev->qdev, "ssi2");
+    qdev_init_gpio_in(d, corgi_ssp_gpio_cs, 3);
+    s->bus[0] = ssi_create_bus(d, "ssi0");
+    s->bus[1] = ssi_create_bus(d, "ssi1");
+    s->bus[2] = ssi_create_bus(d, "ssi2");
 
     return 0;
 }

Here with only two additional patch lines we can swap the names as preparation for QOM realize.

hw/display/ads7846.c static int ads7846_init(SSISlave *dev) · line 143

Quoted 13 lines
hw/display/ads7846.c +1 -1
index 5da3dc5..87beefe 100644
@@ -137,7 +137,7 @@ static int ads7846_init(SSISlave *dev)
 {
     ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, dev);
 
-    qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1);
+    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 
     s->input[0] = ADS_TEMP0;	/* TEMP0 */
     s->input[2] = ADS_VBAT;	/* VBAT */

Ditto here.

Quoted 6 lines
hw/display/ssd0323.c +0 -0
index c3231c6..c463bd8 100644
@@ -345,9 +345,9 @@ static int ssd0323_init(SSISlave *dev)
     s->con = graphic_console_init(DEVICE(dev), &ssd0323_ops, s);

hw/display/ssd0323.c static int ssd0323_init(SSISlave *dev) · line 353

Quoted 10 lines
hw/display/ssd0323.c +2 -2
     qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY);
 
-    qdev_init_gpio_in(&dev->qdev, ssd0323_cd, 1);
+    qdev_init_gpio_in(DEVICE(dev), ssd0323_cd, 1);
 
-    register_savevm(&dev->qdev, "ssd0323_oled", -1, 1,
+    register_savevm(DEVICE(dev), "ssd0323_oled", -1, 1,
                     ssd0323_save, ssd0323_load, s);
     return 0;
 }

Duplicate DEVICE() cast can be avoided here.

Quoted 14 lines
hw/misc/max111x.c +1 -1
index d477ecd..fcf2a4d 100644
@@ -119,7 +119,7 @@ static int max111x_init(SSISlave *dev, int inputs)
 {
     MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
 
-    qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1);
+    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 
     s->inputs = inputs;
     /* TODO: add a user interface for setting these */

hw/misc/max111x.c static int max111x_init(SSISlave *dev, int inputs) · line 139

Quoted 8 lines
hw/misc/max111x.c +1 -1
@@ -133,7 +133,7 @@ static int max111x_init(SSISlave *dev, int inputs)
     s->input[7] = 0x80;
     s->com = 0;
 
-    vmstate_register(&dev->qdev, -1, &vmstate_max111x, s);
+    vmstate_register(DEVICE(dev), -1, &vmstate_max111x, s);
     return 0;
 }
 

Dito.

hw/sd/ssi-sd.c static int ssi_sd_init(SSISlave *dev) · line 255

Quoted 13 lines
hw/sd/ssi-sd.c +1 -1
index 1bb56c4..2f34dc6 100644
@@ -249,7 +249,7 @@ static int ssi_sd_init(SSISlave *dev)
     if (s->sd == NULL) {
         return -1;
     }
-    register_savevm(&dev->qdev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
+    register_savevm(DEVICE(dev), "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
     return 0;
 }
 

Here's my changes, requiring to adjust 4/6:

hw/arm/spitz.c +0 -0
index 9020879..392ca84 100644
@@ -658,15 +658,15 @@ static void spitz_adc_temp_on(void *opaque, int

line, int level)

         max111x_set_input(max1111, MAX1111_BATT_TEMP, 0);

}

-static int corgi_ssp_init(SSISlave *dev)
+static int corgi_ssp_init(SSISlave *d)
{

-    DeviceState *d = DEVICE(dev);
-    CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, dev);
+    DeviceState *dev = DEVICE(d);
+    CorgiSSPState *s = FROM_SSI_SLAVE(CorgiSSPState, d);
-    qdev_init_gpio_in(d, corgi_ssp_gpio_cs, 3);
-    s->bus[0] = ssi_create_bus(d, "ssi0");
-    s->bus[1] = ssi_create_bus(d, "ssi1");
-    s->bus[2] = ssi_create_bus(d, "ssi2");
+    qdev_init_gpio_in(dev, corgi_ssp_gpio_cs, 3);
+    s->bus[0] = ssi_create_bus(dev, "ssi0");
+    s->bus[1] = ssi_create_bus(dev, "ssi1");
+    s->bus[2] = ssi_create_bus(dev, "ssi2");
     return 0;

}

hw/display/ads7846.c +4 -3
index 87beefe..85252a2 100644
@@ -133,11 +133,12 @@ static const VMStateDescription vmstate_ads7846 = {
     }
 };
 
-static int ads7846_init(SSISlave *dev)
+static int ads7846_init(SSISlave *d)
 {
-    ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, dev);
+    DeviceState *dev = DEVICE(d);
+    ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, d);
 
-    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
+    qdev_init_gpio_out(dev, &s->interrupt, 1);
 
     s->input[0] = ADS_TEMP0;	/* TEMP0 */
     s->input[2] = ADS_VBAT;	/* VBAT */
hw/display/ssd0323.c +6 -5
index c463bd8..4f55f57 100644
@@ -336,18 +336,19 @@ static const GraphicHwOps ssd0323_ops = {
     .gfx_update  = ssd0323_update_display,
 };
 
-static int ssd0323_init(SSISlave *dev)
+static int ssd0323_init(SSISlave *d)
 {
-    ssd0323_state *s = FROM_SSI_SLAVE(ssd0323_state, dev);
+    DeviceState *dev = DEVICE(d);
+    ssd0323_state *s = FROM_SSI_SLAVE(ssd0323_state, d);
 
     s->col_end = 63;
     s->row_end = 79;
-    s->con = graphic_console_init(DEVICE(dev), &ssd0323_ops, s);
+    s->con = graphic_console_init(dev, &ssd0323_ops, s);
     qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY);
 
-    qdev_init_gpio_in(DEVICE(dev), ssd0323_cd, 1);
+    qdev_init_gpio_in(dev, ssd0323_cd, 1);
 
-    register_savevm(DEVICE(dev), "ssd0323_oled", -1, 1,
+    register_savevm(dev, "ssd0323_oled", -1, 1,
                     ssd0323_save, ssd0323_load, s);
     return 0;
 }
hw/misc/max111x.c +5 -4
index fcf2a4d..28dfa0b 100644
@@ -115,11 +115,12 @@ static const VMStateDescription vmstate_max111x = {
     }
 };
 
-static int max111x_init(SSISlave *dev, int inputs)
+static int max111x_init(SSISlave *d, int inputs)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    DeviceState *dev = DEVICE(d);
+    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, d);
 
-    qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
+    qdev_init_gpio_out(dev, &s->interrupt, 1);
 
     s->inputs = inputs;
     /* TODO: add a user interface for setting these */
@@ -133,7 +134,7 @@ static int max111x_init(SSISlave *dev, int inputs)
     s->input[7] = 0x80;
     s->com = 0;
 
-    vmstate_register(DEVICE(dev), -1, &vmstate_max111x, s);
+    vmstate_register(dev, -1, &vmstate_max111x, s);
     return 0;
 }
 
hw/sd/ssi-sd.c +0 -0
index 2f34dc6..3273c8a 100644
@@ -238,9 +238,10 @@ static int ssi_sd_load(QEMUFile *f, void *opaque,

int version_id)

     return 0;

}

-static int ssi_sd_init(SSISlave *dev)
+static int ssi_sd_init(SSISlave *d)
{

-    ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, dev);
+    DeviceState *dev = DEVICE(d);
+    ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
     DriveInfo *dinfo;

     s->mode = SSI_SD_CMD;
@@ -249,7 +250,7 @@ static int ssi_sd_init(SSISlave *dev)
     if (s->sd == NULL) {
         return -1;
     }
-    register_savevm(DEVICE(dev), "ssi_sd", -1, 1, ssi_sd_save,
ssi_sd_load, s);
+    register_savevm(dev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
     return 0;

}

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

Re: [Qemu-devel] [PATCH qom-next v1 1/6] ssi: Convert legacy casts from SSI_SLAVE->DEVICE

Am 04.03.2014 23:07, schrieb Andreas Färber:

Quoted 6 lines

Am 12.02.2014 01:27, schrieb Peter Crosthwaite:

Quoted 5 lines

Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE.

---

Quoted 8 lines
Quoted 6 lines
 hw/arm/spitz.c       | 9 +++++----
 hw/display/ads7846.c | 2 +-
 hw/display/ssd0323.c | 4 ++--
 hw/misc/max111x.c    | 4 ++--
 hw/sd/ssi-sd.c       | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

Here's my changes, requiring to adjust 4/6:

[snip]

And another one blocking SSISlave::dev rename:

hw/ssi/ssi.c +1 -1
index 7be7c53..017f022 100644
@@ -60,7 +60,7 @@ static int ssi_slave_init(DeviceState *dev)
 
     if (ssc->transfer_raw == ssi_transfer_raw_default &&
             ssc->cs_polarity != SSI_CS_NONE) {
-        qdev_init_gpio_in(&s->qdev, ssi_cs_default, 1);
+        qdev_init_gpio_in(dev, ssi_cs_default, 1);
     }
 
     return ssc->init(s);

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw

PATCH 2/6 ssi: Remove legacy SSI_BUS->BUS cast

In reply to Peter Crosthwaite

Remove two legacy ->qbus style casts from TYPE_SSI_BUS to TYPE_BUS in ssi.c.

---

 hw/ssi/ssi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ssi/ssi.c +2 -2
index 2c25260..f2bdf30 100644
@@ -88,7 +88,7 @@ static const TypeInfo ssi_slave_info = {
 
 DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name)
 {
-    return qdev_create(&bus->qbus, name);
+    return qdev_create(BUS(bus), name);
 }
 
 DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
@@ -156,7 +156,7 @@ static int ssi_auto_connect_slave(Object *child, void *opaque)
     }
 
     cs_line = qdev_get_gpio_in(DEVICE(dev), 0);
-    qdev_set_parent_bus(DEVICE(dev), &arg->bus->qbus);
+    qdev_set_parent_bus(DEVICE(dev), BUS(arg->bus));
     **arg->cs_linep = cs_line;
     (*arg->cs_linep)++;
     return 0;
Signature · 1 line
1.8.5.4
#5 lore raw

Re: [Qemu-devel] [PATCH qom-next v1 2/6] ssi: Remove legacy SSI_BUS->BUS cast

Am 12.02.2014 01:28, schrieb Peter Crosthwaite:

Quoted 23 lines

Remove two legacy ->qbus style casts from TYPE_SSI_BUS to TYPE_BUS in ssi.c.

---

 hw/ssi/ssi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ssi/ssi.c +1 -1
index 2c25260..f2bdf30 100644
@@ -88,7 +88,7 @@ static const TypeInfo ssi_slave_info = {
 
 DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name)
 {
-    return qdev_create(&bus->qbus, name);
+    return qdev_create(BUS(bus), name);
 }
 
 DeviceState *ssi_create_slave(SSIBus *bus, const char *name)

hw/ssi/ssi.c static int ssi_auto_connect_slave(Object *child, void *opaque) · line 162

Quoted 8 lines
hw/ssi/ssi.c +1 -1
@@ -156,7 +156,7 @@ static int ssi_auto_connect_slave(Object *child, void *opaque)
     }
 
     cs_line = qdev_get_gpio_in(DEVICE(dev), 0);
-    qdev_set_parent_bus(DEVICE(dev), &arg->bus->qbus);
+    qdev_set_parent_bus(DEVICE(dev), BUS(arg->bus));
     **arg->cs_linep = cs_line;
     (*arg->cs_linep)++;
     return 0;

Let's be consequent and add this:

hw/ssi/ssi.c +1 -1
index f2bdf30..7be7c53 100644
@@ -15,7 +15,7 @@
 #include "hw/ssi.h"
 
 struct SSIBus {
-    BusState qbus;
+    BusState parent_obj;
 };
 
 #define TYPE_SSI_BUS "SSI"
@@ -108,11 +108,12 @@ SSIBus *ssi_create_bus(DeviceState *parent, const

char *name)

uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
{

+    BusState *b = BUS(bus);
     BusChild *kid;
     SSISlaveClass *ssc;
     uint32_t r = 0;

- QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {

+    QTAILQ_FOREACH(kid, &b->children, sibling) {
         SSISlave *slave = SSI_SLAVE(kid->child);
         ssc = SSI_SLAVE_GET_CLASS(slave);
         r |= ssc->transfer_raw(slave, val);

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw

PATCH 3/6 misc: max111x: Create abstract max111x class

In reply to Peter Crosthwaite

Create an abstract class that encompasses both max111x variants. This is needed for QOM cast macro creation (and is the right thing to do anyway). Macroify type-names in the process.

---

 hw/misc/max111x.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)
hw/misc/max111x.c +25 -8
index fcf2a4d..9e50e7e 100644
@@ -22,6 +22,11 @@ typedef struct {
     int inputs, com;
 } MAX111xState;
 
+#define TYPE_MAX_111X "max111x"
+
+#define TYPE_MAX_1110 "max1110"
+#define TYPE_MAX_1111 "max1111"
+
 /* Control-byte bitfields */
 #define CB_PD0		(1 << 0)
 #define CB_PD1		(1 << 1)
@@ -154,18 +159,31 @@ void max111x_set_input(DeviceState *dev, int line, uint8_t value)
     s->input[line] = value;
 }
 
-static void max1110_class_init(ObjectClass *klass, void *data)
+static void max111x_class_init(ObjectClass *klass, void *data)
 {
     SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
 
-    k->init = max1110_init;
     k->transfer = max111x_transfer;
 }
 
-static const TypeInfo max1110_info = {
-    .name          = "max1110",
+static const TypeInfo max111x_info = {
+    .name          = TYPE_MAX_111X,
     .parent        = TYPE_SSI_SLAVE,
     .instance_size = sizeof(MAX111xState),
+    .class_init    = max111x_class_init,
+    .abstract      = true,
+};
+
+static void max1110_class_init(ObjectClass *klass, void *data)
+{
+    SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
+
+    k->init = max1110_init;
+}
+
+static const TypeInfo max1110_info = {
+    .name          = TYPE_MAX_1110,
+    .parent        = TYPE_MAX_111X,
     .class_init    = max1110_class_init,
 };
 
@@ -174,18 +192,17 @@ static void max1111_class_init(ObjectClass *klass, void *data)
     SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
 
     k->init = max1111_init;
-    k->transfer = max111x_transfer;
 }
 
 static const TypeInfo max1111_info = {
-    .name          = "max1111",
-    .parent        = TYPE_SSI_SLAVE,
-    .instance_size = sizeof(MAX111xState),
+    .name          = TYPE_MAX_1111,
+    .parent        = TYPE_MAX_111X,
     .class_init    = max1111_class_init,
 };
 
 static void max111x_register_types(void)
 {
+    type_register_static(&max111x_info);
     type_register_static(&max1110_info);
     type_register_static(&max1111_info);
 }
Signature · 1 line
1.8.5.4
#7 lore raw

PATCH 4/6 misc: max111x: QOM casting sweep

In reply to Peter Crosthwaite

Define and use QOM cast macro. Removes some usages of legacy casting systems.

---

 hw/misc/max111x.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/misc/max111x.c +6 -3
index 9e50e7e..8c78979 100644
@@ -24,6 +24,9 @@ typedef struct {
 
 #define TYPE_MAX_111X "max111x"
 
+#define MAX_111X(obj) \
+    OBJECT_CHECK(MAX111xState, (obj), TYPE_MAX_111X)
+
 #define TYPE_MAX_1110 "max1110"
 #define TYPE_MAX_1111 "max1111"
 
@@ -97,7 +100,7 @@ static void max111x_write(MAX111xState *s, uint32_t value)
 
 static uint32_t max111x_transfer(SSISlave *dev, uint32_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    MAX111xState *s = MAX_111X(dev);
     max111x_write(s, value);
     return max111x_read(s);
 }
@@ -122,7 +125,7 @@ static const VMStateDescription vmstate_max111x = {
 
 static int max111x_init(SSISlave *dev, int inputs)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    MAX111xState *s = MAX_111X(dev);
 
     qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 
@@ -154,7 +157,7 @@ static int max1111_init(SSISlave *dev)
 
 void max111x_set_input(DeviceState *dev, int line, uint8_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, SSI_SLAVE_FROM_QDEV(dev));
+    MAX111xState *s = MAX_111X(dev);
     assert(line >= 0 && line < s->inputs);
     s->input[line] = value;
 }
Signature · 1 line
1.8.5.4
#8 lore raw

Re: [Qemu-devel] [PATCH qom-next v1 4/6] misc: max111x: QOM casting sweep

Am 12.02.2014 01:29, schrieb Peter Crosthwaite:

Quoted 42 lines

Define and use QOM cast macro. Removes some usages of legacy casting systems.

---

 hw/misc/max111x.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/misc/max111x.c +5 -2
index 9e50e7e..8c78979 100644
@@ -24,6 +24,9 @@ typedef struct {
 
 #define TYPE_MAX_111X "max111x"
 
+#define MAX_111X(obj) \
+    OBJECT_CHECK(MAX111xState, (obj), TYPE_MAX_111X)
+
 #define TYPE_MAX_1110 "max1110"
 #define TYPE_MAX_1111 "max1111"
 
@@ -97,7 +100,7 @@ static void max111x_write(MAX111xState *s, uint32_t value)
 
 static uint32_t max111x_transfer(SSISlave *dev, uint32_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    MAX111xState *s = MAX_111X(dev);
     max111x_write(s, value);
     return max111x_read(s);
 }
@@ -122,7 +125,7 @@ static const VMStateDescription vmstate_max111x = {
 
 static int max111x_init(SSISlave *dev, int inputs)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, dev);
+    MAX111xState *s = MAX_111X(dev);
 
     qdev_init_gpio_out(DEVICE(dev), &s->interrupt, 1);
 

hw/misc/max111x.c static int max1111_init(SSISlave *dev) · line 163

Quoted 8 lines
hw/misc/max111x.c +1 -1
@@ -154,7 +157,7 @@ static int max1111_init(SSISlave *dev)
 
 void max111x_set_input(DeviceState *dev, int line, uint8_t value)
 {
-    MAX111xState *s = FROM_SSI_SLAVE(MAX111xState, SSI_SLAVE_FROM_QDEV(dev));
+    MAX111xState *s = MAX_111X(dev);
     assert(line >= 0 && line < s->inputs);
     s->input[line] = value;
 }

Adding:

hw/misc/max111x.c +3 -2
index 8c78979..7aacfff 100644
@@ -13,7 +13,8 @@
 #include "hw/ssi.h"
 
 typedef struct {
-    SSISlave ssidev;
+    SSISlave parent_obj;
+
     qemu_irq interrupt;
     uint8_t tb1, rb2, rb3;
     int cycle;
@@ -111,7 +112,7 @@ static const VMStateDescription vmstate_max111x = {
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields      = (VMStateField[]) {
-        VMSTATE_SSI_SLAVE(ssidev, MAX111xState),
+        VMSTATE_SSI_SLAVE(parent_obj, MAX111xState),
         VMSTATE_UINT8(tb1, MAX111xState),
         VMSTATE_UINT8(rb2, MAX111xState),
         VMSTATE_UINT8(rb3, MAX111xState),

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#9 lore raw

PATCH 5/6 ssi: Remove SSI_SLAVE_FROM_QDEV macro

In reply to Peter Crosthwaite

There are no usages left of this legacy cast. delete.

---

 include/hw/ssi.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/ssi.h +0 -1
index fdae317..38e5b03 100644
@@ -62,7 +62,6 @@ struct SSISlave {
     bool cs;
 };
 
-#define SSI_SLAVE_FROM_QDEV(dev) DO_UPCAST(SSISlave, qdev, dev)
 #define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
 
 extern const VMStateDescription vmstate_ssi_slave;
Signature · 1 line
1.8.5.4
#10 lore raw

PATCH 6/6 block/m25p80: Remove FROM_SSI_SLAVE usages

In reply to Peter Crosthwaite

---

 hw/block/m25p80.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/block/m25p80.c +3 -3
index 02a1544..bdbb139 100644
@@ -545,7 +545,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)
 
 static int m25p80_cs(SSISlave *ss, bool select)
 {
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
 
     if (select) {
         s->len = 0;
@@ -561,7 +561,7 @@ static int m25p80_cs(SSISlave *ss, bool select)
 
 static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
 {
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
     uint32_t r = 0;
 
     switch (s->state) {
@@ -610,7 +610,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
 static int m25p80_init(SSISlave *ss)
 {
     DriveInfo *dinfo;
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
     M25P80Class *mc = M25P80_GET_CLASS(s);
 
     s->pi = mc->pi;
Signature · 1 line
1.8.5.4
#11 lore raw

Re: [Qemu-devel] [PATCH qom-next v1 6/6] block/m25p80: Remove FROM_SSI_SLAVE usages

Am 12.02.2014 01:30, schrieb Peter Crosthwaite:

Quoted 29 lines

---

 hw/block/m25p80.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/block/m25p80.c +2 -2
index 02a1544..bdbb139 100644
@@ -545,7 +545,7 @@ static void decode_new_cmd(Flash *s, uint32_t value)
 
 static int m25p80_cs(SSISlave *ss, bool select)
 {
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
 
     if (select) {
         s->len = 0;
@@ -561,7 +561,7 @@ static int m25p80_cs(SSISlave *ss, bool select)
 
 static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
 {
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
     uint32_t r = 0;
 
     switch (s->state) {

hw/block/m25p80.c static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) · line 616

Quoted 8 lines
hw/block/m25p80.c +1 -1
@@ -610,7 +610,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
 static int m25p80_init(SSISlave *ss)
 {
     DriveInfo *dinfo;
-    Flash *s = FROM_SSI_SLAVE(Flash, ss);
+    Flash *s = M25P80(ss);
     M25P80Class *mc = M25P80_GET_CLASS(s);
 
     s->pi = mc->pi;

Adding:

hw/block/m25p80.c +2 -1
index bdbb139..e29a738 100644
@@ -241,7 +241,8 @@ typedef enum {
 } CMDState;
 
 typedef struct Flash {
-    SSISlave ssidev;
+    SSISlave parent_obj;
+
     uint32_t r;
 
     BlockDriverState *bdrv;

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#12 lore raw
In reply to Peter Crosthwaite

Ping!

Quoted 33 lines · Peter Crosthwaite

Hi Andreas,

Here is a mixed bag of QOM cleanups, moving us slightly closer to QOMification of SSI.

This prepares support for some major refactoring around SSI (in particular some QSPI patches).

Regards,
Peter

Peter Crosthwaite (6):
ssi: Convert legacy casts from SSI_SLAVE->DEVICE
ssi: Remove legacy SSI_BUS->BUS cast
misc: max111x: Create abstract max111x class
misc: max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV macro block/m25p80: Remove FROM_SSI_SLAVE usages

 hw/arm/spitz.c       |  9 +++++----
 hw/block/m25p80.c    |  6 +++---
 hw/display/ads7846.c |  2 +-
 hw/display/ssd0323.c |  4 ++--
 hw/misc/max111x.c    | 46 +++++++++++++++++++++++++++++++++-------------
 hw/sd/ssi-sd.c       |  2 +-
 hw/ssi/ssi.c         |  4 ++--
 include/hw/ssi.h     |  1 -
 8 files changed, 47 insertions(+), 27 deletions(-)

--
1.8.5.4

#13 lore raw

Am 25.02.2014 09:46, schrieb Peter Crosthwaite:

Quoted 1 line

Ping!

Looked good, didn't get to applying them yet. I did wonder though a) why 1/6 is not renaming the parent field to verify and b) whether I can swap d vs. dev naming in one hunk there while at it.

Cheers,
Andreas

Quoted 36 lines
Quoted 33 lines · Peter Crosthwaite

Hi Andreas,

Here is a mixed bag of QOM cleanups, moving us slightly closer to QOMification of SSI.

This prepares support for some major refactoring around SSI (in particular some QSPI patches).

Regards,
Peter

Peter Crosthwaite (6):
ssi: Convert legacy casts from SSI_SLAVE->DEVICE
ssi: Remove legacy SSI_BUS->BUS cast
misc: max111x: Create abstract max111x class
misc: max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV macro block/m25p80: Remove FROM_SSI_SLAVE usages

 hw/arm/spitz.c       |  9 +++++----
 hw/block/m25p80.c    |  6 +++---
 hw/display/ads7846.c |  2 +-
 hw/display/ssd0323.c |  4 ++--
 hw/misc/max111x.c    | 46 +++++++++++++++++++++++++++++++++-------------
 hw/sd/ssi-sd.c       |  2 +-
 hw/ssi/ssi.c         |  4 ++--
 include/hw/ssi.h     |  1 -
 8 files changed, 47 insertions(+), 27 deletions(-)

--
1.8.5.4

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#14 lore raw

Am 25.02.2014 09:51, schrieb Andreas Färber:

Quoted 6 lines

Am 25.02.2014 09:46, schrieb Peter Crosthwaite:

Quoted 1 line

Ping!

Looked good, didn't get to applying them yet. I did wonder though a) why 1/6 is not renaming the parent field to verify and b) whether I can swap d vs. dev naming in one hunk there while at it.

a) i) SSISlave::dev was still in use one more time - fixed and renamed with ..._FROM_QDEV() macro drop.
ii) SSIBus::qbus was still in use one more time - fixed and renamed
in situ.
b) Uniformly introduced DeviceState *dev for all affected initfns.

Thanks, applied them to qom-next with the above changes:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Regards,
Andreas

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

Peter Crosthwaite (6):
ssi: Convert legacy casts from SSI_SLAVE->DEVICE
ssi: Remove legacy SSI_BUS->BUS cast
misc: max111x: Create abstract max111x class
misc: max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV macro block/m25p80: Remove FROM_SSI_SLAVE usages

 hw/arm/spitz.c       |  9 +++++----
 hw/block/m25p80.c    |  6 +++---
 hw/display/ads7846.c |  2 +-
 hw/display/ssd0323.c |  4 ++--
 hw/misc/max111x.c    | 46 +++++++++++++++++++++++++++++++++-------------
 hw/sd/ssi-sd.c       |  2 +-
 hw/ssi/ssi.c         |  4 ++--
 include/hw/ssi.h     |  1 -
 8 files changed, 47 insertions(+), 27 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#15 lore raw
Quoted 8 lines · Andreas Färber

Am 25.02.2014 09:51, schrieb Andreas Färber:

Quoted 6 lines

Am 25.02.2014 09:46, schrieb Peter Crosthwaite:

Quoted 1 line

Ping!

Looked good, didn't get to applying them yet. I did wonder though a) why 1/6 is not renaming the parent field to verify and b) whether I can swap d vs. dev naming in one hunk there while at it.

Quoted 9 lines

a) i) SSISlave::dev was still in use one more time - fixed and renamed with ..._FROM_QDEV() macro drop.
ii) SSIBus::qbus was still in use one more time - fixed and renamed
in situ.
b) Uniformly introduced DeviceState *dev for all affected initfns.

Thanks, applied them to qom-next with the above changes:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Thanks,

Regards,
Peter

Quoted 25 lines

Regards,
Andreas

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Peter Crosthwaite (6):
ssi: Convert legacy casts from SSI_SLAVE->DEVICE
ssi: Remove legacy SSI_BUS->BUS cast
misc: max111x: Create abstract max111x class
misc: max111x: QOM casting sweep
ssi: Remove SSI_SLAVE_FROM_QDEV macro block/m25p80: Remove FROM_SSI_SLAVE usages

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
 hw/arm/spitz.c       |  9 +++++----
 hw/block/m25p80.c    |  6 +++---
 hw/display/ads7846.c |  2 +-
 hw/display/ssd0323.c |  4 ++--
 hw/misc/max111x.c    | 46 +++++++++++++++++++++++++++++++++-------------
 hw/sd/ssi-sd.c       |  2 +-
 hw/ssi/ssi.c         |  4 ++--
 include/hw/ssi.h     |  1 -
 8 files changed, 47 insertions(+), 27 deletions(-)

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