* [patch] [media] s3c-camif: forever loop in camif_hw_set_source_format()
@ 2013-08-23 9:41 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2013-08-23 9:41 UTC (permalink / raw)
To: Sylwester Nawrocki
Cc: Mauro Carvalho Chehab, linux-media, linux-samsung-soc,
kernel-janitors
Because "i" is unsigned then "i-- >= 0" is always true. If we don't
find what we are looking for then we loop forever.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Why do we count backwards anyway? Counting upwards is easier.
diff --git a/drivers/media/platform/s3c-camif/camif-regs.c b/drivers/media/platform/s3c-camif/camif-regs.c
index a9e3b16..ebf5b18 100644
--- a/drivers/media/platform/s3c-camif/camif-regs.c
+++ b/drivers/media/platform/s3c-camif/camif-regs.c
@@ -106,15 +106,15 @@ static const u32 src_pixfmt_map[8][2] = {
void camif_hw_set_source_format(struct camif_dev *camif)
{
struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
- unsigned int i = ARRAY_SIZE(src_pixfmt_map);
+ int i;
u32 cfg;
- while (i-- >= 0) {
+ for (i = ARRAY_SIZE(src_pixfmt_map) - 1; i >= 0; i--) {
if (src_pixfmt_map[i][0] = mf->code)
break;
}
-
- if (i = 0 && src_pixfmt_map[i][0] != mf->code) {
+ if (i < 0) {
+ i = 0;
dev_err(camif->dev,
"Unsupported pixel code, falling back to %#08x\n",
src_pixfmt_map[i][0]);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-08-23 9:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23 9:41 [patch] [media] s3c-camif: forever loop in camif_hw_set_source_format() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox