From 80ff4ad4c62f7b7694327712f1aaf5a38eae4a61 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 11 May 2019 14:48:13 +0100 Subject: staging: vc04_services: bcm2835-camera: remove redundant assignment to variable ret The variable ret is being initialized however this is never read and later it is being reassigned to a new value. The initialization is redundant and hence can be removed. Addresses-Coverity: ("Unused Value") Signed-off-by: Colin Ian King Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 9841c30450ce..74410fedffad 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -579,7 +579,7 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, struct v4l2_ctrl *ctrl, const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl) { - int ret = -EINVAL; + int ret; struct vchiq_mmal_port *control; control = &dev->component[MMAL_COMPONENT_CAMERA]->control; -- cgit v1.2.3 From 061ca1401f96c254e7f179bf97a1fc5c7f47e1e1 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:33 +0200 Subject: staging: vchiq_2835_arm: revert "quit using custom down_interruptible()" The killable version of down() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: ff5979ad8636 ("staging: vchiq_2835_arm: quit using custom down_interruptible()") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index a9a22917ecdb..49d3b39b1059 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -514,7 +514,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) (g_cache_line_size - 1)))) { char *fragments; - if (down_killable(&g_free_fragments_sema)) { + if (down_interruptible(&g_free_fragments_sema) != 0) { cleanup_pagelistinfo(pagelistinfo); return NULL; } -- cgit v1.2.3 From 086efbabdc04563268372aaef4d66039d85ee76c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:34 +0200 Subject: staging: vchiq: revert "switch to wait_for_completion_killable" The killable version of wait_for_completion() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: a772f116702e ("staging: vchiq: switch to wait_for_completion_killable") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 21 +++++++++++---------- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 21 +++++++++++---------- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 6 +++--- 3 files changed, 25 insertions(+), 23 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ab7d6a0ce94c..62d8f599e765 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -532,7 +532,8 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, vchiq_log_trace(vchiq_arm_log_level, "%s - completion queue full", __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); - if (wait_for_completion_killable(&instance->remove_event)) { + if (wait_for_completion_interruptible( + &instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); return VCHIQ_RETRY; @@ -643,7 +644,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, } DEBUG_TRACE(SERVICE_CALLBACK_LINE); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &user_service->remove_event) != 0) { vchiq_log_info(vchiq_arm_log_level, @@ -978,7 +979,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) has been closed until the client library calls the CLOSE_DELIVERED ioctl, signalling close_event. */ if (user_service->close_pending && - wait_for_completion_killable( + wait_for_completion_interruptible( &user_service->close_event)) status = VCHIQ_RETRY; break; @@ -1154,7 +1155,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) DEBUG_TRACE(AWAIT_COMPLETION_LINE); mutex_unlock(&instance->completion_mutex); - rc = wait_for_completion_killable( + rc = wait_for_completion_interruptible( &instance->insert_event); mutex_lock(&instance->completion_mutex); if (rc != 0) { @@ -1324,7 +1325,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) do { spin_unlock(&msg_queue_spinlock); DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &user_service->insert_event)) { vchiq_log_info(vchiq_arm_log_level, "DEQUEUE_MESSAGE interrupted"); @@ -2328,7 +2329,7 @@ vchiq_keepalive_thread_func(void *v) while (1) { long rc = 0, uc = 0; - if (wait_for_completion_killable(&arm_state->ka_evt) + if (wait_for_completion_interruptible(&arm_state->ka_evt) != 0) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); @@ -2579,7 +2580,7 @@ block_resume(struct vchiq_arm_state *arm_state) write_unlock_bh(&arm_state->susp_res_lock); vchiq_log_info(vchiq_susp_log_level, "%s wait for previously " "blocked clients", __func__); - if (wait_for_completion_killable_timeout( + if (wait_for_completion_interruptible_timeout( &arm_state->blocked_blocker, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2605,7 +2606,7 @@ block_resume(struct vchiq_arm_state *arm_state) write_unlock_bh(&arm_state->susp_res_lock); vchiq_log_info(vchiq_susp_log_level, "%s wait for resume", __func__); - if (wait_for_completion_killable_timeout( + if (wait_for_completion_interruptible_timeout( &arm_state->vc_resume_complete, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2812,7 +2813,7 @@ vchiq_arm_force_suspend(struct vchiq_state *state) do { write_unlock_bh(&arm_state->susp_res_lock); - rc = wait_for_completion_killable_timeout( + rc = wait_for_completion_interruptible_timeout( &arm_state->vc_suspend_complete, msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS)); @@ -2908,7 +2909,7 @@ vchiq_arm_allow_resume(struct vchiq_state *state) write_unlock_bh(&arm_state->susp_res_lock); if (resume) { - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &arm_state->vc_resume_complete) < 0) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 0c387b6473a5..c65cf1e6f910 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -560,7 +560,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) remote_event_signal(&state->remote->trigger); if (!is_blocking || - (wait_for_completion_killable( + (wait_for_completion_interruptible( &state->slot_available_event))) return NULL; /* No space available */ } @@ -830,7 +830,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &state->data_quota_event)) return VCHIQ_RETRY; @@ -861,7 +861,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, service_quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &service_quota->quota_event)) return VCHIQ_RETRY; if (service->closing) @@ -1710,7 +1710,8 @@ parse_rx_slots(struct vchiq_state *state) &service->bulk_rx : &service->bulk_tx; DEBUG_TRACE(PARSE_LINE); - if (mutex_lock_killable(&service->bulk_mutex)) { + if (mutex_lock_killable( + &service->bulk_mutex) != 0) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -2428,7 +2429,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) QMFLAGS_IS_BLOCKING); if (status == VCHIQ_SUCCESS) { /* Wait for the ACK/NAK */ - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && @@ -2795,7 +2796,7 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { - if (wait_for_completion_killable(&state->connect)) + if (wait_for_completion_interruptible(&state->connect)) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -2894,7 +2895,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -2955,7 +2956,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -3038,7 +3039,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; @@ -3115,7 +3116,7 @@ waiting: if (bulk_waiter) { bulk_waiter->bulk = bulk; - if (wait_for_completion_killable(&bulk_waiter->event)) + if (wait_for_completion_interruptible(&bulk_waiter->event)) status = VCHIQ_RETRY; else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) status = VCHIQ_ERROR; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 6c519d8e48cb..8ee85c5e6f77 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -50,7 +50,7 @@ void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) return; while (queue->write == queue->read + queue->size) { - if (wait_for_completion_killable(&queue->pop)) + if (wait_for_completion_interruptible(&queue->pop)) flush_signals(current); } @@ -63,7 +63,7 @@ void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue) { while (queue->write == queue->read) { - if (wait_for_completion_killable(&queue->push)) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } @@ -77,7 +77,7 @@ struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue) struct vchiq_header *header; while (queue->write == queue->read) { - if (wait_for_completion_killable(&queue->push)) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } -- cgit v1.2.3 From 77cf3f5dcf35c8f547f075213dbc15146d44cc76 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:35 +0200 Subject: staging: vchiq: make wait events interruptible The killable version of wait_event() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. Wait events in VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: 852b2876a8a8 ("staging: vchiq: rework remove_event handling") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index c65cf1e6f910..44bfa890e0e5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -395,13 +395,21 @@ remote_event_create(wait_queue_head_t *wq, struct remote_event *event) init_waitqueue_head(wq); } +/* + * All the event waiting routines in VCHIQ used a custom semaphore + * implementation that filtered most signals. This achieved a behaviour similar + * to the "killable" family of functions. While cleaning up this code all the + * routines where switched to the "interruptible" family of functions, as the + * former was deemed unjustified and the use "killable" set all VCHIQ's + * threads in D state. + */ static inline int remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) { if (!event->fired) { event->armed = 1; dsb(sy); - if (wait_event_killable(*wq, event->fired)) { + if (wait_event_interruptible(*wq, event->fired)) { event->armed = 0; return 0; } -- cgit v1.2.3 From 023dbe17dd38ae6b9d232e5f6144ce65befbf84d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:36 +0200 Subject: staging: vchiq: stop explicitly comparing with zero to catch errors The vchiq code tends to follow a coding pattern that's not accepted as per the Linux kernel coding style We have this: if (expression != 0) We want this: if (expression) We make an exception if the expression refers to a size, in which case it's accepted for the sake of clarity. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 11 ++-- .../interface/vchiq_arm/vchiq_2835_arm.c | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 66 ++++++++++------------ .../interface/vchiq_arm/vchiq_connected.c | 4 +- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 28 +++++---- .../interface/vchiq_arm/vchiq_debugfs.c | 4 +- 6 files changed, 52 insertions(+), 63 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 68f08dc18da9..57f79c153277 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -327,7 +327,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, "%s: status:%d, buf:%p, length:%lu, flags %u, pts %lld\n", __func__, status, buf, length, mmal_flags, pts); - if (status != 0) { + if (status) { /* error in transfer */ if (buf) { /* there was a buffer with the error so return it */ @@ -359,8 +359,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, } } else { if (dev->capture.frame_count) { - if (dev->capture.vc_start_timestamp != -1 && - pts != 0) { + if (dev->capture.vc_start_timestamp != -1 && pts) { ktime_t timestamp; s64 runtime_us = pts - dev->capture.vc_start_timestamp; @@ -826,7 +825,7 @@ static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) { /* only a single camera input */ - if (inp->index != 0) + if (inp->index) return -EINVAL; inp->type = V4L2_INPUT_TYPE_CAMERA; @@ -842,7 +841,7 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) static int vidioc_s_input(struct file *file, void *priv, unsigned int i) { - if (i != 0) + if (i) return -EINVAL; return 0; @@ -1281,7 +1280,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, } ret = mmal_setup_components(dev, f); - if (ret != 0) { + if (ret) { v4l2_err(&dev->v4l2_dev, "%s: failed to setup mmal components: %d\n", __func__, ret); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 49d3b39b1059..cb588c0b9364 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -514,7 +514,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) (g_cache_line_size - 1)))) { char *fragments; - if (down_interruptible(&g_free_fragments_sema) != 0) { + if (down_interruptible(&g_free_fragments_sema)) { cleanup_pagelistinfo(pagelistinfo); return NULL; } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 62d8f599e765..9264a07cf160 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -238,7 +238,7 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); - if (mutex_lock_killable(&state->mutex) != 0) + if (mutex_lock_killable(&state->mutex)) return VCHIQ_RETRY; /* Remove all services */ @@ -280,7 +280,7 @@ VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); - if (mutex_lock_killable(&state->mutex) != 0) { + if (mutex_lock_killable(&state->mutex)) { vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", __func__); status = VCHIQ_RETRY; @@ -645,8 +645,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, DEBUG_TRACE(SERVICE_CALLBACK_LINE); if (wait_for_completion_interruptible( - &user_service->remove_event) - != 0) { + &user_service->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); @@ -850,7 +849,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } rc = mutex_lock_killable(&instance->state->mutex); - if (rc != 0) { + if (rc) { vchiq_log_error(vchiq_arm_log_level, "vchiq: connect: could not lock mutex for " "state %d: %d", @@ -874,9 +873,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) void *userdata; int srvstate; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -940,7 +938,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &(((struct vchiq_create_service __user *) arg)->handle), (const void *)&service->handle, - sizeof(service->handle)) != 0) { + sizeof(service->handle))) { ret = -EFAULT; vchiq_remove_service(service->handle); } @@ -1015,9 +1013,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_QUEUE_MESSAGE: { struct vchiq_queue_message args; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1049,9 +1046,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1125,7 +1121,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &(((struct vchiq_queue_bulk_transfer __user *) arg)->mode), (const void *)&mode_waiting, - sizeof(mode_waiting)) != 0) + sizeof(mode_waiting))) ret = -EFAULT; } } break; @@ -1140,7 +1136,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } if (copy_from_user(&args, (const void __user *)arg, - sizeof(args)) != 0) { + sizeof(args))) { ret = -EFAULT; break; } @@ -1158,7 +1154,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = wait_for_completion_interruptible( &instance->insert_event); mutex_lock(&instance->completion_mutex); - if (rc != 0) { + if (rc) { DEBUG_TRACE(AWAIT_COMPLETION_LINE); vchiq_log_info(vchiq_arm_log_level, "AWAIT_COMPLETION interrupted"); @@ -1224,7 +1220,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_from_user(&msgbuf, (const void __user *) &args.msgbufs[msgbufcount], - sizeof(msgbuf)) != 0) { + sizeof(msgbuf))) { if (ret == 0) ret = -EFAULT; break; @@ -1232,7 +1228,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* Copy the message to user space */ if (copy_to_user(msgbuf, header, - msglen) != 0) { + msglen)) { if (ret == 0) ret = -EFAULT; break; @@ -1257,8 +1253,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) (size_t)args.buf + ret * sizeof(struct vchiq_completion_data)), completion, - sizeof(struct vchiq_completion_data)) - != 0) { + sizeof(struct vchiq_completion_data))) { if (ret == 0) ret = -EFAULT; break; @@ -1278,13 +1273,13 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &((struct vchiq_await_completion *)arg) ->msgbufcount, &msgbufcount, - sizeof(msgbufcount)) != 0) { + sizeof(msgbufcount))) { ret = -EFAULT; } } } - if (ret != 0) + if (ret) complete(&instance->remove_event); mutex_unlock(&instance->completion_mutex); DEBUG_TRACE(AWAIT_COMPLETION_LINE); @@ -1296,9 +1291,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_header *header; DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1384,7 +1378,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_config config; if (copy_from_user(&args, (const void __user *)arg, - sizeof(args)) != 0) { + sizeof(args))) { ret = -EFAULT; break; } @@ -1403,9 +1397,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_SET_SERVICE_OPTION: { struct vchiq_set_service_option args; - if (copy_from_user( - &args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -2329,8 +2322,7 @@ vchiq_keepalive_thread_func(void *v) while (1) { long rc = 0, uc = 0; - if (wait_for_completion_interruptible(&arm_state->ka_evt) - != 0) { + if (wait_for_completion_interruptible(&arm_state->ka_evt)) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); flush_signals(current); @@ -3011,7 +3003,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, vchiq_log_info(vchiq_susp_log_level, "%s %s resume " "blocked - waiting...", __func__, entity); if (wait_for_completion_killable( - &arm_state->resume_blocker) != 0) { + &arm_state->resume_blocker)) { vchiq_log_error(vchiq_susp_log_level, "%s %s " "wait for resume blocker interrupted", __func__, entity); @@ -3060,7 +3052,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, vchiq_log_info(vchiq_susp_log_level, "%s %s wait for resume", __func__, entity); if (wait_for_completion_killable( - &arm_state->vc_resume_complete) != 0) { + &arm_state->vc_resume_complete)) { vchiq_log_error(vchiq_susp_log_level, "%s %s wait for " "resume interrupted", __func__, entity); ret = VCHIQ_ERROR; @@ -3505,13 +3497,13 @@ static int vchiq_probe(struct platform_device *pdev) platform_set_drvdata(pdev, drvdata); err = vchiq_platform_init(pdev, &g_state); - if (err != 0) + if (err) goto failed_platform_init; cdev_init(&vchiq_cdev, &vchiq_fops); vchiq_cdev.owner = THIS_MODULE; err = cdev_add(&vchiq_cdev, vchiq_devid, 1); - if (err != 0) { + if (err) { vchiq_log_error(vchiq_arm_log_level, "Unable to register device"); goto failed_platform_init; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c index e87e6619695e..1640906e3929 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -41,7 +41,7 @@ void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback) { connected_init(); - if (mutex_lock_killable(&g_connected_mutex) != 0) + if (mutex_lock_killable(&g_connected_mutex)) return; if (g_connected) @@ -76,7 +76,7 @@ void vchiq_call_connected_callbacks(void) connected_init(); - if (mutex_lock_killable(&g_connected_mutex) != 0) + if (mutex_lock_killable(&g_connected_mutex)) return; for (i = 0; i < g_num_deferred_callbacks; i++) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 44bfa890e0e5..44f0eb64952a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -800,7 +800,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, WARN_ON(!(stride <= VCHIQ_SLOT_SIZE)); if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && - (mutex_lock_killable(&state->slot_mutex) != 0)) + mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (type == VCHIQ_MSG_DATA) { @@ -812,8 +812,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_ERROR; } - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); if (service->closing) { /* The service has been closed */ @@ -874,7 +874,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_RETRY; if (service->closing) return VCHIQ_ERROR; - if (mutex_lock_killable(&state->slot_mutex) != 0) + if (mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (service->srvstate != VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ @@ -912,8 +912,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, header, size, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); callback_result = copy_message_data(copy_callback, context, @@ -1040,8 +1040,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, local = state->local; - if ((VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME) && - (mutex_lock_killable(&state->sync_mutex) != 0)) + if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME && + mutex_lock_killable(&state->sync_mutex)) return VCHIQ_RETRY; remote_event_wait(&state->sync_release_event, &local->sync_release); @@ -1718,8 +1718,7 @@ parse_rx_slots(struct vchiq_state *state) &service->bulk_rx : &service->bulk_tx; DEBUG_TRACE(PARSE_LINE); - if (mutex_lock_killable( - &service->bulk_mutex) != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -2523,7 +2522,7 @@ do_abort_bulks(struct vchiq_service *service) VCHIQ_STATUS_T status; /* Abort any outstanding bulk transfers */ - if (mutex_lock_killable(&service->bulk_mutex) != 0) + if (mutex_lock_killable(&service->bulk_mutex)) return 0; abort_outstanding_bulks(service, &service->bulk_tx); abort_outstanding_bulks(service, &service->bulk_rx); @@ -3038,7 +3037,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, queue = (dir == VCHIQ_BULK_TRANSMIT) ? &service->bulk_tx : &service->bulk_rx; - if (mutex_lock_killable(&service->bulk_mutex) != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3052,8 +3051,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, status = VCHIQ_RETRY; goto error_exit; } - if (mutex_lock_killable(&service->bulk_mutex) - != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3081,7 +3079,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, /* The slot mutex must be held when the service is being closed, so claim it here to ensure that isn't happening */ - if (mutex_lock_killable(&state->slot_mutex) != 0) { + if (mutex_lock_killable(&state->slot_mutex)) { status = VCHIQ_RETRY; goto cancel_bulk_error_exit; } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 2bb9120883fd..f217b78d95a0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -86,7 +86,7 @@ static ssize_t debugfs_log_write(struct file *file, if (count >= DEBUGFS_WRITE_BUF_SIZE) count = DEBUGFS_WRITE_BUF_SIZE; - if (copy_from_user(kbuf, buffer, count) != 0) + if (copy_from_user(kbuf, buffer, count)) return -EFAULT; kbuf[count - 1] = 0; @@ -151,7 +151,7 @@ static ssize_t debugfs_trace_write(struct file *file, VCHIQ_INSTANCE_T instance = f->private; char firstchar; - if (copy_from_user(&firstchar, buffer, 1) != 0) + if (copy_from_user(&firstchar, buffer, 1)) return -EFAULT; switch (firstchar) { -- cgit v1.2.3 From 37d13c28eb4c2463e3ac4fedc81d8a801b2127d0 Mon Sep 17 00:00:00 2001 From: Madhumitha Prabakaran Date: Thu, 16 May 2019 16:33:40 -0500 Subject: Staging: bcm2835-camera: Prefer kernel types Fix the warning issued by checkpatch Prefer kernel type 'u32' over 'uint32_t'. Along with that include a blank line after a declaration to maintain Linux kernel coding style. Signed-off-by: Madhumitha Prabakaran Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 3 ++- drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 74410fedffad..5ad957e23895 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -52,7 +52,8 @@ static const s64 ev_bias_qmenu[] = { static const s64 iso_qmenu[] = { 0, 100000, 200000, 400000, 800000, }; -static const uint32_t iso_values[] = { + +static const u32 iso_values[] = { 0, 100, 200, 400, 800, }; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index d1c57edbe2b8..90793c9f9a0f 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -309,7 +309,7 @@ struct mmal_msg_port_parameter_set { u32 port_handle; /* port */ u32 id; /* Parameter ID */ u32 size; /* Parameter size */ - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE]; + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; struct mmal_msg_port_parameter_set_reply { @@ -331,7 +331,7 @@ struct mmal_msg_port_parameter_get_reply { u32 status; /* Status of mmal_port_parameter_get call */ u32 id; /* Parameter ID */ u32 size; /* Parameter size */ - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE]; + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; /* event messages */ -- cgit v1.2.3 From 313cca245d4b85189b3fc7e75e4fef837b2ed4e2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 31 May 2019 14:39:26 +0100 Subject: staging: vc04_services: remove redundant assignment to pointer service Pointer service is being set to NULL however this value is never read and so the assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 13910d205fce..17a4f2c8d8b1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -639,10 +639,8 @@ int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) if (service) { VCHIQ_STATUS_T status = vchiq_close_service(service->handle); - if (status == VCHIQ_SUCCESS) { + if (status == VCHIQ_SUCCESS) service_free(service); - service = NULL; - } ret = vchiq_status_to_vchi(status); } -- cgit v1.2.3 From 7bce355180a82961e1fbc06e62ee0aba9053bad0 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Fri, 7 Jun 2019 01:59:45 -0400 Subject: Staging: vc04_services : vchiq_core: Fix a brace issue Remove braces in a single line if statement in the vchiq_core.c file Signed-off-by: Maxime Desroches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 44f0eb64952a..0dca6e834ffa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3100,9 +3100,8 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, QMFLAGS_IS_BLOCKING | QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) { + if (status != VCHIQ_SUCCESS) goto unlock_both_error_exit; - } queue->local_insert++; -- cgit v1.2.3 From 74a2f3cb321261c7e985523e8386609f34928223 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:01 +0530 Subject: staging: vc04_services: Remove function vchiu_queue_is_full() Remove unused function vchiu_queue_is_full. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 5 ----- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h | 1 - 2 files changed, 6 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 8ee85c5e6f77..5e6d3035dc05 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -39,11 +39,6 @@ int vchiu_queue_is_empty(struct vchiu_queue *queue) return queue->read == queue->write; } -int vchiu_queue_is_full(struct vchiu_queue *queue) -{ - return queue->write == queue->read + queue->size; -} - void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) { if (!queue->initialized) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index ee1459468171..f03a4250de0d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -40,7 +40,6 @@ extern int vchiu_queue_init(struct vchiu_queue *queue, int size); extern void vchiu_queue_delete(struct vchiu_queue *queue); extern int vchiu_queue_is_empty(struct vchiu_queue *queue); -extern int vchiu_queue_is_full(struct vchiu_queue *queue); extern void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header); -- cgit v1.2.3 From 49bc145285f8c8be6ad446cd000e1e2fb70407f0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:02 +0530 Subject: staging: vc04_services: Remove function vchiq_arm_allow_resume() Remove unused function vchiq_arm_allow_resume. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 43 ---------------------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 3 -- 2 files changed, 46 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 9264a07cf160..bf7c1e2bce67 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2883,49 +2883,6 @@ out: vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__); } -int -vchiq_arm_allow_resume(struct vchiq_state *state) -{ - struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - int resume = 0; - int ret = -1; - - if (!arm_state) - goto out; - - vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); - - write_lock_bh(&arm_state->susp_res_lock); - unblock_resume(arm_state); - resume = vchiq_check_resume(state); - write_unlock_bh(&arm_state->susp_res_lock); - - if (resume) { - if (wait_for_completion_interruptible( - &arm_state->vc_resume_complete) < 0) { - vchiq_log_error(vchiq_susp_log_level, - "%s interrupted", __func__); - /* failed, cannot accurately derive suspend - * state, so exit early. */ - goto out; - } - } - - read_lock_bh(&arm_state->susp_res_lock); - if (arm_state->vc_suspend_state == VC_SUSPEND_SUSPENDED) { - vchiq_log_info(vchiq_susp_log_level, - "%s: Videocore remains suspended", __func__); - } else { - vchiq_log_info(vchiq_susp_log_level, - "%s: Videocore resumed", __func__); - ret = 0; - } - read_unlock_bh(&arm_state->susp_res_lock); -out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, ret); - return ret; -} - /* This function should be called with the write lock held */ int vchiq_check_resume(struct vchiq_state *state) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index c1d5a9d17071..61b15278c999 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -115,9 +115,6 @@ vchiq_arm_vcsuspend(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_arm_force_suspend(struct vchiq_state *state); -extern int -vchiq_arm_allow_resume(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_arm_vcresume(struct vchiq_state *state); -- cgit v1.2.3 From 248a58a3d765733218d7a64207a51d204ffec46a Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:03 +0530 Subject: staging: vc04_services: Remove vchiq_arm_force_suspend() Remove unused function vchiq_arm_force_suspend. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 120 --------------------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 3 - 2 files changed, 123 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index bf7c1e2bce67..6e59470d44ab 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2741,126 +2741,6 @@ output_msg: } -/* Try to get videocore into suspended state, regardless of autosuspend state. -** We don't actually force suspend, since videocore may get into a bad state -** if we force suspend at a bad time. Instead, we wait for autosuspend to -** determine a good point to suspend. If this doesn't happen within 100ms we -** report failure. -** -** Returns VCHIQ_SUCCESS if videocore suspended successfully, VCHIQ_RETRY if -** videocore failed to suspend in time or VCHIQ_ERROR if interrupted. -*/ -VCHIQ_STATUS_T -vchiq_arm_force_suspend(struct vchiq_state *state) -{ - struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T status = VCHIQ_ERROR; - long rc = 0; - int repeat = -1; - - if (!arm_state) - goto out; - - vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); - - write_lock_bh(&arm_state->susp_res_lock); - - status = block_resume(arm_state); - if (status != VCHIQ_SUCCESS) - goto unlock; - if (arm_state->vc_suspend_state == VC_SUSPEND_SUSPENDED) { - /* Already suspended - just block resume and exit */ - vchiq_log_info(vchiq_susp_log_level, "%s already suspended", - __func__); - status = VCHIQ_SUCCESS; - goto unlock; - } else if (arm_state->vc_suspend_state <= VC_SUSPEND_IDLE) { - /* initiate suspend immediately in the case that we're waiting - * for the timeout */ - stop_suspend_timer(arm_state); - if (!vchiq_videocore_wanted(state)) { - vchiq_log_info(vchiq_susp_log_level, "%s videocore " - "idle, initiating suspend", __func__); - status = vchiq_arm_vcsuspend(state); - } else if (arm_state->autosuspend_override < - FORCE_SUSPEND_FAIL_MAX) { - vchiq_log_info(vchiq_susp_log_level, "%s letting " - "videocore go idle", __func__); - status = VCHIQ_SUCCESS; - } else { - vchiq_log_warning(vchiq_susp_log_level, "%s failed too " - "many times - attempting suspend", __func__); - status = vchiq_arm_vcsuspend(state); - } - } else { - vchiq_log_info(vchiq_susp_log_level, "%s videocore suspend " - "in progress - wait for completion", __func__); - status = VCHIQ_SUCCESS; - } - - /* Wait for suspend to happen due to system idle (not forced..) */ - if (status != VCHIQ_SUCCESS) - goto unblock_resume; - - do { - write_unlock_bh(&arm_state->susp_res_lock); - - rc = wait_for_completion_interruptible_timeout( - &arm_state->vc_suspend_complete, - msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS)); - - write_lock_bh(&arm_state->susp_res_lock); - if (rc < 0) { - vchiq_log_warning(vchiq_susp_log_level, "%s " - "interrupted waiting for suspend", __func__); - status = VCHIQ_ERROR; - goto unblock_resume; - } else if (rc == 0) { - if (arm_state->vc_suspend_state > VC_SUSPEND_IDLE) { - /* Repeat timeout once if in progress */ - if (repeat < 0) { - repeat = 1; - continue; - } - } - arm_state->autosuspend_override++; - output_timeout_error(state); - - status = VCHIQ_RETRY; - goto unblock_resume; - } - } while (0 < (repeat--)); - - /* Check and report state in case we need to abort ARM suspend */ - if (arm_state->vc_suspend_state != VC_SUSPEND_SUSPENDED) { - status = VCHIQ_RETRY; - vchiq_log_error(vchiq_susp_log_level, - "%s videocore suspend failed (state %s)", __func__, - suspend_state_names[arm_state->vc_suspend_state + - VC_SUSPEND_NUM_OFFSET]); - /* Reset the state only if it's still in an error state. - * Something could have already initiated another suspend. */ - if (arm_state->vc_suspend_state < VC_SUSPEND_IDLE) - set_suspend_state(arm_state, VC_SUSPEND_IDLE); - - goto unblock_resume; - } - - /* successfully suspended - unlock and exit */ - goto unlock; - -unblock_resume: - /* all error states need to unblock resume before exit */ - unblock_resume(arm_state); - -unlock: - write_unlock_bh(&arm_state->susp_res_lock); - -out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, status); - return status; -} - void vchiq_check_suspend(struct vchiq_state *state) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 61b15278c999..b424323e9613 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -112,9 +112,6 @@ vchiq_get_state(void); extern VCHIQ_STATUS_T vchiq_arm_vcsuspend(struct vchiq_state *state); -extern VCHIQ_STATUS_T -vchiq_arm_force_suspend(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_arm_vcresume(struct vchiq_state *state); -- cgit v1.2.3 From a4013c6422f09bf92530f40ead3cc44d94b83829 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:04 +0530 Subject: staging: vc04_services: Remove vchiq_pause_internal() Remove unused function vchiq_pause_internal. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 23 ---------------------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 26 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 0dca6e834ffa..7f093b2679ae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2830,29 +2830,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_pause_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - switch (state->conn_state) { - case VCHIQ_CONNSTATE_CONNECTED: - /* Request a pause */ - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSING); - request_poll(state, NULL, 0); - break; - default: - vchiq_log_error(vchiq_core_log_level, - "%s in state %s\n", - __func__, conn_state_names[state->conn_state]); - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - break; - } - - return status; -} - VCHIQ_STATUS_T vchiq_resume_internal(struct vchiq_state *state) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index aee2d362e88d..b319031145ed 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -518,9 +518,6 @@ vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T -vchiq_pause_internal(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_resume_internal(struct vchiq_state *state); -- cgit v1.2.3 From 49d07ccb75201d56796b8891c6f9be64922e6064 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:05 +0530 Subject: staging: vc04_services: Remove vchiq_resume_internal() Remove unused function vchiq_resume_internal. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 16 ---------------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 19 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7f093b2679ae..5e231cc5c87d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2830,22 +2830,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_resume_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_RESUMING); - request_poll(state, NULL, 0); - } else { - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - } - - return status; -} - VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index b319031145ed..b5e09d52b202 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -518,9 +518,6 @@ vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T -vchiq_resume_internal(struct vchiq_state *state); - extern void remote_event_pollall(struct vchiq_state *state); -- cgit v1.2.3 From 6795dbb8609d0782aa74691c55c129d3a20091e0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:06 +0530 Subject: staging: vc04_services: Remove vchiq_use_service_no_resume() Remove unused function vchiq_use_service_no_resume. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 14 -------------- .../staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 2 -- 2 files changed, 16 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6e59470d44ab..a97076c18a0f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3072,20 +3072,6 @@ static void suspend_timer_callback(struct timer_list *t) vchiq_check_suspend(state); } -VCHIQ_STATUS_T -vchiq_use_service_no_resume(VCHIQ_SERVICE_HANDLE_T handle) -{ - VCHIQ_STATUS_T ret = VCHIQ_ERROR; - struct vchiq_service *service = find_service_by_handle(handle); - - if (service) { - ret = vchiq_use_internal(service->state, service, - USE_TYPE_SERVICE_NO_RESUME); - unlock_service(service); - } - return ret; -} - VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 5445f201e284..c23bd105c40f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -107,8 +107,6 @@ extern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, extern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_use_service_no_resume( - VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, -- cgit v1.2.3 From bf1ca0c6c208dfbf5af2d49cff31153358a1815b Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:07 +0530 Subject: staging: vc04_services: Remove vchiq_send_remote_release() Remove unused function vchiq_send_remote_release. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ----------- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 14 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 5e231cc5c87d..183f5cf887e0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3538,17 +3538,6 @@ VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_release(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_RETRY; - - if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) - status = queue_message(state, NULL, - VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_RELEASE, 0, 0), - NULL, NULL, 0, 0); - return status; -} - VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index b5e09d52b202..63f71b2a492f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -639,9 +639,6 @@ vchiq_on_remote_use_active(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state); -extern VCHIQ_STATUS_T -vchiq_send_remote_release(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state); -- cgit v1.2.3 From efe06b2317f9eca18caedfc852f94e312a250f66 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:08 +0530 Subject: staging: vc04_services: Remove function output_timeout_error() Remove function output_timeout_error as it was only called by vchiq_arm_force_suspend, which was deleted in a previous patch. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 36 ---------------------- 1 file changed, 36 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index a97076c18a0f..ebf7e2a3bd3b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2705,42 +2705,6 @@ out: return; } -static void -output_timeout_error(struct vchiq_state *state) -{ - struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - char err[50] = ""; - int vc_use_count = arm_state->videocore_use_count; - int active_services = state->unused_service; - int i; - - if (!arm_state->videocore_use_count) { - snprintf(err, sizeof(err), " Videocore usecount is 0"); - goto output_msg; - } - for (i = 0; i < active_services; i++) { - struct vchiq_service *service_ptr = state->services[i]; - - if (service_ptr && service_ptr->service_use_count && - (service_ptr->srvstate != VCHIQ_SRVSTATE_FREE)) { - snprintf(err, sizeof(err), " %c%c%c%c(%d) service has " - "use count %d%s", VCHIQ_FOURCC_AS_4CHARS( - service_ptr->base.fourcc), - service_ptr->client_id, - service_ptr->service_use_count, - service_ptr->service_use_count == - vc_use_count ? "" : " (+ more)"); - break; - } - } - -output_msg: - vchiq_log_error(vchiq_susp_log_level, - "timed out waiting for vc suspend (%d).%s", - arm_state->autosuspend_override, err); - -} - void vchiq_check_suspend(struct vchiq_state *state) { -- cgit v1.2.3 From 4a808fa3aa48663d6432e1078dea498b0e72e5d2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:09 +0530 Subject: staging: vc04_services: Remove function block_resume() Remove function block_resume as it was only called by vchiq_arm_force_suspend, which was removed in a previous patch. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 66 ---------------------- 1 file changed, 66 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ebf7e2a3bd3b..cc4383d1ec3e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2554,72 +2554,6 @@ need_resume(struct vchiq_state *state) vchiq_videocore_wanted(state); } -static int -block_resume(struct vchiq_arm_state *arm_state) -{ - int status = VCHIQ_SUCCESS; - const unsigned long timeout_val = - msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS); - int resume_count = 0; - - /* Allow any threads which were blocked by the last force suspend to - * complete if they haven't already. Only give this one shot; if - * blocked_count is incremented after blocked_blocker is completed - * (which only happens when blocked_count hits 0) then those threads - * will have to wait until next time around */ - if (arm_state->blocked_count) { - reinit_completion(&arm_state->blocked_blocker); - write_unlock_bh(&arm_state->susp_res_lock); - vchiq_log_info(vchiq_susp_log_level, "%s wait for previously " - "blocked clients", __func__); - if (wait_for_completion_interruptible_timeout( - &arm_state->blocked_blocker, timeout_val) - <= 0) { - vchiq_log_error(vchiq_susp_log_level, "%s wait for " - "previously blocked clients failed", __func__); - status = VCHIQ_ERROR; - write_lock_bh(&arm_state->susp_res_lock); - goto out; - } - vchiq_log_info(vchiq_susp_log_level, "%s previously blocked " - "clients resumed", __func__); - write_lock_bh(&arm_state->susp_res_lock); - } - - /* We need to wait for resume to complete if it's in process */ - while (arm_state->vc_resume_state != VC_RESUME_RESUMED && - arm_state->vc_resume_state > VC_RESUME_IDLE) { - if (resume_count > 1) { - status = VCHIQ_ERROR; - vchiq_log_error(vchiq_susp_log_level, "%s waited too " - "many times for resume", __func__); - goto out; - } - write_unlock_bh(&arm_state->susp_res_lock); - vchiq_log_info(vchiq_susp_log_level, "%s wait for resume", - __func__); - if (wait_for_completion_interruptible_timeout( - &arm_state->vc_resume_complete, timeout_val) - <= 0) { - vchiq_log_error(vchiq_susp_log_level, "%s wait for " - "resume failed (%s)", __func__, - resume_state_names[arm_state->vc_resume_state + - VC_RESUME_NUM_OFFSET]); - status = VCHIQ_ERROR; - write_lock_bh(&arm_state->susp_res_lock); - goto out; - } - vchiq_log_info(vchiq_susp_log_level, "%s resumed", __func__); - write_lock_bh(&arm_state->susp_res_lock); - resume_count++; - } - reinit_completion(&arm_state->resume_blocker); - arm_state->resume_blocked = 1; - -out: - return status; -} - static inline void unblock_resume(struct vchiq_arm_state *arm_state) { -- cgit v1.2.3 From f816db1dc17b99b059325f41ed5a78f85d15368c Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 26 Jun 2019 17:48:11 +0200 Subject: staging: bcm2835-camera: Restore return behavior of ctrl_set_bitrate() The commit 52c4dfcead49 ("Staging: vc04_services: Cleanup in ctrl_set_bitrate()") changed the return behavior of ctrl_set_bitrate(). We cannot do this because of a bug in the firmware, which breaks probing of bcm2835-camera: bcm2835-v4l2: mmal_init: failed to set all camera controls: -3 Cleanup: Destroy video encoder Cleanup: Destroy image encoder Cleanup: Destroy video render Cleanup: Destroy camera bcm2835-v4l2: bcm2835_mmal_probe: mmal init failed: -3 bcm2835-camera: probe of bcm2835-camera failed with error -3 So restore the old behavior, add an explaining comment and a debug message to verify that the bug has been fixed in firmware. Fixes: 52c4dfcead49 ("Staging: vc04_services: Cleanup in ctrl_set_bitrate()") Signed-off-by: Stefan Wahren Cc: stable Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/controls.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'drivers/staging/vc04_services') diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index d60e378bdfce..c251164655ba 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -604,15 +604,28 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev, struct v4l2_ctrl *ctrl, const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl) { + int ret; struct vchiq_mmal_port *encoder_out; dev->capture.encode_bitrate = ctrl->val; encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; - return vchiq_mmal_port_parameter_set(dev->instance, encoder_out, - mmal_ctrl->mmal_id, &ctrl->val, - sizeof(ctrl->val)); + ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out, + mmal_ctrl->mmal_id, &ctrl->val, + sizeof(ctrl->val)); + + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "%s: After: mmal_ctrl:%p ctrl id:0x%x ctrl val:%d ret %d(%d)\n", + __func__, mmal_ctrl, ctrl->id, ctrl->val, ret, + (ret == 0 ?