Patchwork [RFT,v1,01/30] net/e1000: QOM Upcast Sweep

login
register
mail settings
Submitter Peter Crosthwaite
Date June 11, 2013, 6:40 a.m.
Message ID <989f2c773ba51f1d3c6e74f93771326b4b344ea6.1370931825.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/250447/
State New
Headers show

Comments

Peter Crosthwaite - June 11, 2013, 6:40 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Define and use standard QOM cast macro. Remove usages of DO_UPCAST
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/net/e1000.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
Peter Crosthwaite - June 24, 2013, 3:42 a.m.
On Tue, Jun 11, 2013 at 4:40 PM,  <peter.crosthwaite@xilinx.com> wrote:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Define and use standard QOM cast macro. Remove usages of DO_UPCAST
> and direct -> style upcasting.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
>  hw/net/e1000.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index e6f46f0..a7de400 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -138,6 +138,11 @@ typedef struct E1000State_st {
>      uint32_t compat_flags;
>  } E1000State;
>
> +#define TYPE_E1000 "e1000"
> +
> +#define E1000(obj) \
> +    OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
> +
>  #define        defreg(x)       x = (E1000_##x>>2)
>  enum {
>      defreg(CTRL),      defreg(EECD),   defreg(EERD),   defreg(GPRC),
> @@ -1175,7 +1180,7 @@ static int e1000_post_load(void *opaque, int version_id)
>  }
>
>  static const VMStateDescription vmstate_e1000 = {
> -    .name = "e1000",
> +    .name = TYPE_E1000,

Will fix v2 as per discussion recent discussion on type string usages.

Regards,
Peter

Patch

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index e6f46f0..a7de400 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -138,6 +138,11 @@  typedef struct E1000State_st {
     uint32_t compat_flags;
 } E1000State;
 
+#define TYPE_E1000 "e1000"
+
+#define E1000(obj) \
+    OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
+
 #define	defreg(x)	x = (E1000_##x>>2)
 enum {
     defreg(CTRL),	defreg(EECD),	defreg(EERD),	defreg(GPRC),
@@ -1175,7 +1180,7 @@  static int e1000_post_load(void *opaque, int version_id)
 }
 
 static const VMStateDescription vmstate_e1000 = {
-    .name = "e1000",
+    .name = TYPE_E1000,
     .version_id = 2,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
@@ -1296,7 +1301,7 @@  e1000_cleanup(NetClientState *nc)
 static void
 pci_e1000_uninit(PCIDevice *dev)
 {
-    E1000State *d = DO_UPCAST(E1000State, dev, dev);
+    E1000State *d = E1000(dev);
 
     qemu_del_timer(d->autoneg_timer);
     qemu_free_timer(d->autoneg_timer);
@@ -1316,7 +1321,8 @@  static NetClientInfo net_e1000_info = {
 
 static int pci_e1000_init(PCIDevice *pci_dev)
 {
-    E1000State *d = DO_UPCAST(E1000State, dev, pci_dev);
+    DeviceState *dev = DEVICE(pci_dev);
+    E1000State *d = E1000(pci_dev);
     uint8_t *pci_conf;
     uint16_t checksum = 0;
     int i;
@@ -1347,11 +1353,11 @@  static int pci_e1000_init(PCIDevice *pci_dev)
     d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum;
 
     d->nic = qemu_new_nic(&net_e1000_info, &d->conf,
-                          object_get_typename(OBJECT(d)), d->dev.qdev.id, d);
+                          object_get_typename(OBJECT(d)), dev->id, d);
 
     qemu_format_nic_info_str(qemu_get_queue(d->nic), macaddr);
 
-    add_boot_device_path(d->conf.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
+    add_boot_device_path(d->conf.bootindex, dev, "/ethernet-phy@0");
 
     d->autoneg_timer = qemu_new_timer_ms(vm_clock, e1000_autoneg_timer, d);
 
@@ -1360,7 +1366,7 @@  static int pci_e1000_init(PCIDevice *pci_dev)
 
 static void qdev_e1000_reset(DeviceState *dev)
 {
-    E1000State *d = DO_UPCAST(E1000State, dev.qdev, dev);
+    E1000State *d = E1000(dev);
     e1000_reset(d);
 }
 
@@ -1390,7 +1396,7 @@  static void e1000_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo e1000_info = {
-    .name          = "e1000",
+    .name          = TYPE_E1000,
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(E1000State),
     .class_init    = e1000_class_init,