From: Hans Verkuil <hverkuil@xs4all.nl>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 4/9] ov2640: avoid calling ov2640_select_win() twice
Date: Mon, 04 May 2015 09:25:51 +0200 [thread overview]
Message-ID: <55471EFF.4040004@xs4all.nl> (raw)
In-Reply-To: <Pine.LNX.4.64.1505032011550.4237@axis700.grange>
On 05/03/2015 08:19 PM, Guennadi Liakhovetski wrote:
> Hi Hans,
>
> On Sun, 3 May 2015, Hans Verkuil wrote:
>
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> Simplify ov2640_set_params and ov2640_set_fmt.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>> Reported-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>> ---
>> drivers/media/i2c/soc_camera/ov2640.c | 21 ++++++++++-----------
>> 1 file changed, 10 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
>> index 9b4f5de..5dcaf24 100644
>> --- a/drivers/media/i2c/soc_camera/ov2640.c
>> +++ b/drivers/media/i2c/soc_camera/ov2640.c
>> @@ -769,15 +769,15 @@ static const struct ov2640_win_size *ov2640_select_win(u32 *width, u32 *height)
>> return &ov2640_supported_win_sizes[default_size];
>> }
>>
>> -static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
>> - u32 code)
>> +static int ov2640_set_params(struct i2c_client *client,
>> + const struct ov2640_win_size *win, u32 code)
>> {
>> struct ov2640_priv *priv = to_ov2640(client);
>> const struct regval_list *selected_cfmt_regs;
>> int ret;
>>
>> /* select win */
>> - priv->win = ov2640_select_win(width, height);
>> + priv->win = win;
>>
>> /* select format */
>> priv->cfmt_code = 0;
>> @@ -798,6 +798,7 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
>> case MEDIA_BUS_FMT_UYVY8_2X8:
>> dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__);
>> selected_cfmt_regs = ov2640_uyvy_regs;
>> + break;
>
> Hm, IIRC, some versions of gcc complain like "break at the end of a switch
> statement is deprecated." Why did you add this at two locations? Are you
> seeing a warning? If not, maybe better not do that.
I have never seen such a warning in 20 odd years of using gcc. It is bad practice
not to add a break at the end in case someone adds a new case later or shuffles
cases around and misses that there was no break.
And since 99% of all switch statements in the kernel have a break at the end,
I would say that any gcc issues with that would have been spotted ages ago.
Regards,
Hans
>
> Otherwise
>
> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> Thanks
> Guennadi
>
>> }
>>
>> /* reset hardware */
>> @@ -832,8 +833,6 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
>> goto err;
>>
>> priv->cfmt_code = code;
>> - *width = priv->win->width;
>> - *height = priv->win->height;
>>
>> return 0;
>>
>> @@ -887,14 +886,13 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
>> {
>> struct v4l2_mbus_framefmt *mf = &format->format;
>> struct i2c_client *client = v4l2_get_subdevdata(sd);
>> + const struct ov2640_win_size *win;
>>
>> if (format->pad)
>> return -EINVAL;
>>
>> - /*
>> - * select suitable win, but don't store it
>> - */
>> - ov2640_select_win(&mf->width, &mf->height);
>> + /* select suitable win */
>> + win = ov2640_select_win(&mf->width, &mf->height);
>>
>> mf->field = V4L2_FIELD_NONE;
>>
>> @@ -905,14 +903,15 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
>> break;
>> default:
>> mf->code = MEDIA_BUS_FMT_UYVY8_2X8;
>> + /* fall through */
>> case MEDIA_BUS_FMT_YUYV8_2X8:
>> case MEDIA_BUS_FMT_UYVY8_2X8:
>> mf->colorspace = V4L2_COLORSPACE_JPEG;
>> + break;
>> }
>>
>> if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
>> - return ov2640_set_params(client, &mf->width,
>> - &mf->height, mf->code);
>> + return ov2640_set_params(client, win, mf->code);
>> cfg->try_fmt = *mf;
>> return 0;
>> }
>> --
>> 2.1.4
>>
next prev parent reply other threads:[~2015-05-04 7:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-03 9:54 [PATCH 0/9] soc-camera sensor improvements Hans Verkuil
2015-05-03 9:54 ` [PATCH 1/9] imx074: don't call imx074_find_datafmt() twice Hans Verkuil
2015-05-03 17:54 ` Guennadi Liakhovetski
2015-05-04 7:22 ` Hans Verkuil
2015-05-03 9:54 ` [PATCH 2/9] mt9m001: avoid calling mt9m001_find_datafmt() twice Hans Verkuil
2015-05-03 17:56 ` Guennadi Liakhovetski
2015-05-03 9:54 ` [PATCH 3/9] mt9v022: avoid calling mt9v022_find_datafmt() twice Hans Verkuil
2015-05-03 17:57 ` Guennadi Liakhovetski
2015-05-03 9:54 ` [PATCH 4/9] ov2640: avoid calling ov2640_select_win() twice Hans Verkuil
2015-05-03 18:19 ` Guennadi Liakhovetski
2015-05-04 7:25 ` Hans Verkuil [this message]
2015-05-03 9:54 ` [PATCH 5/9] ov5642: avoid calling ov5642_find_datafmt() twice Hans Verkuil
2015-05-03 20:24 ` Guennadi Liakhovetski
2015-05-04 7:26 ` Hans Verkuil
2015-05-03 9:54 ` [PATCH 6/9] ov772x: avoid calling ov772x_select_params() twice Hans Verkuil
2015-05-03 20:30 ` Guennadi Liakhovetski
2015-05-03 9:54 ` [PATCH 7/9] ov9640: avoid calling ov9640_res_roundup() twice Hans Verkuil
2015-05-03 20:34 ` Guennadi Liakhovetski
2015-05-03 9:54 ` [PATCH 8/9] ov9740: avoid calling ov9740_res_roundup() twice Hans Verkuil
2015-05-03 20:47 ` Guennadi Liakhovetski
2015-05-04 10:20 ` Hans Verkuil
2015-05-03 9:54 ` [PATCH 9/9] mt9t112: initialize left and top Hans Verkuil
2015-05-03 21:02 ` Guennadi Liakhovetski
2015-05-03 21:09 ` Guennadi Liakhovetski
2015-05-04 7:31 ` Hans Verkuil
2015-05-04 7:40 ` Guennadi Liakhovetski
2015-05-04 7:43 ` Hans Verkuil
2015-05-04 7:54 ` Guennadi Liakhovetski
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=55471EFF.4040004@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=g.liakhovetski@gmx.de \
--cc=hans.verkuil@cisco.com \
--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.