All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Trivial cleanups
@ 2023-05-21 12:30 Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 1/6] hw/timer/i8254_common: Share "iobase" property via base class Bernhard Beschow
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow

This series:
* Removes dead code from omap_uart and i82378
* Resolves redundant code in the i8254 timer devices
* Exports ParallelState and ISAParallelState in order to replac string literals
  by TYPE_ISA_PARALLEL macro usage

v2:
* Export ParallelState and ISAParallelState (Mark)

Testing done:
* `make check`

Bernhard Beschow (6):
  hw/timer/i8254_common: Share "iobase" property via base class
  hw/arm/omap: Remove unused omap_uart_attach()
  hw/isa/i82378: Remove unused "io" attribute
  hw/char/parallel: Export ParallelState
  hw/char/parallel-isa: Export ISAParallelState
  hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro

 include/hw/arm/omap.h          |  1 -
 include/hw/char/parallel-isa.h | 46 ++++++++++++++++++++++++++++
 include/hw/char/parallel.h     | 44 +++++++++++++++++++++++++++
 hw/char/omap_uart.c            |  9 ------
 hw/char/parallel-isa.c         |  3 +-
 hw/char/parallel.c             | 55 +---------------------------------
 hw/i386/kvm/i8254.c            |  1 -
 hw/isa/i82378.c                |  1 -
 hw/isa/isa-superio.c           |  3 +-
 hw/timer/i8254.c               |  6 ----
 hw/timer/i8254_common.c        |  6 ++++
 11 files changed, 101 insertions(+), 74 deletions(-)
 create mode 100644 include/hw/char/parallel-isa.h

-- 
2.40.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/6] hw/timer/i8254_common: Share "iobase" property via base class
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 2/6] hw/arm/omap: Remove unused omap_uart_attach() Bernhard Beschow
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow,
	Mark Cave-Ayland, Philippe Mathieu-Daudé

Both TYPE_KVM_I8254 and TYPE_I8254 have their own but same implementation of
the "iobase" property. The storage for the property already resides in
PITCommonState, so also move the property definition there.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/kvm/i8254.c     | 1 -
 hw/timer/i8254.c        | 6 ------
 hw/timer/i8254_common.c | 6 ++++++
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index 191a26fa57..6a7383d877 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -301,7 +301,6 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
 }
 
 static Property kvm_pit_properties[] = {
-    DEFINE_PROP_UINT32("iobase", PITCommonState, iobase,  -1),
     DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", KVMPITState,
                                lost_tick_policy, LOST_TICK_POLICY_DELAY),
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c
index c8388ea432..c235496fc9 100644
--- a/hw/timer/i8254.c
+++ b/hw/timer/i8254.c
@@ -350,11 +350,6 @@ static void pit_realizefn(DeviceState *dev, Error **errp)
     pc->parent_realize(dev, errp);
 }
 
-static Property pit_properties[] = {
-    DEFINE_PROP_UINT32("iobase", PITCommonState, iobase,  -1),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
 static void pit_class_initfn(ObjectClass *klass, void *data)
 {
     PITClass *pc = PIT_CLASS(klass);
@@ -366,7 +361,6 @@ static void pit_class_initfn(ObjectClass *klass, void *data)
     k->get_channel_info = pit_get_channel_info_common;
     k->post_load = pit_post_load;
     dc->reset = pit_reset;
-    device_class_set_props(dc, pit_properties);
 }
 
 static const TypeInfo pit_info = {
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 050875b497..e4093e2904 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -240,6 +240,11 @@ static const VMStateDescription vmstate_pit_common = {
     }
 };
 
+static Property pit_common_properties[] = {
+    DEFINE_PROP_UINT32("iobase", PITCommonState, iobase,  -1),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void pit_common_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -252,6 +257,7 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
      * done by board code.
      */
     dc->user_creatable = false;
+    device_class_set_props(dc, pit_common_properties);
 }
 
 static const TypeInfo pit_common_type = {
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/6] hw/arm/omap: Remove unused omap_uart_attach()
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 1/6] hw/timer/i8254_common: Share "iobase" property via base class Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 3/6] hw/isa/i82378: Remove unused "io" attribute Bernhard Beschow
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow,
	Mark Cave-Ayland, Philippe Mathieu-Daudé

The function is unused since commit
bdad3654d3c55f478e538037d9eccd204e5fc8ee ('hw/arm/nseries: Remove
invalid/unnecessary n8x0_uart_setup()').

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/arm/omap.h | 1 -
 hw/char/omap_uart.c   | 9 ---------
 2 files changed, 10 deletions(-)

diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index c275d9b681..067e9419f7 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -724,7 +724,6 @@ struct omap_uart_s *omap2_uart_init(MemoryRegion *sysmem,
                 qemu_irq txdma, qemu_irq rxdma,
                 const char *label, Chardev *chr);
 void omap_uart_reset(struct omap_uart_s *s);
-void omap_uart_attach(struct omap_uart_s *s, Chardev *chr);
 
 struct omap_mpuio_s;
 qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
index 1c890b9201..6848bddb4e 100644
--- a/hw/char/omap_uart.c
+++ b/hw/char/omap_uart.c
@@ -175,12 +175,3 @@ struct omap_uart_s *omap2_uart_init(MemoryRegion *sysmem,
 
     return s;
 }
-
-void omap_uart_attach(struct omap_uart_s *s, Chardev *chr)
-{
-    /* TODO: Should reuse or destroy current s->serial */
-    s->serial = serial_mm_init(get_system_memory(), s->base, 2, s->irq,
-                               omap_clk_getrate(s->fclk) / 16,
-                               chr ?: qemu_chr_new("null", "null", NULL),
-                               DEVICE_NATIVE_ENDIAN);
-}
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/6] hw/isa/i82378: Remove unused "io" attribute
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 1/6] hw/timer/i8254_common: Share "iobase" property via base class Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 2/6] hw/arm/omap: Remove unused omap_uart_attach() Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 4/6] hw/char/parallel: Export ParallelState Bernhard Beschow
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow,
	Mark Cave-Ayland

