All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] Some V4L2 documentation pending patches
@ 2017-12-19 11:18 Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 1/8] media: v4l2-device.h: document helper macros Mauro Carvalho Chehab
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

This series contain the patches of a /17 and a /24 series
of documentation that required non-trivial changes.

-

v2: 
 - added acks on patch 3/8
 - added a missing fixup on patch 5/8, for staging/media/imx
 - on patch 6/8, use pad=0 when WARN_ON() if pad is out of range

Mauro Carvalho Chehab (8):
  media: v4l2-device.h: document helper macros
  media: v4l2-ioctl.h: convert debug into an enum of bits
  media: v4l2-async: simplify v4l2_async_subdev structure
  media: v4l2-async: better describe match union at async match struct
  media: v4l2-mediabus: convert flags to enums and document them
  media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
  media: v4l2-subdev: document remaining undocumented functions
  media: v4l2-subdev: use kernel-doc markups to document subdev flags

 drivers/media/i2c/adv7180.c                        |  10 +-
 drivers/media/i2c/ml86v7667.c                      |   5 +-
 drivers/media/i2c/mt9m111.c                        |   8 +-
 drivers/media/i2c/ov6650.c                         |  19 +-
 drivers/media/i2c/soc_camera/imx074.c              |   6 +-
 drivers/media/i2c/soc_camera/mt9m001.c             |  10 +-
 drivers/media/i2c/soc_camera/mt9t031.c             |  11 +-
 drivers/media/i2c/soc_camera/mt9t112.c             |  11 +-
 drivers/media/i2c/soc_camera/mt9v022.c             |  16 +-
 drivers/media/i2c/soc_camera/ov5642.c              |   5 +-
 drivers/media/i2c/soc_camera/ov772x.c              |  10 +-
 drivers/media/i2c/soc_camera/ov9640.c              |  10 +-
 drivers/media/i2c/soc_camera/ov9740.c              |  10 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c          |  12 +-
 drivers/media/i2c/soc_camera/tw9910.c              |  13 +-
 drivers/media/i2c/tc358743.c                       |  10 +-
 drivers/media/i2c/tvp5150.c                        |   6 +-
 drivers/media/platform/am437x/am437x-vpfe.c        |   6 +-
 drivers/media/platform/atmel/atmel-isc.c           |   2 +-
 drivers/media/platform/atmel/atmel-isi.c           |   2 +-
 drivers/media/platform/davinci/vpif_capture.c      |   4 +-
 drivers/media/platform/exynos4-is/media-dev.c      |   4 +-
 drivers/media/platform/pxa_camera.c                |  10 +-
 drivers/media/platform/qcom/camss-8x16/camss.c     |   2 +-
 drivers/media/platform/rcar-vin/rcar-core.c        |   6 +-
 drivers/media/platform/rcar-vin/rcar-dma.c         |   4 +-
 drivers/media/platform/rcar_drif.c                 |   4 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c     |   2 +-
 drivers/media/platform/soc_camera/soc_camera.c     |   5 +-
 .../platform/soc_camera/soc_camera_platform.c      |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |   2 +-
 drivers/media/platform/stm32/stm32-dcmi.c          |   2 +-
 drivers/media/platform/ti-vpe/cal.c                |   2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c        |   2 +-
 drivers/media/v4l2-core/v4l2-async.c               |  16 +-
 drivers/media/v4l2-core/v4l2-dev.c                 |  18 +-
 drivers/media/v4l2-core/v4l2-fwnode.c              |  15 +-
 drivers/media/v4l2-core/v4l2-ioctl.c               |   7 +-
 drivers/staging/media/imx/imx-media-csi.c          |   7 +-
 drivers/staging/media/imx/imx-media-dev.c          |   4 +-
 include/media/v4l2-async.h                         |  33 ++-
 include/media/v4l2-device.h                        | 246 ++++++++++++++++++---
 include/media/v4l2-fwnode.h                        |   4 +-
 include/media/v4l2-ioctl.h                         |  33 +--
 include/media/v4l2-mediabus.h                      | 145 ++++++++----
 include/media/v4l2-subdev.h                        | 143 +++++++++---
 46 files changed, 636 insertions(+), 268 deletions(-)

-- 
2.14.3

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/8] media: v4l2-device.h: document helper macros
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

There are several macros that aren't documented using kernel-docs
markups.

Document them.

While here, add cross-references to structs on this file.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/media/v4l2-device.h | 246 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 211 insertions(+), 35 deletions(-)

diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8ffa94009d1a..448616b392f3 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -38,7 +38,7 @@ struct v4l2_ctrl_handler;
  * @lock: lock this struct; can be used by the driver as well
  *	if this struct is embedded into a larger struct.
  * @name: unique device name, by default the driver name + bus ID
- * @notify: notify callback called by some sub-devices.
+ * @notify: notify operation called by some sub-devices.
  * @ctrl_handler: The control handler. May be %NULL.
  * @prio: Device's priority state
  * @ref: Keep track of the references to this struct.
