diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-11 20:52:16 +0000 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-11 20:52:16 +0000 |
commit | dabbb6b1c9d6df38c1f140b22303c9e8935bbc38 (patch) | |
tree | fa04f6cebfea98f39e19001c553d66e7b4338a70 | |
parent | f9bf244a99c60bc5c062682e996582f3ed109bad (diff) | |
download | mediapointer-dvb-s2-dabbb6b1c9d6df38c1f140b22303c9e8935bbc38.tar.gz mediapointer-dvb-s2-dabbb6b1c9d6df38c1f140b22303c9e8935bbc38.tar.bz2 |
ov7670: clean up ov7670_read semantics
From: Andres Salomon <dilinger@queued.net>
Cortland Setlow pointed out a bug in ov7670.c where the result from
ov7670_read() was just being checked for !0, rather than <0. This
made me realize that ov7670_read's semantics were rather confusing;
it both fills in 'value' with the result, and returns it. This is
goes against general kernel convention; so rather than fixing callers,
let's fix the function.
This makes ov7670_read return <0 in the case of an error, and 0 upon
success. Thus, code like:
res = ov7670_read(...);
if (!res)
goto error;
..will work properly.
Signed-off-by: Cortland Setlow <csetlow@tower-research.com>
Signed-off-by: Andres Salomon <dilinger@debian.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | linux/drivers/media/video/ov7670.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/linux/drivers/media/video/ov7670.c b/linux/drivers/media/video/ov7670.c index fb8c607fc..f226161bc 100644 --- a/linux/drivers/media/video/ov7670.c +++ b/linux/drivers/media/video/ov7670.c @@ -407,8 +407,10 @@ static int ov7670_read(struct i2c_client *c, unsigned char reg, int ret; ret = i2c_smbus_read_byte_data(c, reg); - if (ret >= 0) + if (ret >= 0) { *value = (unsigned char) ret; + ret = 0; + } return ret; } |