The attribute isn't used since commit 5c9736789b79ea49cd236ac326f0a414f63b1015
"i82378: Cleanup implementation".

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/isa/i82378.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index 5432ab5065..63e0857208 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -34,7 +34,6 @@ struct I82378State {
 
     qemu_irq cpu_intr;
     qemu_irq *isa_irqs_in;
-    MemoryRegion io;
 };
 
 static const VMStateDescription vmstate_i82378 = {
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 4/6] hw/char/parallel: Export ParallelState
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
                   ` (2 preceding siblings ...)
  2023-05-21 12:30 ` [PATCH v2 3/6] hw/isa/i82378: Remove unused "io" attribute Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-21 12:43   ` BALATON Zoltan
  2023-05-22  6:05   ` Philippe Mathieu-Daudé
  2023-05-21 12:30 ` [PATCH v2 5/6] hw/char/parallel-isa: Export ISAParallelState Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro Bernhard Beschow
  5 siblings, 2 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow,
	Mark Cave-Ayland

Exporting ParallelState is a precondition for exporing TYPE_ISA_PARALLEL.

Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/hw/char/parallel.h | 44 ++++++++++++++++++++++++++++++++++++++
 hw/char/parallel.c         | 42 ------------------------------------
 2 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
index 0a23c0f57e..2d4907c1fe 100644
--- a/include/hw/char/parallel.h
+++ b/include/hw/char/parallel.h
@@ -1,9 +1,53 @@
 #ifndef HW_PARALLEL_H
 #define HW_PARALLEL_H
 
+#include "exec/ioport.h"
+#include "exec/memory.h"
 #include "hw/isa/isa.h"
+#include "hw/irq.h"
+#include "chardev/char-fe.h"
 #include "chardev/char.h"
 
+/*
+ * These are the definitions for the Printer Status Register
+ */
+#define PARA_STS_BUSY   0x80    /* Busy complement */
+#define PARA_STS_ACK    0x40    /* Acknowledge */
+#define PARA_STS_PAPER  0x20    /* Out of paper */
+#define PARA_STS_ONLINE 0x10    /* Online */
+#define PARA_STS_ERROR  0x08    /* Error complement */
+#define PARA_STS_TMOUT  0x01    /* EPP timeout */
+
+/*
+ * These are the definitions for the Printer Control Register
+ */
+#define PARA_CTR_DIR    0x20    /* Direction (1=read, 0=write) */
+#define PARA_CTR_INTEN  0x10    /* IRQ Enable */
+#define PARA_CTR_SELECT 0x08    /* Select In complement */
+#define PARA_CTR_INIT   0x04    /* Initialize Printer complement */
+#define PARA_CTR_AUTOLF 0x02    /* Auto linefeed complement */
+#define PARA_CTR_STROBE 0x01    /* Strobe complement */
+
+#define PARA_CTR_SIGNAL (PARA_CTR_SELECT | PARA_CTR_INIT | PARA_CTR_AUTOLF \
+                         | PARA_CTR_STROBE)
+
+typedef struct ParallelState {
+    MemoryRegion iomem;
+    uint8_t dataw;
+    uint8_t datar;
+    uint8_t status;
+    uint8_t control;
+    qemu_irq irq;
+    int irq_pending;
+    CharBackend chr;
+    int hw_driver;
+    int epp_timeout;
+    uint32_t last_read_offset; /* For debugging */
+    /* Memory-mapped interface */
+    int it_shift;
+    PortioList portio_list;
+} ParallelState;
+
 void parallel_hds_isa_init(ISABus *bus, int n);
 
 bool parallel_mm_init(MemoryRegion *address_space,
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index af551e7864..522301f43a 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -27,10 +27,7 @@
 #include "qapi/error.h"
 #include "qemu/module.h"
 #include "chardev/char-parallel.h"
-#include "chardev/char-fe.h"
 #include "hw/acpi/acpi_aml_interface.h"
-#include "hw/irq.h"
-#include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "migration/vmstate.h"
@@ -54,45 +51,6 @@
 #define PARA_REG_EPP_ADDR 3
 #define PARA_REG_EPP_DATA 4
 
-/*
- * These are the definitions for the Printer Status Register
- */
-#define PARA_STS_BUSY   0x80    /* Busy complement */
-#define PARA_STS_ACK    0x40    /* Acknowledge */
-#define PARA_STS_PAPER  0x20    /* Out of paper */
-#define PARA_STS_ONLINE 0x10    /* Online */
-#define PARA_STS_ERROR  0x08    /* Error complement */
-#define PARA_STS_TMOUT  0x01    /* EPP timeout */
-
-/*
- * These are the definitions for the Printer Control Register
- */
-#define PARA_CTR_DIR    0x20    /* Direction (1=read, 0=write) */
-#define PARA_CTR_INTEN  0x10    /* IRQ Enable */
-#define PARA_CTR_SELECT 0x08    /* Select In complement */
-#define PARA_CTR_INIT   0x04    /* Initialize Printer complement */
-#define PARA_CTR_AUTOLF 0x02    /* Auto linefeed complement */
-#define PARA_CTR_STROBE 0x01    /* Strobe complement */
-
-#define PARA_CTR_SIGNAL (PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
-
-typedef struct ParallelState {
-    MemoryRegion iomem;
-    uint8_t dataw;
-    uint8_t datar;
-    uint8_t status;
-    uint8_t control;
-    qemu_irq irq;
-    int irq_pending;
-    CharBackend chr;
-    int hw_driver;
-    int epp_timeout;
-    uint32_t last_read_offset; /* For debugging */
-    /* Memory-mapped interface */
-    int it_shift;
-    PortioList portio_list;
-} ParallelState;
-
 #define TYPE_ISA_PARALLEL "isa-parallel"
 OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
 
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 5/6] hw/char/parallel-isa: Export ISAParallelState
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
                   ` (3 preceding siblings ...)
  2023-05-21 12:30 ` [PATCH v2 4/6] hw/char/parallel: Export ParallelState Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-21 12:30 ` [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro Bernhard Beschow
  5 siblings, 0 replies; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow,
	Mark Cave-Ayland

In order to replace string literals with the TYPE_ISA_PARALLEL macro we need to
export the whole structure as well.

Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 include/hw/char/parallel-isa.h | 46 ++++++++++++++++++++++++++++++++++
 hw/char/parallel.c             | 13 +---------
 2 files changed, 47 insertions(+), 12 deletions(-)
 create mode 100644 include/hw/char/parallel-isa.h

diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h
new file mode 100644
index 0000000000..27bdacf1a3
--- /dev/null
+++ b/include/hw/char/parallel-isa.h
@@ -0,0 +1,46 @@
+/*
+ * QEMU ISA Parallel PORT emulation
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ * Copyright (c) 2007 Marko Kohtala
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef HW_PARALLEL_ISA_H
+#define HW_PARALLEL_ISA_H
+
+#include "parallel.h"
+
+#include "hw/isa/isa.h"
+#include "qom/object.h"
+
+#define TYPE_ISA_PARALLEL "isa-parallel"
+OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
+
+struct ISAParallelState {
+    ISADevice parent_obj;
+
+    uint32_t index;
+    uint32_t iobase;
+    uint32_t isairq;
+    ParallelState state;
+};
+
+#endif /* HW_PARALLEL_ISA_H */
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 522301f43a..d89f750cc1 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "migration/vmstate.h"
+#include "hw/char/parallel-isa.h"
 #include "hw/char/parallel.h"
 #include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
@@ -51,18 +52,6 @@
 #define PARA_REG_EPP_ADDR 3
 #define PARA_REG_EPP_DATA 4
 
-#define TYPE_ISA_PARALLEL "isa-parallel"
-OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
-
-struct ISAParallelState {
-    ISADevice parent_obj;
-
-    uint32_t index;
-    uint32_t iobase;
-    uint32_t isairq;
-    ParallelState state;
-};
-
 static void parallel_update_irq(ParallelState *s)
 {
     if (s->irq_pending)
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro
  2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
                   ` (4 preceding siblings ...)
  2023-05-21 12:30 ` [PATCH v2 5/6] hw/char/parallel-isa: Export ISAParallelState Bernhard Beschow
@ 2023-05-21 12:30 ` Bernhard Beschow
  2023-05-22  6:06   ` Philippe Mathieu-Daudé
  5 siblings, 1 reply; 10+ messages in thread
From: Bernhard Beschow @ 2023-05-21 12:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Bernhard Beschow

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>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/char/parallel-isa.c | 3 ++-
 hw/isa/isa-superio.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c
index 1ccbb96e70..ab0f879998 100644
--- a/hw/char/parallel-isa.c
+++ b/hw/char/parallel-isa.c
@@ -13,6 +13,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
+#include "hw/char/parallel-isa.h"
 #include "hw/char/parallel.h"
 #include "qapi/error.h"
 
@@ -21,7 +22,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/isa/isa-superio.c b/hw/isa/isa-superio.c
index c81bfe58ef..3baa9777be 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-isa.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) {
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/6] hw/char/parallel: Export ParallelState
  2023-05-21 12:30 ` [PATCH v2 4/6] hw/char/parallel: Export ParallelState Bernhard Beschow
@ 2023-05-21 12:43   ` BALATON Zoltan
  2023-05-22  6:05   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 10+ messages in thread
From: BALATON Zoltan @ 2023-05-21 12:43 UTC (permalink / raw)
  To: Bernhard Beschow
  Cc: qemu-devel, Michael Tokarev, Laurent Vivier, Marcel Apfelbaum,
	qemu-trivial, qemu-arm, Hervé Poussineau,
	Michael S. Tsirkin, Paolo Bonzini, Eduardo Habkost,
	Marc-André Lureau, Richard Henderson, qemu-ppc,
	Peter Maydell, Mark Cave-Ayland

On Sun, 21 May 2023, Bernhard Beschow wrote:
> Exporting ParallelState is a precondition for exporing TYPE_ISA_PARALLEL.

This may need a better commit message. It's not a precondition per coding 
standards I think just a preference for allowing embedding the device in 
other devices but otherwise unnecessary. Or at least fix the typo 
"exporing" -> exporting.

Regards,
BALATON Zoltan

> Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
> include/hw/char/parallel.h | 44 ++++++++++++++++++++++++++++++++++++++
> hw/char/parallel.c         | 42 ------------------------------------
> 2 files changed, 44 insertions(+), 42 deletions(-)
>
> diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
> index 0a23c0f57e..2d4907c1fe 100644
> --- a/include/hw/char/parallel.h
> +++ b/include/hw/char/parallel.h
> @@ -1,9 +1,53 @@
> #ifndef HW_PARALLEL_H
> #define HW_PARALLEL_H
>
> +#include "exec/ioport.h"
> +#include "exec/memory.h"
> #include "hw/isa/isa.h"
> +#include "hw/irq.h"
> +#include "chardev/char-fe.h"
> #include "chardev/char.h"
>
> +/*
> + * These are the definitions for the Printer Status Register
> + */
> +#define PARA_STS_BUSY   0x80    /* Busy complement */
> +#define PARA_STS_ACK    0x40    /* Acknowledge */
> +#define PARA_STS_PAPER  0x20    /* Out of paper */
> +#define PARA_STS_ONLINE 0x10    /* Online */
> +#define PARA_STS_ERROR  0x08    /* Error complement */
> +#define PARA_STS_TMOUT  0x01    /* EPP timeout */
> +
> +/*
> + * These are the definitions for the Printer Control Register
> + */
> +#define PARA_CTR_DIR    0x20    /* Direction (1=read, 0=write) */
> +#define PARA_CTR_INTEN  0x10    /* IRQ Enable */
> +#define PARA_CTR_SELECT 0x08    /* Select In complement */
> +#define PARA_CTR_INIT   0x04    /* Initialize Printer complement */
> +#define PARA_CTR_AUTOLF 0x02    /* Auto linefeed complement */
> +#define PARA_CTR_STROBE 0x01    /* Strobe complement */
> +
> +#define PARA_CTR_SIGNAL (PARA_CTR_SELECT | PARA_CTR_INIT | PARA_CTR_AUTOLF \
> +                         | PARA_CTR_STROBE)
> +
> +typedef struct ParallelState {
> +    MemoryRegion iomem;
> +    uint8_t dataw;
> +    uint8_t datar;
> +    uint8_t status;
> +    uint8_t control;
> +    qemu_irq irq;
> +    int irq_pending;
> +    CharBackend chr;
> +    int hw_driver;
> +    int epp_timeout;
> +    uint32_t last_read_offset; /* For debugging */
> +    /* Memory-mapped interface */
> +    int it_shift;
> +    PortioList portio_list;
> +} ParallelState;
> +
> void parallel_hds_isa_init(ISABus *bus, int n);
>
> bool parallel_mm_init(MemoryRegion *address_space,
> diff --git a/hw/char/parallel.c b/hw/char/parallel.c
> index af551e7864..522301f43a 100644
> --- a/hw/char/parallel.c
> +++ b/hw/char/parallel.c
> @@ -27,10 +27,7 @@
> #include "qapi/error.h"
> #include "qemu/module.h"
> #include "chardev/char-parallel.h"
> -#include "chardev/char-fe.h"
> #include "hw/acpi/acpi_aml_interface.h"
> -#include "hw/irq.h"
> -#include "hw/isa/isa.h"
> #include "hw/qdev-properties.h"
> #include "hw/qdev-properties-system.h"
> #include "migration/vmstate.h"
> @@ -54,45 +51,6 @@
> #define PARA_REG_EPP_ADDR 3
> #define PARA_REG_EPP_DATA 4
>
> -/*
> - * These are the definitions for the Printer Status Register
> - */
> -#define PARA_STS_BUSY   0x80    /* Busy complement */
> -#define PARA_STS_ACK    0x40    /* Acknowledge */
> -#define PARA_STS_PAPER  0x20    /* Out of paper */
> -#define PARA_STS_ONLINE 0x10    /* Online */
> -#define PARA_STS_ERROR  0x08    /* Error complement */
> -#define PARA_STS_TMOUT  0x01    /* EPP timeout */
> -
> -/*
> - * These are the definitions for the Printer Control Register
> - */
> -#define PARA_CTR_DIR    0x20    /* Direction (1=read, 0=write) */
> -#define PARA_CTR_INTEN  0x10    /* IRQ Enable */
> -#define PARA_CTR_SELECT 0x08    /* Select In complement */
> -#define PARA_CTR_INIT   0x04    /* Initialize Printer complement */
> -#define PARA_CTR_AUTOLF 0x02    /* Auto linefeed complement */
> -#define PARA_CTR_STROBE 0x01    /* Strobe complement */
> -
> -#define PARA_CTR_SIGNAL (PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
> -
> -typedef struct ParallelState {
> -    MemoryRegion iomem;
> -    uint8_t dataw;
> -    uint8_t datar;
> -    uint8_t status;
> -    uint8_t control;
> -    qemu_irq irq;
> -    int irq_pending;
> -    CharBackend chr;
> -    int hw_driver;
> -    int epp_timeout;
> -    uint32_t last_read_offset; /* For debugging */
> -    /* Memory-mapped interface */
> -    int it_shift;
> -    PortioList portio_list;
> -} ParallelState;
> -
> #define TYPE_ISA_PARALLEL "isa-parallel"
> OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
>
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/6] hw/char/parallel: Export ParallelState
  2023-05-21 12:30 ` [PATCH v2 4/6] hw/char/parallel: Export ParallelState Bernhard Beschow
  2023-05-21 12:43   ` BALATON Zoltan
