Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
ecdf0cfe ca50c197

+23
+15
drivers/media/v4l2-core/v4l2-async.c
··· 14 14 #include <linux/list.h> 15 15 #include <linux/module.h> 16 16 #include <linux/mutex.h> 17 + #include <linux/of.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/slab.h> 19 20 #include <linux/types.h> ··· 45 44 { 46 45 return !of_node_cmp(of_node_full_name(sd->of_node), 47 46 of_node_full_name(asd->match.of.node)); 47 + } 48 + 49 + static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) 50 + { 51 + if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode)) 52 + return sd->fwnode == asd->match.fwnode.fwnode; 53 + 54 + return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)), 55 + of_node_full_name( 56 + to_of_node(asd->match.fwnode.fwnode))); 48 57 } 49 58 50 59 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) ··· 90 79 break; 91 80 case V4L2_ASYNC_MATCH_OF: 92 81 match = match_of; 82 + break; 83 + case V4L2_ASYNC_MATCH_FWNODE: 84 + match = match_fwnode; 93 85 break; 94 86 default: 95 87 /* Cannot happen, unless someone breaks us */ ··· 172 158 case V4L2_ASYNC_MATCH_DEVNAME: 173 159 case V4L2_ASYNC_MATCH_I2C: 174 160 case V4L2_ASYNC_MATCH_OF: 161 + case V4L2_ASYNC_MATCH_FWNODE: 175 162 break; 176 163 default: 177 164 dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL,
+5
include/media/v4l2-async.h
··· 32 32 * @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name 33 33 * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address 34 34 * @V4L2_ASYNC_MATCH_OF: Match will use OF node 35 + * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node 35 36 * 36 37 * This enum is used by the asyncrhronous sub-device logic to define the 37 38 * algorithm that will be used to match an asynchronous device. ··· 42 41 V4L2_ASYNC_MATCH_DEVNAME, 43 42 V4L2_ASYNC_MATCH_I2C, 44 43 V4L2_ASYNC_MATCH_OF, 44 + V4L2_ASYNC_MATCH_FWNODE, 45 45 }; 46 46 47 47 /** ··· 59 57 struct { 60 58 const struct device_node *node; 61 59 } of; 60 + struct { 61 + struct fwnode_handle *fwnode; 62 + } fwnode; 62 63 struct { 63 64 const char *name; 64 65 } device_name;
+3
include/media/v4l2-subdev.h
··· 788 788 * @devnode: subdev device node 789 789 * @dev: pointer to the physical device, if any 790 790 * @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). 791 793 * @async_list: Links this subdev to a global subdev_list or @notifier->done 792 794 * list. 793 795 * @asd: Pointer to respective &struct v4l2_async_subdev. ··· 821 819 struct video_device *devnode; 822 820 struct device *dev; 823 821 struct device_node *of_node; 822 + struct fwnode_handle *fwnode; 824 823 struct list_head async_list; 825 824 struct v4l2_async_subdev *asd; 826 825 struct v4l2_async_notifier *notifier;