Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sakari Ailus and committed by
Hans Verkuil
04f541ce 5a0400ac

+11 -4
+8 -3
drivers/media/v4l2-core/v4l2-ctrls-core.c
··· 1631 1631 EXPORT_SYMBOL(v4l2_ctrl_handler_init_class); 1632 1632 1633 1633 /* Free all controls and control refs */ 1634 - void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) 1634 + int v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) 1635 1635 { 1636 1636 struct v4l2_ctrl_ref *ref, *next_ref; 1637 1637 struct v4l2_ctrl *ctrl, *next_ctrl; 1638 1638 struct v4l2_subscribed_event *sev, *next_sev; 1639 1639 1640 - if (hdl == NULL || hdl->buckets == NULL) 1641 - return; 1640 + if (!hdl) 1641 + return 0; 1642 + 1643 + if (!hdl->buckets) 1644 + return hdl->error; 1642 1645 1643 1646 v4l2_ctrl_handler_free_request(hdl); 1644 1647 ··· 1666 1663 hdl->cached = NULL; 1667 1664 mutex_unlock(hdl->lock); 1668 1665 mutex_destroy(&hdl->_lock); 1666 + 1667 + return hdl->error; 1669 1668 } 1670 1669 EXPORT_SYMBOL(v4l2_ctrl_handler_free); 1671 1670
+3 -1
include/media/v4l2-ctrls.h
··· 579 579 * @hdl: The control handler. 580 580 * 581 581 * Does nothing if @hdl == NULL. 582 + * 583 + * Return: @hdl's error field or 0 if @hdl is NULL. 582 584 */ 583 - void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl); 585 + int v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl); 584 586 585 587 /** 586 588 * v4l2_ctrl_lock() - Helper function to lock the handler