mirror of https://github.com/torvalds/linux.git
media: v4l2-ctrls: Return the handler's error in v4l2_ctrl_handler_free()
v4l2_ctrl_handler_free() used to return void but changing this to int, returning the handler's error code, enables the drivers to simply return the handler's error in this common error handling pattern: if (handler->error) return v4l2_ctrl_handler_free(handler); Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
This commit is contained in:
parent
5a0400aca5
commit
04f541cef2
|
|
@ -1631,14 +1631,17 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
|
||||||
EXPORT_SYMBOL(v4l2_ctrl_handler_init_class);
|
EXPORT_SYMBOL(v4l2_ctrl_handler_init_class);
|
||||||
|
|
||||||
/* Free all controls and control refs */
|
/* Free all controls and control refs */
|
||||||
void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
|
int v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
|
||||||
{
|
{
|
||||||
struct v4l2_ctrl_ref *ref, *next_ref;
|
struct v4l2_ctrl_ref *ref, *next_ref;
|
||||||
struct v4l2_ctrl *ctrl, *next_ctrl;
|
struct v4l2_ctrl *ctrl, *next_ctrl;
|
||||||
struct v4l2_subscribed_event *sev, *next_sev;
|
struct v4l2_subscribed_event *sev, *next_sev;
|
||||||
|
|
||||||
if (hdl == NULL || hdl->buckets == NULL)
|
if (!hdl)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
|
if (!hdl->buckets)
|
||||||
|
return hdl->error;
|
||||||
|
|
||||||
v4l2_ctrl_handler_free_request(hdl);
|
v4l2_ctrl_handler_free_request(hdl);
|
||||||
|
|
||||||
|
|
@ -1663,6 +1666,8 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
|
||||||
hdl->cached = NULL;
|
hdl->cached = NULL;
|
||||||
mutex_unlock(hdl->lock);
|
mutex_unlock(hdl->lock);
|
||||||
mutex_destroy(&hdl->_lock);
|
mutex_destroy(&hdl->_lock);
|
||||||
|
|
||||||
|
return hdl->error;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(v4l2_ctrl_handler_free);
|
EXPORT_SYMBOL(v4l2_ctrl_handler_free);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -579,8 +579,10 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
|
||||||
* @hdl: The control handler.
|
* @hdl: The control handler.
|
||||||
*
|
*
|
||||||
* Does nothing if @hdl == NULL.
|
* Does nothing if @hdl == NULL.
|
||||||
|
*
|
||||||
|
* Return: @hdl's error field or 0 if @hdl is NULL.
|
||||||
*/
|
*/
|
||||||
void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
|
int v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v4l2_ctrl_lock() - Helper function to lock the handler
|
* v4l2_ctrl_lock() - Helper function to lock the handler
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue