aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2021-01-27 19:36:37 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2021-01-28 14:22:49 +1100
commitb2176a9ce6b397fd39d320eb1ceb9ef9dae6895d (patch)
tree91035b9985c34e2ceea8634424dbaf8662372b7f
parentb7ea243afd3917b9dfc58fda046138fba0aa9b1e (diff)
downloadSLOF-b2176a9ce6b397fd39d320eb1ceb9ef9dae6895d.zip
SLOF-b2176a9ce6b397fd39d320eb1ceb9ef9dae6895d.tar.gz
SLOF-b2176a9ce6b397fd39d320eb1ceb9ef9dae6895d.tar.bz2
helpers: Define MIN()
We already have MAX() defined, add MIN() to the common helpers header. Using the common helper also fixes a bug in tpmdrivers's MIN() where it was reverted. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * updated the comment about a fixed bug
-rw-r--r--include/helpers.h1
-rw-r--r--lib/libtpm/tcgbios.c2
-rw-r--r--lib/libtpm/tpm_drivers.c2
3 files changed, 1 insertions, 4 deletions
diff --git a/include/helpers.h b/include/helpers.h
index 112184f..898c02c 100644
--- a/include/helpers.h
+++ b/include/helpers.h
@@ -53,5 +53,6 @@ extern unsigned long SLOF_get_vtpm_unit(void);
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define ROUNDUP(x,v) ((((x) + ((v) - 1)) / (v)) * (v))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index ee052e1..8e80811 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -43,8 +43,6 @@
#define dprintf(_x ...)
#endif
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
static struct {
unsigned tpm_probed:1;
unsigned tpm_found:1;
diff --git a/lib/libtpm/tpm_drivers.c b/lib/libtpm/tpm_drivers.c
index 5005176..0e13561 100644
--- a/lib/libtpm/tpm_drivers.c
+++ b/lib/libtpm/tpm_drivers.c
@@ -30,8 +30,6 @@
#define dprintf(_x ...)
#endif
-#define MIN(a, b) ((a) > (b) ? (b) : (a))
-
/* layout of the command request queue for vTPM; all fields are big endian */
struct crq {
uint8_t valid;