Skip to content

Commit

Permalink
media: videobuf2-core: Rework and rename helper for request buffer count
Browse files Browse the repository at this point in the history
The helper indicating whether buffers are associated with the request is
reworked and renamed to return the number of associated buffer objects.

This is useful for drivers that need to check how many buffers are in
the request to validate it.

Existing users of the helper don't need particular adaptation since the
meaning of zero/non-zero remains consistent.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
  • Loading branch information
Paul Kocialkowski authored and Mauro Carvalho Chehab committed Sep 24, 2018
1 parent 7390ba4 commit 515c5a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions drivers/media/common/videobuf2/videobuf2-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,23 +1368,21 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj)
}
EXPORT_SYMBOL_GPL(vb2_request_object_is_buffer);

bool vb2_request_has_buffers(struct media_request *req)
unsigned int vb2_request_buffer_cnt(struct media_request *req)
{
struct media_request_object *obj;
unsigned long flags;
bool has_buffers = false;
unsigned int buffer_cnt = 0;

spin_lock_irqsave(&req->lock, flags);
list_for_each_entry(obj, &req->objects, list) {
if (vb2_request_object_is_buffer(obj)) {
has_buffers = true;
break;
}
}
list_for_each_entry(obj, &req->objects, list)
if (vb2_request_object_is_buffer(obj))
buffer_cnt++;
spin_unlock_irqrestore(&req->lock, flags);
return has_buffers;

return buffer_cnt;
}
EXPORT_SYMBOL_GPL(vb2_request_has_buffers);
EXPORT_SYMBOL_GPL(vb2_request_buffer_cnt);

int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/common/videobuf2/videobuf2-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ int vb2_request_validate(struct media_request *req)
struct media_request_object *obj;
int ret = 0;

if (!vb2_request_has_buffers(req))
if (!vb2_request_buffer_cnt(req))
return -ENOENT;

list_for_each_entry(obj, &req->objects, list) {
Expand Down
4 changes: 2 additions & 2 deletions include/media/videobuf2-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,10 @@ int vb2_verify_memory_type(struct vb2_queue *q,
bool vb2_request_object_is_buffer(struct media_request_object *obj);

/**
* vb2_request_has_buffers() - return true if the request contains buffers
* vb2_request_buffer_cnt() - return the number of buffers in the request
*
* @req: the request.
*/
bool vb2_request_has_buffers(struct media_request *req);
unsigned int vb2_request_buffer_cnt(struct media_request *req);

#endif /* _MEDIA_VIDEOBUF2_CORE_H */

0 comments on commit 515c5a7

Please sign in to comment.