On 04/12/2018 10:13 AM, Tomasz Figa wrote:
> Hi Hans,
> 
> On Mon, Apr 9, 2018 at 11:20 PM Hans Verkuil <hverk...@xs4all.nl> wrote:
> 
>> From: Hans Verkuil <hans.verk...@cisco.com>
> 
>> Buffers can now be prepared or queued for a request.
> 
>> A buffer is unbound from the request at vb2_buffer_done time or
>> when the queue is cancelled.
> 
> Please see my comments inline.
> 
> [snip]
>> -int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void
> *pb)
>> +static int vb2_req_prepare(struct media_request_object *obj)
>>   {
>> -       struct vb2_buffer *vb;
>> +       struct vb2_buffer *vb = container_of(obj, struct vb2_buffer,
> req_obj);
>>          int ret;
> 
>> +       if (WARN_ON(vb->state != VB2_BUF_STATE_IN_REQUEST))
>> +               return -EINVAL;
>> +
>> +       ret = __buf_prepare(vb, NULL);
>> +       if (ret)
>> +               vb->state = VB2_BUF_STATE_IN_REQUEST;
> 
> Hmm, I suppose this is here because __buf_prepare() changes the state to
> VB2_BUF_STATE_DEQUEUED on error (other than q->error)? I guess it's
> harmless, but perhaps we could have a comment explaining this?

Yes, that's the reason. But it is really ugly, so I changed __buf_prepare
instead: it now remembers the original state and restores it on error.

Much cleaner.

Regards,

        Hans

> 
> Best regards,
> Tomasz
> 

Reply via email to