From: "Cristian Rodríguez" <crrodriguez@opensuse.org>
To: netdev@vger.kernel.org
Cc: ben@decadent.org.uk, "Cristian Rodríguez" <crrodriguez@opensuse.org>
Subject: [PATCH ethtool 2/2] Use htobe64, htobe16 from libc instead of local byteswap code
Date: Thu, 3 Apr 2014 00:06:16 -0300 [thread overview]
Message-ID: <1396494376-6521-2-git-send-email-crrodriguez@opensuse.org> (raw)
In-Reply-To: <1396494376-6521-1-git-send-email-crrodriguez@opensuse.org>
They are implemented in <endian.h> which is already included
in internal.h, no need to reinvent them with different names.
Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
---
ethtool.c | 2 +-
internal.h | 31 -------------------------------
rxclass.c | 4 ++--
3 files changed, 3 insertions(+), 34 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index acb4397..e47ce0b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -368,7 +368,7 @@ static void parse_generic_cmdline(struct cmd_context *ctx,
}
case CMDL_BE16: {
u16 *p = info[idx].wanted_val;
- *p = cpu_to_be16(
+ *p = htobe16(
get_uint_range(argp[i], 0,
0xffff));
break;
diff --git a/internal.h b/internal.h
index 86a64f2..7e7266b 100644
--- a/internal.h
+++ b/internal.h
@@ -31,37 +31,6 @@ typedef __int32_t s32;
#include "ethtool-copy.h"
#include "net_tstamp-copy.h"
-#if __BYTE_ORDER == __BIG_ENDIAN
-static inline u16 cpu_to_be16(u16 value)
-{
- return value;
-}
-static inline u32 cpu_to_be32(u32 value)
-{
- return value;
-}
-static inline u64 cpu_to_be64(u64 value)
-{
- return value;
-}
-#else
-static inline u16 cpu_to_be16(u16 value)
-{
- return (value >> 8) | (value << 8);
-}
-static inline u32 cpu_to_be32(u32 value)
-{
- return cpu_to_be16(value >> 16) | (cpu_to_be16(value) << 16);
-}
-static inline u64 cpu_to_be64(u64 value)
-{
- return cpu_to_be32(value >> 32) | ((u64)cpu_to_be32(value) << 32);
-}
-#endif
-
-#define ntohll cpu_to_be64
-#define htonll cpu_to_be64
-
#define BITS_PER_BYTE 8
#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
diff --git a/rxclass.c b/rxclass.c
index cd686a3..a013e06 100644
--- a/rxclass.c
+++ b/rxclass.c
@@ -836,7 +836,7 @@ static int rxclass_get_val(char *str, unsigned char *p, u32 *flags,
err = rxclass_get_ulong(str, &val, 64);
if (err)
return -1;
- *(__be64 *)&p[opt->offset] = htonll((u64)val);
+ *(__be64 *)&p[opt->offset] = htobe64((u64)val);
if (opt->moffset >= 0)
*(__be64 *)&p[opt->moffset] = (__be64)mask;
break;
@@ -939,7 +939,7 @@ static int rxclass_get_mask(char *str, unsigned char *p,
err = rxclass_get_ulong(str, &val, 64);
if (err)
return -1;
- *(__be64 *)&p[opt->moffset] = ~htonll((u64)val);
+ *(__be64 *)&p[opt->moffset] = ~htobe64((u64)val);
break;
}
case OPT_IP4: {
--
1.8.4.5
next prev parent reply other threads:[~2014-04-03 3:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 3:06 [PATCH ethtool 1/2] ixgbe: missing "static" in function definition Cristian Rodríguez
2014-04-03 3:06 ` Cristian Rodríguez [this message]
2014-04-21 21:18 ` [PATCH ethtool 2/2] Use htobe64, htobe16 from libc instead of local byteswap code Ben Hutchings
2014-04-21 21:18 ` Ben Hutchings
2014-04-21 21:35 ` [PATCH ethtool 1/2] ixgbe: missing "static" in function definition Ben Hutchings
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=1396494376-6521-2-git-send-email-crrodriguez@opensuse.org \
--to=crrodriguez@opensuse.org \
--cc=ben@decadent.org.uk \
--cc=netdev@vger.kernel.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).