@@ -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
@@ -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. */
+/* Helper macros to iterate over all subdevs. */
+
+/**
+ * v4l2_device_for_each_subdev - Helper macro that interates over all
+ *	sub-devices of a given &v4l2_device.
+ *
+ * @sd: pointer that will be filled by the macro with all
+ *	&struct v4l2_subdev pointer used as an iterator by the loop.
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ *
+ * 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 operation for
+ *	all subdevs matching the condition.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @sd: pointer that will be filled by the macro with all
+ *	&struct v4l2_subdev pointer used as an iterator by the loop.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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
+ * 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 operation for
+ *	all subdevs matching the condition.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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
+ * the subdevs list.
+ */
 #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...)	\
 	do {								\
 		struct v4l2_subdev *__sd;				\
@@ -236,10 +283,30 @@ 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 operation for
+ *	all subdevs matching the condition.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation functions are defined in groups, according to
+ *	each element at &struct v4l2_subdev_ops.
+ * @args...: arguments for @f.
+ *
+ * Return:
+ *
+ * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
+ * for any subdevice, then abort and return with that error code, zero
+ * otherwise.
+ *
+ * Note: subdevs cannot be added or deleted while walking
+ * the subdevs list.
+ */
 #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
 ({									\
 	long __err = 0;							\
@@ -253,6 +320,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
 	(__err == -ENOIOCTLCMD) ? 0 : __err;				\
 })
 
+/**
+ * __v4l2_device_call_subdevs_until_err - Calls the specified operation for
+ *	all subdevs matching the condition.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation functions are defined in groups, according to
+ *	each element at &struct v4l2_subdev_ops.
+ * @args...: arguments for @f.
+ *
+ * Return:
+ *
+ * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
+ * for any subdevice, then abort and return with that error code,
+ * zero otherwise.
+ *
+ * Note: subdevs cannot be added or deleted while walking
+ * the subdevs list.
+ */
 #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
 ({									\
 	struct v4l2_subdev *__sd;					\
@@ -260,9 +349,26 @@ 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 operation for
+ *	all subdevs matching the &v4l2_subdev.grp_id, as assigned
+ *	by the bridge driver.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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
+ * the subdevs list.
+ */
 #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...)		\
 	do {								\
 		struct v4l2_subdev *__sd;				\
@@ -272,10 +378,30 @@ 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 operation for
+ *	all subdevs matching the &v4l2_subdev.grp_id, as assigned
+ *	by the bridge driver, until an error occurs.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation functions are defined in groups, according to
+ *	each element at &struct v4l2_subdev_ops.
+ * @args...: arguments for @f.
+ *
+ * Return:
+ *
+ * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
+ * for any subdevice, then abort and return with that error code,
+ * zero otherwise.
+ *
+ * Note: subdevs cannot be added or deleted while walking
+ * the subdevs list.
+ */
 #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...)	\
 ({									\
 	struct v4l2_subdev *__sd;					\
@@ -284,10 +410,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 operation for
+ *	all subdevices where a group ID matches a specified bitmask.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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
+ * the subdevs list.
  */
 #define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...)	\
 	do {								\
@@ -298,11 +438,28 @@ 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 operation for
+ *	all subdevices where a group ID matches a specified bitmask.
+ *
+ * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation functions are defined in groups, according to
+ *	each element at &struct v4l2_subdev_ops.
+ * @args...: arguments for @f.
+ *
+ * Return:
+ *
+ * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
+ * for any subdevice, then abort and return with that error code,
+ * zero otherwise.
+ *
+ * Note: subdevs cannot be added or deleted while walking
+ * the subdevs list.
  */
 #define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \
 ({									\
@@ -312,9 +469,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: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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 +498,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: &struct v4l2_device owning the sub-devices to iterate over.
+ * @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 operations functions.
+ * @f: operation function that will be called if @cond matches.
+ * 	The operation 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)			\
 ({									\
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 1/8] media: v4l2-device.h: document helper macros Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-19 11:18   ` Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Sakari Ailus, Laurent Pinchart, Evgeni Raikhel,
	Ramesh Shanmugasundaram, Tomasz Figa, Ricardo Ribalda Delgado

The V4L2_DEV_DEBUG_IOCTL macros actually define a bitmask,
but without using Kernel's modern standards. Also,
documentation looks akward.

So, convert them into an enum with valid bits, adding
the correspoinding kernel-doc documentation for it.

In order to avoid possible conflicts, rename them from
V4L2_DEV_DEBUG_foo to V4L2_DEBUG_foo.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/v4l2-core/v4l2-dev.c   | 18 +++++++++---------
 drivers/media/v4l2-core/v4l2-ioctl.c |  7 ++++---
 include/media/v4l2-ioctl.h           | 33 +++++++++++++++++++--------------
 3 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d5e0e536ef04..ab876ddaa707 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -307,8 +307,8 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
 		return -EINVAL;
 	if (video_is_registered(vdev))
 		ret = vdev->fops->read(filp, buf, sz, off);
-	if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) &&
-	    (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING))
+	if ((vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) &&
+	    (vdev->dev_debug & BIT(V4L2_DEBUG_STREAMING)))
 		printk(KERN_DEBUG "%s: read: %zd (%d)\n",
 			video_device_node_name(vdev), sz, ret);
 	return ret;
@@ -324,8 +324,8 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
 		return -EINVAL;
 	if (video_is_registered(vdev))
 		ret = vdev->fops->write(filp, buf, sz, off);
-	if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) &&
-	    (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING))
+	if ((vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) &&
+	    (vdev->dev_debug & BIT(V4L2_DEBUG_STREAMING)))
 		printk(KERN_DEBUG "%s: write: %zd (%d)\n",
 			video_device_node_name(vdev), sz, ret);
 	return ret;
@@ -340,7 +340,7 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
 		return DEFAULT_POLLMASK;
 	if (video_is_registered(vdev))
 		res = vdev->fops->poll(filp, poll);
-	if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL)
+	if (vdev->dev_debug & BIT(V4L2_DEBUG_POLL))
 		printk(KERN_DEBUG "%s: poll: %08x\n",
 			video_device_node_name(vdev), res);
 	return res;
@@ -381,7 +381,7 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp,
 	if (!video_is_registered(vdev))
 		return -ENODEV;
 	ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
-	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
+	if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP))
 		printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n",
 			video_device_node_name(vdev), ret);
 	return ret;
@@ -397,7 +397,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
 		return -ENODEV;
 	if (video_is_registered(vdev))
 		ret = vdev->fops->mmap(filp, vm);
-	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
+	if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP))
 		printk(KERN_DEBUG "%s: mmap (%d)\n",
 			video_device_node_name(vdev), ret);
 	return ret;
@@ -427,7 +427,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
 			ret = -ENODEV;
 	}
 
-	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
+	if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP))
 		printk(KERN_DEBUG "%s: open (%d)\n",
 			video_device_node_name(vdev), ret);
 	/* decrease the refcount in case of an error */
@@ -444,7 +444,7 @@ static int v4l2_release(struct inode *inode, struct file *filp)
 
 	if (vdev->fops->release)
 		ret = vdev->fops->release(filp);
-	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
+	if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP))
 		printk(KERN_DEBUG "%s: release\n",
 			video_device_node_name(vdev));
 
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 79614992ee21..cdd1e9470dbe 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2760,15 +2760,16 @@ static long __video_do_ioctl(struct file *file,
 	}
 
 done:
-	if (dev_debug & (V4L2_DEV_DEBUG_IOCTL | V4L2_DEV_DEBUG_IOCTL_ARG)) {
-		if (!(dev_debug & V4L2_DEV_DEBUG_STREAMING) &&
+	if (dev_debug & (BIT(V4L2_DEBUG_IOCTL)
+			 | BIT(V4L2_DEBUG_IOCTL_ARG))) {
+		if (!(dev_debug & BIT(V4L2_DEBUG_STREAMING)) &&
 		    (cmd == VIDIOC_QBUF || cmd == VIDIOC_DQBUF))
 			return ret;
 
 		v4l_printk_ioctl(video_device_node_name(vfd), cmd);
 		if (ret < 0)
 			pr_cont(": error %ld", ret);
-		if (!(dev_debug & V4L2_DEV_DEBUG_IOCTL_ARG))
+		if (!(dev_debug & BIT(V4L2_DEBUG_IOCTL_ARG)))
 			pr_cont("\n");
 		else if (_IOC_DIR(cmd) == _IOC_NONE)
 			info->debug(arg, write_only);
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index a7b3f7c75d62..9f8d04ad4bdd 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -589,20 +589,25 @@ struct v4l2_ioctl_ops {
 };
 
 
-/* v4l debugging and diagnostics */
-
-/* Device debug flags to be used with the video device debug attribute */
-
-/* Just log the ioctl name + error code */
-#define V4L2_DEV_DEBUG_IOCTL		0x01
-/* Log the ioctl name arguments + error code */
-#define V4L2_DEV_DEBUG_IOCTL_ARG	0x02
-/* Log the file operations open, release, mmap and get_unmapped_area */
-#define V4L2_DEV_DEBUG_FOP		0x04
-/* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */
-#define V4L2_DEV_DEBUG_STREAMING	0x08
-/* Log poll() */
-#define V4L2_DEV_DEBUG_POLL		0x10
+/**
+ * enum v4l2_debug_bits - Device debug bits to be used with the video
+ *	device debug attribute
+ *
+ * @V4L2_DEBUG_IOCTL:		Just log the ioctl name + error code.
+ * @V4L2_DEBUG_IOCTL_ARG:	Log the ioctl name arguments + error code.
+ * @V4L2_DEBUG_FOP:		Log the file operations and open, release,
+ *				mmap and get_unmapped_area syscalls.
+ * @V4L2_DEBUG_STREAMING:	Log the read and write syscalls and
+ *				:c:ref:`VIDIOC_[Q|DQ]BUF <VIDIOC_QBUF>` ioctls.
+ * @V4L2_DEBUG_POLL:		Log poll syscalls.
+ */
+enum v4l2_debug_bits {
+	V4L2_DEBUG_IOCTL	= 0,
+	V4L2_DEBUG_IOCTL_ARG	= 1,
+	V4L2_DEBUG_FOP		= 2,
+	V4L2_DEBUG_STREAMING	= 3,
+	V4L2_DEBUG_POLL		= 4,
+};
 
 /*  Video standard functions  */
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 1/8] media: v4l2-device.h: document helper macros Mauro Carvalho Chehab
@ 2017-12-19 11:18   ` Mauro Carvalho Chehab
  2017-12-19 11:18   ` Mauro Carvalho Chehab
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Songjun Wu, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Niklas Söderlund,
	Ramesh Shanmugasundaram, Guennadi Liakhovetski, Maxime Coquelin,
	Alexandre Torgue, Benoit Parrot, Hyun Kwon, Laurent Pinchart,
	Michal Simek, Steve Longerbeam, Philipp Zabel,
	Greg Kroah-Hartman, Hans Verkuil, Petr Cvek, Sakari Ailus,
	Julia Lawall, Arnd Bergmann, Hugues Fruchet, Gustavo A. R. Silva,
	Sebastian Reichel, Tomasz Figa, linux-arm-kernel,
	linux-samsung-soc, linux-renesas-soc, devel

The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
match criteria requires just a device name.

So, it doesn't make sense to enclose those into structs,
as the criteria can go directly into the union.

That makes easier to document it, as we don't need to document
weird senseless structs.

At drivers, this makes even clearer about the match criteria.

Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Benoit Parrot <bparrot@ti.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
 drivers/media/platform/atmel/atmel-isc.c       |  2 +-
 drivers/media/platform/atmel/atmel-isi.c       |  2 +-
 drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
 drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
 drivers/media/platform/pxa_camera.c            |  2 +-
 drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
 drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
 drivers/media/platform/rcar_drif.c             |  4 ++--
 drivers/media/platform/soc_camera/soc_camera.c |  2 +-
 drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
 drivers/media/platform/ti-vpe/cal.c            |  2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
 drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
 drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
 drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
 include/media/v4l2-async.h                     |  8 ++------
 17 files changed, 35 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index 0997c640191d..601ae6487617 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
 	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
 
 	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
-		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
-		    asd[i].match.fwnode.fwnode) {
+		if (vpfe->cfg->asd[i]->match.fwnode ==
+		    asd[i].match.fwnode) {
 			sdinfo = &vpfe->cfg->sub_devs[i];
 			vpfe->sd[i] = subdev;
 			vpfe->sd[i]->grp_id = sdinfo->grp_id;
@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index 0c2635647f69..34676409ca08 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
 			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
 
 		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		subdev_entity->asd->match.fwnode.fwnode =
+		subdev_entity->asd->match.fwnode =
 			of_fwnode_handle(rem);
 		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
 	}
diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index e900995143a3..9958918e2449 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
 		/* Remote node to connect */
 		isi->entity.node = remote;
 		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index e45916f69def..e1c273c8b9a6 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
 
 	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
 		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
-		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
+		const struct fwnode_handle *fwnode = _asd->match.fwnode;
 
 		if (fwnode == subdev->fwnode) {
 			vpif_obj.sd[i] = subdev;
@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 0ef583cfc424..78b48a1fa26c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
+	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
 	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
 
 	fmd->num_sensors++;
@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
 
 	/* Find platform data for this sensor subdev */
 	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
-		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
+		if (fmd->sensor[i].asd.match.fwnode ==
 		    of_fwnode_handle(subdev->dev->of_node))
 			si = &fmd->sensor[i];
 
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 305cf1cac210..f028084f0775 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	remote = of_graph_get_remote_port(np);
 	if (remote) {
-		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
+		asd->match.fwnode = of_fwnode_handle(remote);
 		of_node_put(remote);
 	} else {
 		dev_notice(dev, "no remote for %pOF\n", np);
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
index 390a42c17b66..05f06c98aa64 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss.c
@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
 		}
 
 		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		csd->asd.match.fwnode = of_fwnode_handle(remote);
 	}
 
 	return notifier->num_subdevs;
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 108d776f3265..f1fc7978d6d1 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 		return -ENODEV;
 
 	vin_dbg(vin, "Found digital subdevice %pOF\n",
-		to_of_node(vin->digital->asd.match.fwnode.fwnode));
+		to_of_node(vin->digital->asd.match.fwnode));
 
 	vin->notifier.ops = &rvin_digital_notify_ops;
 	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index 63c94f4028a7..b2e080ef5391 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
 	struct rcar_drif_sdr *sdr =
 		container_of(notifier, struct rcar_drif_sdr, notifier);
 
-	if (sdr->ep.asd.match.fwnode.fwnode !=
+	if (sdr->ep.asd.match.fwnode !=
 	    of_fwnode_handle(subdev->dev->of_node)) {
 		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
 		return -EINVAL;
@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
 		return -EINVAL;
 	}
 
-	sdr->ep.asd.match.fwnode.fwnode = fwnode;
+	sdr->ep.asd.match.fwnode = fwnode;
 	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	notifier->num_subdevs++;
 
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 916ff68b73d4..d13e2c5fb06f 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
 	if (!info)
 		return -ENOMEM;
 
-	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
 	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	info->subdev = &info->sasd.asd;
 
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index ac4c450a6c7d..9460b3080dca 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
 		/* Remote node to connect */
 		dcmi->entity.node = remote;
 		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 719ed1d79957..d1febe5baa6d 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 		goto cleanup_exit;
 	}
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
+	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
 	remote_ep = of_graph_get_remote_endpoint(ep_node);
 	if (!remote_ep) {
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index f4c3e48ed2c0..6bb28cd49dae 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
 
 		entity->node = remote;
 		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		entity->asd.match.fwnode = of_fwnode_handle(remote);
 		list_add_tail(&entity->list, &xdev->entities);
 		xdev->num_subdevs++;
 	}
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index e5acfab470a5..2b08d03b251d 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 static bool match_devname(struct v4l2_subdev *sd,
 			  struct v4l2_async_subdev *asd)
 {
-	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
+	return !strcmp(asd->match.device_name, dev_name(sd->dev));
 }
 
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	return sd->fwnode == asd->match.fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (asd->match.fwnode.fwnode == fwnode)
+		if (asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (sd->asd->match.fwnode.fwnode == fwnode)
+		if (sd->asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
 		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
 
 		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
-		    asd->match.fwnode.fwnode ==
-		    other_asd->match.fwnode.fwnode)
+		    asd->match.fwnode ==
+		    other_asd->match.fwnode)
 			return true;
 	}
 
@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
 			break;
 		case V4L2_ASYNC_MATCH_FWNODE:
 			if (v4l2_async_notifier_fwnode_has_async_subdev(
-				    notifier, asd->match.fwnode.fwnode, i)) {
+				    notifier, asd->match.fwnode, i)) {
 				dev_err(dev,
 					"fwnode has already been registered or in notifier's subdev list\n");
 				ret = -EEXIST;
@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			fwnode_handle_put(asd->match.fwnode.fwnode);
+			fwnode_handle_put(asd->match.fwnode);
 			break;
 		default:
 			WARN_ON_ONCE(true);
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index fb72c7ac04d4..d630640642ee 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 		return -ENOMEM;
 
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode =
+	asd->match.fwnode =
 		fwnode_graph_get_remote_port_parent(endpoint);
-	if (!asd->match.fwnode.fwnode) {
+	if (!asd->match.fwnode) {
 		dev_warn(dev, "bad remote port parent\n");
 		ret = -EINVAL;
 		goto out_err;
@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 	return 0;
 
 out_err:
-	fwnode_handle_put(asd->match.fwnode.fwnode);
+	fwnode_handle_put(asd->match.fwnode);
 	kfree(asd);
 
 	return ret == -ENOTCONN ? 0 : ret;
@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = args.fwnode;
+		asd->match.fwnode = args.fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
index 2800700482d6..f7ed5f506fa9 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
 		asd = &imxasd->asd;
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			if (fwnode && asd->match.fwnode.fwnode == fwnode)
+			if (fwnode && asd->match.fwnode == fwnode)
 				return asd;
 			break;
 		case V4L2_ASYNC_MATCH_DEVNAME:
@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
 
 	if (fwnode) {
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 	} else {
 		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
 		asd->match.device_name.name = devname;
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 6152434cbe82..a010af5134b2 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -58,12 +58,8 @@ enum v4l2_async_match_type {
 struct v4l2_async_subdev {
 	enum v4l2_async_match_type match_type;
 	union {
-		struct {
-			struct fwnode_handle *fwnode;
-		} fwnode;
-		struct {
-			const char *name;
-		} device_name;
+		struct fwnode_handle *fwnode;
+		const char *device_name;
 		struct {
 			int adapter_id;
 			unsigned short address;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-19 11:18   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Songjun Wu, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Niklas Söderlund,
	Ramesh Shanmugasundaram, Guennadi Liakhovetski, Maxime Coquelin

The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
match criteria requires just a device name.

So, it doesn't make sense to enclose those into structs,
as the criteria can go directly into the union.

That makes easier to document it, as we don't need to document
weird senseless structs.

At drivers, this makes even clearer about the match criteria.

Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Benoit Parrot <bparrot@ti.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
 drivers/media/platform/atmel/atmel-isc.c       |  2 +-
 drivers/media/platform/atmel/atmel-isi.c       |  2 +-
 drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
 drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
 drivers/media/platform/pxa_camera.c            |  2 +-
 drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
 drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
 drivers/media/platform/rcar_drif.c             |  4 ++--
 drivers/media/platform/soc_camera/soc_camera.c |  2 +-
 drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
 drivers/media/platform/ti-vpe/cal.c            |  2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
 drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
 drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
 drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
 include/media/v4l2-async.h                     |  8 ++------
 17 files changed, 35 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index 0997c640191d..601ae6487617 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
 	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
 
 	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
-		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
-		    asd[i].match.fwnode.fwnode) {
+		if (vpfe->cfg->asd[i]->match.fwnode ==
+		    asd[i].match.fwnode) {
 			sdinfo = &vpfe->cfg->sub_devs[i];
 			vpfe->sd[i] = subdev;
 			vpfe->sd[i]->grp_id = sdinfo->grp_id;
@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index 0c2635647f69..34676409ca08 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
 			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
 
 		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		subdev_entity->asd->match.fwnode.fwnode =
+		subdev_entity->asd->match.fwnode =
 			of_fwnode_handle(rem);
 		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
 	}
diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index e900995143a3..9958918e2449 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
 		/* Remote node to connect */
 		isi->entity.node = remote;
 		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index e45916f69def..e1c273c8b9a6 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
 
 	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
 		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
-		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
+		const struct fwnode_handle *fwnode = _asd->match.fwnode;
 
 		if (fwnode == subdev->fwnode) {
 			vpif_obj.sd[i] = subdev;
@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 0ef583cfc424..78b48a1fa26c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
+	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
 	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
 
 	fmd->num_sensors++;
@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
 
 	/* Find platform data for this sensor subdev */
 	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
-		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
+		if (fmd->sensor[i].asd.match.fwnode ==
 		    of_fwnode_handle(subdev->dev->of_node))
 			si = &fmd->sensor[i];
 
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 305cf1cac210..f028084f0775 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	remote = of_graph_get_remote_port(np);
 	if (remote) {
-		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
+		asd->match.fwnode = of_fwnode_handle(remote);
 		of_node_put(remote);
 	} else {
 		dev_notice(dev, "no remote for %pOF\n", np);
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
index 390a42c17b66..05f06c98aa64 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss.c
@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
 		}
 
 		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		csd->asd.match.fwnode = of_fwnode_handle(remote);
 	}
 
 	return notifier->num_subdevs;
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 108d776f3265..f1fc7978d6d1 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 		return -ENODEV;
 
 	vin_dbg(vin, "Found digital subdevice %pOF\n",
-		to_of_node(vin->digital->asd.match.fwnode.fwnode));
+		to_of_node(vin->digital->asd.match.fwnode));
 
 	vin->notifier.ops = &rvin_digital_notify_ops;
 	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index 63c94f4028a7..b2e080ef5391 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
 	struct rcar_drif_sdr *sdr =
 		container_of(notifier, struct rcar_drif_sdr, notifier);
 
-	if (sdr->ep.asd.match.fwnode.fwnode !=
+	if (sdr->ep.asd.match.fwnode !=
 	    of_fwnode_handle(subdev->dev->of_node)) {
 		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
 		return -EINVAL;
@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
 		return -EINVAL;
 	}
 
-	sdr->ep.asd.match.fwnode.fwnode = fwnode;
+	sdr->ep.asd.match.fwnode = fwnode;
 	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	notifier->num_subdevs++;
 
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 916ff68b73d4..d13e2c5fb06f 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
 	if (!info)
 		return -ENOMEM;
 
-	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
 	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	info->subdev = &info->sasd.asd;
 
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index ac4c450a6c7d..9460b3080dca 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
 		/* Remote node to connect */
 		dcmi->entity.node = remote;
 		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 719ed1d79957..d1febe5baa6d 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 		goto cleanup_exit;
 	}
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
+	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
 	remote_ep = of_graph_get_remote_endpoint(ep_node);
 	if (!remote_ep) {
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index f4c3e48ed2c0..6bb28cd49dae 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
 
 		entity->node = remote;
 		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		entity->asd.match.fwnode = of_fwnode_handle(remote);
 		list_add_tail(&entity->list, &xdev->entities);
 		xdev->num_subdevs++;
 	}
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index e5acfab470a5..2b08d03b251d 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 static bool match_devname(struct v4l2_subdev *sd,
 			  struct v4l2_async_subdev *asd)
 {
-	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
+	return !strcmp(asd->match.device_name, dev_name(sd->dev));
 }
 
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	return sd->fwnode == asd->match.fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (asd->match.fwnode.fwnode == fwnode)
+		if (asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (sd->asd->match.fwnode.fwnode == fwnode)
+		if (sd->asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
 		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
 
 		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
-		    asd->match.fwnode.fwnode ==
-		    other_asd->match.fwnode.fwnode)
+		    asd->match.fwnode ==
+		    other_asd->match.fwnode)
 			return true;
 	}
 
@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
 			break;
 		case V4L2_ASYNC_MATCH_FWNODE:
 			if (v4l2_async_notifier_fwnode_has_async_subdev(
-				    notifier, asd->match.fwnode.fwnode, i)) {
+				    notifier, asd->match.fwnode, i)) {
 				dev_err(dev,
 					"fwnode has already been registered or in notifier's subdev list\n");
 				ret = -EEXIST;
@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			fwnode_handle_put(asd->match.fwnode.fwnode);
+			fwnode_handle_put(asd->match.fwnode);
 			break;
 		default:
 			WARN_ON_ONCE(true);
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index fb72c7ac04d4..d630640642ee 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 		return -ENOMEM;
 
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode =
+	asd->match.fwnode =
 		fwnode_graph_get_remote_port_parent(endpoint);
-	if (!asd->match.fwnode.fwnode) {
+	if (!asd->match.fwnode) {
 		dev_warn(dev, "bad remote port parent\n");
 		ret = -EINVAL;
 		goto out_err;
@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 	return 0;
 
 out_err:
-	fwnode_handle_put(asd->match.fwnode.fwnode);
+	fwnode_handle_put(asd->match.fwnode);
 	kfree(asd);
 
 	return ret == -ENOTCONN ? 0 : ret;
@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = args.fwnode;
+		asd->match.fwnode = args.fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
index 2800700482d6..f7ed5f506fa9 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
 		asd = &imxasd->asd;
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			if (fwnode && asd->match.fwnode.fwnode == fwnode)
+			if (fwnode && asd->match.fwnode == fwnode)
 				return asd;
 			break;
 		case V4L2_ASYNC_MATCH_DEVNAME:
@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
 
 	if (fwnode) {
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 	} else {
 		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
 		asd->match.device_name.name = devname;
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 6152434cbe82..a010af5134b2 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -58,12 +58,8 @@ enum v4l2_async_match_type {
 struct v4l2_async_subdev {
 	enum v4l2_async_match_type match_type;
 	union {
-		struct {
-			struct fwnode_handle *fwnode;
-		} fwnode;
-		struct {
-			const char *name;
-		} device_name;
+		struct fwnode_handle *fwnode;
+		const char *device_name;
 		struct {
 			int adapter_id;
 			unsigned short address;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-19 11:18   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: linux-arm-kernel

The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
match criteria requires just a device name.

So, it doesn't make sense to enclose those into structs,
as the criteria can go directly into the union.

That makes easier to document it, as we don't need to document
weird senseless structs.

At drivers, this makes even clearer about the match criteria.

Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Benoit Parrot <bparrot@ti.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
 drivers/media/platform/atmel/atmel-isc.c       |  2 +-
 drivers/media/platform/atmel/atmel-isi.c       |  2 +-
 drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
 drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
 drivers/media/platform/pxa_camera.c            |  2 +-
 drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
 drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
 drivers/media/platform/rcar_drif.c             |  4 ++--
 drivers/media/platform/soc_camera/soc_camera.c |  2 +-
 drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
 drivers/media/platform/ti-vpe/cal.c            |  2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
 drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
 drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
 drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
 include/media/v4l2-async.h                     |  8 ++------
 17 files changed, 35 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index 0997c640191d..601ae6487617 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
 	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
 
 	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
-		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
-		    asd[i].match.fwnode.fwnode) {
+		if (vpfe->cfg->asd[i]->match.fwnode ==
+		    asd[i].match.fwnode) {
 			sdinfo = &vpfe->cfg->sub_devs[i];
 			vpfe->sd[i] = subdev;
 			vpfe->sd[i]->grp_id = sdinfo->grp_id;
@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index 0c2635647f69..34676409ca08 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
 			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
 
 		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		subdev_entity->asd->match.fwnode.fwnode =
+		subdev_entity->asd->match.fwnode =
 			of_fwnode_handle(rem);
 		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
 	}
diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index e900995143a3..9958918e2449 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
 		/* Remote node to connect */
 		isi->entity.node = remote;
 		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index e45916f69def..e1c273c8b9a6 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
 
 	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
 		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
-		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
+		const struct fwnode_handle *fwnode = _asd->match.fwnode;
 
 		if (fwnode == subdev->fwnode) {
 			vpif_obj.sd[i] = subdev;
@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 		}
 
 		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
 		of_node_put(rem);
 	}
 
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 0ef583cfc424..78b48a1fa26c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
+	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
 	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
 
 	fmd->num_sensors++;
@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
 
 	/* Find platform data for this sensor subdev */
 	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
-		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
+		if (fmd->sensor[i].asd.match.fwnode ==
 		    of_fwnode_handle(subdev->dev->of_node))
 			si = &fmd->sensor[i];
 
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 305cf1cac210..f028084f0775 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 	remote = of_graph_get_remote_port(np);
 	if (remote) {
-		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
+		asd->match.fwnode = of_fwnode_handle(remote);
 		of_node_put(remote);
 	} else {
 		dev_notice(dev, "no remote for %pOF\n", np);
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
index 390a42c17b66..05f06c98aa64 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss.c
@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
 		}
 
 		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		csd->asd.match.fwnode = of_fwnode_handle(remote);
 	}
 
 	return notifier->num_subdevs;
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 108d776f3265..f1fc7978d6d1 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 		return -ENODEV;
 
 	vin_dbg(vin, "Found digital subdevice %pOF\n",
-		to_of_node(vin->digital->asd.match.fwnode.fwnode));
+		to_of_node(vin->digital->asd.match.fwnode));
 
 	vin->notifier.ops = &rvin_digital_notify_ops;
 	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index 63c94f4028a7..b2e080ef5391 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
 	struct rcar_drif_sdr *sdr =
 		container_of(notifier, struct rcar_drif_sdr, notifier);
 
-	if (sdr->ep.asd.match.fwnode.fwnode !=
+	if (sdr->ep.asd.match.fwnode !=
 	    of_fwnode_handle(subdev->dev->of_node)) {
 		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
 		return -EINVAL;
@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
 		return -EINVAL;
 	}
 
-	sdr->ep.asd.match.fwnode.fwnode = fwnode;
+	sdr->ep.asd.match.fwnode = fwnode;
 	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	notifier->num_subdevs++;
 
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 916ff68b73d4..d13e2c5fb06f 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
 	if (!info)
 		return -ENOMEM;
 
-	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
 	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	info->subdev = &info->sasd.asd;
 
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index ac4c450a6c7d..9460b3080dca 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
 		/* Remote node to connect */
 		dcmi->entity.node = remote;
 		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
 		return 0;
 	}
 }
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 719ed1d79957..d1febe5baa6d 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
 		goto cleanup_exit;
 	}
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
+	asd->match.fwnode = of_fwnode_handle(sensor_node);
 
 	remote_ep = of_graph_get_remote_endpoint(ep_node);
 	if (!remote_ep) {
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index f4c3e48ed2c0..6bb28cd49dae 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
 
 		entity->node = remote;
 		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+		entity->asd.match.fwnode = of_fwnode_handle(remote);
 		list_add_tail(&entity->list, &xdev->entities);
 		xdev->num_subdevs++;
 	}
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index e5acfab470a5..2b08d03b251d 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 static bool match_devname(struct v4l2_subdev *sd,
 			  struct v4l2_async_subdev *asd)
 {
-	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
+	return !strcmp(asd->match.device_name, dev_name(sd->dev));
 }
 
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	return sd->fwnode == asd->match.fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (asd->match.fwnode.fwnode == fwnode)
+		if (asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
 		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
 			continue;
 
-		if (sd->asd->match.fwnode.fwnode == fwnode)
+		if (sd->asd->match.fwnode == fwnode)
 			return true;
 	}
 
@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
 		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
 
 		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
-		    asd->match.fwnode.fwnode ==
-		    other_asd->match.fwnode.fwnode)
+		    asd->match.fwnode ==
+		    other_asd->match.fwnode)
 			return true;
 	}
 
@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
 			break;
 		case V4L2_ASYNC_MATCH_FWNODE:
 			if (v4l2_async_notifier_fwnode_has_async_subdev(
-				    notifier, asd->match.fwnode.fwnode, i)) {
+				    notifier, asd->match.fwnode, i)) {
 				dev_err(dev,
 					"fwnode has already been registered or in notifier's subdev list\n");
 				ret = -EEXIST;
@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			fwnode_handle_put(asd->match.fwnode.fwnode);
+			fwnode_handle_put(asd->match.fwnode);
 			break;
 		default:
 			WARN_ON_ONCE(true);
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index fb72c7ac04d4..d630640642ee 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 		return -ENOMEM;
 
 	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-	asd->match.fwnode.fwnode =
+	asd->match.fwnode =
 		fwnode_graph_get_remote_port_parent(endpoint);
-	if (!asd->match.fwnode.fwnode) {
+	if (!asd->match.fwnode) {
 		dev_warn(dev, "bad remote port parent\n");
 		ret = -EINVAL;
 		goto out_err;
@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
 	return 0;
 
 out_err:
-	fwnode_handle_put(asd->match.fwnode.fwnode);
+	fwnode_handle_put(asd->match.fwnode);
 	kfree(asd);
 
 	return ret == -ENOTCONN ? 0 : ret;
@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = args.fwnode;
+		asd->match.fwnode = args.fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
 		}
 
 		notifier->subdevs[notifier->num_subdevs] = asd;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
 		notifier->num_subdevs++;
 	}
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
index 2800700482d6..f7ed5f506fa9 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
 		asd = &imxasd->asd;
 		switch (asd->match_type) {
 		case V4L2_ASYNC_MATCH_FWNODE:
-			if (fwnode && asd->match.fwnode.fwnode == fwnode)
+			if (fwnode && asd->match.fwnode == fwnode)
 				return asd;
 			break;
 		case V4L2_ASYNC_MATCH_DEVNAME:
@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
 
 	if (fwnode) {
 		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-		asd->match.fwnode.fwnode = fwnode;
+		asd->match.fwnode = fwnode;
 	} else {
 		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
 		asd->match.device_name.name = devname;
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index 6152434cbe82..a010af5134b2 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -58,12 +58,8 @@ enum v4l2_async_match_type {
 struct v4l2_async_subdev {
 	enum v4l2_async_match_type match_type;
 	union {
-		struct {
-			struct fwnode_handle *fwnode;
-		} fwnode;
-		struct {
-			const char *name;
-		} device_name;
+		struct fwnode_handle *fwnode;
+		const char *device_name;
 		struct {
 			int adapter_id;
 			unsigned short address;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 4/8] media: v4l2-async: better describe match union at async match struct
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2017-12-19 11:18   ` Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

Now that kernel-doc handles nested unions, better document the
match union at struct v4l2_async_subdev.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/media/v4l2-async.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index a010af5134b2..96e19246b934 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -48,6 +48,31 @@ enum v4l2_async_match_type {
  *
  * @match_type:	type of match that will be used
  * @match:	union of per-bus type matching data sets
+ * @match.fwnode:
+ *		pointer to &struct fwnode_handle to be matched.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE.
+ * @match.device_name:
+ *		string containing the device name to be matched.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_DEVNAME.
+ * @match.i2c:	embedded struct with I2C parameters to be matched.
+ * 		Both @match.i2c.adapter_id and @match.i2c.address
+ *		should be matched.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
+ * @match.i2c.adapter_id:
+ *		I2C adapter ID to be matched.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
+ * @match.i2c.address:
+ *		I2C address to be matched.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_I2C.
+ * @match.custom:
+ *		Driver-specific match criteria.
+ *		Used if @match_type is %V4L2_ASYNC_MATCH_CUSTOM.
+ * @match.custom.match:
+ *		Driver-specific match function to be used if
+ *		%V4L2_ASYNC_MATCH_CUSTOM.
+ * @match.custom.priv:
+ *		Driver-specific private struct with match parameters
+ *		to be used if %V4L2_ASYNC_MATCH_CUSTOM.
  * @list:	used to link struct v4l2_async_subdev objects, waiting to be
  *		probed, to a notifier->waiting list
  *
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2017-12-19 11:18 ` [PATCH v2 4/8] media: v4l2-async: better describe match union at async match struct Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-19 11:48   ` Philipp Zabel
  2017-12-19 11:18 ` [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Lars-Peter Clausen,
	Guennadi Liakhovetski, Mats Randgaard, Niklas Söderlund,
	Steve Longerbeam, Philipp Zabel, Greg Kroah-Hartman,
	Hans Verkuil, Bhumika Goyal, Sakari Ailus, Julia Lawall,
	Fabio Estevam, Janusz Krzysztofik, Markus Elfring,
	Laurent Pinchart, Gustavo A. R. Silva, Petr Cvek, Rob Herring,
	Pravin Shedge, Sebastian Reichel, Tomasz Figa, linux-renesas-soc,
	devel

There is a mess with media bus flags: there are two sets of
flags, one used by parallel and ITU-R BT.656 outputs,
and another one for CSI2.

Depending on the type, the same bit has different meanings.

That's very confusing, and counter-intuitive. So, split them
into two sets of flags, inside an enum.

This way, it becomes clearer that there are two separate sets
of flags. It also makes easier if CSI1, CSP, CSI3, etc. would
need a different set of flags.

As a side effect, enums can be documented via kernel-docs,
so there will be an improvement at flags documentation.

Unfortunately, soc_camera and pxa_camera do a mess with
the flags, using either one set of flags without proper
checks about the type. That could be fixed, but, as both drivers
are obsolete and in the process of cleanings, I opted to just
keep the behavior, using an unsigned int inside those two
drivers.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/i2c/adv7180.c                        |  10 +-
 drivers/media/i2c/ml86v7667.c                      |   5 +-
 drivers/media/i2c/mt9m111.c                        |   8 +-
 drivers/media/i2c/ov6650.c                         |  19 +--
 drivers/media/i2c/soc_camera/imx074.c              |   6 +-
 drivers/media/i2c/soc_camera/mt9m001.c             |  10 +-
 drivers/media/i2c/soc_camera/mt9t031.c             |  11 +-
 drivers/media/i2c/soc_camera/mt9t112.c             |  11 +-
 drivers/media/i2c/soc_camera/mt9v022.c             |  16 ++-
 drivers/media/i2c/soc_camera/ov5642.c              |   5 +-
 drivers/media/i2c/soc_camera/ov772x.c              |  10 +-
 drivers/media/i2c/soc_camera/ov9640.c              |  10 +-
 drivers/media/i2c/soc_camera/ov9740.c              |  10 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c          |  12 +-
 drivers/media/i2c/soc_camera/tw9910.c              |  13 +-
 drivers/media/i2c/tc358743.c                       |  10 +-
 drivers/media/i2c/tvp5150.c                        |   6 +-
 drivers/media/platform/pxa_camera.c                |   8 +-
 drivers/media/platform/rcar-vin/rcar-core.c        |   4 +-
 drivers/media/platform/rcar-vin/rcar-dma.c         |   4 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c     |   2 +-
 drivers/media/platform/soc_camera/soc_camera.c     |   3 +-
 .../platform/soc_camera/soc_camera_platform.c      |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |   2 +-
 drivers/media/v4l2-core/v4l2-fwnode.c              |   5 +-
 drivers/staging/media/imx/imx-media-csi.c          |   7 +-
 include/media/v4l2-fwnode.h                        |   4 +-
 include/media/v4l2-mediabus.h                      | 145 ++++++++++++++-------
 28 files changed, 222 insertions(+), 136 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 25d24a3f10a7..4bf25a72ef4f 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -743,16 +743,16 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,
 
 	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
 		cfg->type = V4L2_MBUS_CSI2;
-		cfg->flags = V4L2_MBUS_CSI2_1_LANE |
-				V4L2_MBUS_CSI2_CHANNEL_0 |
-				V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+		cfg->csi2_flags = V4L2_MBUS_CSI2_1_LANE
+				  | V4L2_MBUS_CSI2_CHANNEL_0
+				  | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 	} else {
 		/*
 		 * The ADV7180 sensor supports BT.601/656 output modes.
 		 * The BT.656 is default and not yet configurable by s/w.
 		 */
-		cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-				 V4L2_MBUS_DATA_ACTIVE_HIGH;
+		cfg->pb_flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
+			        | V4L2_MBUS_DATA_ACTIVE_HIGH;
 		cfg->type = V4L2_MBUS_BT656;
 	}
 
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index 57ef901edb06..a25114d0c31f 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -226,8 +226,9 @@ static int ml86v7667_fill_fmt(struct v4l2_subdev *sd,
 static int ml86v7667_g_mbus_config(struct v4l2_subdev *sd,
 				   struct v4l2_mbus_config *cfg)
 {
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-		     V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_BT656;
 
 	return 0;
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index b1665d97e0fd..d9698b535080 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -857,9 +857,11 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,
 static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
 				struct v4l2_mbus_config *cfg)
 {
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+		        | V4L2_MBUS_PCLK_SAMPLE_RISING
+		        | V4L2_MBUS_HSYNC_ACTIVE_HIGH
+		        | V4L2_MBUS_VSYNC_ACTIVE_HIGH
+		        | V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
 
 	return 0;
diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index 8975d16b2b24..61223bbe077e 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -880,11 +880,14 @@ static int ov6650_g_mbus_config(struct v4l2_subdev *sd,
 				struct v4l2_mbus_config *cfg)
 {
 
-	cfg->flags = V4L2_MBUS_MASTER |
-		V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_PCLK_SAMPLE_FALLING
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_LOW
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_LOW
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
 
 	return 0;
@@ -897,21 +900,21 @@ static int ov6650_s_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	int ret;
 
-	if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
+	if (cfg->pb_flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
 		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
 	else
 		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
 	if (ret)
 		return ret;
 
-	if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+	if (cfg->pb_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
 		ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
 	else
 		ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
 	if (ret)
 		return ret;
 
-	if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
+	if (cfg->pb_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
 		ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
 	else
 		ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c
index 77f1e0243d6e..f52d64e31975 100644
--- a/drivers/media/i2c/soc_camera/imx074.c
+++ b/drivers/media/i2c/soc_camera/imx074.c
@@ -264,9 +264,9 @@ static int imx074_g_mbus_config(struct v4l2_subdev *sd,
 				struct v4l2_mbus_config *cfg)
 {
 	cfg->type = V4L2_MBUS_CSI2;
-	cfg->flags = V4L2_MBUS_CSI2_2_LANE |
-		V4L2_MBUS_CSI2_CHANNEL_0 |
-		V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->csi2_flags = V4L2_MBUS_CSI2_2_LANE
+			  | V4L2_MBUS_CSI2_CHANNEL_0
+			  | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
index 1bfb0d53059e..91545e8160b7 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -603,11 +603,13 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
 	/* MT9M001 has all capture_format parameters fixed */
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_FALLING
+		        | V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_DATA_ACTIVE_HIGH
+			| V4L2_MBUS_MASTER;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c
index 4802d30e47de..c3c531cd5caa 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -704,11 +704,14 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING |
-		V4L2_MBUS_PCLK_SAMPLE_FALLING | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_PCLK_SAMPLE_FALLING
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c
index 297d22ebcb18..4fa761693872 100644
--- a/drivers/media/i2c/soc_camera/mt9t112.c
+++ b/drivers/media/i2c/soc_camera/mt9t112.c
@@ -1009,11 +1009,14 @@ static int mt9t112_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH |
-		V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_DATA_ACTIVE_HIGH
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_PCLK_SAMPLE_FALLING;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index 762f06919329..8297dfdad4e9 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -798,13 +798,17 @@ static int mt9v022_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_SLAVE |
-		V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_SLAVE
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_PCLK_SAMPLE_FALLING
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_LOW
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_LOW
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c
index 39f420db9c70..629370d8feaa 100644
--- a/drivers/media/i2c/soc_camera/ov5642.c
+++ b/drivers/media/i2c/soc_camera/ov5642.c
@@ -914,8 +914,9 @@ static int ov5642_g_mbus_config(struct v4l2_subdev *sd,
 				struct v4l2_mbus_config *cfg)
 {
 	cfg->type = V4L2_MBUS_CSI2;
-	cfg->flags = V4L2_MBUS_CSI2_2_LANE | V4L2_MBUS_CSI2_CHANNEL_0 |
-					V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->csi2_flags = V4L2_MBUS_CSI2_2_LANE
+			  | V4L2_MBUS_CSI2_CHANNEL_0
+			  | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
index 806383500313..7e1391460393 100644
--- a/drivers/media/i2c/soc_camera/ov772x.c
+++ b/drivers/media/i2c/soc_camera/ov772x.c
@@ -1003,11 +1003,13 @@ static int ov772x_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_MASTER
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c
index c63948989688..30ed9c07d42c 100644
--- a/drivers/media/i2c/soc_camera/ov9640.c
+++ b/drivers/media/i2c/soc_camera/ov9640.c
@@ -634,11 +634,13 @@ static int ov9640_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_RISING
+		        | V4L2_MBUS_MASTER
+		        | V4L2_MBUS_VSYNC_ACTIVE_HIGH
+		        | V4L2_MBUS_HSYNC_ACTIVE_HIGH
+		        | V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c
index 755de2289c39..f3103e7b2924 100644
--- a/drivers/media/i2c/soc_camera/ov9740.c
+++ b/drivers/media/i2c/soc_camera/ov9740.c
@@ -882,11 +882,13 @@ static int ov9740_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_MASTER
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
index 02398d0bc649..f1d36f6a72b7 100644
--- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c
+++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c
@@ -1227,12 +1227,14 @@ static int rj54n1_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags =
-		V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
-		V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_PCLK_SAMPLE_FALLING
+			| V4L2_MBUS_MASTER
+			| V4L2_MBUS_DATA_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c
index bdb5e0a431e9..aa64bea2ef9f 100644
--- a/drivers/media/i2c/soc_camera/tw9910.c
+++ b/drivers/media/i2c/soc_camera/tw9910.c
@@ -862,12 +862,15 @@ static int tw9910_g_mbus_config(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
 
-	cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
-		V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
-		V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW |
-		V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_MASTER
+			| V4L2_MBUS_VSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_VSYNC_ACTIVE_LOW
+			| V4L2_MBUS_HSYNC_ACTIVE_HIGH
+			| V4L2_MBUS_HSYNC_ACTIVE_LOW
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 	cfg->type = V4L2_MBUS_PARALLEL;
-	cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
+	cfg->pb_flags = soc_camera_apply_board_flags(ssdd, cfg);
 
 	return 0;
 }
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 2b8181469b93..668fe1eab93d 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1623,20 +1623,20 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd,
 	cfg->type = V4L2_MBUS_CSI2;
 
 	/* Support for non-continuous CSI-2 clock is missing in the driver */
-	cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+	cfg->csi2_flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
 
 	switch (state->csi_lanes_in_use) {
 	case 1:
-		cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
+		cfg->csi2_flags |= V4L2_MBUS_CSI2_1_LANE;
 		break;
 	case 2:
-		cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
+		cfg->csi2_flags |= V4L2_MBUS_CSI2_2_LANE;
 		break;
 	case 3:
-		cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
+		cfg->csi2_flags |= V4L2_MBUS_CSI2_3_LANE;
 		break;
 	case 4:
-		cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
+		cfg->csi2_flags |= V4L2_MBUS_CSI2_4_LANE;
 		break;
 	default:
 		return -EINVAL;
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 3c1851984b90..b25ed35de13e 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -976,8 +976,10 @@ static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
 	struct tvp5150 *decoder = to_tvp5150(sd);
 
 	cfg->type = decoder->mbus_type;
-	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
-		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+	cfg->pb_flags = V4L2_MBUS_MASTER
+			| V4L2_MBUS_PCLK_SAMPLE_RISING
+			| V4L2_MBUS_FIELD_EVEN_LOW
+			| V4L2_MBUS_DATA_ACTIVE_HIGH;
 
 	return 0;
 }
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index f028084f0775..2b9d862b883f 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -616,7 +616,7 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cf
 	bool hsync = true, vsync = true, pclk, data, mode;
 	bool mipi_lanes, mipi_clock;
 
-	common_flags = cfg->flags & flags;
+	common_flags = cfg->__legacy_flags & flags;
 
 	switch (cfg->type) {
 	case V4L2_MBUS_PARALLEL:
@@ -1621,7 +1621,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
 		if (!common_flags) {
 			dev_warn(pcdev_to_dev(pcdev),
 				 "Flags incompatible: camera 0x%x, host 0x%lx\n",
-				 cfg.flags, bus_flags);
+				 cfg.__legacy_flags, bus_flags);
 			return -EINVAL;
 		}
 	} else if (ret != -ENOIOCTLCMD) {
@@ -1657,7 +1657,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
 			common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING;
 	}
 
-	cfg.flags = common_flags;
+	cfg.__legacy_flags = common_flags;
 	ret = sensor_call(pcdev, video, s_mbus_config, &cfg);
 	if (ret < 0 && ret != -ENOIOCTLCMD) {
 		dev_dbg(pcdev_to_dev(pcdev),
@@ -1688,7 +1688,7 @@ static int pxa_camera_try_bus_param(struct pxa_camera_dev *pcdev,
 		if (!common_flags) {
 			dev_warn(pcdev_to_dev(pcdev),
 				 "Flags incompatible: camera 0x%x, host 0x%lx\n",
-				 cfg.flags, bus_flags);
+				 cfg.__legacy_flags, bus_flags);
 			return -EINVAL;
 		}
 	} else if (ret == -ENOIOCTLCMD) {
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index f1fc7978d6d1..3803ff31eb44 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -157,11 +157,11 @@ static int rvin_digital_parse_v4l2(struct device *dev,
 	switch (rvge->mbus_cfg.type) {
 	case V4L2_MBUS_PARALLEL:
 		vin_dbg(vin, "Found PARALLEL media bus\n");
-		rvge->mbus_cfg.flags = vep->bus.parallel.flags;
+		rvge->mbus_cfg.pb_flags = vep->bus.parallel.flags;
 		break;
 	case V4L2_MBUS_BT656:
 		vin_dbg(vin, "Found BT656 media bus\n");
-		rvge->mbus_cfg.flags = 0;
+		rvge->mbus_cfg.pb_flags = 0;
 		break;
 	default:
 		vin_err(vin, "Unknown media bus type\n");
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index 23fdff7a7370..ed28fef07cd5 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -212,11 +212,11 @@ static int rvin_setup(struct rvin_dev *vin)
 	dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
 
 	/* Hsync Signal Polarity Select */
-	if (!(vin->digital->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
+	if (!(vin->digital->mbus_cfg.pb_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
 		dmr2 |= VNDMR2_HPS;
 
 	/* Vsync Signal Polarity Select */
-	if (!(vin->digital->mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
+	if (!(vin->digital->mbus_cfg.pb_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
 		dmr2 |= VNDMR2_VPS;
 
 	/*
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 36762ec954e7..7f3c7c152347 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -744,7 +744,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd)
 			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
 	}
 
-	cfg.flags = common_flags;
+	cfg.__legacy_flags = common_flags;
 	ret = v4l2_subdev_call(sd, video, s_mbus_config, &cfg);
 	if (ret < 0 && ret != -ENOIOCTLCMD)
 		return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index d13e2c5fb06f..871554a71c2d 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -217,7 +217,8 @@ EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);
 unsigned long soc_camera_apply_board_flags(struct soc_camera_subdev_desc *ssdd,
 					   const struct v4l2_mbus_config *cfg)
 {
-	unsigned long f, flags = cfg->flags;
+	unsigned long f;
+	enum v4l2_mbus_parallel_and_bt656_flags flags = cfg->pb_flags;
 
 	/* If only one of the two polarities is supported, switch to the opposite */
 	if (ssdd->flags & SOCAM_SENSOR_INVERT_HSYNC) {
diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c
index cb4986b8f798..c9230aaef614 100644
--- a/drivers/media/platform/soc_camera/soc_camera_platform.c
+++ b/drivers/media/platform/soc_camera/soc_camera_platform.c
@@ -104,7 +104,7 @@ static int soc_camera_platform_g_mbus_config(struct v4l2_subdev *sd,
 {
 	struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd);
 
-	cfg->flags = p->mbus_param;
+	cfg->__legacy_flags = p->mbus_param;
 	cfg->type = p->mbus_type;
 
 	return 0;
diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c b/drivers/media/platform/soc_camera/soc_mediabus.c
index 0ad4b28266e4..f46cc51940e4 100644
--- a/drivers/media/platform/soc_camera/soc_mediabus.c
+++ b/drivers/media/platform/soc_camera/soc_mediabus.c
@@ -486,7 +486,7 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
 	bool hsync = true, vsync = true, pclk, data, mode;
 	bool mipi_lanes, mipi_clock;
 
-	common_flags = cfg->flags & flags;
+	common_flags = cfg->__legacy_flags & flags;
 
 	switch (cfg->type) {
 	case V4L2_MBUS_PARALLEL:
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index d630640642ee..f9c75a66457a 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -44,7 +44,8 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
 {
 	struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;
 	bool have_clk_lane = false;
-	unsigned int flags = 0, lanes_used = 0;
+	unsigned int lanes_used = 0;
+	enum v4l2_mbus_csi2_flags flags = 0;
 	unsigned int i;
 	u32 v;
 	int rval;
@@ -112,7 +113,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
 	struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep)
 {
 	struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel;
-	unsigned int flags = 0;
+	enum v4l2_mbus_parallel_and_bt656_flags flags = 0;
 	u32 v;
 
 	if (!fwnode_property_read_u32(fwnode, "hsync-active", &v))
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index eb7be5093a9d..b1daac3a537d 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -636,9 +636,10 @@ static int csi_setup(struct csi_priv *priv)
 
 	/* compose mbus_config from the upstream endpoint */
 	mbus_cfg.type = priv->upstream_ep.bus_type;
-	mbus_cfg.flags = (priv->upstream_ep.bus_type == V4L2_MBUS_CSI2) ?
-		priv->upstream_ep.bus.mipi_csi2.flags :
-		priv->upstream_ep.bus.parallel.flags;
+	if (priv->upstream_ep.bus_type == V4L2_MBUS_CSI2)
+		mbus_cfg.csi2_flags = priv->upstream_ep.bus.mipi_csi2.flags;
+	else
+		mbus_cfg.pb_flags = priv->upstream_ep.bus.parallel.flags;
 
 	/*
 	 * we need to pass input frame to CSI interface, but
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index c228ec1c77cf..6ccb971835f8 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -32,7 +32,7 @@ struct v4l2_async_subdev;
 
 /**
  * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
- * @flags: media bus (V4L2_MBUS_*) flags
+ * @flags: media bus CSI flags, as defined by &enum v4l2_mbus_csi2_flags
  * @data_lanes: an array of physical data lane indexes
  * @clock_lane: physical lane index of the clock lane
  * @num_data_lanes: number of data lanes
@@ -40,7 +40,7 @@ struct v4l2_async_subdev;
  *		   the physical lanes.
  */
 struct v4l2_fwnode_bus_mipi_csi2 {
-	unsigned int flags;
+	enum v4l2_mbus_csi2_flags flags;
 	unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES];
 	unsigned char clock_lane;
 	unsigned short num_data_lanes;
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 4d8626c468bc..560e03db0d9b 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -15,51 +15,90 @@
 #include <linux/bitops.h>
 
 
-/* Parallel flags */
-/*
- * Can the client run in master or in slave mode. By "Master mode" an operation
- * mode is meant, when the client (e.g., a camera sensor) is producing
- * horizontal and vertical synchronisation. In "Slave mode" the host is
- * providing these signals to the slave.
+/**
+ * enum v4l2_mbus_flags - Media bus parallel and polarity flags
+ *
+ * @V4L2_MBUS_MASTER:			the client runs on parallel master mode;
+ * @V4L2_MBUS_SLAVE:			the client runs on parallel slave mode.
+ * @V4L2_MBUS_HSYNC_ACTIVE_HIGH:	horizontal sync active on high level
+ * @V4L2_MBUS_HSYNC_ACTIVE_LOW:		horizontal sync active on low level
+ * @V4L2_MBUS_VSYNC_ACTIVE_HIGH:	vertical sync active on high level
+ * @V4L2_MBUS_VSYNC_ACTIVE_LOW:		vertical sync active on low level
+ * @V4L2_MBUS_PCLK_SAMPLE_RISING:	pixel clock sample on level rising
+ * @V4L2_MBUS_PCLK_SAMPLE_FALLING:	pixel clock sample on level falling
+ * @V4L2_MBUS_DATA_ACTIVE_HIGH:		data active on high level
+ * @V4L2_MBUS_DATA_ACTIVE_LOW:		data active on low level
+ * @V4L2_MBUS_FIELD_EVEN_HIGH:		FIELD = 0/1 - Field1 (odd)/Field2 (even)
+ * @V4L2_MBUS_FIELD_EVEN_LOW:		FIELD = 1/0 - Field1 (odd)/Field2 (even)
+ * @V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH:	Sync-on-green (SoG) signal active
+ *					on high level
+ * @V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW:	Sync-on-green (SoG) signal active
+ *					on low level
+ *
+ * Those flags are used when the bus is in %V4L2_MBUS_PARALLEL or
+ * %V4L2_MBUS_BT656 mode.
+ *
+ * .. note::
+ *
+ *    #) @V4L2_MBUS_MASTER and @V4L2_MBUS_SLAVE are only valid if the bus
+ *       is in %V4L2_MBUS_PARALLEL mode. They are used to specify if the
+ *       client runs in master or in slave mode.
+ *
+ *       In "Master mode" (@V4L2_MBUS_MASTER), the client (e.g., a camera
+ *       sensor) is producing horizontal and vertical synchronization.
+ *
+ *       In "Slave mode" (@V4L2_MBUS_SLAVE) the host is providing these signals
+ *       to the slave.
+ *    #) in %V4L2_MBUS_BT656 mode, ``V4L2_MBUS_HSYNC_*``, ``V4L2_MBUS_VSYNC_*``
+ *       and ``V4L2_MBUS_FIELD_*`` flags are unused.
+ *    #) ``V4L2_MBUS_[HV]SYNC*`` flags should be also used for specifying
+ *       configuration of hardware that uses [HV]REF signals
  */
-#define V4L2_MBUS_MASTER			BIT(0)
-#define V4L2_MBUS_SLAVE				BIT(1)
-/*
- * Signal polarity flags
- * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
- * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
- * configuration of hardware that uses [HV]REF signals
- */
-#define V4L2_MBUS_HSYNC_ACTIVE_HIGH		BIT(2)
-#define V4L2_MBUS_HSYNC_ACTIVE_LOW		BIT(3)
-#define V4L2_MBUS_VSYNC_ACTIVE_HIGH		BIT(4)
-#define V4L2_MBUS_VSYNC_ACTIVE_LOW		BIT(5)
-#define V4L2_MBUS_PCLK_SAMPLE_RISING		BIT(6)
-#define V4L2_MBUS_PCLK_SAMPLE_FALLING		BIT(7)
-#define V4L2_MBUS_DATA_ACTIVE_HIGH		BIT(8)
-#define V4L2_MBUS_DATA_ACTIVE_LOW		BIT(9)
-/* FIELD = 0/1 - Field1 (odd)/Field2 (even) */
-#define V4L2_MBUS_FIELD_EVEN_HIGH		BIT(10)
-/* FIELD = 1/0 - Field1 (odd)/Field2 (even) */
-#define V4L2_MBUS_FIELD_EVEN_LOW		BIT(11)
-/* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */
-#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH		BIT(12)
-#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW		BIT(13)
+enum v4l2_mbus_parallel_and_bt656_flags {
+	V4L2_MBUS_MASTER		= BIT(0),
+	V4L2_MBUS_SLAVE			= BIT(1),
+	V4L2_MBUS_HSYNC_ACTIVE_HIGH	= BIT(2),
+	V4L2_MBUS_HSYNC_ACTIVE_LOW	= BIT(3),
+	V4L2_MBUS_VSYNC_ACTIVE_HIGH	= BIT(4),
+	V4L2_MBUS_VSYNC_ACTIVE_LOW	= BIT(5),
+	V4L2_MBUS_PCLK_SAMPLE_RISING	= BIT(6),
+	V4L2_MBUS_PCLK_SAMPLE_FALLING	= BIT(7),
+	V4L2_MBUS_DATA_ACTIVE_HIGH	= BIT(8),
+	V4L2_MBUS_DATA_ACTIVE_LOW	= BIT(9),
+	V4L2_MBUS_FIELD_EVEN_HIGH	= BIT(10),
+	V4L2_MBUS_FIELD_EVEN_LOW	= BIT(11),
+	V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH	= BIT(12),
+	V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW	= BIT(13),
+};
 
-/* Serial flags */
-/* How many lanes the client can use */
-#define V4L2_MBUS_CSI2_1_LANE			BIT(0)
-#define V4L2_MBUS_CSI2_2_LANE			BIT(1)
-#define V4L2_MBUS_CSI2_3_LANE			BIT(2)
-#define V4L2_MBUS_CSI2_4_LANE			BIT(3)
-/* On which channels it can send video data */
-#define V4L2_MBUS_CSI2_CHANNEL_0		BIT(4)
-#define V4L2_MBUS_CSI2_CHANNEL_1		BIT(5)
-#define V4L2_MBUS_CSI2_CHANNEL_2		BIT(6)
-#define V4L2_MBUS_CSI2_CHANNEL_3		BIT(7)
-/* Does it support only continuous or also non-continuous clock mode */
-#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		BIT(8)
-#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	BIT(9)
+/**
+ * enum v4l2_mbus_csi2_flags - Media bus serial flags
+ *
+ * @V4L2_MBUS_CSI2_1_LANE:		One lane in use
+ * @V4L2_MBUS_CSI2_2_LANE:		Two lanes in use
+ * @V4L2_MBUS_CSI2_3_LANE:		Three lanes in use
+ * @V4L2_MBUS_CSI2_4_LANE:		Four lanes in use
+ * @V4L2_MBUS_CSI2_CHANNEL_0:		Channel 0 can send video data
+ * @V4L2_MBUS_CSI2_CHANNEL_1:		Channel 1 can send video data
+ * @V4L2_MBUS_CSI2_CHANNEL_2:		Channel 2 can send video data
+ * @V4L2_MBUS_CSI2_CHANNEL_3:		Channel 3 can send video data
+ * @V4L2_MBUS_CSI2_CONTINUOUS_CLOCK:	Supports continuous clock mode
+ * @V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK:	Supports non-continuous clock mode
+ *
+ * Used only when the bus type is MIPI CSI-2.
+ */
+enum v4l2_mbus_csi2_flags {
+	V4L2_MBUS_CSI2_1_LANE			= BIT(0),
+	V4L2_MBUS_CSI2_2_LANE			= BIT(1),
+	V4L2_MBUS_CSI2_3_LANE			= BIT(2),
+	V4L2_MBUS_CSI2_4_LANE			= BIT(3),
+	V4L2_MBUS_CSI2_CHANNEL_0		= BIT(4),
+	V4L2_MBUS_CSI2_CHANNEL_1		= BIT(5),
+	V4L2_MBUS_CSI2_CHANNEL_2		= BIT(6),
+	V4L2_MBUS_CSI2_CHANNEL_3		= BIT(7),
+	V4L2_MBUS_CSI2_CONTINUOUS_CLOCK		= BIT(8),
+	V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK	= BIT(9),
+};
 
 #define V4L2_MBUS_CSI2_LANES		(V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
 					 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
@@ -69,8 +108,8 @@
 /**
  * enum v4l2_mbus_type - media bus type
  * @V4L2_MBUS_PARALLEL:	parallel interface with hsync and vsync
- * @V4L2_MBUS_BT656:	parallel interface with embedded synchronisation, can
- *			also be used for BT.1120
+ * @V4L2_MBUS_BT656:	parallel interface with embedded synchronization using ITU-R BT.656
+ * 			signaling. Can also be used for ISO-R BT.1120 signaling.
  * @V4L2_MBUS_CSI1:	MIPI CSI-1 serial interface
  * @V4L2_MBUS_CCP2:	CCP2 (Compact Camera Port 2)
  * @V4L2_MBUS_CSI2:	MIPI CSI-2 serial interface
@@ -86,11 +125,23 @@ enum v4l2_mbus_type {
 /**
  * struct v4l2_mbus_config - media bus configuration
  * @type:	in: interface type
- * @flags:	in / out: configuration flags, depending on @type
+ * @pb_flags:	in / out: configuration flags, if @type is
+ *		%V4L2_MBUS_PARALLEL or %V4L2_MBUS_BT656.
+ * @csi2_flags:	in / out: configuration flags, if @type is
+ *		%V4L2_MBUS_CSI2.
+ * @__legacy_flags:
+ *		access flags, no matter the @type.
+ *		Used just to avoid needing to rewrite the logic inside
+ *		soc_camera and pxa_camera drivers. Don't use on newer
+ * 		drivers!
  */
 struct v4l2_mbus_config {
 	enum v4l2_mbus_type type;
-	unsigned int flags;
+	union {
+		enum v4l2_mbus_parallel_and_bt656_flags	pb_flags;
+		enum v4l2_mbus_csi2_flags		csi2_flags;
+		unsigned int				__legacy_flags;
+	};
 };
 
 /**
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2017-12-19 11:18 ` [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-27 21:31   ` Sakari Ailus
  2017-12-19 11:18 ` [PATCH v2 7/8] media: v4l2-subdev: document remaining undocumented functions Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 8/8] media: v4l2-subdev: use kernel-doc markups to document subdev flags Mauro Carvalho Chehab
  7 siblings, 1 reply; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

The __V4L2_SUBDEV_MK_GET_TRY() macro is used to define
3 functions that have the same arguments. The code of those
functions is simple enough to just declare them, de-obfuscating
the code.

While here, replace BUG_ON() by WARN_ON() as there's no reason
why to panic the Kernel if this fails.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/media/v4l2-subdev.h | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 71b8ff4b2e0e..443e5e019006 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -896,19 +896,35 @@ struct v4l2_subdev_fh {
 	container_of(fh, struct v4l2_subdev_fh, vfh)
 
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name)		\
-	static inline struct rtype *					\
-	fun_name(struct v4l2_subdev *sd,				\
-		 struct v4l2_subdev_pad_config *cfg,			\
-		 unsigned int pad)					\
-	{								\
-		BUG_ON(pad >= sd->entity.num_pads);			\
-		return &cfg[pad].field_name;				\
-	}
+static inline struct v4l2_mbus_framefmt
+*v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
+			    struct v4l2_subdev_pad_config *cfg,
+			    unsigned int pad)
+{
+	if (WARN_ON(pad >= sd->entity.num_pads))
+		pad = 0;
+	return &cfg[pad].try_fmt;
+}
 
-__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt)
-__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop)
-__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose)
+static inline struct v4l2_rect
+*v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
+			  struct v4l2_subdev_pad_config *cfg,
+			  unsigned int pad)
+{
+	if (WARN_ON(pad >= sd->entity.num_pads))
+		pad = 0;
+	return &cfg[pad].try_crop;
+}
+
+static inline struct v4l2_rect
+*v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
+			     struct v4l2_subdev_pad_config *cfg,
+			     unsigned int pad)
+{
+	if (WARN_ON(pad >= sd->entity.num_pads))
+		pad = 0;
+	return &cfg[pad].try_compose;
+}
 #endif
 
 extern const struct v4l2_file_operations v4l2_subdev_fops;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 7/8] media: v4l2-subdev: document remaining undocumented functions
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2017-12-19 11:18 ` [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  2017-12-19 11:18 ` [PATCH v2 8/8] media: v4l2-subdev: use kernel-doc markups to document subdev flags Mauro Carvalho Chehab
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

There are several undocumented v4l2-subdev functions that are
part of kAPI. Document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/media/v4l2-subdev.h | 69 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 64 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 443e5e019006..c8c827553042 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -867,6 +867,13 @@ struct v4l2_subdev {
 	struct v4l2_subdev_platform_data *pdata;
 };
 
+
+/**
+ * media_entity_to_v4l2_subdev - Returns a &struct v4l2_subdev from
+ *     the &struct media_entity embedded in it.
+ *
+ * @ent: pointer to &struct media_entity.
+ */
 #define media_entity_to_v4l2_subdev(ent)				\
 ({									\
 	typeof(ent) __me_sd_ent = (ent);				\
@@ -876,14 +883,20 @@ struct v4l2_subdev {
 		NULL;							\
 })
 
+/**
+ * vdev_to_v4l2_subdev - Returns a &struct v4l2_subdev from
+ *     the &struct video_device embedded on it.
+ *
+ * @vdev: pointer to &struct video_device
+ */
 #define vdev_to_v4l2_subdev(vdev) \
 	((struct v4l2_subdev *)video_get_drvdata(vdev))
 
 /**
  * struct v4l2_subdev_fh - Used for storing subdev information per file handle
  *
- * @vfh: pointer to struct v4l2_fh
- * @pad: pointer to v4l2_subdev_pad_config
+ * @vfh: pointer to &struct v4l2_fh
+ * @pad: pointer to &struct v4l2_subdev_pad_config
  */
 struct v4l2_subdev_fh {
 	struct v4l2_fh vfh;
@@ -892,10 +905,25 @@ struct v4l2_subdev_fh {
 #endif
 };
 
+/**
+ * to_v4l2_subdev_fh - Returns a &struct v4l2_subdev_fh from
+ *     the &struct v4l2_fh embedded on it.
+ *
+ * @fh: pointer to &struct v4l2_fh
+ */
 #define to_v4l2_subdev_fh(fh)	\
 	container_of(fh, struct v4l2_subdev_fh, vfh)
 
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
+
+/**
+ * v4l2_subdev_get_try_format - ancillary routine to call
+ * 	&struct v4l2_subdev_pad_config->try_fmt
+ *
+ * @sd: pointer to &struct v4l2_subdev
+ * @cfg: pointer to &struct v4l2_subdev_pad_config array.
+ * @pad: index of the pad in the @cfg array.
+ */
 static inline struct v4l2_mbus_framefmt
 *v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
 			    struct v4l2_subdev_pad_config *cfg,
@@ -906,6 +934,14 @@ static inline struct v4l2_mbus_framefmt
 	return &cfg[pad].try_fmt;
 }
 
+/**
+ * v4l2_subdev_get_try_crop - ancillary routine to call
+ * 	&struct v4l2_subdev_pad_config->try_crop
+ *
+ * @sd: pointer to &struct v4l2_subdev
+ * @cfg: pointer to &struct v4l2_subdev_pad_config array.
+ * @pad: index of the pad in the @cfg array.
+ */
 static inline struct v4l2_rect
 *v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
 			  struct v4l2_subdev_pad_config *cfg,
@@ -916,6 +952,14 @@ static inline struct v4l2_rect
 	return &cfg[pad].try_crop;
 }
 
+/**
+ * v4l2_subdev_get_try_crop - ancillary routine to call
+ * 	&struct v4l2_subdev_pad_config->try_compose
+ *
+ * @sd: pointer to &struct v4l2_subdev
+ * @cfg: pointer to &struct v4l2_subdev_pad_config array.
+ * @pad: index of the pad in the @cfg array.
+ */
 static inline struct v4l2_rect
 *v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
 			     struct v4l2_subdev_pad_config *cfg,
@@ -1032,9 +1076,16 @@ void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
 void v4l2_subdev_init(struct v4l2_subdev *sd,
 		      const struct v4l2_subdev_ops *ops);
 
-/*
- * Call an ops of a v4l2_subdev, doing the right checks against
- * NULL pointers.
+/**
+ * v4l2_subdev_call - call an operation of a v4l2_subdev.
+ *
+ * @sd: pointer to the &struct v4l2_subdev
+ * @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.
  *
  * Example: err = v4l2_subdev_call(sd, video, s_std, norm);
  */
@@ -1050,6 +1101,14 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
 		__result;						\
 	})
 
+/**
+ * v4l2_subdev_has_op - Checks if a subdev defines a certain operation.
+ *
+ * @sd: pointer to the &struct v4l2_subdev
+ * @o: The group of callback functions in &struct v4l2_subdev_ops
+ * which @f is a part of.
+ * @f: callback function to be checked for its existence.
+ */
 #define v4l2_subdev_has_op(sd, o, f) \
 	((sd)->ops->o && (sd)->ops->o->f)
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 8/8] media: v4l2-subdev: use kernel-doc markups to document subdev flags
  2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2017-12-19 11:18 ` [PATCH v2 7/8] media: v4l2-subdev: document remaining undocumented functions Mauro Carvalho Chehab
@ 2017-12-19 11:18 ` Mauro Carvalho Chehab
  7 siblings, 0 replies; 23+ messages in thread
From: Mauro Carvalho Chehab @ 2017-12-19 11:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

Right now, those are documented together with the subdev struct,
instead of together with the definitions.

Convert the definitions to an enum, use BIT() macros and document
it at its right place.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/media/v4l2-subdev.h | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index c8c827553042..473ddb1b2d39 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -18,6 +18,7 @@
 #define _V4L2_SUBDEV_H
 
 #include <linux/types.h>
+#include <linux/bitops.h>
 #include <linux/v4l2-subdev.h>
 #include <media/media-entity.h>
 #include <media/v4l2-async.h>
@@ -772,14 +773,23 @@ struct v4l2_subdev_internal_ops {
 
 #define V4L2_SUBDEV_NAME_SIZE 32
 
-/* Set this flag if this subdev is a i2c device. */
-#define V4L2_SUBDEV_FL_IS_I2C			(1U << 0)
-/* Set this flag if this subdev is a spi device. */
-#define V4L2_SUBDEV_FL_IS_SPI			(1U << 1)
-/* Set this flag if this subdev needs a device node. */
-#define V4L2_SUBDEV_FL_HAS_DEVNODE		(1U << 2)
-/* Set this flag if this subdev generates events. */
-#define V4L2_SUBDEV_FL_HAS_EVENTS		(1U << 3)
+/**
+ * enum v4l2_subdev_flags - flags used to describe a sub-device
+ *	at &struct v4l2_subdev.
+ *
+ * @V4L2_SUBDEV_FL_IS_I2C: set this flag if this subdev is an I2C device;
+ * @V4L2_SUBDEV_FL_IS_SPI: set this flag if this subdev is a SPI device;
+ * @V4L2_SUBDEV_FL_HAS_DEVNODE: set this flag if this subdev needs
+ *				a device node;
+ * @V4L2_SUBDEV_FL_HAS_EVENTS: set this flag if this subdev
+ *			       generates events.
+ */
+enum v4l2_subdev_flags {
+	V4L2_SUBDEV_FL_IS_I2C		= BIT(0),
+	V4L2_SUBDEV_FL_IS_SPI		= BIT(1),
+	V4L2_SUBDEV_FL_HAS_DEVNODE	= BIT(2),
+	V4L2_SUBDEV_FL_HAS_EVENTS	= BIT(3),
+};
 
 struct regulator_bulk_data;
 
@@ -805,13 +815,7 @@ struct v4l2_subdev_platform_data {
  * @owner: The owner is the same as the driver's &struct device owner.
  * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev
  *	owner. Initialized by v4l2_device_register_subdev().
- * @flags: subdev flags. Can be:
- *   %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device;
- *   %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device;
- *   %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if this subdev needs a
- *   device node;
- *   %V4L2_SUBDEV_FL_HAS_EVENTS -  Set this flag if this subdev generates
- *   events.
+ * @flags: subdev flags, as defined by &enum v4l2_subdev_flags.
  *
  * @v4l2_dev: pointer to struct &v4l2_device
  * @ops: pointer to struct &v4l2_subdev_ops
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them
  2017-12-19 11:18 ` [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them Mauro Carvalho Chehab
@ 2017-12-19 11:48   ` Philipp Zabel
  0 siblings, 0 replies; 23+ messages in thread
From: Philipp Zabel @ 2017-12-19 11:48 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Lars-Peter Clausen, Guennadi Liakhovetski,
	Mats Randgaard, Niklas Söderlund, Steve Longerbeam,
	Greg Kroah-Hartman, Hans Verkuil, Bhumika Goyal, Sakari Ailus,
	Julia Lawall, Fabio Estevam, Janusz Krzysztofik, Markus Elfring,
	Laurent Pinchart, Gustavo A. R. Silva, Petr Cvek, Rob Herring,
	Pravin Shedge, Sebastian Reichel, Tomasz Figa, linux-renesas-soc,
	devel

On Tue, 2017-12-19 at 09:18 -0200, Mauro Carvalho Chehab wrote:
> There is a mess with media bus flags: there are two sets of
> flags, one used by parallel and ITU-R BT.656 outputs,
> and another one for CSI2.
> 
> Depending on the type, the same bit has different meanings.
> 
> That's very confusing, and counter-intuitive. So, split them
> into two sets of flags, inside an enum.
> 
> This way, it becomes clearer that there are two separate sets
> of flags. It also makes easier if CSI1, CSP, CSI3, etc. would
> need a different set of flags.
> 
> As a side effect, enums can be documented via kernel-docs,
> so there will be an improvement at flags documentation.
> 
> Unfortunately, soc_camera and pxa_camera do a mess with
> the flags, using either one set of flags without proper
> checks about the type. That could be fixed, but, as both drivers
> are obsolete and in the process of cleanings, I opted to just
> keep the behavior, using an unsigned int inside those two
> drivers.
> 
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

For imx-media,
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

thanks
Philipp

^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
  2017-12-19 11:18   ` Mauro Carvalho Chehab
  (?)
@ 2017-12-19 18:38     ` Hyun Kwon
  -1 siblings, 0 replies; 23+ messages in thread
From: Hyun Kwon @ 2017-12-19 18:38 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Lad, Prabhakar, Songjun Wu, Nicolas Ferre,
	Alexandre Belloni, Ludovic Desroches, Kyungmin Park,
	Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski, Todor Tomov,
	Niklas Söderlund, Ramesh Shanmugasundaram,
	Guennadi Liakhovetski, Maxime Coquelin, Alexandre Torgue,
	Benoit Parrot, Laurent Pinchart, Michal Simek, Steve Longerbeam,
	Philipp Zabel, Greg Kroah-Hartman, Hans Verkuil, Petr Cvek,
	Sakari Ailus, Julia Lawall, Arnd Bergmann, Hugues Fruchet,
	Gustavo A. R. Silva, Sebastian Reichel, Tomasz Figa,
	linux-arm-kernel, linux-samsung-soc, linux-renesas-soc, devel

Hi Mauro,

Thanks for the patch.

> -----Original Message-----
> From: Mauro Carvalho Chehab [mailto:mchehab@smtp.s-opensource.com]
> On Behalf Of Mauro Carvalho Chehab
> Sent: Tuesday, December 19, 2017 3:18 AM
> To: Linux Media Mailing List <linux-media@vger.kernel.org>
> Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>; Mauro
> Carvalho Chehab <mchehab@infradead.org>; Lad, Prabhakar
> <prabhakar.csengg@gmail.com>; Songjun Wu
> <songjun.wu@microchip.com>; Nicolas Ferre
> <nicolas.ferre@microchip.com>; Alexandre Belloni <alexandre.belloni@free-
> electrons.com>; Ludovic Desroches <ludovic.desroches@microchip.com>;
> Kyungmin Park <kyungmin.park@samsung.com>; Sylwester Nawrocki
> <s.nawrocki@samsung.com>; Kukjin Kim <kgene@kernel.org>; Krzysztof
> Kozlowski <krzk@kernel.org>; Todor Tomov <todor.tomov@linaro.org>;
> Niklas Söderlund <niklas.soderlund@ragnatech.se>; Ramesh
> Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>;
> Guennadi Liakhovetski <g.liakhovetski@gmx.de>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Alexandre Torgue
> <alexandre.torgue@st.com>; Benoit Parrot <bparrot@ti.com>; Hyun Kwon
> <hyunk@xilinx.com>; Laurent Pinchart
> <laurent.pinchart@ideasonboard.com>; Michal Simek
> <michal.simek@xilinx.com>; Steve Longerbeam <slongerbeam@gmail.com>;
> Philipp Zabel <p.zabel@pengutronix.de>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Hans Verkuil <hverkuil@xs4all.nl>; Petr
> Cvek <petr.cvek@tul.cz>; Sakari Ailus <sakari.ailus@iki.fi>; Julia Lawall
> <Julia.Lawall@lip6.fr>; Arnd Bergmann <arnd@arndb.de>; Hugues Fruchet
> <hugues.fruchet@st.com>; Gustavo A. R. Silva
> <garsilva@embeddedor.com>; Sebastian Reichel <sre@kernel.org>; Tomasz
> Figa <tfiga@chromium.org>; linux-arm-kernel@lists.infradead.org; linux-
> samsung-soc@vger.kernel.org; linux-renesas-soc@vger.kernel.org;
> devel@driverdev.osuosl.org
> Subject: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev
> structure
> 
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The
> V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

For xilinx-vipp.c, please add,

	Acked-by: Hyun Kwon <hyun.kwon@xilinx.com>

Thanks,
-hyun

> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier
> *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
> 
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/atmel/atmel-isc.c
> b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct
> isc_device *isc)
>  			subdev_entity->pfe_cfg0 |=
> ISC_PFE_CFG0_PPOL_LOW;
> 
>  		subdev_entity->asd->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi,
> struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c
> b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode;
> 
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device
> *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c
> b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct
> fimc_md *fmd,
>  	}
> 
>  	fmd->sensor[index].asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
> 
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
> 
> diff --git a/drivers/media/platform/pxa_camera.c
> b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct
> device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c
> b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
> 
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
> 
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev
> *vin)
>  		return -ENODEV;
> 
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
> 
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c
> b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct
> v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
> 
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct
> rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
> 
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c
> b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host
> *ici,
>  	if (!info)
>  		return -ENOMEM;
> 
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
> 
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c
> b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi
> *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode =
> of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c
> b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx
> *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
> 
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c
> b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct
> xvip_composite_device *xdev,
> 
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-
> core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd,
> struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd-
> >dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
> 
>  static bool match_fwnode(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
> 
>  static bool match_custom(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -330,7 +330,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -355,8 +355,8 @@ static bool
> v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
> 
>  		if (other_asd->match_type ==
> V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
> 
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct
> v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered
> or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct
> v4l2_async_notifier *notifier)
> 
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-
> core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
> 
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
> 
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
> 
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c
> b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode ==
> fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct
> imx_media_dev *imxmd,
> 
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> --
> 2.14.3


^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-19 18:38     ` Hyun Kwon
  0 siblings, 0 replies; 23+ messages in thread
From: Hyun Kwon @ 2017-12-19 18:38 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Lad, Prabhakar, Songjun Wu, Nicolas Ferre,
	Alexandre Belloni, Ludovic Desroches, Kyungmin Park,
	Sylwester Nawrocki, Kukjin Kim, Krzysztof Kozlowski, Todor Tomov,
	Niklas Söderlund, Ramesh Shanmugasundaram,
	Guennadi Liakhovetski, Maxime Coquelin, Alexandre Torgue

Hi Mauro,

Thanks for the patch.

> -----Original Message-----
> From: Mauro Carvalho Chehab [mailto:mchehab@smtp.s-opensource.com]
> On Behalf Of Mauro Carvalho Chehab
> Sent: Tuesday, December 19, 2017 3:18 AM
> To: Linux Media Mailing List <linux-media@vger.kernel.org>
> Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>; Mauro
> Carvalho Chehab <mchehab@infradead.org>; Lad, Prabhakar
> <prabhakar.csengg@gmail.com>; Songjun Wu
> <songjun.wu@microchip.com>; Nicolas Ferre
> <nicolas.ferre@microchip.com>; Alexandre Belloni <alexandre.belloni@free-
> electrons.com>; Ludovic Desroches <ludovic.desroches@microchip.com>;
> Kyungmin Park <kyungmin.park@samsung.com>; Sylwester Nawrocki
> <s.nawrocki@samsung.com>; Kukjin Kim <kgene@kernel.org>; Krzysztof
> Kozlowski <krzk@kernel.org>; Todor Tomov <todor.tomov@linaro.org>;
> Niklas Söderlund <niklas.soderlund@ragnatech.se>; Ramesh
> Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>;
> Guennadi Liakhovetski <g.liakhovetski@gmx.de>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Alexandre Torgue
> <alexandre.torgue@st.com>; Benoit Parrot <bparrot@ti.com>; Hyun Kwon
> <hyunk@xilinx.com>; Laurent Pinchart
> <laurent.pinchart@ideasonboard.com>; Michal Simek
> <michal.simek@xilinx.com>; Steve Longerbeam <slongerbeam@gmail.com>;
> Philipp Zabel <p.zabel@pengutronix.de>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Hans Verkuil <hverkuil@xs4all.nl>; Petr
> Cvek <petr.cvek@tul.cz>; Sakari Ailus <sakari.ailus@iki.fi>; Julia Lawall
> <Julia.Lawall@lip6.fr>; Arnd Bergmann <arnd@arndb.de>; Hugues Fruchet
> <hugues.fruchet@st.com>; Gustavo A. R. Silva
> <garsilva@embeddedor.com>; Sebastian Reichel <sre@kernel.org>; Tomasz
> Figa <tfiga@chromium.org>; linux-arm-kernel@lists.infradead.org; linux-
> samsung-soc@vger.kernel.org; linux-renesas-soc@vger.kernel.org;
> devel@driverdev.osuosl.org
> Subject: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev
> structure
> 
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The
> V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

For xilinx-vipp.c, please add,

	Acked-by: Hyun Kwon <hyun.kwon@xilinx.com>

Thanks,
-hyun

> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier
> *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
> 
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/atmel/atmel-isc.c
> b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct
> isc_device *isc)
>  			subdev_entity->pfe_cfg0 |=
> ISC_PFE_CFG0_PPOL_LOW;
> 
>  		subdev_entity->asd->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi,
> struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c
> b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode;
> 
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device
> *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c
> b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct
> fimc_md *fmd,
>  	}
> 
>  	fmd->sensor[index].asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
> 
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
> 
> diff --git a/drivers/media/platform/pxa_camera.c
> b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct
> device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c
> b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
> 
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
> 
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev
> *vin)
>  		return -ENODEV;
> 
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
> 
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c
> b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct
> v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
> 
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct
> rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
> 
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c
> b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host
> *ici,
>  	if (!info)
>  		return -ENOMEM;
> 
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
> 
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c
> b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi
> *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode =
> of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c
> b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx
> *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
> 
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c
> b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct
> xvip_composite_device *xdev,
> 
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-
> core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd,
> struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd-
> >dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
> 
>  static bool match_fwnode(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
> 
>  static bool match_custom(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -330,7 +330,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -355,8 +355,8 @@ static bool
> v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
> 
>  		if (other_asd->match_type ==
> V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
> 
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct
> v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered
> or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct
> v4l2_async_notifier *notifier)
> 
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-
> core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
> 
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
> 
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
> 
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c
> b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode ==
> fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct
> imx_media_dev *imxmd,
> 
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> --
> 2.14.3


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-19 18:38     ` Hyun Kwon
  0 siblings, 0 replies; 23+ messages in thread
From: Hyun Kwon @ 2017-12-19 18:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mauro,

Thanks for the patch.

> -----Original Message-----
> From: Mauro Carvalho Chehab [mailto:mchehab at smtp.s-opensource.com]
> On Behalf Of Mauro Carvalho Chehab
> Sent: Tuesday, December 19, 2017 3:18 AM
> To: Linux Media Mailing List <linux-media@vger.kernel.org>
> Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>; Mauro
> Carvalho Chehab <mchehab@infradead.org>; Lad, Prabhakar
> <prabhakar.csengg@gmail.com>; Songjun Wu
> <songjun.wu@microchip.com>; Nicolas Ferre
> <nicolas.ferre@microchip.com>; Alexandre Belloni <alexandre.belloni@free-
> electrons.com>; Ludovic Desroches <ludovic.desroches@microchip.com>;
> Kyungmin Park <kyungmin.park@samsung.com>; Sylwester Nawrocki
> <s.nawrocki@samsung.com>; Kukjin Kim <kgene@kernel.org>; Krzysztof
> Kozlowski <krzk@kernel.org>; Todor Tomov <todor.tomov@linaro.org>;
> Niklas S?derlund <niklas.soderlund@ragnatech.se>; Ramesh
> Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>;
> Guennadi Liakhovetski <g.liakhovetski@gmx.de>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Alexandre Torgue
> <alexandre.torgue@st.com>; Benoit Parrot <bparrot@ti.com>; Hyun Kwon
> <hyunk@xilinx.com>; Laurent Pinchart
> <laurent.pinchart@ideasonboard.com>; Michal Simek
> <michal.simek@xilinx.com>; Steve Longerbeam <slongerbeam@gmail.com>;
> Philipp Zabel <p.zabel@pengutronix.de>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Hans Verkuil <hverkuil@xs4all.nl>; Petr
> Cvek <petr.cvek@tul.cz>; Sakari Ailus <sakari.ailus@iki.fi>; Julia Lawall
> <Julia.Lawall@lip6.fr>; Arnd Bergmann <arnd@arndb.de>; Hugues Fruchet
> <hugues.fruchet@st.com>; Gustavo A. R. Silva
> <garsilva@embeddedor.com>; Sebastian Reichel <sre@kernel.org>; Tomasz
> Figa <tfiga@chromium.org>; linux-arm-kernel at lists.infradead.org; linux-
> samsung-soc at vger.kernel.org; linux-renesas-soc at vger.kernel.org;
> devel at driverdev.osuosl.org
> Subject: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev
> structure
> 
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The
> V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

For xilinx-vipp.c, please add,

	Acked-by: Hyun Kwon <hyun.kwon@xilinx.com>

Thanks,
-hyun

> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-
>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier
> *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
> 
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/atmel/atmel-isc.c
> b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct
> isc_device *isc)
>  			subdev_entity->pfe_cfg0 |=
> ISC_PFE_CFG0_PPOL_LOW;
> 
>  		subdev_entity->asd->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi,
> struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c
> b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd-
> >match.fwnode;
> 
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device
> *pdev)
>  		}
> 
>  		pdata->asd[i]->match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
> 
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c
> b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct
> fimc_md *fmd,
>  	}
> 
>  	fmd->sensor[index].asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode =
> of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
> 
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct
> v4l2_async_notifier *notifier,
> 
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
> 
> diff --git a/drivers/media/platform/pxa_camera.c
> b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct
> device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c
> b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
> 
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
> 
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev
> *vin)
>  		return -ENODEV;
> 
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
> 
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c
> b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct
> v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
> 
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct
> rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
> 
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c
> b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host
> *ici,
>  	if (!info)
>  		return -ENOMEM;
> 
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
> 
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c
> b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi
> *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type =
> V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode =
> of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c
> b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx
> *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
> 
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c
> b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct
> xvip_composite_device *xdev,
> 
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode =
> of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-
> core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd,
> struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd-
> >dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
> 
>  static bool match_fwnode(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
> 
>  static bool match_custom(struct v4l2_subdev *sd, struct
> v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -330,7 +330,7 @@ static bool
> __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
> 
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
> 
> @@ -355,8 +355,8 @@ static bool
> v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
> 
>  		if (other_asd->match_type ==
> V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
> 
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct
> v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered
> or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct
> v4l2_async_notifier *notifier)
> 
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-
> core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
> 
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int
> v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
> 
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
> 
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
> 
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c
> b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode ==
> fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct
> imx_media_dev *imxmd,
> 
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
  2017-12-19 11:18   ` Mauro Carvalho Chehab
  (?)
  (?)
@ 2017-12-20 10:55     ` Niklas Söderlund
  -1 siblings, 0 replies; 23+ messages in thread
From: Niklas Söderlund @ 2017-12-20 10:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Lad, Prabhakar,
	Songjun Wu, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Ramesh Shanmugasundaram,
	Guennadi Liakhovetski, Maxime Coquelin, Alexandre Torgue,
	Benoit Parrot, Hyun Kwon, Laurent Pinchart, Michal Simek,
	Steve Longerbeam, Philipp Zabel, Greg Kroah-Hartman,
	Hans Verkuil, Petr Cvek, Sakari Ailus, Julia Lawall,
	Arnd Bergmann, Hugues Fruchet, Gustavo A. R. Silva,
	Sebastian Reichel, Tomasz Figa, linux-arm-kernel,
	linux-samsung-soc, linux-renesas-soc, devel

Hi Mauro,

On 2017-12-19 09:18:19 -0200, Mauro Carvalho Chehab wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-

For rcar-vin:

Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
>  			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>  		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
>  
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd->match.fwnode;
>  
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>  	}
>  
>  	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
>  
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
>  
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
>  
> diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
>  
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
>  
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  		return -ENODEV;
>  
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
>  
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
>  
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
>  
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
>  
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
>  	if (!info)
>  		return -ENOMEM;
>  
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
>  
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
>  
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
>  
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
>  
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
>  
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
>  
>  		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
>  
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
>  
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
>  
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
>  
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
>  
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode == fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
>  
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> -- 
> 2.14.3
> 

-- 
Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-20 10:55     ` Niklas Söderlund
  0 siblings, 0 replies; 23+ messages in thread
From: Niklas Söderlund @ 2017-12-20 10:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Lad, Prabhakar,
	Songjun Wu, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Ramesh Shanmugasundaram,
	Guennadi Liakhovetski, Maxime Coquelin, Alexandre Torgue,
	Benoit Parrot, Hyun Kwon, Laurent Pinchart, Michal Simek,
	Steve Longerbeam, Philipp Zabel, Greg Kroah-Hartman,
	Hans Verkuil, Petr Cvek, Sakari Ailus, Julia Lawall,
	Arnd Bergmann, Hugues Fruchet, Gustavo A. R. Silva,
	Sebastian Reichel, Tomasz Figa, linux-arm-kernel,
	linux-samsung-soc, linux-renesas-soc, devel

Hi Mauro,

On 2017-12-19 09:18:19 -0200, Mauro Carvalho Chehab wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-

For rcar-vin:

Acked-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>

>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
>  			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>  		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
>  
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd->match.fwnode;
>  
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>  	}
>  
>  	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
>  
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
>  
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
>  
> diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
>  
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
>  
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  		return -ENODEV;
>  
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
>  
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
>  
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
>  
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
>  
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
>  	if (!info)
>  		return -ENOMEM;
>  
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
>  
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
>  
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
>  
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
>  
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
>  
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
>  
>  		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
>  
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
>  
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
>  
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
>  
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
>  
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode == fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
>  
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> -- 
> 2.14.3
> 

-- 
Regards,
Niklas S�derlund

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-20 10:55     ` Niklas Söderlund
  0 siblings, 0 replies; 23+ messages in thread
From: Niklas Söderlund @ 2017-12-20 10:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Lad, Prabhakar,
	Songjun Wu, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Ramesh Shanmugasundaram,
	Guennadi Liakhovetski, Maxime Coquelin, Alexandre Torgue,
	Benoit Parrot

Hi Mauro,

On 2017-12-19 09:18:19 -0200, Mauro Carvalho Chehab wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-

For rcar-vin:

Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
>  			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>  		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
>  
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd->match.fwnode;
>  
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>  	}
>  
>  	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
>  
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
>  
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
>  
> diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
>  
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
>  
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  		return -ENODEV;
>  
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
>  
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
>  
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
>  
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
>  
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
>  	if (!info)
>  		return -ENOMEM;
>  
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
>  
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
>  
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
>  
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
>  
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
>  
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
>  
>  		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
>  
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
>  
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
>  
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
>  
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
>  
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode == fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
>  
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> -- 
> 2.14.3
> 

-- 
Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-20 10:55     ` Niklas Söderlund
  0 siblings, 0 replies; 23+ messages in thread
From: Niklas Söderlund @ 2017-12-20 10:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mauro,

On 2017-12-19 09:18:19 -0200, Mauro Carvalho Chehab wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c       |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c       |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c            |  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c    |  2 +-

For rcar-vin:

Acked-by: Niklas S?derlund <niklas.soderlund+renesas@ragnatech.se>

>  drivers/media/platform/rcar_drif.c             |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c      |  2 +-
>  drivers/media/platform/ti-vpe/cal.c            |  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c    |  2 +-
>  drivers/media/v4l2-core/v4l2-async.c           | 16 ++++++++--------
>  drivers/media/v4l2-core/v4l2-fwnode.c          | 10 +++++-----
>  drivers/staging/media/imx/imx-media-dev.c      |  4 ++--
>  include/media/v4l2-async.h                     |  8 ++------
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>  	vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>  	for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> -		if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> -		    asd[i].match.fwnode.fwnode) {
> +		if (vpfe->cfg->asd[i]->match.fwnode ==
> +		    asd[i].match.fwnode) {
>  			sdinfo = &vpfe->cfg->sub_devs[i];
>  			vpfe->sd[i] = subdev;
>  			vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
>  			subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>  		subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		subdev_entity->asd->match.fwnode.fwnode =
> +		subdev_entity->asd->match.fwnode =
>  			of_fwnode_handle(rem);
>  		list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>  	}
> diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)
>  		/* Remote node to connect */
>  		isi->entity.node = remote;
>  		isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
>  
>  	for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>  		struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> -		const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> +		const struct fwnode_handle *fwnode = _asd->match.fwnode;
>  
>  		if (fwnode == subdev->fwnode) {
>  			vpif_obj.sd[i] = subdev;
> @@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>  		}
>  
>  		pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> +		pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>  		of_node_put(rem);
>  	}
>  
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 0ef583cfc424..78b48a1fa26c 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>  	}
>  
>  	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	fmd->sensor[index].asd.match.fwnode.fwnode = of_fwnode_handle(rem);
> +	fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
>  	fmd->async_subdevs[index] = &fmd->sensor[index].asd;
>  
>  	fmd->num_sensors++;
> @@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,
>  
>  	/* Find platform data for this sensor subdev */
>  	for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++)
> -		if (fmd->sensor[i].asd.match.fwnode.fwnode ==
> +		if (fmd->sensor[i].asd.match.fwnode ==
>  		    of_fwnode_handle(subdev->dev->of_node))
>  			si = &fmd->sensor[i];
>  
> diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
> index 305cf1cac210..f028084f0775 100644
> --- a/drivers/media/platform/pxa_camera.c
> +++ b/drivers/media/platform/pxa_camera.c
> @@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	remote = of_graph_get_remote_port(np);
>  	if (remote) {
> -		asd->match.fwnode.fwnode = of_fwnode_handle(remote);
> +		asd->match.fwnode = of_fwnode_handle(remote);
>  		of_node_put(remote);
>  	} else {
>  		dev_notice(dev, "no remote for %pOF\n", np);
> diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
> index 390a42c17b66..05f06c98aa64 100644
> --- a/drivers/media/platform/qcom/camss-8x16/camss.c
> +++ b/drivers/media/platform/qcom/camss-8x16/camss.c
> @@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev,
>  		}
>  
>  		csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		csd->asd.match.fwnode = of_fwnode_handle(remote);
>  	}
>  
>  	return notifier->num_subdevs;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 108d776f3265..f1fc7978d6d1 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  		return -ENODEV;
>  
>  	vin_dbg(vin, "Found digital subdevice %pOF\n",
> -		to_of_node(vin->digital->asd.match.fwnode.fwnode));
> +		to_of_node(vin->digital->asd.match.fwnode));
>  
>  	vin->notifier.ops = &rvin_digital_notify_ops;
>  	ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
> index 63c94f4028a7..b2e080ef5391 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,
>  	struct rcar_drif_sdr *sdr =
>  		container_of(notifier, struct rcar_drif_sdr, notifier);
>  
> -	if (sdr->ep.asd.match.fwnode.fwnode !=
> +	if (sdr->ep.asd.match.fwnode !=
>  	    of_fwnode_handle(subdev->dev->of_node)) {
>  		rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
>  		return -EINVAL;
> @@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
>  		return -EINVAL;
>  	}
>  
> -	sdr->ep.asd.match.fwnode.fwnode = fwnode;
> +	sdr->ep.asd.match.fwnode = fwnode;
>  	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	notifier->num_subdevs++;
>  
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 916ff68b73d4..d13e2c5fb06f 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
>  	if (!info)
>  		return -ENOMEM;
>  
> -	info->sasd.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +	info->sasd.asd.match.fwnode = of_fwnode_handle(remote);
>  	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
>  	info->subdev = &info->sasd.asd;
>  
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index ac4c450a6c7d..9460b3080dca 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
>  		/* Remote node to connect */
>  		dcmi->entity.node = remote;
>  		dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		dcmi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>  		return 0;
>  	}
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 719ed1d79957..d1febe5baa6d 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
>  		goto cleanup_exit;
>  	}
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
> +	asd->match.fwnode = of_fwnode_handle(sensor_node);
>  
>  	remote_ep = of_graph_get_remote_endpoint(ep_node);
>  	if (!remote_ep) {
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index f4c3e48ed2c0..6bb28cd49dae 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
>  
>  		entity->node = remote;
>  		entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		entity->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> +		entity->asd.match.fwnode = of_fwnode_handle(remote);
>  		list_add_tail(&entity->list, &xdev->entities);
>  		xdev->num_subdevs++;
>  	}
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index e5acfab470a5..2b08d03b251d 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  static bool match_devname(struct v4l2_subdev *sd,
>  			  struct v4l2_async_subdev *asd)
>  {
> -	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
> +	return !strcmp(asd->match.device_name, dev_name(sd->dev));
>  }
>  
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
>  {
> -	return sd->fwnode == asd->match.fwnode.fwnode;
> +	return sd->fwnode == asd->match.fwnode;
>  }
>  
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
> @@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (asd->match.fwnode.fwnode == fwnode)
> +		if (asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(
>  		if (sd->asd->match_type != V4L2_ASYNC_MATCH_FWNODE)
>  			continue;
>  
> -		if (sd->asd->match.fwnode.fwnode == fwnode)
> +		if (sd->asd->match.fwnode == fwnode)
>  			return true;
>  	}
>  
> @@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(
>  		struct v4l2_async_subdev *other_asd = notifier->subdevs[j];
>  
>  		if (other_asd->match_type == V4L2_ASYNC_MATCH_FWNODE &&
> -		    asd->match.fwnode.fwnode ==
> -		    other_asd->match.fwnode.fwnode)
> +		    asd->match.fwnode ==
> +		    other_asd->match.fwnode)
>  			return true;
>  	}
>  
> @@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
>  			break;
>  		case V4L2_ASYNC_MATCH_FWNODE:
>  			if (v4l2_async_notifier_fwnode_has_async_subdev(
> -				    notifier, asd->match.fwnode.fwnode, i)) {
> +				    notifier, asd->match.fwnode, i)) {
>  				dev_err(dev,
>  					"fwnode has already been registered or in notifier's subdev list\n");
>  				ret = -EEXIST;
> @@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
>  
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			fwnode_handle_put(asd->match.fwnode.fwnode);
> +			fwnode_handle_put(asd->match.fwnode);
>  			break;
>  		default:
>  			WARN_ON_ONCE(true);
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index fb72c7ac04d4..d630640642ee 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  		return -ENOMEM;
>  
>  	asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -	asd->match.fwnode.fwnode =
> +	asd->match.fwnode =
>  		fwnode_graph_get_remote_port_parent(endpoint);
> -	if (!asd->match.fwnode.fwnode) {
> +	if (!asd->match.fwnode) {
>  		dev_warn(dev, "bad remote port parent\n");
>  		ret = -EINVAL;
>  		goto out_err;
> @@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(
>  	return 0;
>  
>  out_err:
> -	fwnode_handle_put(asd->match.fwnode.fwnode);
> +	fwnode_handle_put(asd->match.fwnode);
>  	kfree(asd);
>  
>  	return ret == -ENOTCONN ? 0 : ret;
> @@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = args.fwnode;
> +		asd->match.fwnode = args.fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> @@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props(
>  		}
>  
>  		notifier->subdevs[notifier->num_subdevs] = asd;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
>  		notifier->num_subdevs++;
>  	}
> diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
> index 2800700482d6..f7ed5f506fa9 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd,
>  		asd = &imxasd->asd;
>  		switch (asd->match_type) {
>  		case V4L2_ASYNC_MATCH_FWNODE:
> -			if (fwnode && asd->match.fwnode.fwnode == fwnode)
> +			if (fwnode && asd->match.fwnode == fwnode)
>  				return asd;
>  			break;
>  		case V4L2_ASYNC_MATCH_DEVNAME:
> @@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,
>  
>  	if (fwnode) {
>  		asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> -		asd->match.fwnode.fwnode = fwnode;
> +		asd->match.fwnode = fwnode;
>  	} else {
>  		asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
>  		asd->match.device_name.name = devname;
> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
> index 6152434cbe82..a010af5134b2 100644
> --- a/include/media/v4l2-async.h
> +++ b/include/media/v4l2-async.h
> @@ -58,12 +58,8 @@ enum v4l2_async_match_type {
>  struct v4l2_async_subdev {
>  	enum v4l2_async_match_type match_type;
>  	union {
> -		struct {
> -			struct fwnode_handle *fwnode;
> -		} fwnode;
> -		struct {
> -			const char *name;
> -		} device_name;
> +		struct fwnode_handle *fwnode;
> +		const char *device_name;
>  		struct {
>  			int adapter_id;
>  			unsigned short address;
> -- 
> 2.14.3
> 

-- 
Regards,
Niklas S?derlund

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
  2017-12-19 11:18   ` Mauro Carvalho Chehab
  (?)
@ 2017-12-20 13:15     ` Lad, Prabhakar
  -1 siblings, 0 replies; 23+ messages in thread
From: Lad, Prabhakar @ 2017-12-20 13:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Songjun Wu,
	Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Niklas Söderlund,
	Ramesh Shanmugasundaram, Guennadi Liakhovetski, Maxime Coquelin,
	Alexandre Torgue, Benoit Parrot, Hyun Kwon, Laurent Pinchart,
	Michal Simek, Steve Longerbeam, Philipp Zabel,
	Greg Kroah-Hartman, Hans Verkuil, Petr Cvek, Sakari Ailus,
	Julia Lawall, Arnd Bergmann, Hugues Fruchet, Gustavo A. R. Silva,
	Sebastian Reichel, Tomasz Figa, LAK, linux-samsung-soc,
	linux-renesas-soc, OSUOSL Drivers

Hi Mauro,

Thanks for the patch.

On Tue, Dec 19, 2017 at 11:18 AM, Mauro Carvalho Chehab
<mchehab@s-opensource.com> wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
>
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
>
> That makes easier to document it, as we don't need to document
> weird senseless structs.
>
> At drivers, this makes even clearer about the match criteria.
>
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---

For above:

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-20 13:15     ` Lad, Prabhakar
  0 siblings, 0 replies; 23+ messages in thread
