All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: javier Martin <javier.martin@vista-silicon.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	carlighting@yahoo.co.nz, beagleboard@googlegroups.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor.
Date: Mon, 23 May 2011 10:48:36 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.1105231027150.30305@axis700.grange> (raw)
In-Reply-To: <BANLkTinjNUVH4pvxsKos=wTd0fCB-2zz2A@mail.gmail.com>

On Mon, 23 May 2011, javier Martin wrote:

> On 21 May 2011 17:29, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> > On Fri, 20 May 2011, Javier Martin wrote:
> >
> >> This driver adds basic support for Aptina mt9p031 sensor.
> >>
> >> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
> >> ---
> >>  drivers/media/video/Kconfig   |    8 +
> >>  drivers/media/video/Makefile  |    1 +
> >>  drivers/media/video/mt9p031.c |  751 +++++++++++++++++++++++++++++++++++++++++
> >>  include/media/mt9p031.h       |   11 +
> >>  4 files changed, 771 insertions(+), 0 deletions(-)
> >>  create mode 100644 drivers/media/video/mt9p031.c
> >>  create mode 100644 include/media/mt9p031.h
> >>
> >> diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
> >> new file mode 100644
> >> index 0000000..e406b64
> >> --- /dev/null
> >> +++ b/drivers/media/video/mt9p031.c
> >> @@ -0,0 +1,751 @@
> >> +/*
> >> + * Driver for MT9P031 CMOS Image Sensor from Aptina
> >> + *
> >> + * Copyright (C) 2011, Javier Martin <javier.martin@vista-silicon.com>
> >> + *
> >> + * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> >> + *
> >> + * Based on the MT9V032 driver and Bastian Hecht's code.
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/delay.h>
> >> +#include <linux/device.h>
> >> +#include <linux/i2c.h>
> >> +#include <linux/log2.h>
> >> +#include <linux/pm.h>
> >> +#include <linux/regulator/consumer.h>
> >> +#include <linux/slab.h>
> >> +#include <media/v4l2-subdev.h>
> >> +#include <linux/videodev2.h>
> >> +
> >> +#include <media/mt9p031.h>
> >> +#include <media/v4l2-chip-ident.h>
> >> +#include <media/v4l2-subdev.h>
> >> +#include <media/v4l2-device.h>
> >> +
> >> +/* mt9p031 selected register addresses */
> >> +#define MT9P031_CHIP_VERSION                 0x00
> >> +#define              MT9P031_CHIP_VERSION_VALUE      0x1801
> >> +#define MT9P031_ROW_START                    0x01
> >
> > Don't mix spaces and TABs between "#define" and the macro - just use one
> > space everywhere.
> >
> 
> I've done this in order to follow Laurent's directions. He does the
> same in mt9v032 driver.
> So, unless Laurent and you agree I think I won't change it.

Ah, so, you use a space for registers and TABs for their values, ok then.

