All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Mauro Carvalho Chehab <mchehab@s-opensource.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 03/17] media: v4l2-common: get rid of struct v4l2_discrete_probe
Date: Fri, 13 Oct 2017 15:27:29 +0200	[thread overview]
Message-ID: <fb2ddcfa-12d8-0c00-08b9-bde6ba1d5cdb@xs4all.nl> (raw)
In-Reply-To: <2c6deebfb792a95fb5a0b60ed715671c6398e20f.1506548682.git.mchehab@s-opensource.com>

On 09/27/17 23:46, Mauro Carvalho Chehab wrote:
> This struct is there just two store two arguments of
> v4l2_find_nearest_format(). The other two arguments are passed
> as parameter.
> 
> IMHO, there isn't much sense on doing that, and that will just
> add one more struct to document ;)
> 
> So, let's get rid of the struct, passing the parameters directly.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/vivid/vivid-vid-cap.c |  9 +++------
>  drivers/media/v4l2-core/v4l2-common.c        | 13 +++++++------
>  include/media/v4l2-common.h                  | 12 ++++--------
>  3 files changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
> index 01419455e545..0fbbcde19f0d 100644
> --- a/drivers/media/platform/vivid/vivid-vid-cap.c
> +++ b/drivers/media/platform/vivid/vivid-vid-cap.c
> @@ -93,11 +93,6 @@ static const struct v4l2_fract webcam_intervals[VIVID_WEBCAM_IVALS] = {
>  	{  1, 60 },
>  };
>  
> -static const struct v4l2_discrete_probe webcam_probe = {
> -	webcam_sizes,
> -	VIVID_WEBCAM_SIZES
> -};
> -
>  static int vid_cap_queue_setup(struct vb2_queue *vq,
>  		       unsigned *nbuffers, unsigned *nplanes,
>  		       unsigned sizes[], struct device *alloc_devs[])
> @@ -578,7 +573,9 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
>  	mp->field = vivid_field_cap(dev, mp->field);
>  	if (vivid_is_webcam(dev)) {
>  		const struct v4l2_frmsize_discrete *sz =
> -			v4l2_find_nearest_format(&webcam_probe, mp->width, mp->height);
> +			v4l2_find_nearest_format(webcam_sizes,
> +						 VIVID_WEBCAM_SIZES,
> +						 mp->width, mp->height);
>  
>  		w = sz->width;
>  		h = sz->height;
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index a5ea1f517291..fb9a2a3c1072 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -371,18 +371,19 @@ void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax,
>  }
>  EXPORT_SYMBOL_GPL(v4l_bound_align_image);
>  
> -const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
> -		const struct v4l2_discrete_probe *probe,
> -		s32 width, s32 height)
> +const struct v4l2_frmsize_discrete
> +*v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes,

Please move the initial '*' to the end of the first line. Otherwise it is very
hard to see that this function returns a pointer.

> +			  const size_t num_sizes,
> +			  s32 width, s32 height)
>  {
>  	int i;
>  	u32 error, min_error = UINT_MAX;
>  	const struct v4l2_frmsize_discrete *size, *best = NULL;
>  
> -	if (!probe)
> -		return best;
> +	if (!sizes)
> +		return NULL;
>  
> -	for (i = 0, size = probe->sizes; i < probe->num_sizes; i++, size++) {
> +	for (i = 0, size = sizes; i < num_sizes; i++, size++) {
>  		error = abs(size->width - width) + abs(size->height - height);
>  		if (error < min_error) {
>  			min_error = error;
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index 7dbecbe3009c..7ae7840df068 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -249,14 +249,10 @@ void v4l_bound_align_image(unsigned int *w, unsigned int wmin,
>  			   unsigned int hmax, unsigned int halign,
>  			   unsigned int salign);
>  
> -struct v4l2_discrete_probe {
> -	const struct v4l2_frmsize_discrete	*sizes;
> -	int					num_sizes;
> -};
> -
> -const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
> -		const struct v4l2_discrete_probe *probe,
> -		s32 width, s32 height);
> +const struct v4l2_frmsize_discrete
> +*v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes,

Same here.

> +			  const size_t num_sizes,
> +			  s32 width, s32 height);
>  
>  void v4l2_get_timestamp(struct timeval *tv);
>  
> 

After changing that you can add my:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

  parent reply	other threads:[~2017-10-13 13:27 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 21:46 [PATCH v2 00/17] V4L cleanups and documentation improvements Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 01/17] media: tuner-types: add kernel-doc markups for struct tunertype Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 02/17] media: v4l2-common: get rid of v4l2_routing dead struct Mauro Carvalho Chehab
2017-10-13 11:23   ` Laurent Pinchart
2017-10-13 13:24   ` Hans Verkuil
2017-12-18 14:11     ` Mauro Carvalho Chehab
2017-12-18 14:51       ` Sean Young
2017-09-27 21:46 ` [PATCH v2 03/17] media: v4l2-common: get rid of struct v4l2_discrete_probe Mauro Carvalho Chehab
2017-10-13 11:21   ` Laurent Pinchart
2017-10-13 13:27   ` Hans Verkuil [this message]
2017-09-27 21:46 ` [PATCH v2 04/17] media: v4l2-common.h: document ancillary functions Mauro Carvalho Chehab
2017-10-13 11:30   ` Laurent Pinchart
2017-10-13 13:31   ` Hans Verkuil
2017-09-27 21:46 ` [PATCH v2 05/17] media: v4l2-device.h: document ancillary macros Mauro Carvalho Chehab
2017-10-13 12:33   ` Laurent Pinchart
2017-12-18 14:58     ` Mauro Carvalho Chehab
2017-10-13 15:31   ` Hans Verkuil
2017-09-27 21:46 ` [PATCH v2 06/17] media: v4l2-dv-timings.h: convert comment into kernel-doc markup Mauro Carvalho Chehab
2017-10-13 12:34   ` Laurent Pinchart
2017-10-13 15:31   ` Hans Verkuil
2017-09-27 21:46 ` [PATCH v2 07/17] media: v4l2-event.rst: improve events description Mauro Carvalho Chehab
2017-09-28 12:34   ` Sakari Ailus
2017-10-13 15:40   ` Hans Verkuil
2017-09-27 21:46 ` [PATCH v2 08/17] media: v4l2-ioctl.h: convert debug macros into enum and document Mauro Carvalho Chehab
2017-10-13 12:38   ` Laurent Pinchart
2017-12-18 15:13     ` Mauro Carvalho Chehab
2017-12-18 15:32       ` Laurent Pinchart
2017-12-18 22:21         ` Mauro Carvalho Chehab
2017-10-13 15:41   ` Hans Verkuil
2017-09-27 21:46 ` [PATCH v2 09/17] media: cec-pin.h: convert comments for cec_pin_state into kernel-doc Mauro Carvalho Chehab
2017-10-13 15:48   ` Hans Verkuil
2017-10-13 20:16     ` Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 10/17] media: rc-core.rst: add an introduction for RC core Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 11/17] media: rc-core.h: minor adjustments at rc_driver_type doc Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 12/17] media: v4l2-fwnode.h: better describe bus union at fwnode endpoint struct Mauro Carvalho Chehab
2017-09-28 12:15   ` Sakari Ailus
2017-10-13 12:42   ` Laurent Pinchart
2017-09-27 21:46 ` [PATCH v2 13/17] media: v4l2-async: simplify v4l2_async_subdev structure Mauro Carvalho Chehab
2017-09-27 21:46   ` Mauro Carvalho Chehab
2017-09-27 21:46   ` Mauro Carvalho Chehab
     [not found]   ` <CGME20170928090623epcas2p37888b0350217812c84921c4e11340df1@epcas2p3.samsung.com>
2017-09-28  9:06     ` Sylwester Nawrocki
2017-09-28  9:06       ` Sylwester Nawrocki
2017-09-28 12:09   ` Sakari Ailus
2017-09-28 12:09     ` Sakari Ailus
2017-09-28 12:09     ` Sakari Ailus
2017-09-29  9:27     ` Mauro Carvalho Chehab
2017-09-29  9:27       ` Mauro Carvalho Chehab
2017-09-29  9:27       ` Mauro Carvalho Chehab
2017-09-29 22:05       ` Sakari Ailus
2017-09-29 22:05         ` Sakari Ailus
2017-12-18 19:04         ` Mauro Carvalho Chehab
2017-12-18 19:04           ` Mauro Carvalho Chehab
2017-09-28 12:53   ` [RESEND PATCH " Sakari Ailus
2017-09-28 12:53     ` Sakari Ailus
2017-09-27 21:46 ` [PATCH v2 14/17] media: v4l2-async: better describe match union at async match struct Mauro Carvalho Chehab
2017-10-13 12:49   ` Laurent Pinchart
2017-12-18 19:10     ` Mauro Carvalho Chehab
2017-09-27 21:46 ` [PATCH v2 15/17] media: v4l2-ctrls: document nested members of structs Mauro Carvalho Chehab
2017-10-13 12:54   ` Laurent Pinchart
2017-09-27 21:46 ` [PATCH v2 16/17] media: videobuf2-core: improve kernel-doc markups Mauro Carvalho Chehab
2017-09-29 12:04   ` Marek Szyprowski
2017-09-27 21:47 ` [PATCH v2 17/17] media: media-entity.h: add kernel-doc markups for nested structs Mauro Carvalho Chehab
2017-09-28 12:50 ` [PATCH v2 00/17] V4L cleanups and documentation improvements Sakari Ailus
2017-09-28 12:53 ` [RESEND PATCH v2 13/17] media: v4l2-async: simplify v4l2_async_subdev structure Mauro Carvalho Chehab
2017-09-28 12:53   ` Mauro Carvalho Chehab
2017-09-28 12:53   ` Mauro Carvalho Chehab
     [not found]   ` <CGME20170928130249epcas2p2c1f6e52226c3a5c72829b1bf3cbaa0cd@epcas2p2.samsung.com>
2017-09-28 13:02     ` Sylwester Nawrocki
2017-09-28 13:02       ` Sylwester Nawrocki
2017-09-28 13:27   ` Sakari Ailus
2017-09-28 13:27     ` 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=fb2ddcfa-12d8-0c00-08b9-bde6ba1d5cdb@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mchehab@s-opensource.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 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.