Commit 6afda56a authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: intel-ipu3: Rename arr_size macro, use min

The arr_size() macro which is used to calculate the size of the chunk in the
array to be arranged resembles ARRAY_SIZE naming-wise. Avoid confusion by
renaming it to CHUNK_SIZE instead.

Also use min() macro to calculate the minimum of two numbers.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 96780202
...@@ -1894,20 +1894,17 @@ static void arrange(void *ptr, size_t elem_size, size_t elems, size_t start) ...@@ -1894,20 +1894,17 @@ static void arrange(void *ptr, size_t elem_size, size_t elems, size_t start)
{ start, elems - 1 }, { start, elems - 1 },
}; };
#define arr_size(a) ((a)->end - (a)->begin + 1) #define CHUNK_SIZE(a) ((a)->end - (a)->begin + 1)
/* Loop as long as we have out-of-place entries */ /* Loop as long as we have out-of-place entries */
while (arr_size(&arr[0]) && arr_size(&arr[1])) { while (CHUNK_SIZE(&arr[0]) && CHUNK_SIZE(&arr[1])) {
size_t size0, i; size_t size0, i;
/* /*
* Find the number of entries that can be arranged on this * Find the number of entries that can be arranged on this
* iteration. * iteration.
*/ */
if (arr_size(&arr[0]) > arr_size(&arr[1])) size0 = min(CHUNK_SIZE(&arr[0]), CHUNK_SIZE(&arr[1]));
size0 = arr_size(&arr[1]);
else
size0 = arr_size(&arr[0]);
/* Swap the entries in two parts of the array. */ /* Swap the entries in two parts of the array. */
for (i = 0; i < size0; i++) { for (i = 0; i < size0; i++) {
...@@ -1919,7 +1916,7 @@ static void arrange(void *ptr, size_t elem_size, size_t elems, size_t start) ...@@ -1919,7 +1916,7 @@ static void arrange(void *ptr, size_t elem_size, size_t elems, size_t start)
swap(d[j], s[j]); swap(d[j], s[j]);
} }
if (arr_size(&arr[0]) > arr_size(&arr[1])) { if (CHUNK_SIZE(&arr[0]) > CHUNK_SIZE(&arr[1])) {
/* The end of the first array remains unarranged. */ /* The end of the first array remains unarranged. */
arr[0].begin += size0; arr[0].begin += size0;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment