qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] hw/char/parallel: Export TYPE_ISA_PARALLEL macro


From: Mark Cave-Ayland
Subject: Re: [PATCH 3/4] hw/char/parallel: Export TYPE_ISA_PARALLEL macro
Date: Sun, 14 May 2023 13:34:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

On 13/05/2023 11:09, Bernhard Beschow wrote:

Rather than using a string literal which is prone to typos let's use a macro
instead which is caught by the compiler if mistyped.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
  include/hw/char/parallel.h | 2 ++
  hw/char/parallel-isa.c     | 2 +-
  hw/char/parallel.c         | 1 -
  hw/isa/isa-superio.c       | 3 ++-
  4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
index 0a23c0f57e..29d2876d00 100644
--- a/include/hw/char/parallel.h
+++ b/include/hw/char/parallel.h
@@ -4,6 +4,8 @@
  #include "hw/isa/isa.h"
  #include "chardev/char.h"
+#define TYPE_ISA_PARALLEL "isa-parallel"
+

We don't really want to separate the QOM TYPE_* constant macro and the OBJECT_* declaration macro.

It looks like the real issue is that ParallelState should be in include/hw/char/parallel.h, and ISAParallelState along with its QOM macros should be in a new include/hw/char/parallel-isa.h header.

Once that is done then using the TYPE_ISA_PARALLEL QOM macro will "just work".

  void parallel_hds_isa_init(ISABus *bus, int n);
bool parallel_mm_init(MemoryRegion *address_space,
diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c
index 1ccbb96e70..547ae69304 100644
--- a/hw/char/parallel-isa.c
+++ b/hw/char/parallel-isa.c
@@ -21,7 +21,7 @@ static void parallel_init(ISABus *bus, int index, Chardev 
*chr)
      DeviceState *dev;
      ISADevice *isadev;
- isadev = isa_new("isa-parallel");
+    isadev = isa_new(TYPE_ISA_PARALLEL);
      dev = DEVICE(isadev);
      qdev_prop_set_uint32(dev, "index", index);
      qdev_prop_set_chr(dev, "chardev", chr);
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index af551e7864..3d32589bb3 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -93,7 +93,6 @@ typedef struct ParallelState {
      PortioList portio_list;
  } ParallelState;
-#define TYPE_ISA_PARALLEL "isa-parallel"
  OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
struct ISAParallelState {
diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c
index c81bfe58ef..53b80de0ce 100644
--- a/hw/isa/isa-superio.c
+++ b/hw/isa/isa-superio.c
@@ -20,6 +20,7 @@
  #include "hw/isa/superio.h"
  #include "hw/qdev-properties.h"
  #include "hw/input/i8042.h"
+#include "hw/char/parallel.h"
  #include "hw/char/serial.h"
  #include "trace.h"
@@ -51,7 +52,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
              } else {
                  name = g_strdup_printf("parallel%d", i);
              }
-            isa = isa_new("isa-parallel");
+            isa = isa_new(TYPE_ISA_PARALLEL);
              d = DEVICE(isa);
              qdev_prop_set_uint32(d, "index", i);
              if (k->parallel.get_iobase) {


ATB,

Mark.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]