[PATCH 1/3] hw/net/e1000: Add readops/writeops typedefs

Philippe Mathieu-Daudé posted 3 patches 5 years, 8 months ago
Maintainers: Greg Kurz <groug@kaod.org>, Jason Wang <jasowang@redhat.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Christian Schoenebeck <qemu_oss@crudebyte.com>
There is a newer version of this series
[PATCH 1/3] hw/net/e1000: Add readops/writeops typedefs
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
Express the macreg[] arrays using typedefs.
No logical changes introduced here.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/net/e1000.c       | 6 ++++--
 hw/net/e1000e_core.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0b833d5a15..972d9b5083 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1150,7 +1150,8 @@ set_ims(E1000State *s, int index, uint32_t val)
 }
 
 #define getreg(x)    [x] = mac_readreg
-static uint32_t (*macreg_readops[])(E1000State *, int) = {
+typedef uint32_t (*readops)(E1000State *, int);
+static readops macreg_readops[] = {
     getreg(PBA),      getreg(RCTL),     getreg(TDH),      getreg(TXDCTL),
     getreg(WUFC),     getreg(TDT),      getreg(CTRL),     getreg(LEDCTL),
     getreg(MANC),     getreg(MDIC),     getreg(SWSM),     getreg(STATUS),
@@ -1205,7 +1206,8 @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
 enum { NREADOPS = ARRAY_SIZE(macreg_readops) };
 
 #define putreg(x)    [x] = mac_writereg
-static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
+typedef void (*writeops)(E1000State *, int, uint32_t);
+static writeops macreg_writeops[] = {
     putreg(PBA),      putreg(EERD),     putreg(SWSM),     putreg(WUFC),
     putreg(TDBAL),    putreg(TDBAH),    putreg(TXDCTL),   putreg(RDBAH),
     putreg(RDBAL),    putreg(LEDCTL),   putreg(VET),      putreg(FCRUC),
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index 94ea34dca5..38bdb90114 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -2855,7 +2855,8 @@ e1000e_set_gcr(E1000ECore *core, int index, uint32_t val)
 }
 
 #define e1000e_getreg(x)    [x] = e1000e_mac_readreg
-static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
+typedef uint32_t (*readops)(E1000ECore *, int);
+static readops e1000e_macreg_readops[] = {
     e1000e_getreg(PBA),
     e1000e_getreg(WUFC),
     e1000e_getreg(MANC),
@@ -3061,7 +3062,8 @@ static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
 enum { E1000E_NREADOPS = ARRAY_SIZE(e1000e_macreg_readops) };
 
 #define e1000e_putreg(x)    [x] = e1000e_mac_writereg
-static void (*e1000e_macreg_writeops[])(E1000ECore *, int, uint32_t) = {
+typedef void (*writeops)(E1000ECore *, int, uint32_t);
+static writeops e1000e_macreg_writeops[] = {
     e1000e_putreg(PBA),
     e1000e_putreg(SWSM),
     e1000e_putreg(WUFC),
-- 
2.21.1


Re: [PATCH 1/3] hw/net/e1000: Add readops/writeops typedefs
Posted by Dmitry Fleytman 5 years, 8 months ago
> On 5 Mar 2020, at 3:04, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 
> Express the macreg[] arrays using typedefs.
> No logical changes introduced here.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>


> ---
> hw/net/e1000.c       | 6 ++++--
> hw/net/e1000e_core.c | 6 ++++--
> 2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index 0b833d5a15..972d9b5083 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -1150,7 +1150,8 @@ set_ims(E1000State *s, int index, uint32_t val)
> }
> 
> #define getreg(x)    [x] = mac_readreg
> -static uint32_t (*macreg_readops[])(E1000State *, int) = {
> +typedef uint32_t (*readops)(E1000State *, int);
> +static readops macreg_readops[] = {
>     getreg(PBA),      getreg(RCTL),     getreg(TDH),      getreg(TXDCTL),
>     getreg(WUFC),     getreg(TDT),      getreg(CTRL),     getreg(LEDCTL),
>     getreg(MANC),     getreg(MDIC),     getreg(SWSM),     getreg(STATUS),
> @@ -1205,7 +1206,8 @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
> enum { NREADOPS = ARRAY_SIZE(macreg_readops) };
> 
> #define putreg(x)    [x] = mac_writereg
> -static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
> +typedef void (*writeops)(E1000State *, int, uint32_t);
> +static writeops macreg_writeops[] = {
>     putreg(PBA),      putreg(EERD),     putreg(SWSM),     putreg(WUFC),
>     putreg(TDBAL),    putreg(TDBAH),    putreg(TXDCTL),   putreg(RDBAH),
>     putreg(RDBAL),    putreg(LEDCTL),   putreg(VET),      putreg(FCRUC),
> diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
> index 94ea34dca5..38bdb90114 100644
> --- a/hw/net/e1000e_core.c
> +++ b/hw/net/e1000e_core.c
> @@ -2855,7 +2855,8 @@ e1000e_set_gcr(E1000ECore *core, int index, uint32_t val)
> }
> 
> #define e1000e_getreg(x)    [x] = e1000e_mac_readreg
> -static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
> +typedef uint32_t (*readops)(E1000ECore *, int);
> +static readops e1000e_macreg_readops[] = {
>     e1000e_getreg(PBA),
>     e1000e_getreg(WUFC),
>     e1000e_getreg(MANC),
> @@ -3061,7 +3062,8 @@ static uint32_t (*e1000e_macreg_readops[])(E1000ECore *, int) = {
> enum { E1000E_NREADOPS = ARRAY_SIZE(e1000e_macreg_readops) };
> 
> #define e1000e_putreg(x)    [x] = e1000e_mac_writereg
> -static void (*e1000e_macreg_writeops[])(E1000ECore *, int, uint32_t) = {
> +typedef void (*writeops)(E1000ECore *, int, uint32_t);
> +static writeops e1000e_macreg_writeops[] = {
>     e1000e_putreg(PBA),
>     e1000e_putreg(SWSM),
>     e1000e_putreg(WUFC),
> -- 
> 2.21.1
>