@ 2023-05-22  6:05   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-05-22  6:05 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell, Mark Cave-Ayland

On 21/5/23 14:30, Bernhard Beschow wrote:
> Exporting ParallelState is a precondition for exporing TYPE_ISA_PARALLEL.
> 
> Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Missing your S-o-b.

> ---
>   include/hw/char/parallel.h | 44 ++++++++++++++++++++++++++++++++++++++
>   hw/char/parallel.c         | 42 ------------------------------------
>   2 files changed, 44 insertions(+), 42 deletions(-)
> 
> diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
> index 0a23c0f57e..2d4907c1fe 100644
> --- a/include/hw/char/parallel.h
> +++ b/include/hw/char/parallel.h
> @@ -1,9 +1,53 @@
>   #ifndef HW_PARALLEL_H
>   #define HW_PARALLEL_H
>   
> +#include "exec/ioport.h"
> +#include "exec/memory.h"
>   #include "hw/isa/isa.h"
> +#include "hw/irq.h"
> +#include "chardev/char-fe.h"
>   #include "chardev/char.h"
>   
> +/*
> + * These are the definitions for the Printer Status Register
> + */
> +#define PARA_STS_BUSY   0x80    /* Busy complement */
> +#define PARA_STS_ACK    0x40    /* Acknowledge */
> +#define PARA_STS_PAPER  0x20    /* Out of paper */
> +#define PARA_STS_ONLINE 0x10    /* Online */
> +#define PARA_STS_ERROR  0x08    /* Error complement */
> +#define PARA_STS_TMOUT  0x01    /* EPP timeout */
> +
> +/*
> + * These are the definitions for the Printer Control Register
> + */
> +#define PARA_CTR_DIR    0x20    /* Direction (1=read, 0=write) */
> +#define PARA_CTR_INTEN  0x10    /* IRQ Enable */
> +#define PARA_CTR_SELECT 0x08    /* Select In complement */
> +#define PARA_CTR_INIT   0x04    /* Initialize Printer complement */
> +#define PARA_CTR_AUTOLF 0x02    /* Auto linefeed complement */
> +#define PARA_CTR_STROBE 0x01    /* Strobe complement */
> +
> +#define PARA_CTR_SIGNAL (PARA_CTR_SELECT | PARA_CTR_INIT | PARA_CTR_AUTOLF \
> +                         | PARA_CTR_STROBE)

