[media] v4l2-core: add code to check for specific ops

This patch adds a v4l2_subdev_has_op() macro and a v4l2_device_has_op macro to
quickly check if a specific subdev or any subdev supports a particular subdev
operation.
This makes it easy for drivers to disable certain ioctls if none of the subdevs
supports the necessary functionality.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index d61febfb..c9b1593 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -190,4 +190,17 @@
 			##args);					\
 })
 
+#define v4l2_device_has_op(v4l2_dev, o, f)				\
+({									\
+	struct v4l2_subdev *__sd;					\
+	bool __result = false;						\
+	list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) {		\
+		if (v4l2_subdev_has_op(__sd, o, f)) {			\
+			__result = true;				\
+			break;						\
+		}							\
+	}								\
+	__result;							\
+})
+
 #endif