From: Lad, Prabhakar @ 2017-12-20 13:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Songjun Wu,
	Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
	Kyungmin Park, Sylwester Nawrocki, Kukjin Kim,
	Krzysztof Kozlowski, Todor Tomov, Niklas Söderlund,
	Ramesh Shanmugasundaram, Guennadi Liakhovetski, Maxime Coquelin,
	Alexandre Torgue

Hi Mauro,

Thanks for the patch.

On Tue, Dec 19, 2017 at 11:18 AM, Mauro Carvalho Chehab
<mchehab@s-opensource.com> wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
>
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
>
> That makes easier to document it, as we don't need to document
> weird senseless structs.
>
> At drivers, this makes even clearer about the match criteria.
>
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---

For above:

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure
@ 2017-12-20 13:15     ` Lad, Prabhakar
  0 siblings, 0 replies; 23+ messages in thread
From: Lad, Prabhakar @ 2017-12-20 13:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mauro,

Thanks for the patch.

On Tue, Dec 19, 2017 at 11:18 AM, Mauro Carvalho Chehab
<mchehab@s-opensource.com> wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
>
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
>
> That makes easier to document it, as we don't need to document
> weird senseless structs.
>
> At drivers, this makes even clearer about the match criteria.
>
> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Acked-by: Benoit Parrot <bparrot@ti.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c    |  6 +++---

For above:

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
  2017-12-19 11:18 ` [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro Mauro Carvalho Chehab
@ 2017-12-27 21:31   ` Sakari Ailus
  0 siblings, 0 replies; 23+ messages in thread
From: Sakari Ailus @ 2017-12-27 21:31 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Hi Mauro,

Thanks for the patch. Please see my comments below.

On Tue, Dec 19, 2017 at 09:18:22AM -0200, Mauro Carvalho Chehab wrote:
> The __V4L2_SUBDEV_MK_GET_TRY() macro is used to define
> 3 functions that have the same arguments. The code of those
> functions is simple enough to just declare them, de-obfuscating
> the code.
> 
> While here, replace BUG_ON() by WARN_ON() as there's no reason
> why to panic the Kernel if this fails.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  include/media/v4l2-subdev.h | 40 ++++++++++++++++++++++++++++------------
>  1 file changed, 28 insertions(+), 12 deletions(-)
> 
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 71b8ff4b2e0e..443e5e019006 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -896,19 +896,35 @@ struct v4l2_subdev_fh {
>  	container_of(fh, struct v4l2_subdev_fh, vfh)
>  
>  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> -#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name)		\
> -	static inline struct rtype *					\
> -	fun_name(struct v4l2_subdev *sd,				\
> -		 struct v4l2_subdev_pad_config *cfg,			\
> -		 unsigned int pad)					\
> -	{								\
> -		BUG_ON(pad >= sd->entity.num_pads);			\
> -		return &cfg[pad].field_name;				\
> -	}
> +static inline struct v4l2_mbus_framefmt
> +*v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
> +			    struct v4l2_subdev_pad_config *cfg,
> +			    unsigned int pad)
> +{
> +	if (WARN_ON(pad >= sd->entity.num_pads))
> +		pad = 0;
> +	return &cfg[pad].try_fmt;

After I suggested this I came to think what happens if there are no pads?

How about adding, before the first check:

if (WARN_ON(!sd->entity.num_pads))
	return NULL;

Instead of copying the code, you could still use a macro while having the
function declaration itself separate from the macro. Up to you.

> +}
>  
> -__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt)
> -__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop)
> -__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose)
> +static inline struct v4l2_rect
> +*v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
> +			  struct v4l2_subdev_pad_config *cfg,
> +			  unsigned int pad)
> +{
> +	if (WARN_ON(pad >= sd->entity.num_pads))
> +		pad = 0;
> +	return &cfg[pad].try_crop;
> +}
> +
> +static inline struct v4l2_rect
> +*v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
> +			     struct v4l2_subdev_pad_config *cfg,
> +			     unsigned int pad)
> +{
> +	if (WARN_ON(pad >= sd->entity.num_pads))
> +		pad = 0;
> +	return &cfg[pad].try_compose;
> +}
>  #endif
>  
>  extern const struct v4l2_file_operations v4l2_subdev_fops;
> -- 
> 2.14.3
> 

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-12-27 21:31 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 11:18 [PATCH v2 0/8] Some V4L2 documentation pending patches Mauro Carvalho Chehab
2017-12-19 11:18 ` [PATCH v2 1/8] media: v4l2-device.h: document helper macros Mauro Carvalho Chehab
2017-12-19 11:18 ` [PATCH v2 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits Mauro Carvalho Chehab
2017-12-19 11:18 ` [PATCH v2 3/8] media: v4l2-async: simplify v4l2_async_subdev structure Mauro Carvalho Chehab
2017-12-19 11:18   ` Mauro Carvalho Chehab
2017-12-19 11:18   ` Mauro Carvalho Chehab
2017-12-19 18:38   ` Hyun Kwon
2017-12-19 18:38     ` Hyun Kwon
2017-12-19 18:38     ` Hyun Kwon
2017-12-20 10:55   ` Niklas Söderlund
2017-12-20 10:55     ` Niklas Söderlund
2017-12-20 10:55     ` Niklas Söderlund
2017-12-20 10:55     ` Niklas Söderlund
2017-12-20 13:15   ` Lad, Prabhakar
2017-12-20 13:15     ` Lad, Prabhakar
2017-12-20 13:15     ` Lad, Prabhakar
2017-12-19 11:18 ` [PATCH v2 4/8] media: v4l2-async: better describe match union at async match struct Mauro Carvalho Chehab
2017-12-19 11:18 ` [PATCH v2 5/8] media: v4l2-mediabus: convert flags to enums and document them Mauro Carvalho Chehab
2017-12-19 11:48   ` Philipp Zabel
2017-12-19 11:18 ` [PATCH v2 6/8] media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro Mauro Carvalho Chehab
2017-12-27 21:31   ` Sakari Ailus
2017-12-19 11:18 ` [PATCH v2 7/8] media: v4l2-subdev: document remaining undocumented functions Mauro Carvalho Chehab
2017-12-19 11:18 ` [PATCH v2 8/8] media: v4l2-subdev: use kernel-doc markups to document subdev flags Mauro Carvalho Chehab

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.