diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-01-30 04:30:06 -0500 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2013-02-01 00:28:32 -0500 |
commit | 0d2a1b2d03dfd5ee79e7ebc59635690c8f08810f (patch) | |
tree | 743a2995f53cef27082a1e3fbe99726322d48e1d /lib/mpi | |
parent | 26d438457ed1b99b6cb26d8f694e8d3de336f9d8 (diff) |
mpilib: use DIV_ROUND_UP and remove unused macros
Remove MIN, MAX and ABS macros that are duplicates kernel's native
implementation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'lib/mpi')
-rw-r--r-- | lib/mpi/mpi-internal.h | 4 | ||||
-rw-r--r-- | lib/mpi/mpicoder.c | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/lib/mpi/mpi-internal.h b/lib/mpi/mpi-internal.h index 77adcf6bc257..60cf765628e9 100644 --- a/lib/mpi/mpi-internal.h +++ b/lib/mpi/mpi-internal.h | |||
@@ -65,10 +65,6 @@ | |||
65 | typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */ | 65 | typedef mpi_limb_t *mpi_ptr_t; /* pointer to a limb */ |
66 | typedef int mpi_size_t; /* (must be a signed type) */ | 66 | typedef int mpi_size_t; /* (must be a signed type) */ |
67 | 67 | ||
68 | #define ABS(x) (x >= 0 ? x : -x) | ||
69 | #define MIN(l, o) ((l) < (o) ? (l) : (o)) | ||
70 | #define MAX(h, i) ((h) > (i) ? (h) : (i)) | ||
71 | |||
72 | static inline int RESIZE_IF_NEEDED(MPI a, unsigned b) | 68 | static inline int RESIZE_IF_NEEDED(MPI a, unsigned b) |
73 | { | 69 | { |
74 | if (a->alloced < b) | 70 | if (a->alloced < b) |
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c index 3962b7f7fe3f..5f9c44cdf1f5 100644 --- a/lib/mpi/mpicoder.c +++ b/lib/mpi/mpicoder.c | |||
@@ -52,7 +52,7 @@ MPI mpi_read_raw_data(const void *xbuffer, size_t nbytes) | |||
52 | else | 52 | else |
53 | nbits = 0; | 53 | nbits = 0; |
54 | 54 | ||
55 | nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB; | 55 | nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); |
56 | val = mpi_alloc(nlimbs); | 56 | val = mpi_alloc(nlimbs); |
57 | if (!val) | 57 | if (!val) |
58 | return NULL; | 58 | return NULL; |
@@ -96,8 +96,8 @@ MPI mpi_read_from_buffer(const void *xbuffer, unsigned *ret_nread) | |||
96 | buffer += 2; | 96 | buffer += 2; |
97 | nread = 2; | 97 | nread = 2; |
98 | 98 | ||
99 | nbytes = (nbits + 7) / 8; | 99 | nbytes = DIV_ROUND_UP(nbits, 8); |
100 | nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB; | 100 | nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); |
101 | val = mpi_alloc(nlimbs); | 101 | val = mpi_alloc(nlimbs); |
102 | if (!val) | 102 | if (!val) |
103 | return NULL; | 103 | return NULL; |
@@ -193,7 +193,7 @@ int mpi_set_buffer(MPI a, const void *xbuffer, unsigned nbytes, int sign) | |||
193 | int nlimbs; | 193 | int nlimbs; |
194 | int i; | 194 | int i; |
195 | 195 | ||
196 | nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB; | 196 | nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); |
197 | if (RESIZE_IF_NEEDED(a, nlimbs) < 0) | 197 | if (RESIZE_IF_NEEDED(a, nlimbs) < 0) |
198 | return -ENOMEM; | 198 | return -ENOMEM; |
199 | a->sign = sign; | 199 | a->sign = sign; |