* [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
@ 2017-06-07 9:52 Kieran Bingham
2017-06-07 11:16 ` Sakari Ailus
2017-06-08 18:00 ` Mauro Carvalho Chehab
0 siblings, 2 replies; 6+ messages in thread
From: Kieran Bingham @ 2017-06-07 9:52 UTC (permalink / raw)
To: sakari.ailus, linux-media
Cc: laurent.pinchart, niklas.soderlund, linux-renesas-soc,
kieran.bingham, Kieran Bingham
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Return NULL, if a null entity is parsed for it's v4l2_subdev
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
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(-)
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))
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
2017-06-07 9:52 [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev Kieran Bingham
@ 2017-06-07 11:16 ` Sakari Ailus
2017-06-08 18:00 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2017-06-07 11:16 UTC (permalink / raw)
To: Kieran Bingham
Cc: linux-media, laurent.pinchart, niklas.soderlund,
linux-renesas-soc, kieran.bingham, Kieran Bingham
On Wed, Jun 07, 2017 at 10:52:07AM +0100, Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
> Return NULL, if a null entity is parsed for it's v4l2_subdev
>
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
2017-06-07 9:52 [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev Kieran Bingham
2017-06-07 11:16 ` Sakari Ailus
@ 2017-06-08 18:00 ` Mauro Carvalho Chehab
2017-06-08 19:32 ` Sakari Ailus
1 sibling, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2017-06-08 18:00 UTC (permalink / raw)
To: Kieran Bingham
Cc: sakari.ailus, linux-media, laurent.pinchart, niklas.soderlund,
linux-renesas-soc, kieran.bingham, Kieran Bingham
Em Wed, 7 Jun 2017 10:52:07 +0100
Kieran Bingham <kbingham@kernel.org> escreveu:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
> Return NULL, if a null entity is parsed for it's v4l2_subdev
>
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
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
>
> ---
> 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(-)
>
> 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))
>
Thanks,
Mauro
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
2017-06-08 18:00 ` Mauro Carvalho Chehab
@ 2017-06-08 19:32 ` Sakari Ailus
2017-06-08 20:10 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2017-06-08 19:32 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Kieran Bingham, linux-media, laurent.pinchart, niklas.soderlund,
linux-renesas-soc, kieran.bingham, Kieran Bingham
Hi Mauro,
On Thu, Jun 08, 2017 at 03:00:22PM -0300, Mauro Carvalho Chehab wrote:
> Em Wed, 7 Jun 2017 10:52:07 +0100
> Kieran Bingham <kbingham@kernel.org> escreveu:
>
> > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >
> > Return NULL, if a null entity is parsed for it's v4l2_subdev
> >
> > Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
> 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.
--
Regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
2017-06-08 19:32 ` Sakari Ailus
@ 2017-06-08 20:10 ` Mauro Carvalho Chehab
2017-06-09 10:03 ` Kieran Bingham
0 siblings, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2017-06-08 20:10 UTC (permalink / raw)
To: Sakari Ailus
Cc: Kieran Bingham, linux-media, laurent.pinchart, niklas.soderlund,
linux-renesas-soc, kieran.bingham, Kieran Bingham
Em Thu, 8 Jun 2017 22:32:10 +0300
Sakari Ailus <sakari.ailus@iki.fi> escreveu:
> Hi Mauro,
>
> On Thu, Jun 08, 2017 at 03:00:22PM -0300, Mauro Carvalho Chehab wrote:
> > Em Wed, 7 Jun 2017 10:52:07 +0100
> > Kieran Bingham <kbingham@kernel.org> escreveu:
> >
> > > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > >
> > > Return NULL, if a null entity is parsed for it's v4l2_subdev
> > >
> > > Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >
> > 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.
Patch added, with a description based on the above.
Thanks!
Mauro
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
2017-06-08 20:10 ` Mauro Carvalho Chehab
@ 2017-06-09 10:03 ` Kieran Bingham
0 siblings, 0 replies; 6+ messages in thread
From: Kieran Bingham @ 2017-06-09 10:03 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Sakari Ailus
Cc: Kieran Bingham, linux-media, laurent.pinchart, niklas.soderlund,
linux-renesas-soc, Kieran Bingham
Hi Sakari, Mauro,
On 08/06/17 21:10, Mauro Carvalho Chehab wrote:
> Em Thu, 8 Jun 2017 22:32:10 +0300
> Sakari Ailus <sakari.ailus@iki.fi> escreveu:
>
>> Hi Mauro,
>>
>> On Thu, Jun 08, 2017 at 03:00:22PM -0300, Mauro Carvalho Chehab wrote:
>>> Em Wed, 7 Jun 2017 10:52:07 +0100
>>> Kieran Bingham <kbingham@kernel.org> escreveu:
>>>
>>>> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>>>
>>>> Return NULL, if a null entity is parsed for it's v4l2_subdev
>>>>
>>>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>>
>>> 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 ...
>>
>> 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 ...
> Patch added, with a description based on the above.
And thank you :)
Regards
--
Kieran
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-09 10:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 9:52 [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev Kieran Bingham
2017-06-07 11:16 ` Sakari Ailus
2017-06-08 18:00 ` Mauro Carvalho Chehab
2017-06-08 19:32 ` Sakari Ailus
2017-06-08 20:10 ` Mauro Carvalho Chehab
2017-06-09 10:03 ` Kieran Bingham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox