v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
PATCH v4 1/1 v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's v4l2_subdev
---
Not sure if this patch ever made it out of my mailbox:
Here's the respin with the parameter evaluated only once.
v4:
- Improve macro usage to evaluate ent only once
include/media/v4l2-subdev.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
include/media/v4l2-subdev.h +9 -2
@@ -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))
Signature · 1 line
2.7.4
Quoted 5 lines · Kieran Bingham
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's
v4l2_subdevSigned-off-by Kieran Bingham <[email protected]>
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Em Wed, 7 Jun 2017 10:52:07 +0100
Kieran Bingham <[email protected]> escreveu:
Quoted 5 lines
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's
v4l2_subdevSigned-off-by Kieran Bingham <[email protected]>
Could you please improve this patch description?
I'm unsure if this is a bug fix, or some sort of feature...
On what situations would a null entity be passed to this function?
Regards,
Mauro
Quoted 24 lines
---
Not sure if this patch ever made it out of my mailbox:Here's the respin with the parameter evaluated only once.
v4:
- Improve macro usage to evaluate ent only onceinclude/media/v4l2-subdev.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)include/media/v4l2-subdev.h +2
-2@@ -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) \ +({ \
include/media/v4l2-subdev.h struct v4l2_subdev { · line 840
Quoted 10 lines
include/media/v4l2-subdev.h +7
-0+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))
Thanks,
Mauro
Hi Mauro,
Quoted 7 lines · Mauro Carvalho Chehab
Em Wed, 7 Jun 2017 10:52:07 +0100
Kieran Bingham <[email protected]> escreveu:Quoted 4 lines
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's
v4l2_subdev
Quoted 7 lines
Quoted 1 line
Signed-off-by Kieran Bingham <[email protected]>Could you please improve this patch description?
I'm unsure if this is a bug fix, or some sort of feature...
On what situations would a null entity be passed to this function?
I actually proposed this patch. This change is simply for convenience --- the caller doesn't need to make sure the subdev is non-NULL, possibly obtained from e.g. media_entity_remote_pad() which returns NULL all links to the pad are disabled. This is a recurring pattern, and making this change avoids an additional check.
Having something along these lines in the patch description wouldn't hurt.
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Em Thu, 8 Jun 2017 22:32:10 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 18 lines
Hi Mauro,
Quoted 7 lines · Mauro Carvalho Chehab
Em Wed, 7 Jun 2017 10:52:07 +0100
Kieran Bingham <[email protected]> escreveu:Quoted 4 lines
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's
v4l2_subdevQuoted 7 lines
Quoted 1 line
Signed-off-by Kieran Bingham <[email protected]>Could you please improve this patch description?
I'm unsure if this is a bug fix, or some sort of feature...
On what situations would a null entity be passed to this function?
Quoted 7 lines
I actually proposed this patch. This change is simply for convenience --- the caller doesn't need to make sure the subdev is non-NULL, possibly obtained from e.g.
media_entity_remote_pad()which returns NULL all links to the pad are disabled. This is a recurring pattern, and making this change avoids an additional check.Having something along these lines in the patch description wouldn't hurt.
Patch added, with a description based on the above.
Thanks!
Mauro
Hi Sakari, Mauro,
Quoted 20 lines · Mauro Carvalho Chehab
Em Thu, 8 Jun 2017 22:32:10 +0300
Sakari Ailus <[email protected]> escreveu:Quoted 17 lines
Hi Mauro,
Quoted 14 lines · Mauro Carvalho Chehab
Em Wed, 7 Jun 2017 10:52:07 +0100
Kieran Bingham <[email protected]> escreveu:Quoted 5 lines
From: Kieran Bingham <[email protected]>
Return NULL, if a null entity is parsed for it's
v4l2_subdevSigned-off-by Kieran Bingham <[email protected]>Could you please improve this patch description?
I'm unsure if this is a bug fix, or some sort of feature...
On what situations would a null entity be passed to this function?
Sorry for not being clear enough there ...
Quoted 8 lines
Quoted 8 lines
I actually proposed this patch. This change is simply for convenience --- the caller doesn't need to make sure the subdev is non-NULL, possibly obtained from e.g.
media_entity_remote_pad()which returns NULL all links to the pad are disabled. This is a recurring pattern, and making this change avoids an additional check.Having something along these lines in the patch description wouldn't hurt.
Yes, the above looks good ...
Quoted 1 line
Patch added, with a description based on the above.
And thank you :)
Regards
--
Kieran