All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <snjw23@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, sakari.ailus@iki.fi,
	Martin Hostettler <martin@neutronstar.dyndns.org>
Subject: Re: [PATCH v5 1/1] v4l: Add driver for Micron MT9M032 camera sensor
Date: Sat, 10 Mar 2012 15:13:29 +0100	[thread overview]
Message-ID: <4F5B6189.907@gmail.com> (raw)
In-Reply-To: <1859441.NBMQGniVTr@avalon>

Hi Laurent,

On 03/10/2012 01:17 PM, Laurent Pinchart wrote:
> Hi Sylwester,
> 
> On Friday 09 March 2012 22:30:15 Sylwester Nawrocki wrote:
>> Hi Laurent,
>>
>> I have a few minor comments, if you don't mind. :)
> 
> Sure, thanks for the review.
> 
>> On 03/09/2012 09:21 PM, Laurent Pinchart wrote:
>>> From: Martin Hostettler<martin@neutronstar.dyndns.org>
>>>
>>> The MT9M032 is a parallel 1.6MP sensor from Micron controlled through I2C.
>>>
>>> The driver creates a V4L2 subdevice. It currently supports cropping, gain,
>>> exposure and v/h flipping controls in monochrome mode with an
>>> external pixel clock.
>>>
>>> Signed-off-by: Martin Hostettler<martin@neutronstar.dyndns.org>
>>> [Lots of clean up, fixes and enhancements]
>>> Signed-off-by: Laurent Pinchart<laurent.pinchart@ideasonboard.com>

If it helps, you can add my:

   Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

...
>>> +static int mt9m032_set_ctrl(struct v4l2_ctrl *ctrl)
>>> +{
>>> +	struct mt9m032 *sensor =
>>> +		container_of(ctrl->handler, struct mt9m032, ctrls);
>>> +	struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev);
>>> +	int ret;
>>> +
>>> +	switch (ctrl->id) {
>>> +	case V4L2_CID_GAIN:
>>> +		return mt9m032_set_gain(sensor, ctrl->val);
>>> +
>>> +	case V4L2_CID_HFLIP:
>>> +	case V4L2_CID_VFLIP:
>>
>> mt9m032_set_ctrl() will never be called with V4L2_CID_VFLIP control id,
>> since the first control in the cluster is HFLIP.
> 
> I agree that V4L2_CID_VFLIP will never be seen here, but I find it more
> explicit to list all controls in the cluster. What do you think of something
> like the following ?
> 
>          case V4L2_CID_HFLIP:
>          /* case V4L2_CID_VFLIP: -- In the same cluster */

Yeah, sounds better, than just removing VFLIP. It might make things 
easier to understand at first sight.

>>> +		return update_read_mode2(sensor, sensor->vflip->val,
>>> +					 sensor->hflip->val);
>>> +
>>> +	case V4L2_CID_EXPOSURE:
>>> +		ret = mt9m032_write(client, MT9M032_SHUTTER_WIDTH_HIGH,
>>> +				    (ctrl->val>>   16)&   0xffff);
>>> +		if (ret<   0)
>>> +			return ret;
>>> +
>>> +		return mt9m032_write(client, MT9M032_SHUTTER_WIDTH_LOW,
>>> +				     ctrl->val&   0xffff);
>>> +
>>
>>> +	default:
>> This is an impossible case, isn't it ? The control framework won't call
>> s_ctrl op for controls that were never registered to the control handler,
>> AFAIK. So it should be safe to omit the "default" case. OTOH some rules say
>> that it is a good practice to always have the "default" case with a switch
>> statement.
> 
> I'll remove it.
> 
>>> +		return -EINVAL;
>>> +	}
>>> +}
> 
> [snip]
> 
>>> +static int mt9m032_probe(struct i2c_client *client,
>>> +			 const struct i2c_device_id *devid)
>>> +{
>>> +	struct i2c_adapter *adapter = client->adapter;
>>> +	struct mt9m032 *sensor;
>>> +	int chip_version;
>>> +	int ret;
>>> +
>>> +	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
>>> +		dev_warn(&client->dev,
>>> +			 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n");
>>> +		return -EIO;
>>> +	}
>>> +
>>> +	if (!client->dev.platform_data)
>>> +		return -ENODEV;
>>> +
>>> +	sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);
>>
>> Haven't you consider using devm_kzalloc() ?
>> (http://www.kernel.org/doc/htmldocs/device-drivers/API-devm-kzalloc.html)
>> It would slightly simplify the code, however it will use a couple of bytes
>> of memory for the resource tracking.
> 
> I came across that recently and haven't made my mind up yet :-) I'll need to
> try it.

Maybe benefits in this case are not that significant, but as more and more 
kernel subsystems support the dynamically managed resources, error handling
in drivers becomes much simpler than before.

--

Regards,
Sylwester

  reply	other threads:[~2012-03-10 14:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 15:01 [PATCH v4 0/5] MT9M032 and MT9P031 sensor patches Laurent Pinchart
2012-03-09 15:01 ` [PATCH v4 1/5] mt9p031: Remove duplicate media/v4l2-subdev.h include Laurent Pinchart
2012-03-09 15:01 ` [PATCH v4 2/5] mt9p031: Remove unused xskip and yskip fields in struct mt9p031 Laurent Pinchart
2012-03-09 15:01 ` [PATCH v4 3/5] v4l: Aptina-style sensor PLL support Laurent Pinchart
2012-03-09 15:01 ` [PATCH v4 4/5] mt9p031: Use generic PLL setup code Laurent Pinchart
2012-03-09 15:01 ` [PATCH v4 5/5] v4l: Add driver for Micron MT9M032 camera sensor Laurent Pinchart
2012-03-09 19:15   ` Sakari Ailus
2012-03-09 20:20     ` Laurent Pinchart
2012-03-11  1:55       ` Sakari Ailus
2012-03-09 20:21   ` [PATCH v5 1/1] " Laurent Pinchart
2012-03-09 21:30     ` Sylwester Nawrocki
2012-03-10 12:17       ` Laurent Pinchart
2012-03-10 14:13         ` Sylwester Nawrocki [this message]
2012-03-11 14:33     ` [PATCH v6] " Laurent Pinchart
2012-03-11 14:42       ` Sakari Ailus

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=4F5B6189.907@gmail.com \
    --to=snjw23@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=martin@neutronstar.dyndns.org \
    --cc=sakari.ailus@iki.fi \
    /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.