diff mbox series

[v5,06/23] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure

Message ID 20190306211343.15302-7-dafna3@gmail.com (mailing list archive)
State New, archived
Headers show
Series support for stateless decoder | expand

Commit Message

Dafna Hirschfeld March 6, 2019, 9:13 p.m. UTC
If one of the controls fails to set,
then 'v4l2_ctrl_request_setup'
immediately returns with the error code.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 18 +++++++++++-------
 include/media/v4l2-ctrls.h           |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)

Comments

Paul Kocialkowski March 12, 2019, 3:40 p.m. UTC | #1
Hi Dafna,

On Wed, 2019-03-06 at 13:13 -0800, Dafna Hirschfeld wrote:
> If one of the controls fails to set,
> then 'v4l2_ctrl_request_setup'
> immediately returns with the error code.

Very neat idea, the error should definitely be propagated!

We should update the cedrus driver to take this into account, marking
both src/dst buffers as error (as suggested by Hans on IRC).

> Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Cheers,

Paul

> ---
>  drivers/media/v4l2-core/v4l2-ctrls.c | 18 +++++++++++-------
>  include/media/v4l2-ctrls.h           |  2 +-
>  2 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index b79d3bbd8350..54d66dbc2a31 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -3899,18 +3899,19 @@ void v4l2_ctrl_request_complete(struct media_request *req,
>  }
>  EXPORT_SYMBOL(v4l2_ctrl_request_complete);
>  
> -void v4l2_ctrl_request_setup(struct media_request *req,
> +int v4l2_ctrl_request_setup(struct media_request *req,
>  			     struct v4l2_ctrl_handler *main_hdl)
>  {
>  	struct media_request_object *obj;
>  	struct v4l2_ctrl_handler *hdl;
>  	struct v4l2_ctrl_ref *ref;
> +	int ret = 0;
>  
>  	if (!req || !main_hdl)
> -		return;
> +		return 0;
>  
>  	if (WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED))
> -		return;
> +		return -EBUSY;
>  
>  	/*
>  	 * Note that it is valid if nothing was found. It means
> @@ -3919,10 +3920,10 @@ void v4l2_ctrl_request_setup(struct media_request *req,
>  	 */
>  	obj = media_request_object_find(req, &req_ops, main_hdl);
>  	if (!obj)
> -		return;
> +		return 0;
>  	if (obj->completed) {
>  		media_request_object_put(obj);
> -		return;
> +		return -EBUSY;
>  	}
>  	hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj);
>  
> @@ -3990,12 +3991,15 @@ void v4l2_ctrl_request_setup(struct media_request *req,
>  				update_from_auto_cluster(master);
>  		}
>  
> -		try_or_set_cluster(NULL, master, true, 0);
> -
> +		ret = try_or_set_cluster(NULL, master, true, 0);
>  		v4l2_ctrl_unlock(master);
> +
> +		if (ret)
> +			break;
>  	}
>  
>  	media_request_object_put(obj);
> +	return ret;
>  }
>  EXPORT_SYMBOL(v4l2_ctrl_request_setup);
>  
> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
> index e5cae37ced2d..200f8a66ecaa 100644
> --- a/include/media/v4l2-ctrls.h
> +++ b/include/media/v4l2-ctrls.h
> @@ -1127,7 +1127,7 @@ __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
>   * applying control values in a request is only applicable to memory-to-memory
>   * devices.
>   */
> -void v4l2_ctrl_request_setup(struct media_request *req,
> +int v4l2_ctrl_request_setup(struct media_request *req,
>  			     struct v4l2_ctrl_handler *parent);
>  
>  /**
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index b79d3bbd8350..54d66dbc2a31 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -3899,18 +3899,19 @@  void v4l2_ctrl_request_complete(struct media_request *req,
 }
 EXPORT_SYMBOL(v4l2_ctrl_request_complete);
 
-void v4l2_ctrl_request_setup(struct media_request *req,
+int v4l2_ctrl_request_setup(struct media_request *req,
 			     struct v4l2_ctrl_handler *main_hdl)
 {
 	struct media_request_object *obj;
 	struct v4l2_ctrl_handler *hdl;
 	struct v4l2_ctrl_ref *ref;
+	int ret = 0;
 
 	if (!req || !main_hdl)
-		return;
+		return 0;
 
 	if (WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED))
-		return;
+		return -EBUSY;
 
 	/*
 	 * Note that it is valid if nothing was found. It means
@@ -3919,10 +3920,10 @@  void v4l2_ctrl_request_setup(struct media_request *req,
 	 */
 	obj = media_request_object_find(req, &req_ops, main_hdl);
 	if (!obj)
-		return;
+		return 0;
 	if (obj->completed) {
 		media_request_object_put(obj);
-		return;
+		return -EBUSY;
 	}
 	hdl = container_of(obj, struct v4l2_ctrl_handler, req_obj);
 
@@ -3990,12 +3991,15 @@  void v4l2_ctrl_request_setup(struct media_request *req,
 				update_from_auto_cluster(master);
 		}
 
-		try_or_set_cluster(NULL, master, true, 0);
-
+		ret = try_or_set_cluster(NULL, master, true, 0);
 		v4l2_ctrl_unlock(master);
+
+		if (ret)
+			break;
 	}
 
 	media_request_object_put(obj);
+	return ret;
 }
 EXPORT_SYMBOL(v4l2_ctrl_request_setup);
 
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index e5cae37ced2d..200f8a66ecaa 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -1127,7 +1127,7 @@  __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
  * applying control values in a request is only applicable to memory-to-memory
  * devices.
  */
-void v4l2_ctrl_request_setup(struct media_request *req,
+int v4l2_ctrl_request_setup(struct media_request *req,
 			     struct v4l2_ctrl_handler *parent);
 
 /**