> >> +struct mt9p031 {
> >> +     struct v4l2_subdev subdev;
> >> +     struct media_pad pad;
> >> +     struct v4l2_rect rect;  /* Sensor window */
> >> +     struct v4l2_mbus_framefmt format;
> >> +     struct mt9p031_platform_data *pdata;
> >> +     struct mutex power_lock;
> >
> > Don't locks _always_ have to be documented? And this one: you only protect
> > set_power() with it, Laurent, is this correct?
> >
> 
> Just following the model Laurent applies in mt9v032. Let's see what he
> has to say about this.

Try running scripts/checkpatch.pl on your patch. I think, it will complain 
about this. And in general it's a good idea to run it before submission;)

> >> +static int mt9p031_reset(struct i2c_client *client)
> >> +{
> >> +     struct mt9p031 *mt9p031 = to_mt9p031(client);
> >> +     int ret;
> >> +
> >> +     /* Disable chip output, synchronous option update */
> >> +     ret = reg_write(client, MT9P031_RST, MT9P031_RST_ENABLE);
> >> +     if (ret < 0)
> >> +             return -EIO;
> >> +     ret = reg_write(client, MT9P031_RST, MT9P031_RST_DISABLE);
> >> +     if (ret < 0)
> >> +             return -EIO;
> >> +     ret = mt9p031_set_output_control(mt9p031, MT9P031_OUTPUT_CONTROL_CEN, 0);
> >> +     if (ret < 0)
> >> +             return -EIO;
> >> +     return 0;
> >
> >
> > I think, a sequence like
> >
> >        ret = fn();
> >        if (!ret)
> >                ret = fn();
> >        if (!ret)
> >                ret = fn();
> >        return ret;
> >
> > is a better way to achieve the same.
> >
> 
> Sorry, but I have to disagree. I understand what you want to achieve
> but this seems quite tricky to me.
> I explicitly changed parts of the code that were written using that
> style because I think It was better understandable.

Well, that was my opinion. Since Laurent will be taking this patch via his 
tree, his decision will be final, of course. But I think, he'll agree, 
that at least you have to be consistent across the driver. And at least 
you'd want to propagate your error code up to the caller instead of 
replacing it with "-EIO."

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

WARNING: multiple messages have this Message-ID (diff)
From: g.liakhovetski@gmx.de (Guennadi Liakhovetski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor.
Date: Mon, 23 May 2011 10:48:36 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.1105231027150.30305@axis700.grange> (raw)
In-Reply-To: <BANLkTinjNUVH4pvxsKos=wTd0fCB-2zz2A@mail.gmail.com>

On Mon, 23 May 2011, javier Martin wrote:

> On 21 May 2011 17:29, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> > On Fri, 20 May 2011, Javier Martin wrote:
> >
> >> This driver adds basic support for Aptina mt9p031 sensor.
> >>
> >> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
> >> ---
> >> ?drivers/media/video/Kconfig ? | ? ?8 +
> >> ?drivers/media/video/Makefile ?| ? ?1 +
> >> ?drivers/media/video/mt9p031.c | ?751 +++++++++++++++++++++++++++++++++++++++++
> >> ?include/media/mt9p031.h ? ? ? | ? 11 +
> >> ?4 files changed, 771 insertions(+), 0 deletions(-)
> >> ?create mode 100644 drivers/media/video/mt9p031.c
> >> ?create mode 100644 include/media/mt9p031.h
> >>
> >> diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
> >> new file mode 100644
> >> index 0000000..e406b64
> >> --- /dev/null
> >> +++ b/drivers/media/video/mt9p031.c
> >> @@ -0,0 +1,751 @@
> >> +/*
> >> + * Driver for MT9P031 CMOS Image Sensor from Aptina
> >> + *
> >> + * Copyright (C) 2011, Javier Martin <javier.martin@vista-silicon.com>
> >> + *
> >> + * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> >> + *
> >> + * Based on the MT9V032 driver and Bastian Hecht's code.
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/delay.h>
> >> +#include <linux/device.h>
> >> +#include <linux/i2c.h>
> >> +#include <linux/log2.h>
> >> +#include <linux/pm.h>
> >> +#include <linux/regulator/consumer.h>
> >> +#include <linux/slab.h>
> >> +#include <media/v4l2-subdev.h>
> >> +#include <linux/videodev2.h>
> >> +
> >> +#include <media/mt9p031.h>
> >> +#include <media/v4l2-chip-ident.h>
> >> +#include <media/v4l2-subdev.h>
> >> +#include <media/v4l2-device.h>
> >> +
> >> +/* mt9p031 selected register addresses */
> >> +#define MT9P031_CHIP_VERSION ? ? ? ? ? ? ? ? 0x00
> >> +#define ? ? ? ? ? ? ?MT9P031_CHIP_VERSION_VALUE ? ? ?0x1801
> >> +#define MT9P031_ROW_START ? ? ? ? ? ? ? ? ? ?0x01
> >
> > Don't mix spaces and TABs between "#define" and the macro - just use one
> > space everywhere.
> >
> 
> I've done this in order to follow Laurent's directions. He does the
> same in mt9v032 driver.
> So, unless Laurent and you agree I think I won't change it.

Ah, so, you use a space for registers and TABs for their values, ok then.

> >> +struct mt9p031 {
> >> + ? ? struct v4l2_subdev subdev;
> >> + ? ? struct media_pad pad;
> >> + ? ? struct v4l2_rect rect; ?/* Sensor window */
> >> + ? ? struct v4l2_mbus_framefmt format;
> >> + ? ? struct mt9p031_platform_data *pdata;
> >> + ? ? struct mutex power_lock;
> >
> > Don't locks _always_ have to be documented? And this one: you only protect
> > set_power() with it, Laurent, is this correct?
> >
> 
> Just following the model Laurent applies in mt9v032. Let's see what he
> has to say about this.

Try running scripts/checkpatch.pl on your patch. I think, it will complain 
about this. And in general it's a good idea to run it before submission;)

> >> +static int mt9p031_reset(struct i2c_client *client)
> >> +{
> >> + ? ? struct mt9p031 *mt9p031 = to_mt9p031(client);
> >> + ? ? int ret;
> >> +
> >> + ? ? /* Disable chip output, synchronous option update */
> >> + ? ? ret = reg_write(client, MT9P031_RST, MT9P031_RST_ENABLE);
> >> + ? ? if (ret < 0)
> >> + ? ? ? ? ? ? return -EIO;
> >> + ? ? ret = reg_write(client, MT9P031_RST, MT9P031_RST_DISABLE);
> >> + ? ? if (ret < 0)
> >> + ? ? ? ? ? ? return -EIO;
> >> + ? ? ret = mt9p031_set_output_control(mt9p031, MT9P031_OUTPUT_CONTROL_CEN, 0);
> >> + ? ? if (ret < 0)
> >> + ? ? ? ? ? ? return -EIO;
> >> + ? ? return 0;
> >
> >
> > I think, a sequence like
> >
> > ? ? ? ?ret = fn();
> > ? ? ? ?if (!ret)
> > ? ? ? ? ? ? ? ?ret = fn();
> > ? ? ? ?if (!ret)
> > ? ? ? ? ? ? ? ?ret = fn();
> > ? ? ? ?return ret;
> >
> > is a better way to achieve the same.
> >
> 
> Sorry, but I have to disagree. I understand what you want to achieve
> but this seems quite tricky to me.
> I explicitly changed parts of the code that were written using that
> style because I think It was better understandable.

Well, that was my opinion. Since Laurent will be taking this patch via his 
tree, his decision will be final, of course. But I think, he'll agree, 
that at least you have to be consistent across the driver. And at least 
you'd want to propagate your error code up to the caller instead of 
replacing it with "-EIO."

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

  reply	other threads:[~2011-05-23  8:48 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 13:47 [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor Javier Martin
2011-05-20 13:47 ` Javier Martin
2011-05-20 13:47 ` [PATCH v2 2/2] OMAP3BEAGLE: Add support for mt9p031 sensor driver Javier Martin
2011-05-20 13:47   ` Javier Martin
2011-05-20 15:57   ` [beagleboard] " Koen Kooi
2011-05-20 15:57     ` Koen Kooi
2011-05-23  7:01     ` javier Martin
2011-05-23  7:01       ` javier Martin
2011-05-23  8:00       ` Laurent Pinchart
2011-05-23  8:00         ` Laurent Pinchart
2011-05-23  8:55         ` Koen Kooi
2011-05-23  8:55           ` Koen Kooi
2011-05-23  9:14           ` Laurent Pinchart
2011-05-23  9:14             ` Laurent Pinchart
2011-05-22 13:49   ` Igor Grinberg
2011-05-22 13:49     ` Igor Grinberg
2011-05-23  7:25     ` javier Martin
2011-05-23  7:25       ` javier Martin
2011-05-23  7:25       ` javier Martin
2011-05-23  7:47       ` Laurent Pinchart
2011-05-23  7:47         ` Laurent Pinchart
2011-05-23 17:03         ` Igor Grinberg
2011-05-23 17:03           ` Igor Grinberg
2011-05-21 12:55 ` [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor Mauro Carvalho Chehab
2011-05-21 12:55   ` Mauro Carvalho Chehab
2011-05-22 20:41   ` Laurent Pinchart
2011-05-22 20:41     ` Laurent Pinchart
2011-05-21 15:29 ` Guennadi Liakhovetski
2011-05-21 15:29   ` Guennadi Liakhovetski
2011-05-23  8:20   ` javier Martin
2011-05-23  8:20     ` javier Martin
2011-05-23  8:48     ` Guennadi Liakhovetski [this message]
2011-05-23  8:48       ` Guennadi Liakhovetski
2011-05-23  9:08       ` Laurent Pinchart
2011-05-23  9:08         ` Laurent Pinchart
2011-05-23  9:03   ` Laurent Pinchart
2011-05-23  9:03     ` Laurent Pinchart
2011-05-23  9:26     ` Guennadi Liakhovetski
2011-05-23  9:26       ` Guennadi Liakhovetski
2011-05-24  8:31     ` javier Martin
2011-05-24  8:31       ` javier Martin
2011-05-24  8:39       ` Laurent Pinchart
2011-05-24  8:39         ` Laurent Pinchart
2011-05-24  8:56         ` javier Martin
2011-05-24  8:56           ` javier Martin
2011-05-24  8:58           ` Laurent Pinchart
2011-05-24  8:58             ` Laurent Pinchart
2011-05-23  3:01 Chris Rodley
2011-05-23  6:54 ` javier Martin
2011-05-24  5:03 Chris Rodley
2011-05-25  3:45 Chris Rodley
2011-05-25  7:00 ` javier Martin
2011-05-25  7:00   ` javier Martin

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=Pine.LNX.4.64.1105231027150.30305@axis700.grange \
    --to=g.liakhovetski@gmx.de \
    --cc=beagleboard@googlegroups.com \
    --cc=carlighting@yahoo.co.nz \
    --cc=javier.martin@vista-silicon.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.