Commit e7359f8e authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] V4L: Add V4L2_ASYNC_MATCH_OF subdev matching type

Add support for matching by device_node pointer. This allows
the notifier user to simply pass a list of device_node pointers
corresponding to sub-devices.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Acked-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent cfca7644
...@@ -39,6 +39,11 @@ static bool match_devname(struct device *dev, struct v4l2_async_subdev *asd) ...@@ -39,6 +39,11 @@ static bool match_devname(struct device *dev, struct v4l2_async_subdev *asd)
return !strcmp(asd->match.device_name.name, dev_name(dev)); return !strcmp(asd->match.device_name.name, dev_name(dev));
} }
static bool match_of(struct device *dev, struct v4l2_async_subdev *asd)
{
return dev->of_node == asd->match.of.node;
}
static LIST_HEAD(subdev_list); static LIST_HEAD(subdev_list);
static LIST_HEAD(notifier_list); static LIST_HEAD(notifier_list);
static DEFINE_MUTEX(list_lock); static DEFINE_MUTEX(list_lock);
...@@ -66,6 +71,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier * ...@@ -66,6 +71,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier *
case V4L2_ASYNC_MATCH_I2C: case V4L2_ASYNC_MATCH_I2C:
match = match_i2c; match = match_i2c;
break; break;
case V4L2_ASYNC_MATCH_OF:
match = match_of;
break;
default: default:
/* Cannot happen, unless someone breaks us */ /* Cannot happen, unless someone breaks us */
WARN_ON(true); WARN_ON(true);
...@@ -145,6 +153,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, ...@@ -145,6 +153,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
case V4L2_ASYNC_MATCH_CUSTOM: case V4L2_ASYNC_MATCH_CUSTOM:
case V4L2_ASYNC_MATCH_DEVNAME: case V4L2_ASYNC_MATCH_DEVNAME:
case V4L2_ASYNC_MATCH_I2C: case V4L2_ASYNC_MATCH_I2C:
case V4L2_ASYNC_MATCH_OF:
break; break;
default: default:
dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL, dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
struct device; struct device;
struct device_node;
struct v4l2_device; struct v4l2_device;
struct v4l2_subdev; struct v4l2_subdev;
struct v4l2_async_notifier; struct v4l2_async_notifier;
...@@ -26,6 +27,7 @@ enum v4l2_async_match_type { ...@@ -26,6 +27,7 @@ enum v4l2_async_match_type {
V4L2_ASYNC_MATCH_CUSTOM, V4L2_ASYNC_MATCH_CUSTOM,
V4L2_ASYNC_MATCH_DEVNAME, V4L2_ASYNC_MATCH_DEVNAME,
V4L2_ASYNC_MATCH_I2C, V4L2_ASYNC_MATCH_I2C,
V4L2_ASYNC_MATCH_OF,
}; };
/** /**
...@@ -38,6 +40,9 @@ enum v4l2_async_match_type { ...@@ -38,6 +40,9 @@ enum v4l2_async_match_type {
struct v4l2_async_subdev { struct v4l2_async_subdev {
enum v4l2_async_match_type match_type; enum v4l2_async_match_type match_type;
union { union {
struct {
const struct device_node *node;
} of;
struct { struct {
const char *name; const char *name;
} device_name; } device_name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment