diff options
author | Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> | 2017-06-07 06:52:07 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-06-08 16:55:25 -0300 |
commit | 47f910f0e0deb880c2114811f7ea1ec115a19ee4 (patch) | |
tree | 073ac6c6b3ccfd1730d199bf5418087ceeebf15e /include/media/v4l2-subdev.h | |
parent | 7eb2bcb2efccf07cc4bc31791e3c36bebe12b8ad (diff) | |
download | linux-47f910f0e0deb880c2114811f7ea1ec115a19ee4.tar.bz2 |
[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: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r-- | include/media/v4l2-subdev.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a40760174797..0f92ebd2d710 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -826,8 +826,15 @@ struct v4l2_subdev { struct v4l2_subdev_platform_data *pdata; }; -#define media_entity_to_v4l2_subdev(ent) \ - container_of(ent, struct v4l2_subdev, entity) +#define media_entity_to_v4l2_subdev(ent) \ +({ \ + 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) \ ((struct v4l2_subdev *)video_get_drvdata(vdev)) |