Trivial cleanups
v2 cover Trivial cleanups
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
Signature · 1 line
2.40.1
PATCH v2 1/6 hw/timer/i8254_common: Share "iobase" property via base class
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.
--- hw/i386/kvm/i8254.c | 1 - hw/timer/i8254.c | 6 ------ hw/timer/i8254_common.c | 6 ++++++ 3 files changed, 6 insertions(+), 7 deletions(-)
hw/i386/kvm/i8254.c +0 -1
@@ -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 (),
hw/timer/i8254.c +0 -6
@@ -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 = {
hw/timer/i8254_common.c +6 -0
@@ -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 = {
Signature · 1 line
2.40.1
PATCH v2 2/6 hw/arm/omap: Remove unused omap_uart_attach()
In reply to Bernhard BeschowThe function is unused since commit bdad3654d3c55f478e538037d9eccd204e5fc8ee ('hw/arm/nseries: Remove invalid/unnecessary n8x0_uart_setup()').
--- include/hw/arm/omap.h | 1 - hw/char/omap_uart.c | 9 --------- 2 files changed, 10 deletions(-)
include/hw/arm/omap.h +0 -1
@@ -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);
hw/char/omap_uart.c +0 -9
@@ -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 ); -}
Signature · 1 line
2.40.1
PATCH v2 3/6 hw/isa/i82378: Remove unused "io" attribute
In reply to Bernhard BeschowThe attribute isn't used since commit 5c9736789b79ea49cd236ac326f0a414f63b1015 "i82378: Cleanup implementation".
--- hw/isa/i82378.c | 1 - 1 file changed, 1 deletion(-)
hw/isa/i82378.c +0 -1
@@ -34,7 +34,6 @@ struct I82378State {qemu_irq cpu_intr;qemu_irq *isa_irqs_in; -MemoryRegion io; };static const VMStateDescription vmstate_i82378 = {
Signature · 1 line
2.40.1
PATCH v2 4/6 hw/char/parallel: Export ParallelState
In reply to Bernhard BeschowExporting ParallelState is a precondition for exporing TYPE_ISA_PARALLEL.
--- include/hw/char/parallel.h | 44 ++++++++++++++++++++++++++++++++++++++ hw/char/parallel.c | 42 ------------------------------------ 2 files changed, 44 insertions(+), 42 deletions(-)
include/hw/char/parallel.h +44 -0
@@ -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,
hw/char/parallel.c +0 -42
55 lines not on this page · raw message
Signature · 1 line
2.40.1
Re: [PATCH v2 4/6] hw/char/parallel: Export ParallelState
Quoted 1 line · Bernhard Beschow
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
Quoted 126 lines
Suggested-by Mark Cave-Ayland <[email protected]>---
include/hw/char/parallel.h| 44 ++++++++++++++++++++++++++++++++++++++hw/char/parallel.c| 42 ------------------------------------2 files changed, 44 insertions(+), 42 deletions(-)include/hw/char/parallel.h +44
-0@@ -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,hw/char/parallel.c +0
-42@@ -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 )
Re: [PATCH v2 4/6] hw/char/parallel: Export ParallelState
In reply to Bernhard BeschowQuoted 3 lines · Bernhard Beschow
Exporting ParallelState is a precondition for exporing
TYPE_ISA_PARALLEL.Suggested-by Mark Cave-Ayland <[email protected]>
Missing your S-o-b.
Quoted 32 lines
--- include/hw/char/parallel.h | 44 ++++++++++++++++++++++++++++++++++++++ hw/char/parallel.c | 42 ------------------------------------ 2 files changed, 44 insertions(+), 42 deletions(-)include/hw/char/parallel.h +16
-0@@ -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
include/hw/char/parallel.h line 32
Quoted 10 lines
include/hw/char/parallel.h +10
-0+*/ +#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?
PATCH v2 5/6 hw/char/parallel-isa: Export ISAParallelState
In reply to Bernhard BeschowIn order to replace string literals with the TYPE_ISA_PARALLEL macro we need to export the whole structure as well.
--- 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
include/hw/char/parallel-isa.h new file +46 -0
@@ -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 */
hw/char/parallel.c +1 -12
@@ -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)
Signature · 1 line
2.40.1
PATCH v2 6/6 hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro
In reply to Bernhard BeschowRather than using a string literal which is prone to typos let's use a macro instead which is caught by the compiler if mistyped.
--- hw/char/parallel-isa.c | 3 ++- hw/isa/isa-superio.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
hw/char/parallel-isa.c +2 -1
@@ -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);
hw/isa/isa-superio.c +2 -1
@@ -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) {
Signature · 1 line
2.40.1
Re: [PATCH v2 6/6] hw/char/parallel: Replace string literals by TYPE_ISA_PARALLEL macro
Quoted 9 lines · 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 <[email protected]>--- hw/char/parallel-isa.c | 3 ++- hw/isa/isa-superio.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)