提交 47f910f0 编写于 作者: K Kieran Bingham 提交者: Mauro Carvalho Chehab

[media] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev

Return NULL, if a null entity is parsed for it's v4l2_subdev

Currently, the callers of media_entity_to_v4l2_subdev() need to
make sure that the subdev is non-NULL, for example, when it is
obtained from media_entity_remote_pad().

As this is a recurring pattern, add the check at the macro in order
to avoid additional checks at the callers.
Signed-off-by: NKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: NSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
上级 7eb2bcb2
...@@ -826,8 +826,15 @@ struct v4l2_subdev { ...@@ -826,8 +826,15 @@ struct v4l2_subdev {
struct v4l2_subdev_platform_data *pdata; struct v4l2_subdev_platform_data *pdata;
}; };
#define media_entity_to_v4l2_subdev(ent) \ #define media_entity_to_v4l2_subdev(ent) \
container_of(ent, struct v4l2_subdev, entity) ({ \
typeof(ent) __me_sd_ent = (ent); \
\
__me_sd_ent ? \
container_of(__me_sd_ent, struct v4l2_subdev, entity) : \
NULL; \
})
#define vdev_to_v4l2_subdev(vdev) \ #define vdev_to_v4l2_subdev(vdev) \
((struct v4l2_subdev *)video_get_drvdata(vdev)) ((struct v4l2_subdev *)video_get_drvdata(vdev))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册