From: Isaku Yamahata <yamahata@valinux.co.jp>
To: qemu-devel@nongnu.org
Cc: yamahata@valinux.co.jp
Subject: [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}().
Date: Fri, 3 Jul 2009 13:42:36 +0900 [thread overview]
Message-ID: <1246596159-16126-4-git-send-email-yamahata@valinux.co.jp> (raw)
In-Reply-To: <1246596159-16126-1-git-send-email-yamahata@valinux.co.jp>
consolidate duplicated logic in register_ioport_{read, write}().
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
ioport.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/ioport.c b/ioport.c
index 04bffc4..01cfaf7 100644
--- a/ioport.c
+++ b/ioport.c
@@ -121,19 +121,27 @@ static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
#endif
}
+static int ioport_bsize(int size, int *bsize)
+{
+ if (size == 1) {
+ *bsize = 0;
+ } else if (size == 2) {
+ *bsize = 1;
+ } else if (size == 4) {
+ *bsize = 2;
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
/* size is the word size in byte */
int register_ioport_read(int start, int length, int size,
IOPortReadFunc *func, void *opaque)
{
int i, bsize;
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
+ if (ioport_bsize(size, &bsize)) {
hw_error("register_ioport_read: invalid size");
return -1;
}
@@ -152,13 +160,7 @@ int register_ioport_write(int start, int length, int size,
{
int i, bsize;
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
+ if (ioport_bsize(size, &bsize)) {
hw_error("register_ioport_write: invalid size");
return -1;
}
--
1.6.0.2
next prev parent reply other threads:[~2009-07-03 4:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-03 4:42 [Qemu-devel] [PATCH 0/6] ioport related clean ups Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
2009-07-03 4:42 ` Isaku Yamahata [this message]
2009-07-03 4:42 ` [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT Isaku Yamahata
2009-07-09 19:10 ` Anthony Liguori
2009-07-09 22:06 ` [Qemu-devel] " Paolo Bonzini
2009-07-09 22:07 ` Anthony Liguori
2009-07-03 4:42 ` [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport port and value instead of int Isaku Yamahata
-- strict thread matches above, loose matches on Subject: below --
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
2009-07-02 10:32 [Qemu-devel] [PATCH 0/6] ioport related clean ups Isaku Yamahata
2009-07-02 10:32 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1246596159-16126-4-git-send-email-yamahata@valinux.co.jp \
--to=yamahata@valinux.co.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).