etsec: (TYPE_)ETSEC_COMMON macro cleanup
cover etsec: (TYPE_)ETSEC_COMMON macro cleanup
When working on other things, I got confused by the etsec code, that didn't use the TYPE_ETSEC_COMMON macro in its type declaration, and had no subclasses despite being named ETSEC_COMMON.
This is a very simple cleanup to remove the _COMMON suffix from the macros, and to use the TYPE_ETSEC macro when registering and creating devices instead of hardcoding the "eTSEC" name.
Eduardo Habkost (2):
etsec: Rename (TYPE_)ETSEC_COMMON to (TYPE_)ETSEC
etsec: Use TYPE_ETSEC macro when registering/creating device
hw/net/fsl_etsec/etsec.h | 6 +++--- hw/net/fsl_etsec/etsec.c | 10 +++++----- hw/ppc/e500.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.11.0.259.g40922b1
PATCH 1/2 etsec: Rename (TYPE_)ETSEC_COMMON to (TYPE_)ETSEC
Types named *_COMMON are normally used when there's a common parent class for multiple classes. We have only one eTSEC type, so rename the TYPE_ETSEC_COMMON and ETSEC_COMMON macros to TYPE_ETSEC and TYPE_ETSEC_COMMON.
--- hw/net/fsl_etsec/etsec.h | 6 +++--- hw/net/fsl_etsec/etsec.c | 6 +++--- hw/ppc/e500.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/net/fsl_etsec/etsec.h +3 -3
@@ -149,9 +149,9 @@ typedef struct eTSEC {bool need_flush; } eTSEC; -#define TYPE_ETSEC_COMMON "eTSEC" -#define ETSEC_COMMON (obj) \ - OBJECT_CHECK(eTSEC, (obj), TYPE_ETSEC_COMMON) +#define TYPE_ETSEC "eTSEC" +#define ETSEC (obj) \ + OBJECT_CHECK(eTSEC, (obj), TYPE_ETSEC)#define eTSEC_TRANSMIT 1#define eTSEC_RECEIVE 2
hw/net/fsl_etsec/etsec.c +3 -3
@@ -303,7 +303,7 @@ static void etsec_timer_hit(void *opaque)static void etsec_reset (DeviceState *d) { -eTSEC *etsec =ETSEC_COMMON (d); +eTSEC *etsec =ETSEC (d);int i =0 ;int reg_index =0 ;
@@ -378,7 +378,7 @@ static NetClientInfo net_etsec_info = {static void etsec_realize (DeviceState *dev,Error **errp) { -eTSEC *etsec =ETSEC_COMMON (dev); +eTSEC *etsec =ETSEC (dev); etsec->nic =qemu_new_nic (&net_etsec_info, &etsec->conf,object_get_typename (OBJECT (dev)), dev->id, etsec);
@@ -392,7 +392,7 @@ static void etsec_realize(DeviceState *dev, Error **errp)static void etsec_instance_init (Object *obj) { -eTSEC *etsec =ETSEC_COMMON (obj); +eTSEC *etsec =ETSEC (obj);SysBusDevice *sbd =SYS_BUS_DEVICE (obj); memory_region_init_io(&etsec->io_area, OBJECT(etsec), &etsec_ops, etsec,
hw/ppc/e500.c +2 -2
@@ -161,7 +161,7 @@ typedef struct PlatformDevtreeData {static int create_devtree_etsec (SysBusDevice *sbdev,PlatformDevtreeData *data) { -eTSEC *etsec =ETSEC_COMMON (sbdev); +eTSEC *etsec =ETSEC (sbdev);PlatformBusDevice *pbus = data->pbus;hwaddr mmio0 =platform_bus_get_mmio_addr (pbus, sbdev,0 );int irq0 =platform_bus_get_irqn (pbus, sbdev,0 );
@@ -201,7 +201,7 @@ static void sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque)PlatformDevtreeData *data = opaque;bool matched = false; -if (object_dynamic_cast (OBJECT (sbdev),TYPE_ETSEC_COMMON )) { +if (object_dynamic_cast (OBJECT (sbdev),TYPE_ETSEC )) {create_devtree_etsec (sbdev, data); matched = true; }
Signature · 1 line
2.11.0.259.g40922b1
PATCH 2/2 etsec: Use TYPE_ETSEC macro when registering/creating device
In reply to Eduardo HabkostInstead of hardcoding the class name, use the TYPE_ETSEC macro when registering the class and creating devices.
--- hw/net/fsl_etsec/etsec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/fsl_etsec/etsec.c +2 -2
@@ -419,7 +419,7 @@ static void etsec_class_init(ObjectClass *klass, void *data) }static TypeInfo etsec_info = { - .name ="eTSEC" , + .name =TYPE_ETSEC , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (eTSEC), .class_init = etsec_class_init,
@@ -442,7 +442,7 @@ DeviceState *etsec_create(hwaddr base, {DeviceState *dev; - dev =qdev_create (NULL ,"eTSEC" ); + dev =qdev_create (NULL ,TYPE_ETSEC );qdev_set_nic_properties (dev, nd);qdev_init_nofail (dev);
Signature · 1 line
2.11.0.259.g40922b1
Quoted 15 lines · Eduardo Habkost
When working on other things, I got confused by the etsec code, that didn't use the
TYPE_ETSEC_COMMONmacro in its type declaration, and had no subclasses despite being namedETSEC_COMMON.This is a very simple cleanup to remove the
_COMMONsuffix from the macros, and to use theTYPE_ETSECmacro when registering and creating devices instead of hardcoding the "eTSEC" name.Cc Alexander Graf <[email protected]>Cc Scott Wood <[email protected]>Cc Jason Wang <[email protected]>Cc Fabien Chouteau <[email protected]>
Quoted 3 lines
Eduardo Habkost (2):
etsec: Rename (TYPE_)ETSEC_COMMON to (TYPE_)ETSEC
etsec: UseTYPE_ETSECmacro when registering/creating device
Quoted 6 lines
hw/net/fsl_etsec/etsec.h | 6 +++--- hw/net/fsl_etsec/etsec.c | 10 +++++----- hw/ppc/e500.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-)
Fabien Chouteau
Reviewed-byQuoted 16 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Eduardo Habkost
When working on other things, I got confused by the etsec code, that didn't use the
TYPE_ETSEC_COMMONmacro in its type declaration, and had no subclasses despite being namedETSEC_COMMON.This is a very simple cleanup to remove the
_COMMONsuffix from the macros, and to use theTYPE_ETSECmacro when registering and creating devices instead of hardcoding the "eTSEC" name.Cc Alexander Graf <[email protected]>Cc Scott Wood <[email protected]>Cc Jason Wang <[email protected]>Cc Fabien Chouteau <[email protected]>
Quoted 6 lines
Quoted 3 lines
Eduardo Habkost (2):
etsec: Rename (TYPE_)ETSEC_COMMON to (TYPE_)ETSEC
etsec: UseTYPE_ETSECmacro when registering/creating deviceReviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks Eduardo,