Skip to contentSkip to conversation

v4l2-event: v4l2_event_queue: do nothing if vdev == NULL

PATCH In review Hans Verkuil 3 participants 4 messages Jun 23, 2015 – Jun 25, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v4l2-event: v4l2_event_queue: do nothing if vdev == NULL

If the vdev pointer == NULL, then just return.

This makes it easier for subdev drivers to use this function without having to check if the sd->devnode pointer is NULL or not.

drivers/media/v4l2-core/v4l2-event.c +3 -0
index 8761aab..8d3171c 100644
@@ -172,6 +172,9 @@ void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev)
 	unsigned long flags;
 	struct timespec timestamp;
 
+	if (vdev == NULL)
+		return;
+
 	ktime_get_ts(&timestamp);
 
 	spin_lock_irqsave(&vdev->fh_lock, flags);
#1 lore raw

Hi Hans,

Quoted 4 lines · Hans Verkuil

If the vdev pointer == NULL, then just return.

This makes it easier for subdev drivers to use this function without having to check if the sd->devnode pointer is NULL or not.

Do you have an example of when this would be useful? Isn't it a rather fundamental question to a driver whether or not it exposes a device node, i.e. why would a driver use v4l2_event_queue() in the first place if it does not expose a device node, and so the event interface?

Quoted 17 lines
drivers/media/v4l2-core/v4l2-event.c +3 -0
index 8761aab..8d3171c 100644
@@ -172,6 +172,9 @@ void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev)
 	unsigned long flags;
 	struct timespec timestamp;
 
+	if (vdev == NULL)
+		return;
+
 	ktime_get_ts(&timestamp);
 
 	spin_lock_irqsave(&vdev->fh_lock, flags);
Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#2 lore raw
Quoted 5 lines · Sakari Ailus

Hi Hans,

Quoted 2 lines · Hans Verkuil

If the vdev pointer == NULL, then just return.

Quoted 7 lines
Quoted 2 lines

This makes it easier for subdev drivers to use this function without having to check if the sd->devnode pointer is NULL or not.

Do you have an example of when this would be useful? Isn't it a rather fundamental question to a driver whether or not it exposes a device node, i.e. why would a driver use v4l2_event_queue() in the first place if it does not expose a device node, and so the event interface?

The device node will only be created if the subdev driver supports it and if the bridge driver requests it. So if the subdev driver supports it, but the bridge driver does not request it there will be no devnode. The patch is to handle that case.

This patch is a requirement for this series which adds support for direct event notification to some subdev drivers. Why this is necessary and useful can be found in the series patch description. http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/92808

- Lars

Acked-by
#3 lore raw

Hi Lars-Peter,

Quoted 19 lines · Lars-Peter Clausen
Quoted 5 lines · Sakari Ailus

Hi Hans,

Quoted 2 lines · Hans Verkuil

If the vdev pointer == NULL, then just return.

Quoted 7 lines
Quoted 2 lines

This makes it easier for subdev drivers to use this function without having to check if the sd->devnode pointer is NULL or not.

Do you have an example of when this would be useful? Isn't it a rather fundamental question to a driver whether or not it exposes a device node, i.e. why would a driver use v4l2_event_queue() in the first place if it does not expose a device node, and so the event interface?

The device node will only be created if the subdev driver supports it and if the bridge driver requests it. So if the subdev driver supports it, but the bridge driver does not request it there will be no devnode. The patch is to handle that case.

Quoted 4 lines

This patch is a requirement for this series which adds support for direct event notification to some subdev drivers. Why this is necessary and useful can be found in the series patch description.
http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/92808

Ok, fair enough.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]