summaryrefslogtreecommitdiff
path: root/include/scsi/libfc.h
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2010-04-09 14:22:39 -0700
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 14:02:34 -0500
commit0b2f74a47f2b10bd4c70324820a93c070b3960a5 (patch)
tree406dc45508b5b23fd0212e7891f577e42e8d159e /include/scsi/libfc.h
parent3b719d01617288f4c11307fcb933997d7ca895c3 (diff)
[SCSI] libfc: fix hton24 macro to take expressions as args
hton24(p + 3, value) would fail to compile because p + 3[0] is not a valid expression. Went ahead and converted hton24 and ntoh24 to inline functions, which is better because the parameters are evalutated only once. Signed-off-by: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'include/scsi/libfc.h')
-rw-r--r--include/scsi/libfc.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 8d0d1b2d8258..a26bb50c0c8b 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -47,13 +47,18 @@
#define ntohll(x) be64_to_cpu(x)
#define htonll(x) cpu_to_be64(x)
-#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
-#define hton24(p, v) do { \
- p[0] = (((v) >> 16) & 0xFF); \
- p[1] = (((v) >> 8) & 0xFF); \
- p[2] = ((v) & 0xFF); \
- } while (0)
+static inline u32 ntoh24(const u8 *p)
+{
+ return (p[0] << 16) | (p[1] << 8) | p[2];
+}
+
+static inline void hton24(u8 *p, u32 v)
+{
+ p[0] = (v >> 16) & 0xff;
+ p[1] = (v >> 8) & 0xff;
+ p[2] = v & 0xff;
+}
/**
* enum fc_lport_state - Local port states