From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Linux Doc Mailing List <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 05/17] media: v4l2-device.h: document ancillary macros
Date: Fri, 13 Oct 2017 15:33:01 +0300 [thread overview]
Message-ID: <2033103.DJckbdrl9J@avalon> (raw)
In-Reply-To: <841040813f6fe8f3dbeba66c4f1a046b35e38e51.1506548682.git.mchehab@s-opensource.com>
Hi Mauro,
Thank you for the patch.
On Thursday, 28 September 2017 00:46:48 EEST Mauro Carvalho Chehab wrote:
> There are several widely macros that aren't documented using kernel-docs
What's a widely macro ? :-)
> markups.
>
> Add it.
Did you mean "Add documentation." ? "Document them." is also an option.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
> include/media/v4l2-device.h | 238 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 204 insertions(+), 34 deletions(-)
>
> diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
> index 8ffa94009d1a..d6d1c4f7d42c 100644
> --- a/include/media/v4l2-device.h
> +++ b/include/media/v4l2-device.h
> @@ -56,7 +56,6 @@ struct v4l2_ctrl_handler;
> * #) @dev->driver_data points to this struct.
> * #) @dev might be %NULL if there is no parent device
> */
> -
> struct v4l2_device {
> struct device *dev;
> #if defined(CONFIG_MEDIA_CONTROLLER)
> @@ -166,7 +165,7 @@ void v4l2_device_unregister(struct v4l2_device
> *v4l2_dev); * v4l2_device_register_subdev - Registers a subdev with a v4l2
> device. *
> * @v4l2_dev: pointer to struct &v4l2_device
> - * @sd: pointer to struct &v4l2_subdev
> + * @sd: pointer to &struct v4l2_subdev
> *
> * While registered, the subdev module is marked as in-use.
> *
> @@ -179,7 +178,7 @@ int __must_check v4l2_device_register_subdev(struct
> v4l2_device *v4l2_dev, /**
> * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device.
> *
> - * @sd: pointer to struct &v4l2_subdev
> + * @sd: pointer to &struct v4l2_subdev
> *
> * .. note ::
> *
> @@ -201,7 +200,7 @@ v4l2_device_register_subdev_nodes(struct v4l2_device
> *v4l2_dev); /**
> * v4l2_subdev_notify - Sends a notification to v4l2_device.
> *
> - * @sd: pointer to struct &v4l2_subdev
> + * @sd: pointer to &struct v4l2_subdev
> * @notification: type of notification. Please notice that the notification
> * type is driver-specific.
> * @arg: arguments for the notification. Those are specific to each
While all this makes sense, it's not related to $SUBJECT.
> @@ -214,13 +213,43 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, sd->v4l2_dev->notify(sd, notification, arg);
> }
>
> -/* Iterate over all subdevs. */
> +/* Ancillary macros to iterate over all subdevs. */
Ancillary means supplemental and non-essential. I wouldn't call the macros
below ancillary.
> +/**
> + * v4l2_device_for_each_subdev - Ancillary macro that interates over all
> + * sub-devices
All sub-devices of a given v4l2_device. Otherwise it could be understood as
all sub-devices in the system.
> + * @sd: pointer that will be filled by the macro with all
> + * &struct v4l2_subdev sub-devices associated with @v4l2_dev.
How about "&struct v4l2_subdev pointer used as an iterator by the loop" ?
> + * @v4l2_dev: pointer to &struct v4l2_device
And "&struct v4l2_device owning the sub-devices to iterate over" or something
similar ?
> + *
> + * Sometimes, a driver may need to broadcast a command to all subdevices.
> + * This ancillary macro allows interacting to all sub-devices associated
> + * to a device.
That's just one possible use of this macro. I wouldn't make it the only
documented on. Maybe something as the following ?
"This macro iterates over all sub-devices owned by the @v4l2_dev device. It
acts as a for loop iterator and executes the next statement with the @sd
variable pointing to each sub-device in turn".
> + */
> #define v4l2_device_for_each_subdev(sd, v4l2_dev) \
> list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
>
> -/* Call the specified callback for all subdevs matching the condition.
> - Ignore any errors. Note that you cannot add or delete a subdev
> - while walking the subdevs list. */
> +/**
> + * __v4l2_device_call_subdevs_p - Calls the specified callback for
All the __v4l2_device_* macros are internal, I don't think there's a need to
document them just for the sake of it.
> + * all subdevs matching the condition.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @sd: pointer that will be filled by the macro with all
> + * &struct v4l2_subdev sub-devices associated with @v4l2_dev.
> + * @cond: condition to be match
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Ignore any errors.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> + */
> #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
> do { \
> list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
> @@ -228,6 +257,24 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, (sd)->ops->o->f((sd) , ##args); \
> } while (0)
>
> +/**
> + * __v4l2_device_call_subdevs - Calls the specified callback for
> + * all subdevs matching the condition.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @cond: condition to be match
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Ignore any errors.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> + */
> #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
> do { \
> struct v4l2_subdev *__sd; \
> @@ -236,10 +283,29 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, f , ##args); \
> } while (0)
>
> -/* Call the specified callback for all subdevs matching the condition.
> - If the callback returns an error other than 0 or -ENOIOCTLCMD, then
> - return with that error code. Note that you cannot add or delete a
> - subdev while walking the subdevs list. */
> +/**
> + * __v4l2_device_call_subdevs_until_err_p - Calls the specified callback
> for
> + * all subdevs matching the condition.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @sd: pointer that will be filled by the macro with all
> + * &struct v4l2_subdev sub-devices associated with @v4l2_dev.
> + * @cond: condition to be match
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Return:
> + *
> + * If the callback returns an error other than 0 or ``-ENOIOCTLCMD``
> + * for any subdevice, then abort and return with that error code.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> + */
> #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f,
> args...) \ ({ \
> long __err = 0; \
> @@ -253,6 +319,27 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, (__err == -ENOIOCTLCMD) ? 0 : __err; \
> })
>
> +/**
> + * __v4l2_device_call_subdevs_until_err - Calls the specified callback for
> + * all subdevs matching the condition.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @cond: condition to be match
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Return:
> + *
> + * If the callback returns an error other than 0 or ``-ENOIOCTLCMD``
> + * for any subdevice, then abort and return with that error code.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> + */
> #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...)
> \ ({ \
> struct v4l2_subdev *__sd; \
> @@ -260,9 +347,25 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, f , ##args); \
> })
>
> -/* Call the specified callback for all subdevs matching grp_id (if 0, then
> - match them all). Ignore any errors. Note that you cannot add or delete
> - a subdev while walking the subdevs list. */
> +/**
> + * v4l2_device_call_all - Calls the specified callback for
The word "operation" would be better than the word "callback".
> + * all subdevs matching a device-specific group ID.
How exactly is the group ID device-specific ?
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpid: &struct v4l2_subdev->grp_id group ID to match.
> + * Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
Using the word "group" here makes it very confusing. You could use "operation
class" instead. Another option would be to document @o.@f of Sphinx doesn't
complain/
> + * @args...: arguments for @f.
> + *
> + * Ignore any errors.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
s/walking at/walking/
All these comments apply for the macros below.
> + * the subdevs list.
> + */
> #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
> do { \
> struct v4l2_subdev *__sd; \
> @@ -272,10 +375,28 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, ##args); \
> } while (0)
>
> -/* Call the specified callback for all subdevs matching grp_id (if 0, then
> - match them all). If the callback returns an error other than 0 or
> - -ENOIOCTLCMD, then return with that error code. Note that you cannot
> - add or delete a subdev while walking the subdevs list. */
> +/**
> + * v4l2_device_call_until_err - Calls the specified callback for
> + * all subdevs matching a device-specific group ID.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpid: &struct v4l2_subdev->grp_id group ID to match.
> + * Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Return:
> + *
> + * If the callback returns an error other than 0 or ``-ENOIOCTLCMD``
> + * for any subdevice, then abort and return with that error code.
Otherwise ?
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> + */
> #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
> ({ \
> struct v4l2_subdev *__sd; \
> @@ -284,10 +405,24 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, ##args); \
> })
>
> -/*
> - * Call the specified callback for all subdevs where grp_id & grpmsk != 0
> - * (if grpmsk == `0, then match them all). Ignore any errors. Note that you
> - * cannot add or delete a subdev while walking the subdevs list.
> +/**
> + * v4l2_device_mask_call_all - Calls the specified callback for
> + * all subdevices where a group ID matches a specified bitmask.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
> + * group ID to be matched. Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Ignore any errors.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> */
> #define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \
> do { \
> @@ -298,11 +433,27 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, ##args); \
> } while (0)
>
> -/*
> - * Call the specified callback for all subdevs where grp_id & grpmsk != 0
> - * (if grpmsk == 0, then match them all). If the callback returns an error
> - * other than 0 or %-ENOIOCTLCMD, then return with that error code. Note
> that
> - * you cannot add or delete a subdev while walking the subdevs list.
> +/**
> + * v4l2_device_mask_call_until_err - Calls the specified callback for
> + * all subdevices where a group ID matches a specified bitmask.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
> + * group ID to be matched. Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args...: arguments for @f.
> + *
> + * Return:
> + *
> + * If the callback returns an error other than 0 or ``-ENOIOCTLCMD``
> + * for any subdevice, then abort and return with that error code.
> + *
> + * Note: subdevs cannot be added or deleted while walking at
> + * the subdevs list.
> */
> #define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \
> ({ \
> @@ -312,9 +463,19 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, ##args); \
> })
>
> -/*
> - * Does any subdev with matching grpid (or all if grpid == 0) has the given
> - * op?
> +
> +/**
> + * v4l2_device_has_op - checks if any subdev with matching grpid has a
> + * given ops.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpid: &struct v4l2_subdev->grp_id group ID to match.
> + * Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> */
> #define v4l2_device_has_op(v4l2_dev, grpid, o, f) \
> ({ \
> @@ -331,9 +492,18 @@ static inline void v4l2_subdev_notify(struct
> v4l2_subdev *sd, __result; \
> })
>
> -/*
> - * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the
> given
> - * op?
> +/**
> + * v4l2_device_mask_has_op - checks if any subdev with matching group
> + * mask has a given ops.
> + *
> + * @v4l2_dev: pointer to &struct v4l2_device
> + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
> + * group ID to be matched. Use 0 to match them all.
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function that will be called if @cond matches.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> */
> #define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \
> ({ \
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-10-13 12:32 UTC|newest]
Thread overview: 53+ 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
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 [this message]
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 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 13:02 ` Sylwester Nawrocki
2017-09-28 13:27 ` Sakari Ailus
[not found] ` <CGME20170928090623epcas2p37888b0350217812c84921c4e11340df1@epcas2p3.samsung.com>
[not found] ` <cd089c6dac22c8ea2194c47c48386e52bb6e561f.1506548682.git.mchehab@s-opensource.com>
2017-09-28 9:06 ` [PATCH " Sylwester Nawrocki
2017-09-28 12:53 ` [RESEND PATCH " Sakari Ailus
[not found] ` <20170928120920.ywgbtikkrts25qlj@valkosipuli.retiisi.org.uk>
[not found] ` <20170929062119.192e4fd1@vento.lan>
2017-09-29 22:05 ` [PATCH " Sakari Ailus
2017-12-18 19:04 ` Mauro Carvalho Chehab
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=2033103.DJckbdrl9J@avalon \
--to=laurent.pinchart@ideasonboard.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox