Re: [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 23 May 2011, Laurent Pinchart wrote:

> > > +{
> > > +	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.
> 
> I disagree with you on that :-) I find code sequences that return as soon as 
> an error occurs, using the main code path for the error-free case, easier to 
> read. It can be a matter of personal taste though.

Whichever way, but it should be consistent, IMHO.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux