* [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test
@ 2011-12-21 15:30 Scott Jiang
2012-01-04 15:54 ` Sakari Ailus
0 siblings, 1 reply; 5+ messages in thread
From: Scott Jiang @ 2011-12-21 15:30 UTC (permalink / raw)
To: sakari.ailus, Hans Verkuil, Laurent Pinchart,
Mauro Carvalho Chehab, linux-media, uclinux-dist-devel
Cc: Scott Jiang
list_is_singular accepts a list head to test whether a list has just one entry.
fh->list is the entry, fh->vdev->fh_list is the list head.
Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
---
drivers/media/video/v4l2-fh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c
index 9e3fc04..8292c4a 100644
--- a/drivers/media/video/v4l2-fh.c
+++ b/drivers/media/video/v4l2-fh.c
@@ -113,7 +113,7 @@ int v4l2_fh_is_singular(struct v4l2_fh *fh)
if (fh == NULL || fh->vdev == NULL)
return 0;
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
- is_singular = list_is_singular(&fh->list);
+ is_singular = list_is_singular(&fh->vdev->fh_list);
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
return is_singular;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test
2011-12-21 15:30 [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test Scott Jiang
@ 2012-01-04 15:54 ` Sakari Ailus
2012-01-05 2:52 ` Scott Jiang
0 siblings, 1 reply; 5+ messages in thread
From: Sakari Ailus @ 2012-01-04 15:54 UTC (permalink / raw)
To: Scott Jiang
Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab,
linux-media, uclinux-dist-devel
Hi Scott,
Thanks for the patch.
On Wed, Dec 21, 2011 at 10:30:54AM -0500, Scott Jiang wrote:
> list_is_singular accepts a list head to test whether a list has just one entry.
> fh->list is the entry, fh->vdev->fh_list is the list head.
>
> Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
> ---
> drivers/media/video/v4l2-fh.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c
> index 9e3fc04..8292c4a 100644
> --- a/drivers/media/video/v4l2-fh.c
> +++ b/drivers/media/video/v4l2-fh.c
> @@ -113,7 +113,7 @@ int v4l2_fh_is_singular(struct v4l2_fh *fh)
> if (fh == NULL || fh->vdev == NULL)
> return 0;
> spin_lock_irqsave(&fh->vdev->fh_lock, flags);
> - is_singular = list_is_singular(&fh->list);
> + is_singular = list_is_singular(&fh->vdev->fh_list);
> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> return is_singular;
> }
Is there an issue that this patch resolves, or am I missing something? As
far as I can see, the list_is_singular() test returns the same result
whether you are testing a list item which is part of the list, or its head
in struct video_device.
Kind regards,
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi jabber/XMPP/Gmail: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test
2012-01-04 15:54 ` Sakari Ailus
@ 2012-01-05 2:52 ` Scott Jiang
2012-01-05 7:57 ` Sakari Ailus
0 siblings, 1 reply; 5+ messages in thread
From: Scott Jiang @ 2012-01-05 2:52 UTC (permalink / raw)
To: Sakari Ailus
Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab,
linux-media, uclinux-dist-devel
2012/1/4 Sakari Ailus <sakari.ailus@iki.fi>:
> Hi Scott,
>
> Thanks for the patch.
>
> On Wed, Dec 21, 2011 at 10:30:54AM -0500, Scott Jiang wrote:
>> list_is_singular accepts a list head to test whether a list has just one entry.
>> fh->list is the entry, fh->vdev->fh_list is the list head.
>>
>> Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
>> ---
>> drivers/media/video/v4l2-fh.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c
>> index 9e3fc04..8292c4a 100644
>> --- a/drivers/media/video/v4l2-fh.c
>> +++ b/drivers/media/video/v4l2-fh.c
>> @@ -113,7 +113,7 @@ int v4l2_fh_is_singular(struct v4l2_fh *fh)
>> if (fh == NULL || fh->vdev == NULL)
>> return 0;
>> spin_lock_irqsave(&fh->vdev->fh_lock, flags);
>> - is_singular = list_is_singular(&fh->list);
>> + is_singular = list_is_singular(&fh->vdev->fh_list);
>> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
>> return is_singular;
>> }
>
> Is there an issue that this patch resolves, or am I missing something? As
> far as I can see, the list_is_singular() test returns the same result
> whether you are testing a list item which is part of the list, or its head
> in struct video_device.
>
Yes, the result is the same. But I don't think it's a good example
because it may abuse this api.
Can anybody figure out what this api needs you to pass in? I confess
I am not sure about that.
Scott
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test
2012-01-05 2:52 ` Scott Jiang
@ 2012-01-05 7:57 ` Sakari Ailus
2012-01-07 13:59 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 5+ messages in thread
From: Sakari Ailus @ 2012-01-05 7:57 UTC (permalink / raw)
To: Scott Jiang
Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab,
linux-media, uclinux-dist-devel
On Thu, Jan 05, 2012 at 10:52:02AM +0800, Scott Jiang wrote:
> 2012/1/4 Sakari Ailus <sakari.ailus@iki.fi>:
> > Hi Scott,
> >
> > Thanks for the patch.
> >
> > On Wed, Dec 21, 2011 at 10:30:54AM -0500, Scott Jiang wrote:
> >> list_is_singular accepts a list head to test whether a list has just one entry.
> >> fh->list is the entry, fh->vdev->fh_list is the list head.
> >>
> >> Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
> >> ---
> >> drivers/media/video/v4l2-fh.c | 2 +-
> >> 1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c
> >> index 9e3fc04..8292c4a 100644
> >> --- a/drivers/media/video/v4l2-fh.c
> >> +++ b/drivers/media/video/v4l2-fh.c
> >> @@ -113,7 +113,7 @@ int v4l2_fh_is_singular(struct v4l2_fh *fh)
> >> if (fh == NULL || fh->vdev == NULL)
> >> return 0;
> >> spin_lock_irqsave(&fh->vdev->fh_lock, flags);
> >> - is_singular = list_is_singular(&fh->list);
> >> + is_singular = list_is_singular(&fh->vdev->fh_list);
> >> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
> >> return is_singular;
> >> }
> >
> > Is there an issue that this patch resolves, or am I missing something? As
> > far as I can see, the list_is_singular() test returns the same result
> > whether you are testing a list item which is part of the list, or its head
> > in struct video_device.
> >
> Yes, the result is the same. But I don't think it's a good example
> because it may abuse this api.
> Can anybody figure out what this api needs you to pass in? I confess
> I am not sure about that.
That's true; it's more correct (and intuitive as well) to use the real list
head for the purpose. But if the implementation really changed I bet a huge
number of other things would break as well.
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Hans: you wrote the patch adding this code (dfddb244); what do you think?
Regards,
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi jabber/XMPP/Gmail: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test
2012-01-05 7:57 ` Sakari Ailus
@ 2012-01-07 13:59 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2012-01-07 13:59 UTC (permalink / raw)
To: Sakari Ailus
Cc: Scott Jiang, Hans Verkuil, Laurent Pinchart, linux-media,
uclinux-dist-devel
On 05-01-2012 05:57, Sakari Ailus wrote:
> On Thu, Jan 05, 2012 at 10:52:02AM +0800, Scott Jiang wrote:
>> 2012/1/4 Sakari Ailus <sakari.ailus@iki.fi>:
>>> Hi Scott,
>>>
>>> Thanks for the patch.
>>>
>>> On Wed, Dec 21, 2011 at 10:30:54AM -0500, Scott Jiang wrote:
>>>> list_is_singular accepts a list head to test whether a list has just one entry.
>>>> fh->list is the entry, fh->vdev->fh_list is the list head.
>>>>
>>>> Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
>>>> ---
>>>> drivers/media/video/v4l2-fh.c | 2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c
>>>> index 9e3fc04..8292c4a 100644
>>>> --- a/drivers/media/video/v4l2-fh.c
>>>> +++ b/drivers/media/video/v4l2-fh.c
>>>> @@ -113,7 +113,7 @@ int v4l2_fh_is_singular(struct v4l2_fh *fh)
>>>> if (fh == NULL || fh->vdev == NULL)
>>>> return 0;
>>>> spin_lock_irqsave(&fh->vdev->fh_lock, flags);
>>>> - is_singular = list_is_singular(&fh->list);
>>>> + is_singular = list_is_singular(&fh->vdev->fh_list);
>>>> spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
>>>> return is_singular;
>>>> }
>>>
>>> Is there an issue that this patch resolves, or am I missing something? As
>>> far as I can see, the list_is_singular() test returns the same result
>>> whether you are testing a list item which is part of the list, or its head
>>> in struct video_device.
>>>
>> Yes, the result is the same. But I don't think it's a good example
>> because it may abuse this api.
>> Can anybody figure out what this api needs you to pass in? I confess
>> I am not sure about that.
>
> That's true; it's more correct (and intuitive as well) to use the real list
> head for the purpose. But if the implementation really changed I bet a huge
> number of other things would break as well.
>
> Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
>
> Hans: you wrote the patch adding this code (dfddb244); what do you think?
All those list functions can operate on any node of the list, since the
list is circular. So, there's not a real "head" for the list.
The function implementation shows that:
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
...
static inline int list_is_singular(const struct list_head *head)
{
return !list_empty(head) && (head->next == head->prev);
}
So, I prefer to not change it, _unless_ for some reason, you hit
a bug on it (for example, by not having one of the list pointers
filled).
Regards,
Mauro
>
> Regards,
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-07 13:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 15:30 [PATCH] v4l2: v4l2-fh: v4l2_fh_is_singular should use list head to test Scott Jiang
2012-01-04 15:54 ` Sakari Ailus
2012-01-05 2:52 ` Scott Jiang
2012-01-05 7:57 ` Sakari Ailus
2012-01-07 13:59 ` Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).