Skip to content

Commit ecdf0cf

Browse files
Sakari Ailusmchehab
authored andcommitted
[media] v4l: async: Add fwnode match support
Add fwnode matching to complement OF node matching. And fwnode may also be an OF node. Do not enable fwnode matching yet. It will replace OF matching soon. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent ca50c19 commit ecdf0cf

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎drivers/media/v4l2-core/v4l2-async.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/list.h>
1515
#include <linux/module.h>
1616
#include <linux/mutex.h>
17+
#include <linux/of.h>
1718
#include <linux/platform_device.h>
1819
#include <linux/slab.h>
1920
#include <linux/types.h>
@@ -46,6 +47,16 @@ static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
4647
of_node_full_name(asd->match.of.node));
4748
}
4849

50+
static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
51+
{
52+
if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode))
53+
return sd->fwnode == asd->match.fwnode.fwnode;
54+
55+
return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
56+
of_node_full_name(
57+
to_of_node(asd->match.fwnode.fwnode)));
58+
}
59+
4960
static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
5061
{
5162
if (!asd->match.custom.match)
@@ -80,6 +91,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier *
8091
case V4L2_ASYNC_MATCH_OF:
8192
match = match_of;
8293
break;
94+
case V4L2_ASYNC_MATCH_FWNODE:
95+
match = match_fwnode;
96+
break;
8397
default:
8498
/* Cannot happen, unless someone breaks us */
8599
WARN_ON(true);
@@ -158,6 +172,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
158172
case V4L2_ASYNC_MATCH_DEVNAME:
159173
case V4L2_ASYNC_MATCH_I2C:
160174
case V4L2_ASYNC_MATCH_OF:
175+
case V4L2_ASYNC_MATCH_FWNODE:
161176
break;
162177
default:
163178
dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL,

‎include/media/v4l2-async.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct v4l2_async_notifier;
3232
* @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name
3333
* @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address
3434
* @V4L2_ASYNC_MATCH_OF: Match will use OF node
35+
* @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node
3536
*
3637
* This enum is used by the asyncrhronous sub-device logic to define the
3738
* algorithm that will be used to match an asynchronous device.
@@ -41,6 +42,7 @@ enum v4l2_async_match_type {
4142
V4L2_ASYNC_MATCH_DEVNAME,
4243
V4L2_ASYNC_MATCH_I2C,
4344
V4L2_ASYNC_MATCH_OF,
45+
V4L2_ASYNC_MATCH_FWNODE,
4446
};
4547

4648
/**
@@ -57,6 +59,9 @@ struct v4l2_async_subdev {
5759
struct {
5860
const struct device_node *node;
5961
} of;
62+
struct {
63+
struct fwnode_handle *fwnode;
64+
} fwnode;
6065
struct {
6166
const char *name;
6267
} device_name;

‎include/media/v4l2-subdev.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ struct v4l2_subdev_platform_data {
788788
* @devnode: subdev device node
789789
* @dev: pointer to the physical device, if any
790790
* @of_node: The device_node of the subdev, usually the same as dev->of_node.
791+
* @fwnode: The fwnode_handle of the subdev, usually the same as
792+
* either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL).
791793
* @async_list: Links this subdev to a global subdev_list or @notifier->done
792794
* list.
793795
* @asd: Pointer to respective &struct v4l2_async_subdev.
@@ -819,6 +821,7 @@ struct v4l2_subdev {
819821
struct video_device *devnode;
820822
struct device *dev;
821823
struct device_node *of_node;
824+
struct fwnode_handle *fwnode;
822825
struct list_head async_list;
823826
struct v4l2_async_subdev *asd;
824827
struct v4l2_async_notifier *notifier;

0 commit comments

Comments
 (0)