Skip to content

Commit

Permalink
[media] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs
Browse files Browse the repository at this point in the history
Instead of abusing MEDIA_ENT_T_V4L2_SUBDEV, initialize
new subdev entities as MEDIA_ENT_T_UNKNOWN.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
  • Loading branch information
mchehab committed Jan 11, 2016
1 parent bf4178a commit b50bde4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions drivers/media/media-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ int __must_check media_device_register_entity(struct media_device *mdev,
{
int i;

if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
entity->type == MEDIA_ENT_T_UNKNOWN)
dev_warn(mdev->dev,
"Entity type for entity %s was not initialized!\n",
entity->name);

/* Warn if we apparently re-register an entity */
WARN_ON(entity->graph_obj.mdev != NULL);
entity->graph_obj.mdev = mdev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/v4l2-core/v4l2-subdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
sd->host_priv = NULL;
#if defined(CONFIG_MEDIA_CONTROLLER)
sd->entity.name = sd->name;
sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
#endif
}
EXPORT_SYMBOL(v4l2_subdev_init);
Expand Down
14 changes: 14 additions & 0 deletions include/uapi/linux/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ struct media_device_info {

#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)

/* Used values for media_entity_desc::type */

/*
* Initial value to be used when a new entity is created
* Drivers should change it to something useful
*/
#define MEDIA_ENT_T_UNKNOWN 0x00000000

/*
* Base numbers for entity types
*
Expand Down Expand Up @@ -76,6 +84,12 @@ struct media_device_info {

/* V4L2 Sub-device entities */

/*
* Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
* in order to preserve backward compatibility.
* Drivers should change to the proper subdev type before
* registering the entity.
*/
#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE

#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
Expand Down

0 comments on commit b50bde4

Please sign in to comment.