public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: fix truncated entity specification
@ 2011-11-05 21:42 Clemens Ladisch
  2011-11-15  0:47 ` Laurent Pinchart
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2011-11-05 21:42 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, alsa-devel, linux-kernel

When enumerating an entity, assign the entire entity specification
instead of only the first two words.  (This requires giving the
specification union a name.)

So far, no driver actually uses more than two words, but this will
be needed for ALSA entities.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 include/media/media-entity.h      |    2 +-
 drivers/media/media-device.c      |    3 +--
 drivers/media/video/v4l2-dev.c    |    4 ++--
 drivers/media/video/v4l2-device.c |    4 ++--
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index cd8bca6..d13de27 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -98,7 +98,7 @@ struct media_entity {

 		/* Sub-device specifications */
 		/* Nothing needed yet */
-	};
+	} specification;
 };

 static inline u32 media_entity_type(struct media_entity *entity)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 16b70b4..bfb4e0b 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -107,8 +107,7 @@ static long media_device_enum_entities(struct media_device *mdev,
 	u_ent.group_id = ent->group_id;
 	u_ent.pads = ent->num_pads;
 	u_ent.links = ent->num_links - ent->num_backlinks;
-	u_ent.v4l.major = ent->v4l.major;
-	u_ent.v4l.minor = ent->v4l.minor;
+	memcpy(&u_ent.v4l, &ent->specification, sizeof(ent->specification));
 	if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
 		return -EFAULT;
 	return 0;
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index a5c9ed1..1eb9ba1 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -703,8 +703,8 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
 	    vdev->vfl_type != VFL_TYPE_SUBDEV) {
 		vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
 		vdev->entity.name = vdev->name;
-		vdev->entity.v4l.major = VIDEO_MAJOR;
-		vdev->entity.v4l.minor = vdev->minor;
+		vdev->entity.specification.v4l.major = VIDEO_MAJOR;
+		vdev->entity.specification.v4l.minor = vdev->minor;
 		ret = media_device_register_entity(vdev->v4l2_dev->mdev,
 			&vdev->entity);
 		if (ret < 0)
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index e6a2c3b..d8f58d8 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -217,8 +217,8 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
 		if (err < 0)
 			return err;
 #if defined(CONFIG_MEDIA_CONTROLLER)
-		sd->entity.v4l.major = VIDEO_MAJOR;
-		sd->entity.v4l.minor = vdev->minor;
+		sd->entity.specification.v4l.major = VIDEO_MAJOR;
+		sd->entity.specification.v4l.minor = vdev->minor;
 #endif
 	}
 	return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: fix truncated entity specification
  2011-11-05 21:42 [PATCH] media: fix truncated entity specification Clemens Ladisch
@ 2011-11-15  0:47 ` Laurent Pinchart
  2011-11-15 13:02   ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2011-11-15  0:47 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: Mauro Carvalho Chehab, linux-media, alsa-devel, linux-kernel

Hi Clemens,

Thanks for the patch.

On Saturday 05 November 2011 22:42:01 Clemens Ladisch wrote:
> When enumerating an entity, assign the entire entity specification
> instead of only the first two words.  (This requires giving the
> specification union a name.)
> 
> So far, no driver actually uses more than two words, but this will
> be needed for ALSA entities.
> 
> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
> ---
>  include/media/media-entity.h      |    2 +-
>  drivers/media/media-device.c      |    3 +--
>  drivers/media/video/v4l2-dev.c    |    4 ++--
>  drivers/media/video/v4l2-device.c |    4 ++--
>  4 files changed, 6 insertions(+), 7 deletions(-)