Can't we keep these register definitions local to the implementation?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro
  2023-05-21 12:30 ` [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro Bernhard Beschow
@ 2023-05-22  6:06   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-05-22  6:06 UTC (permalink / raw)
  To: Bernhard Beschow, qemu-devel
  Cc: Michael Tokarev, Laurent Vivier, Marcel Apfelbaum, qemu-trivial,
	qemu-arm, Hervé Poussineau, Michael S. Tsirkin,
	Paolo Bonzini, Eduardo Habkost, Marc-André Lureau,
	Richard Henderson, qemu-ppc, Peter Maydell

On 21/5/23 14:30, 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>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   hw/char/parallel-isa.c | 3 ++-
>   hw/isa/isa-superio.c   | 3 ++-
>   2 files changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-05-22  6:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-21 12:30 [PATCH v2 0/6] Trivial cleanups Bernhard Beschow
2023-05-21 12:30 ` [PATCH v2 1/6] hw/timer/i8254_common: Share "iobase" property via base class Bernhard Beschow
2023-05-21 12:30 ` [PATCH v2 2/6] hw/arm/omap: Remove unused omap_uart_attach() Bernhard Beschow
2023-05-21 12:30 ` [PATCH v2 3/6] hw/isa/i82378: Remove unused "io" attribute Bernhard Beschow
2023-05-21 12:30 ` [PATCH v2 4/6] hw/char/parallel: Export ParallelState Bernhard Beschow
2023-05-21 12:43   ` BALATON Zoltan
2023-05-22  6:05   ` Philippe Mathieu-Daudé
2023-05-21 12:30 ` [PATCH v2 5/6] hw/char/parallel-isa: Export ISAParallelState Bernhard Beschow
2023-05-21 12:30 ` [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro Bernhard Beschow
2023-05-22  6:06   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.