linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] mt9p031: Add mt9p031 sensor driver.
Date: Wed, 18 May 2011 00:18:21 +0100	[thread overview]
Message-ID: <20110517231821.GB5913@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <201105171334.01607.laurent.pinchart@ideasonboard.com>

On Tue, May 17, 2011 at 01:33:52PM +0200, Laurent Pinchart wrote:
> Hi Javier,
> 
> Thanks for the patch.

Sorry, but this laziness is getting beyond a joke...  And the fact that
apparantly no one is picking up on it other than me is also a joke.

> > +static int mt9p031_power_on(struct mt9p031 *mt9p031)
> > +{
> > +	int ret;
> > +
> > +	if (mt9p031->pdata->set_xclk)
> > +		mt9p031->pdata->set_xclk(&mt9p031->subdev, 54000000);
> > +	/* turn on VDD_IO */
> > +	ret = regulator_enable(mt9p031->reg_2v8);
> > +	if (ret) {
> > +		pr_err("Failed to enable 2.8v regulator: %d\n", ret);
> > +		return -1;

And why all these 'return -1's?  My guess is that this is plain laziness
on the authors part.

> > +static int mt9p031_set_params(struct i2c_client *client,
> > +			      struct v4l2_rect *rect, u16 xskip, u16 yskip)
> 
> set_params should apply the parameters, not change them. They should have 
> already been validated by the callers.
> 
> > +{
...
> > +err:
> > +	return -1;

And again...

> > +}
> > +
> > +static int mt9p031_set_crop(struct v4l2_subdev *sd,
> > +				struct v4l2_subdev_fh *fh,
> > +				struct v4l2_subdev_crop *crop)
> > +{
...

> > +	if (crop->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
> > +		ret = mt9p031_set_params(client, &rect, xskip, yskip);
> > +		if (ret < 0)
> > +			return ret;

So this propagates the lazy 'return -1' all the way back to userspace.
This is utter crap - really it is, and I'm getting sick and tired of
telling people that they should not use 'return -1'.  It's down right
lazy and sloppy programming.

I wish people would stop doing it.  I wish people would review their own
stuff for this _before_ posting it onto a mailing list, so I don't have
to keep complaining about it.  And I wish people reviewing drivers would
also look for this as well and complain about it.

'return -1' is generally a big fat warning sign that the author is doing
something wrong, and should _always_ be investigated and complained about.

  parent reply	other threads:[~2011-05-17 23:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17  9:28 No subject Javier Martin
2011-05-17  9:28 ` [PATCH 1/2] mt9p031: Add mt9p031 sensor driver Javier Martin
2011-05-17 11:33   ` Laurent Pinchart
2011-05-17 11:47     ` Guennadi Liakhovetski
2011-05-17 11:59       ` javier Martin
2011-05-17 17:14         ` Ivan Nazarenko
2011-05-18 10:34           ` javier Martin
2011-05-17 23:18     ` Russell King - ARM Linux [this message]
2011-05-18  9:10     ` javier Martin
2011-05-18 14:23       ` Laurent Pinchart
2011-05-17  9:28 ` [PATCH 2/2] OMAP3BEAGLE: Add support for mt9p031 sensor (LI-5M03 module) Javier Martin
2011-05-17 23:08   ` Russell King - ARM Linux
2011-05-18  7:50     ` Laurent Pinchart

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=20110517231821.GB5913@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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 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).