Skip to content

Commit

Permalink
astlpc: Extract MIN()/MAX() to range.h
Browse files Browse the repository at this point in the history
Enable reuse beyond astlpc.c.

Signed-off-by: Andrew Jeffery <[email protected]>
Change-Id: I090358882b2c4b9cb1a9393a9ae38dfbe80335e9
  • Loading branch information
amboar committed Nov 6, 2020
1 parent 85c04e4 commit 4622cad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
15 changes: 1 addition & 14 deletions astlpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "libmctp-log.h"
#include "libmctp-astlpc.h"
#include "container_of.h"
#include "range.h"

#ifdef MCTP_HAVE_FILEIO

Expand Down Expand Up @@ -129,20 +130,6 @@ static const uint32_t control_size = 0x100;
#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)
Expand Down
18 changes: 18 additions & 0 deletions range.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4622cad

Please sign in to comment.