From: Ramiro Oliveira <Ramiro.Oliveira@synopsys.com>
To: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
Ramiro Oliveira <Ramiro.Oliveira@synopsys.com>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
<devicetree@vger.kernel.org>
Cc: CARLOS.PALMINHA@synopsys.com,
"David S. Miller" <davem@davemloft.net>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Hans Verkuil" <hans.verkuil@cisco.com>,
"Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Pali Rohár" <pali.rohar@gmail.com>,
"Pavel Machek" <pavel@ucw.cz>,
"Robert Jarzmik" <robert.jarzmik@free.fr>,
"Rob Herring" <robh+dt@kernel.org>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Steve Longerbeam" <slongerbeam@gmail.com>
Subject: Re: [PATCH v9 2/2] Add support for OV5647 sensor.
Date: Wed, 22 Feb 2017 10:51:21 +0000 [thread overview]
Message-ID: <94622194-78dc-ad6f-3f6e-4d7df0ac5383@synopsys.com> (raw)
In-Reply-To: <21847f33-901c-7d26-15d8-6b92f10c8b15@mentor.com>
Hi Zakari,
On 2/21/2017 8:36 PM, Vladimir Zapolskiy wrote:
> Hi Ramiro,
>
> On 02/21/2017 06:42 PM, Ramiro Oliveira wrote:
>> Hi Vladimir,
>>
>> Thank you for your feedback
>>
>> On 2/21/2017 3:54 PM, Vladimir Zapolskiy wrote:
>>> Hi Ramiro,
>>>
>>> please find some review comments below.
>>>
>>> On 02/17/2017 03:14 PM, Ramiro Oliveira wrote:
>>>> The OV5647 sensor from Omnivision supports up to 2592x1944 @ 15 fps, RAW 8
>>>> and RAW 10 output formats, and MIPI CSI-2 interface.
>>>>
>>>> The driver adds support for 640x480 RAW 8.
>>>>
>>>> Signed-off-by: Ramiro Oliveira <roliveir@synopsys.com>
>>>> ---
>>>
>>> [snip]
>>>
>>>> +
>>>> +struct ov5647 {
>>>> + struct v4l2_subdev sd;
>>>> + struct media_pad pad;
>>>> + struct mutex lock;
>>>> + struct v4l2_mbus_framefmt format;
>>>> + unsigned int width;
>>>> + unsigned int height;
>>>> + int power_count;
>>>> + struct clk *xclk;
>>>> + /* External clock frequency currently supported is 30MHz */
>>>> + u32 xclk_freq;
>>>
>>> See a comment about 25MHz vs 30MHz below.
>>>
>>> Also I assume you can remove 'xclk_freq' from the struct fields,
>>> it can be replaced by a local variable.
>>>
>>
>> I'll do that.
>>
>>>> +};
>>>
>>> [snip]
>>>
>>>> +
>>>> +static int ov5647_read(struct v4l2_subdev *sd, u16 reg, u8 *val)
>>>> +{
>>>> + int ret;
>>>> + unsigned char data_w[2] = { reg >> 8, reg & 0xff };
>>>> + struct i2c_client *client = v4l2_get_subdevdata(sd);
>>>> +
>>>> + ret = i2c_master_send(client, data_w, 2);
>>>> + if (ret < 0) {
>>>> + dev_dbg(&client->dev, "%s: i2c read error, reg: %x\n",
>>>
>>> s/i2c read error/i2c write error/
>>>
>>
>> I'm not sure I understand what you mean.
>
> That's a sed expression for string substitution. Here you do i2c_master_send()
> but dev_dbg() comment says "i2c read error". It's a simple copy-paste typo to fix.
>
Ohh... now I see. I'll change it.
>>>> + __func__, reg);
>>>> + return ret;
>>>> + }
>>>> +
>
> [snip]
>
>>>> +
>>>> +static int sensor_power(struct v4l2_subdev *sd, int on)
>
> On the caller's side (functions ov5647_open() and ov5647_close()) the second
> argument of the function is of 'bool' type, however .s_power callback from
> struct v4l2_subdev_core_ops (see include/media/v4l2-subdev.h) defines it as
> 'int'.
>
> It's just a nitpicking, please feel free to ignore the comment above or
> please consider to change the arguments on callers' side to integers.
>
> Also you may consider to add 'ov5647_' prefix to the function name to
> distinguish it from a potentially added in future sensor_power() function,
> the original name sounds too generic.
>
OK. I'll add the prefix and change the variable type from int to bool.
>>>> +{
>>>> + int ret;
>>>> + struct ov5647 *ov5647 = to_state(sd);
>>>> + struct i2c_client *client = v4l2_get_subdevdata(sd);
>>>> +
>>>> + ret = 0;
>>>> + mutex_lock(&ov5647->lock);
>>>> +
>>>> + if (on && !ov5647->power_count) {
>>>> + dev_dbg(&client->dev, "OV5647 power on\n");
>>>> +
>>>> + clk_set_rate(ov5647->xclk, ov5647->xclk_freq);
>>>
>>> Now clk_set_rate() is redundant, please remove it.
>>>
>>> If once it is needed again, please move it to the .probe function, so
>>> it is called only once in the runtime.
>>>
>>
>> Ok. I'll remove it for now.
>>
>>>> +
>>>> + ret = clk_prepare_enable(ov5647->xclk);
>>>
>>> I wonder would it be possible to unload the driver or to unbind the device
>>> and leave the clock unintentionally enabled? If yes, then this is a bug.
>>>
>>
>> You're saying that if the driver was unloaded and the clock was left enabled
>> when the driver was loaded again this line would cause an error?
>
> Not exactly, here I saw a potential resource leak, namely a potentially left
> prepared/enabled clock.
>
>>
>> Should I disable the clock when the driver is removed?
>>
>
> The driver (and framework) shall guarantee that when it is detached from
> device(s) (e.g. by unloading "ov5647" kernel module or unbinding ov5647 device),
> all acquired resources are released.
>
> But in this particular case most probably I've been overly alert, I believe
> that V4L2 framework correcly handles device power states, so please ignore my
> comment.
>
> To add something valuable to the review, could you please confirm that
> ov5647_subdev_internal_ops data is in use by the driver?
>
> E.g. shouldn't it be registered by
>
> sd->internal_ops = &ov5647_subdev_internal_ops;
>
> before calling v4l2_async_register_subdev(sd) ?
>
You're right, it's not being registered. I think I'll remove them since they
aren't being used.
> --
> With best wishes,
> Vladimir
>
--
Best Regards
Ramiro Oliveira
Ramiro.Oliveira@synopsys.com
next prev parent reply other threads:[~2017-02-22 10:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 13:14 [PATCH v9 0/2] Add support for Omnivision OV5647 Ramiro Oliveira
2017-02-17 13:14 ` [PATCH v9 1/2] Add OV5647 device tree documentation Ramiro Oliveira
2017-02-21 11:57 ` Sakari Ailus
2017-02-21 14:30 ` Ramiro Oliveira
2017-02-21 14:40 ` Sakari Ailus
2017-02-21 15:58 ` Vladimir Zapolskiy
2017-02-21 20:13 ` Ramiro Oliveira
2017-02-21 20:48 ` Vladimir Zapolskiy
2017-02-21 21:48 ` Sakari Ailus
2017-02-21 22:37 ` Vladimir Zapolskiy
2017-02-22 10:57 ` Ramiro Oliveira
2017-02-22 11:39 ` Vladimir Zapolskiy
2017-02-22 14:39 ` Ramiro Oliveira
2017-02-25 14:50 ` Sakari Ailus
2017-02-25 14:55 ` Sakari Ailus
2017-02-17 13:14 ` [PATCH v9 2/2] Add support for OV5647 sensor Ramiro Oliveira
2017-02-21 12:09 ` Sakari Ailus
2017-02-21 14:49 ` Ramiro Oliveira
2017-02-21 14:58 ` Sakari Ailus
2017-02-21 15:54 ` Vladimir Zapolskiy
2017-02-21 16:42 ` Ramiro Oliveira
2017-02-21 20:36 ` Vladimir Zapolskiy
2017-02-22 10:51 ` Ramiro Oliveira [this message]
2017-02-22 11:43 ` Vladimir Zapolskiy
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=94622194-78dc-ad6f-3f6e-4d7df0ac5383@synopsys.com \
--to=ramiro.oliveira@synopsys.com \
--cc=CARLOS.PALMINHA@synopsys.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=hans.verkuil@cisco.com \
--cc=ivo.g.dimitrov.75@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=mchehab@kernel.org \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=robert.jarzmik@free.fr \
--cc=robh+dt@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=slongerbeam@gmail.com \
--cc=vladimir_zapolskiy@mentor.com \
/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
all inboxes | Powered by JetHome®