From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: mchehab@s-opensource.com, yong.zhi@intel.com
Subject: [PATCH 2/2] intel-ipu3: Rename arr_size macro, use min
Date: Fri, 29 Dec 2017 14:59:14 +0200 [thread overview]
Message-ID: <20171229125914.7218-3-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20171229125914.7218-1-sakari.ailus@linux.intel.com>
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: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 941caa987dab..52827d572493 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1894,20 +1894,17 @@ static void arrange(void *ptr, size_t elem_size, size_t elems, size_t start)
{ 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 */
- while (arr_size(&arr[0]) && arr_size(&arr[1])) {
+ while (CHUNK_SIZE(&arr[0]) && CHUNK_SIZE(&arr[1])) {
size_t size0, i;
/*
* Find the number of entries that can be arranged on this
* iteration.
*/
- if (arr_size(&arr[0]) > arr_size(&arr[1]))
- size0 = arr_size(&arr[1]);
- else
- size0 = arr_size(&arr[0]);
+ size0 = min(CHUNK_SIZE(&arr[0]), CHUNK_SIZE(&arr[1]));
/* Swap the entries in two parts of the array. */
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)
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. */
arr[0].begin += size0;
} else {
--
2.11.0
next prev parent reply other threads:[~2017-12-29 12:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-29 12:59 [PATCH 0/2] A few IPU3 CIO2 fixes Sakari Ailus
2017-12-29 12:59 ` [PATCH 1/2] v4l: Fix references in Intel IPU3 Bayer documentation Sakari Ailus
2017-12-29 12:59 ` Sakari Ailus [this message]
2017-12-29 13:42 ` [PATCH 0/2] A few IPU3 CIO2 fixes Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171229125914.7218-3-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@s-opensource.com \
--cc=yong.zhi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).