qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	patches@linaro.org, Anthony Liguori <anthony@codemonkey.ws>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 6/9] bswap.h: Remove cpu_to_be16wu()
Date: Sun, 25 Aug 2013 15:59:34 +0100	[thread overview]
Message-ID: <1377442777-11066-7-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1377442777-11066-1-git-send-email-peter.maydell@linaro.org>

Replace the legacy cpu_to_be16wu() with stw_be_p().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/block/cdrom.c     |    4 ++--
 hw/ide/atapi.c       |   16 ++++++++--------
 hw/net/e1000.c       |   19 ++++++++-----------
 include/qemu/bswap.h |    5 -----
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/hw/block/cdrom.c b/hw/block/cdrom.c
index 38469fa..5c69f34 100644
--- a/hw/block/cdrom.c
+++ b/hw/block/cdrom.c
@@ -77,7 +77,7 @@ int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track)
         q += 4;
     }
     len = q - buf;
-    cpu_to_be16wu((uint16_t *)buf, len - 2);
+    stw_be_p(buf, len - 2);
     return len;
 }
 
@@ -150,6 +150,6 @@ int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num)
     }
 
     len = q - buf;
-    cpu_to_be16wu((uint16_t *)buf, len - 2);
+    stw_be_p(buf, len - 2);
     return len;
 }
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 05e60b1..f7d2009 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -437,7 +437,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
                 cpu_to_ube32(buf + 16, total_sectors - 1); /* l0 end sector */
 
                 /* Size of buffer, not including 2 byte size field */
-                cpu_to_be16wu((uint16_t *)buf, 2048 + 2);
+                stw_be_p(buf, 2048 + 2);
 
                 /* 2k data + 4 byte header */
                 return (2048 + 4);
@@ -448,7 +448,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
             buf[5] = 0; /* no region restrictions */
 
             /* Size of buffer, not including 2 byte size field */
-            cpu_to_be16wu((uint16_t *)buf, 4 + 2);
+            stw_be_p(buf, 4 + 2);
 
             /* 4 byte header + 4 byte data */
             return (4 + 4);
@@ -458,7 +458,7 @@ static int ide_dvd_read_structure(IDEState *s, int format,
 
         case 0x04: /* DVD disc manufacturing information */
             /* Size of buffer, not including 2 byte size field */
-            cpu_to_be16wu((uint16_t *)buf, 2048 + 2);
+            stw_be_p(buf, 2048 + 2);
 
             /* 2k data + 4 byte header */
             return (2048 + 4);
@@ -471,22 +471,22 @@ static int ide_dvd_read_structure(IDEState *s, int format,
 
             buf[4] = 0x00; /* Physical format */
             buf[5] = 0x40; /* Not writable, is readable */
-            cpu_to_be16wu((uint16_t *)(buf + 6), 2048 + 4);
+            stw_be_p(buf + 6, 2048 + 4);
 
             buf[8] = 0x01; /* Copyright info */
             buf[9] = 0x40; /* Not writable, is readable */
-            cpu_to_be16wu((uint16_t *)(buf + 10), 4 + 4);
+            stw_be_p(buf + 10, 4 + 4);
 
             buf[12] = 0x03; /* BCA info */
             buf[13] = 0x40; /* Not writable, is readable */
-            cpu_to_be16wu((uint16_t *)(buf + 14), 188 + 4);
+            stw_be_p(buf + 14, 188 + 4);
 
             buf[16] = 0x04; /* Manufacturing info */
             buf[17] = 0x40; /* Not writable, is readable */
-            cpu_to_be16wu((uint16_t *)(buf + 18), 2048 + 4);
+            stw_be_p(buf + 18, 2048 + 4);
 
             /* Size of buffer, not including 2 byte size field */
-            cpu_to_be16wu((uint16_t *)buf, 16 + 2);
+            stw_be_p(buf, 16 + 2);
 
             /* data written + 4 byte header */
             return (16 + 4);
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index f770f08..b8e3ce9 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -451,8 +451,7 @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse)
         n = cse + 1;
     if (sloc < n-1) {
         sum = net_checksum_add(n-css, data+css);
-        cpu_to_be16wu((uint16_t *)(data + sloc),
-                      net_checksum_finish(sum));
+        stw_be_p(data + sloc, net_checksum_finish(sum));
     }
 }
 
@@ -513,13 +512,11 @@ xmit_seg(E1000State *s)
         DBGOUT(TXSUM, "frames %d size %d ipcss %d\n",
                frames, tp->size, css);
         if (tp->ip) {		// IPv4
-            cpu_to_be16wu((uint16_t *)(tp->data+css+2),
-                          tp->size - css);
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4),
+            stw_be_p(tp->data+css+2, tp->size - css);
+            stw_be_p(tp->data+css+4,
                           be16_to_cpup((uint16_t *)(tp->data+css+4))+frames);
         } else			// IPv6
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4),
-                          tp->size - css);
+            stw_be_p(tp->data+css+4, tp->size - css);
         css = tp->tucss;
         len = tp->size - css;
         DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->tcp, css, len);
@@ -530,14 +527,14 @@ xmit_seg(E1000State *s)
             if (tp->paylen - sofar > tp->mss)
                 tp->data[css + 13] &= ~9;		// PSH, FIN
         } else	// UDP
-            cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
+            stw_be_p(tp->data+css+4, len);
         if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
             unsigned int phsum;
             // add pseudo-header length before checksum calculation
             sp = (uint16_t *)(tp->data + tp->tucso);
             phsum = be16_to_cpup(sp) + len;
             phsum = (phsum >> 16) + (phsum & 0xffff);
-            cpu_to_be16wu(sp, phsum);
+            stw_be_p(sp, phsum);
         }
         tp->tso_frames++;
     }
@@ -606,9 +603,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
     if (vlan_enabled(s) && is_vlan_txd(txd_lower) &&
         (tp->cptse || txd_lower & E1000_TXD_CMD_EOP)) {
         tp->vlan_needed = 1;
-        cpu_to_be16wu((uint16_t *)(tp->vlan_header),
+        stw_be_p(tp->vlan_header,
                       le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
-        cpu_to_be16wu((uint16_t *)(tp->vlan_header + 2),
+        stw_be_p(tp->vlan_header + 2,
                       le16_to_cpu(dp->upper.fields.special));
     }
         
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 9524931..3bb6b71 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -412,11 +412,6 @@ static inline void stfq_be_p(void *ptr, float64 v)
 
 /* Legacy unaligned versions.  Note that we never had a complete set.  */
 
-static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
-{
-    stw_be_p(p, v);
-}
-
 static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
 {
     stl_be_p(p, v);
-- 
1.7.9.5

  parent reply	other threads:[~2013-08-25 14:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-25 14:59 [Qemu-devel] [PATCH 0/9] Remove legacy unaligned bswap functions Peter Maydell
2013-08-25 14:59 ` [Qemu-devel] [PATCH 1/9] bswap.h: Remove cpu_to_le16wu() Peter Maydell
2013-08-25 14:59 ` [Qemu-devel] [PATCH 2/9] bswap.h: Remove cpu_to_le32wu() Peter Maydell
2013-08-26  9:02   ` Stefan Hajnoczi
2013-08-25 14:59 ` [Qemu-devel] [PATCH 3/9] bswap.h: Remove le16_to_cpupu() Peter Maydell
2013-08-25 14:59 ` [Qemu-devel] [PATCH 4/9] bswap.h: Remove le32_to_cpupu() Peter Maydell
2013-08-26  9:04   ` Stefan Hajnoczi
2013-08-25 14:59 ` [Qemu-devel] [PATCH 5/9] bswap.h: Remove be32_to_cpupu() Peter Maydell
2013-08-26  9:05   ` Stefan Hajnoczi
2013-08-25 14:59 ` Peter Maydell [this message]
2013-08-26  9:07   ` [Qemu-devel] [PATCH 6/9] bswap.h: Remove cpu_to_be16wu() Stefan Hajnoczi
2013-08-25 14:59 ` [Qemu-devel] [PATCH 7/9] bswap.h: Remove cpu_to_be32wu() Peter Maydell
2013-08-26  9:08   ` Stefan Hajnoczi
2013-08-25 14:59 ` [Qemu-devel] [PATCH 8/9] bswap.h: Remove cpu_to_be64wu() Peter Maydell
2013-08-26  9:09   ` Stefan Hajnoczi
2013-08-25 14:59 ` [Qemu-devel] [PATCH 9/9] bswap.h: Remove cpu_to_32wu() Peter Maydell
2013-08-26 14:06 ` [Qemu-devel] [PATCH 0/9] Remove legacy unaligned bswap functions Richard Henderson
2013-09-09 10:38 ` Peter Maydell
2013-10-15 13:36   ` Peter Maydell
2013-10-16 19:09     ` Michael S. Tsirkin
2013-09-09 11:54 ` Michael S. Tsirkin
2013-09-09 12:17   ` Peter Maydell
2013-10-15 14:38 ` Michael S. Tsirkin

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=1377442777-11066-7-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=anthony@codemonkey.ws \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /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).