What about this (untested) simpler patch ?

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 16b70b4..34404f6 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -107,8 +107,7 @@ static long media_device_enum_entities(struct media_device 
 	u_ent.group_id = ent->group_id;
 	u_ent.pads = ent->num_pads;
 	u_ent.links = ent->num_links - ent->num_backlinks;
-	u_ent.v4l.major = ent->v4l.major;
-	u_ent.v4l.minor = ent->v4l.minor;
+	memcpy(&u_ent.raw, &ent->raw, sizeof(u_ent.raw));
 	if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
 		return -EFAULT;
 	return 0;

> 
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index cd8bca6..d13de27 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -98,7 +98,7 @@ struct media_entity {
> 
>  		/* Sub-device specifications */
>  		/* Nothing needed yet */
> -	};
> +	} specification;
>  };
> 
>  static inline u32 media_entity_type(struct media_entity *entity)
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 16b70b4..bfb4e0b 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -107,8 +107,7 @@ static long media_device_enum_entities(struct
> media_device *mdev, u_ent.group_id = ent->group_id;
>  	u_ent.pads = ent->num_pads;
>  	u_ent.links = ent->num_links - ent->num_backlinks;
> -	u_ent.v4l.major = ent->v4l.major;
> -	u_ent.v4l.minor = ent->v4l.minor;
> +	memcpy(&u_ent.v4l, &ent->specification, sizeof(ent->specification));
>  	if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
>  		return -EFAULT;
>  	return 0;
> diff --git a/drivers/media/video/v4l2-dev.c
> b/drivers/media/video/v4l2-dev.c index a5c9ed1..1eb9ba1 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -703,8 +703,8 @@ int __video_register_device(struct video_device *vdev,
> int type, int nr, vdev->vfl_type != VFL_TYPE_SUBDEV) {
>  		vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
>  		vdev->entity.name = vdev->name;
> -		vdev->entity.v4l.major = VIDEO_MAJOR;
> -		vdev->entity.v4l.minor = vdev->minor;
> +		vdev->entity.specification.v4l.major = VIDEO_MAJOR;
> +		vdev->entity.specification.v4l.minor = vdev->minor;
>  		ret = media_device_register_entity(vdev->v4l2_dev->mdev,
>  			&vdev->entity);
>  		if (ret < 0)
> diff --git a/drivers/media/video/v4l2-device.c
> b/drivers/media/video/v4l2-device.c index e6a2c3b..d8f58d8 100644
> --- a/drivers/media/video/v4l2-device.c
> +++ b/drivers/media/video/v4l2-device.c
> @@ -217,8 +217,8 @@ int v4l2_device_register_subdev_nodes(struct
> v4l2_device *v4l2_dev) if (err < 0)
>  			return err;
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> -		sd->entity.v4l.major = VIDEO_MAJOR;
> -		sd->entity.v4l.minor = vdev->minor;
> +		sd->entity.specification.v4l.major = VIDEO_MAJOR;
> +		sd->entity.specification.v4l.minor = vdev->minor;
>  #endif
>  	}
>  	return 0;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: fix truncated entity specification
  2011-11-15  0:47 ` Laurent Pinchart
@ 2011-11-15 13:02   ` Clemens Ladisch
  2011-11-16  0:33     ` Laurent Pinchart
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2011-11-15 13:02 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Mauro Carvalho Chehab, linux-media, alsa-devel, linux-kernel

Laurent Pinchart wrote:
> On Saturday 05 November 2011 22:42:01 Clemens Ladisch wrote:
> > When enumerating an entity, assign the entire entity specification
> > instead of only the first two words.  (This requires giving the
> > specification union a name.)
> 
> What about this (untested) simpler patch ?
> 
> -	u_ent.v4l.major = ent->v4l.major;
> -	u_ent.v4l.minor = ent->v4l.minor;
> +	memcpy(&u_ent.raw, &ent->raw, sizeof(u_ent.raw));

I would have written it this way if ent->raw actually existed.
(And please don't tell me you want to increase the size of
struct media_entity by 172 bytes.  :)


Regards,
Clemens

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: fix truncated entity specification
  2011-11-15 13:02   ` Clemens Ladisch
@ 2011-11-16  0:33     ` Laurent Pinchart
  2011-11-16  7:42       ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2011-11-16  0:33 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: Mauro Carvalho Chehab, linux-media, alsa-devel, linux-kernel

Hi Clemens,

On Tuesday 15 November 2011 14:02:21 Clemens Ladisch wrote:
> Laurent Pinchart wrote:
> > On Saturday 05 November 2011 22:42:01 Clemens Ladisch wrote:
> > > When enumerating an entity, assign the entire entity specification
> > > instead of only the first two words.  (This requires giving the
> > > specification union a name.)
> > 
> > What about this (untested) simpler patch ?
> > 
> > -	u_ent.v4l.major = ent->v4l.major;
> > -	u_ent.v4l.minor = ent->v4l.minor;
> > +	memcpy(&u_ent.raw, &ent->raw, sizeof(u_ent.raw));
> 
> I would have written it this way if ent->raw actually existed.
> (And please don't tell me you want to increase the size of
> struct media_entity by 172 bytes.  :)

Oops, my bad :-)

Your patch looks good then, except that I would memcpy to u_ent.raw instead of 
u_ent.v4l. Would you also be ok with shortening specification to spec (or 
info) ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: fix truncated entity specification
  2011-11-16  0:33     ` Laurent Pinchart
@ 2011-11-16  7:42       ` Clemens Ladisch
  0 siblings, 0 replies; 5+ messages in thread
From: Clemens Ladisch @ 2011-11-16  7:42 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Mauro Carvalho Chehab, linux-media, alsa-devel, linux-kernel

Laurent Pinchart wrote:
> > > On Saturday 05 November 2011 22:42:01 Clemens Ladisch wrote:
> > > > When enumerating an entity, assign the entire entity specification
> > > > instead of only the first two words.  (This requires giving the
> > > > specification union a name.)
> 
> Your patch looks good then, except that I would memcpy to u_ent.raw instead of
> u_ent.v4l. Would you also be ok with shortening specification to spec (or
> info) ?

Yes, go ahead.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-16  7:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-05 21:42 [PATCH] media: fix truncated entity specification Clemens Ladisch
2011-11-15  0:47 ` Laurent Pinchart
2011-11-15 13:02   ` Clemens Ladisch
2011-11-16  0:33     ` Laurent Pinchart
2011-11-16  7:42       ` Clemens Ladisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox