[Gta04-owner] [PATCH] ov9655: fix write_regs loop
Dr. H. Nikolaus Schaller
hns at goldelico.com
Sat Jun 8 11:55:08 CEST 2013
Am 07.06.2013 um 23:54 schrieb Andreas Kemnade:
> The no need to write-optimization in ov9655_write_regs caused the
> loop to abort at the first register which needs not to be changed.
> So many registers were not set.
>
> Signed-off-by: Andreas Kemnade <andreas at kemnade.info>
> ---
> drivers/media/i2c/ov9655.c | 13 ++++++-------
> 1 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/i2c/ov9655.c b/drivers/media/i2c/ov9655.c
> index 3904d33..7b2859f 100644
> --- a/drivers/media/i2c/ov9655.c
> +++ b/drivers/media/i2c/ov9655.c
> @@ -735,19 +735,18 @@ static int ov9655_write_regs(struct i2c_client *client,
> {
> int i, ret;
> for (i = 0; i < n; i++) {
> - u8 val = regs->value;
> - if(regs->clear != 0) { /* modify only some bits */
> - ret = ov9655_read(client, regs->addr);
> + u8 val = regs[i].value;
> + if(regs[i].clear != 0) { /* modify only some bits */
> + ret = ov9655_read(client, regs[i].addr);
> if(ret < 0)
> return ret;
> - val |= (ret & regs->clear);
> + val |= (ret & regs[i].clear);
> if(val == (u8) ret)
> - return 0; /* no need to write */
> + continue; /* no need to write */
Oops! You are right. This optimization was introduced very
late and is rarely used. But if it is, it fails.
Thanks for spotting this problem and submitting the patch!
> }
> - ret = ov9655_write(client, regs->addr, val);
> + ret = ov9655_write(client, regs[i].addr, val);
> if (ret < 0)
> return ret;
> - regs++;
> }
> return 0;
> }
> --
> 1.7.2.5
>
> _______________________________________________
> Gta04-owner mailing list
> Gta04-owner at goldelico.com
> http://lists.goldelico.com/mailman/listinfo/gta04-owner
More information about the Gta04-owner
mailing list