* [Qemu-devel] [PATCH 01/10] parallel: refactor device creation
@ 2011-02-12 22:39 Blue Swirl
0 siblings, 0 replies; only message in thread
From: Blue Swirl @ 2011-02-12 22:39 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 3151 bytes --]
Turn parallel_init into an inline function.
Don't expose ParallelState.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
hw/parallel.c | 21 +++++----------------
hw/pc.h | 19 +++++++++++++++----
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/hw/parallel.c b/hw/parallel.c
index ce311aa..cc853a5 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -64,7 +64,7 @@
#define PARA_CTR_SIGNAL
(PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
-struct ParallelState {
+typedef struct ParallelState {
uint8_t dataw;
uint8_t datar;
uint8_t status;
@@ -77,7 +77,7 @@ struct ParallelState {
uint32_t last_read_offset; /* For debugging */
/* Memory-mapped interface */
int it_shift;
-};
+} ParallelState;
typedef struct ISAParallelState {
ISADevice dev;
@@ -500,18 +500,6 @@ static int parallel_isa_initfn(ISADevice *dev)
return 0;
}
-ParallelState *parallel_init(int index, CharDriverState *chr)
-{
- ISADevice *dev;
-
- dev = isa_create("isa-parallel");
- qdev_prop_set_uint32(&dev->qdev, "index", index);
- qdev_prop_set_chr(&dev->qdev, "chardev", chr);
- if (qdev_init(&dev->qdev) < 0)
- return NULL;
- return &DO_UPCAST(ISAParallelState, dev, dev)->state;
-}
-
/* Memory mapped interface */
static uint32_t parallel_mm_readb (void *opaque, target_phys_addr_t addr)
{
@@ -571,7 +559,8 @@ static CPUWriteMemoryFunc * const parallel_mm_write_sw[] = {
};
/* If fd is zero, it means that the parallel device uses the console */
-ParallelState *parallel_mm_init(target_phys_addr_t base, int
it_shift, qemu_irq irq, CharDriverState *chr)
+bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
+ CharDriverState *chr)
{
ParallelState *s;
int io_sw;
@@ -585,7 +574,7 @@ ParallelState *parallel_mm_init(target_phys_addr_t
base, int it_shift, qemu_irq
io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,
s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 8 << it_shift, io_sw);
- return s;
+ return true;
}
static ISADeviceInfo parallel_isa_info = {
diff --git a/hw/pc.h b/hw/pc.h
index d5d2f42..443ba34 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -20,10 +20,21 @@ SerialState *serial_isa_init(int index,
CharDriverState *chr);
void serial_set_frequency(SerialState *s, uint32_t frequency);
/* parallel.c */
+static inline bool parallel_init(int index, CharDriverState *chr)
+{
+ ISADevice *dev;
+
+ dev = isa_create("isa-parallel");
+ qdev_prop_set_uint32(&dev->qdev, "index", index);
+ qdev_prop_set_chr(&dev->qdev, "chardev", chr);
+ if (qdev_init(&dev->qdev) < 0) {
+ return false;
+ }
+ return true;
+}
-typedef struct ParallelState ParallelState;
-ParallelState *parallel_init(int index, CharDriverState *chr);
-ParallelState *parallel_mm_init(target_phys_addr_t base, int
it_shift, qemu_irq irq, CharDriverState *chr);
+bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
+ CharDriverState *chr);
/* i8259.c */
--
1.6.2.4
[-- Attachment #2: 0001-parallel-refactor-device-creation.patch --]
[-- Type: application/mbox, Size: 3460 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-02-12 22:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-12 22:39 [Qemu-devel] [PATCH 01/10] parallel: refactor device creation Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).