astlpc: Extract MIN()/MAX() to range.h
Enable reuse beyond astlpc.c.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I090358882b2c4b9cb1a9393a9ae38dfbe80335e9
diff --git a/astlpc.c b/astlpc.c
index 87a4cca..64dd9de 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -23,6 +23,7 @@
#include "libmctp-log.h"
#include "libmctp-astlpc.h"
#include "container_of.h"
+#include "range.h"
#ifdef MCTP_HAVE_FILEIO
@@ -129,20 +130,6 @@
#define KCS_STATUS_IBF 0x02
#define KCS_STATUS_OBF 0x01
-#define MIN(a, b) \
- ({ \
- typeof(a) _a = a; \
- typeof(b) _b = b; \
- _a < _b ? _a : _b; \
- })
-
-#define MAX(a, b) \
- ({ \
- typeof(a) _a = a; \
- typeof(b) _b = b; \
- _a > _b ? _a : _b; \
- })
-
static inline int mctp_astlpc_kcs_write(struct mctp_binding_astlpc *astlpc,
enum mctp_binding_astlpc_kcs_reg reg,
uint8_t val)
diff --git a/range.h b/range.h
new file mode 100644
index 0000000..6c96015
--- /dev/null
+++ b/range.h
@@ -0,0 +1,18 @@
+#ifndef _RANGE_H
+#define _RANGE_H
+
+#define MIN(a, b) \
+ ({ \
+ typeof(a) _a = a; \
+ typeof(b) _b = b; \
+ _a < _b ? _a : _b; \
+ })
+
+#define MAX(a, b) \
+ ({ \
+ typeof(a) _a = a; \
+ typeof(b) _b = b; \
+ _a > _b ? _a : _b; \
+ })
+
+#endif