From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF9A7C3DA6E for ; Fri, 23 Dec 2022 12:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236225AbiLWMYg (ORCPT ); Fri, 23 Dec 2022 07:24:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236118AbiLWMYc (ORCPT ); Fri, 23 Dec 2022 07:24:32 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A013722D; Fri, 23 Dec 2022 04:24:28 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 41BF1881; Fri, 23 Dec 2022 13:24:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798266; bh=i+l5WvbdnzZvotT55RfMmOFaGgJdX/zxUqBtEXLbNJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGx0wLoN+oS6yp+YTlIesB2KwWJUSeCvUWzj4tg0I3BfFQ5izfJjyM/6E+vD3eiIa 1hjQRqxrsmDYdH5hTEbnNNAuNvGWvr9rnMvfHBB1taLPn5L2efe4RogNIDeMtqLyHq Viyf/FtNFsK0923pznBhpZEfpNBU5lfnHcgcEFQs= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 1/7] staging: vc04_services: Replace vchiq_status return type to int Date: Fri, 23 Dec 2022 17:53:58 +0530 Message-Id: <20221223122404.170585-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Modify the functions' signature using enum vchiq_status to return int. Currently, this patch only touches the function signatures and in subsequent patches each vchiq_status enumerated value will be replaced by a integer value. This patch acts as an initial point to address the TODO item: * Get rid of custom function return values for vc04_services/interface. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../bcm2835-audio/bcm2835-vchiq.c | 8 +-- .../include/linux/raspberrypi/vchiq.h | 59 +++++++++---------- .../interface/vchiq_arm/vchiq_arm.c | 32 +++++----- .../interface/vchiq_arm/vchiq_arm.h | 12 ++-- .../interface/vchiq_arm/vchiq_core.c | 34 +++++------ .../interface/vchiq_arm/vchiq_core.h | 18 +++--- .../interface/vchiq_arm/vchiq_ioctl.h | 8 +-- .../vc04_services/vchiq-mmal/mmal-vchiq.c | 7 +-- 8 files changed, 88 insertions(+), 90 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/= drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index f4c2c9506d86..0fd92affc264 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -91,10 +91,10 @@ static int bcm2835_audio_send_simple(struct bcm2835_aud= io_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } =20 -static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_= instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, void *userdata) +static int audio_vchi_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, void *userdata) { struct bcm2835_audio_instance *instance =3D vchiq_get_service_userdata(vc= hiq_instance, handle); diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index db1441c0cc66..71f4cb5d5cfd 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -57,11 +57,11 @@ struct vchiq_instance; =20 struct vchiq_service_base { int fourcc; - enum vchiq_status (*callback)(struct vchiq_instance *instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; }; =20 @@ -74,11 +74,11 @@ struct vchiq_completion_data_kernel { =20 struct vchiq_service_params_kernel { int fourcc; - enum vchiq_status (*callback)(struct vchiq_instance *instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ @@ -86,33 +86,32 @@ struct vchiq_service_params_kernel { =20 struct vchiq_instance; =20 -extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstanc= e); -extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instanc= e, - const struct vchiq_service_params_kernel *params, - unsigned int *pservice); -extern enum vchiq_status vchiq_close_service(struct vchiq_instance *instan= ce, - unsigned int service); -extern enum vchiq_status vchiq_use_service(struct vchiq_instance *instance= , unsigned int service); -extern enum vchiq_status vchiq_release_service(struct vchiq_instance *inst= ance, - unsigned int service); +extern int vchiq_initialise(struct vchiq_instance **pinstance); +extern int vchiq_shutdown(struct vchiq_instance *instance); +extern int vchiq_connect(struct vchiq_instance *instance); +extern int vchiq_open_service(struct vchiq_instance *instance, + const struct vchiq_service_params_kernel *params, + unsigned int *pservice); +extern int vchiq_close_service(struct vchiq_instance *instance, + unsigned int service); +extern int vchiq_use_service(struct vchiq_instance *instance, unsigned int= service); +extern int vchiq_release_service(struct vchiq_instance *instance, + unsigned int service); extern void vchiq_msg_queue_push(struct vchiq_instance *instance, unsigned= int handle, struct vchiq_header *header); extern void vchiq_release_message(struct vchiq_instance *instance, unsigne= d int service, struct vchiq_header *header); extern int vchiq_queue_kernel_message(struct vchiq_instance *instance, uns= igned int handle, void *data, unsigned int size); -extern enum vchiq_status vchiq_bulk_transmit(struct vchiq_instance *instan= ce, unsigned int service, - const void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instanc= e, unsigned int service, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); +extern int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned i= nt service, + const void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned in= t service, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); extern void *vchiq_get_service_userdata(struct vchiq_instance *instance, u= nsigned int service); -extern enum vchiq_status vchiq_get_peer_version(struct vchiq_instance *ins= tance, - unsigned int handle, - short *peer_version); +extern int vchiq_get_peer_version(struct vchiq_instance *instance, unsigne= d int handle, + short *peer_version); extern struct vchiq_header *vchiq_msg_hold(struct vchiq_instance *instance= , unsigned int handle); =20 #endif /* VCHIQ_H */ 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 dc33490ba7fb..fa92c34890e0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -151,7 +151,7 @@ static struct semaphore g_free_fragments_sema; =20 static DEFINE_SEMAPHORE(g_free_fragments_mutex); =20 -static enum vchiq_status +static int vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); =20 @@ -722,7 +722,7 @@ void free_bulk_waiter(struct vchiq_instance *instance) } } =20 -enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance) +int vchiq_shutdown(struct vchiq_instance *instance) { enum vchiq_status status =3D VCHIQ_SUCCESS; struct vchiq_state *state =3D instance->state; @@ -749,7 +749,7 @@ static int vchiq_is_connected(struct vchiq_instance *in= stance) return instance->connected; } =20 -enum vchiq_status vchiq_connect(struct vchiq_instance *instance) +int vchiq_connect(struct vchiq_instance *instance) { enum vchiq_status status; struct vchiq_state *state =3D instance->state; @@ -773,7 +773,7 @@ enum vchiq_status vchiq_connect(struct vchiq_instance *= instance) } EXPORT_SYMBOL(vchiq_connect); =20 -static enum vchiq_status +static int vchiq_add_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) @@ -803,7 +803,7 @@ vchiq_add_service(struct vchiq_instance *instance, return status; } =20 -enum vchiq_status +int vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) @@ -835,7 +835,7 @@ vchiq_open_service(struct vchiq_instance *instance, } EXPORT_SYMBOL(vchiq_open_service); =20 -enum vchiq_status +int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, = const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { @@ -873,9 +873,9 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, un= signed int handle, const } EXPORT_SYMBOL(vchiq_bulk_transmit); =20 -enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsi= gned int handle, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode) +int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handl= e, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode) { enum vchiq_status status; =20 @@ -910,7 +910,7 @@ enum vchiq_status vchiq_bulk_receive(struct vchiq_insta= nce *instance, unsigned i } EXPORT_SYMBOL(vchiq_bulk_receive); =20 -static enum vchiq_status +static int vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, void *data, unsigned int size, enum vchiq_bulk_dir dir) { @@ -983,7 +983,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl return status; } =20 -static enum vchiq_status +static int add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) @@ -1044,7 +1044,7 @@ add_completion(struct vchiq_instance *instance, enum = vchiq_reason reason, return VCHIQ_SUCCESS; } =20 -enum vchiq_status +int service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { @@ -1314,7 +1314,7 @@ vchiq_get_state(void) * Autosuspend related functionality */ =20 -static enum vchiq_status +static int vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, @@ -1587,7 +1587,7 @@ vchiq_instance_set_trace(struct vchiq_instance *insta= nce, int trace) instance->trace =3D (trace !=3D 0); } =20 -enum vchiq_status +int vchiq_use_service(struct vchiq_instance *instance, unsigned int handle) { enum vchiq_status ret =3D VCHIQ_ERROR; @@ -1601,7 +1601,7 @@ vchiq_use_service(struct vchiq_instance *instance, un= signed int handle) } EXPORT_SYMBOL(vchiq_use_service); =20 -enum vchiq_status +int vchiq_release_service(struct vchiq_instance *instance, unsigned int handle) { enum vchiq_status ret =3D VCHIQ_ERROR; @@ -1695,7 +1695,7 @@ vchiq_dump_service_use_state(struct vchiq_state *stat= e) kfree(service_data); } =20 -enum vchiq_status +int vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_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 2851ef6b9cd0..2fb31f9b527f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -85,13 +85,13 @@ extern struct vchiq_state g_state; extern struct vchiq_state * vchiq_get_state(void); =20 -enum vchiq_status +int vchiq_use_service(struct vchiq_instance *instance, unsigned int handle); =20 -extern enum vchiq_status +extern int vchiq_release_service(struct vchiq_instance *instance, unsigned int handle= ); =20 -extern enum vchiq_status +extern int vchiq_check_service(struct vchiq_service *service); =20 extern void @@ -100,10 +100,10 @@ vchiq_dump_platform_use_state(struct vchiq_state *sta= te); extern void vchiq_dump_service_use_state(struct vchiq_state *state); =20 -extern enum vchiq_status +extern int vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *servic= e, enum USE_TYPE_E use_type); -extern enum vchiq_status +extern int vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service); =20 @@ -137,7 +137,7 @@ static inline int vchiq_register_chrdev(struct device *= parent) { return 0; } =20 #endif /* IS_ENABLED(CONFIG_VCHIQ_CDEV) */ =20 -extern enum vchiq_status +extern int service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason = reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata); =20 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 45ed30bfdbf5..a543c29b1598 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -463,7 +463,7 @@ mark_service_closing(struct vchiq_service *service) mark_service_closing_internal(service, 0); } =20 -static inline enum vchiq_status +static inline int make_service_callback(struct vchiq_service *service, enum vchiq_reason rea= son, struct vchiq_header *header, void *bulk_userdata) { @@ -900,7 +900,7 @@ copy_message_data(ssize_t (*copy_callback)(void *contex= t, void *dest, size_t off } =20 /* Called by the slot handler and application threads */ -static enum vchiq_status +static int queue_message(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1139,7 +1139,7 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, } =20 /* Called by the slot handler and application threads */ -static enum vchiq_status +static int queue_message_sync(struct vchiq_state *state, struct vchiq_service *servic= e, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1299,7 +1299,7 @@ get_bulk_reason(struct vchiq_bulk *bulk) } =20 /* Called by the slot handler - don't hold the bulk mutex */ -static enum vchiq_status +static int notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { @@ -2486,7 +2486,7 @@ vchiq_add_service_internal(struct vchiq_state *state, return service; } =20 -enum vchiq_status +int vchiq_open_service_internal(struct vchiq_service *service, int client_id) { struct vchiq_open_payload payload =3D { @@ -2609,7 +2609,7 @@ do_abort_bulks(struct vchiq_service *service) return (status =3D=3D VCHIQ_SUCCESS); } =20 -static enum vchiq_status +static int close_service_complete(struct vchiq_service *service, int failstate) { enum vchiq_status status; @@ -2674,7 +2674,7 @@ close_service_complete(struct vchiq_service *service,= int failstate) } =20 /* Called by the slot handler */ -enum vchiq_status +int vchiq_close_service_internal(struct vchiq_service *service, int close_recv= d) { struct vchiq_state *state =3D service->state; @@ -2832,7 +2832,7 @@ vchiq_free_service_internal(struct vchiq_service *ser= vice) vchiq_service_put(service); } =20 -enum vchiq_status +int vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *i= nstance) { struct vchiq_service *service; @@ -2879,7 +2879,7 @@ vchiq_shutdown_internal(struct vchiq_state *state, st= ruct vchiq_instance *instan } } =20 -enum vchiq_status +int vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) { /* Unregister the service */ @@ -2937,7 +2937,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) } EXPORT_SYMBOL(vchiq_close_service); =20 -enum vchiq_status +int vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) { /* Unregister the service */ @@ -3004,9 +3004,9 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, uns= igned int handle, - void *offset, void __user *uoffset, int size, void *userdata, - enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir) +int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int hand= le, + void *offset, void __user *uoffset, int size, void *userdata, + enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); struct vchiq_bulk_queue *queue; @@ -3161,7 +3161,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_in= stance *instance, unsigned return status; } =20 -enum vchiq_status +int vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -3277,7 +3277,7 @@ release_message_sync(struct vchiq_state *state, struc= t vchiq_header *header) remote_event_signal(&state->remote->sync_release); } =20 -enum vchiq_status +int vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handl= e, short *peer_version) { enum vchiq_status status =3D VCHIQ_ERROR; @@ -3640,7 +3640,7 @@ vchiq_loud_error_footer(void) "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D"); } =20 -enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) +int vchiq_send_remote_use(struct vchiq_state *state) { if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) return VCHIQ_RETRY; @@ -3648,7 +3648,7 @@ enum vchiq_status vchiq_send_remote_use(struct vchiq_= state *state) return queue_message(state, NULL, MAKE_REMOTE_USE, NULL, NULL, 0, 0); } =20 -enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state) +int vchiq_send_remote_use_active(struct vchiq_state *state) { if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) return 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 8b4a38f5b3f2..ec3505424718 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -458,7 +458,7 @@ vchiq_init_slots(void *mem_base, int mem_size); extern int vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_z= ero, struct device *dev); =20 -extern enum vchiq_status +extern int vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *i= nstance); =20 struct vchiq_service * @@ -467,10 +467,10 @@ vchiq_add_service_internal(struct vchiq_state *state, int srvstate, struct vchiq_instance *instance, void (*userdata_term)(void *userdata)); =20 -extern enum vchiq_status +extern int vchiq_open_service_internal(struct vchiq_service *service, int client_id); =20 -extern enum vchiq_status +extern int vchiq_close_service_internal(struct vchiq_service *service, int close_recv= d); =20 extern void @@ -485,7 +485,7 @@ vchiq_shutdown_internal(struct vchiq_state *state, stru= ct vchiq_instance *instan extern void remote_event_pollall(struct vchiq_state *state); =20 -extern enum vchiq_status +extern int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, = void *offset, void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode= mode, enum vchiq_bulk_dir dir); @@ -536,7 +536,7 @@ vchiq_service_get(struct vchiq_service *service); extern void vchiq_service_put(struct vchiq_service *service); =20 -extern enum vchiq_status +extern int vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -568,13 +568,13 @@ void vchiq_on_remote_release(struct vchiq_state *stat= e); =20 int vchiq_platform_init_state(struct vchiq_state *state); =20 -enum vchiq_status vchiq_check_service(struct vchiq_service *service); +int vchiq_check_service(struct vchiq_service *service); =20 void vchiq_on_remote_use_active(struct vchiq_state *state); =20 -enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state); +int vchiq_send_remote_use(struct vchiq_state *state); =20 -enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state); +int vchiq_send_remote_use_active(struct vchiq_state *state); =20 void vchiq_platform_conn_state_changed(struct vchiq_state *state, enum vchiq_connstate oldstate, @@ -584,7 +584,7 @@ void vchiq_set_conn_state(struct vchiq_state *state, en= um vchiq_connstate newsta =20 void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem,= size_t num_bytes); =20 -enum vchiq_status vchiq_remove_service(struct vchiq_instance *instance, un= signed int service); +int vchiq_remove_service(struct vchiq_instance *instance, unsigned int ser= vice); =20 int vchiq_get_client_id(struct vchiq_instance *instance, unsigned int serv= ice); =20 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.= h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 86d77f2eeea5..96f50beace44 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -12,10 +12,10 @@ =20 struct vchiq_service_params { int fourcc; - enum vchiq_status __user (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int __user (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void __user *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/driver= s/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 294b184d4a49..038881827336 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -548,10 +548,9 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *= instance, } =20 /* incoming event service callback */ -static enum vchiq_status service_callback(struct vchiq_instance *vchiq_ins= tance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, void *bulk_ctx) +static int service_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_ctx) { struct vchiq_mmal_instance *instance =3D vchiq_get_service_userdata(vchiq= _instance, handle); u32 msg_len; --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5D90C3DA6E for ; Fri, 23 Dec 2022 12:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236242AbiLWMYn (ORCPT ); Fri, 23 Dec 2022 07:24:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236118AbiLWMYh (ORCPT ); Fri, 23 Dec 2022 07:24:37 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D09FCCF; Fri, 23 Dec 2022 04:24:35 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C471BAE; Fri, 23 Dec 2022 13:24:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798274; bh=UjcTFXFjoNpWqCvsrrzjGIni3777MtPVvHGdzIyiSxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJIKtTXo7ATc5up+NFValgfLUSQUVWTMoGXEtaq4aVZtBXW0IwpZ998WeTBYlHH+7 tC4U5Imv+bLtmzKCrItwruAF2mPR9ghsP3xZ5Dn4Zqc3vWmvz4n3dMDBALHRWZUen3 u2dKcaeilq76RVyvY1SOVFM9HuyuKD4EmFesYtTA= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 2/7] staging: vc04_services: Drop VCHIQ_SUCCESS usage Date: Fri, 23 Dec 2022 17:53:59 +0530 Message-Id: <20221223122404.170585-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the usage of VCHIQ_SUCCESS vchiq_status enum type. Replace it with 0 to report the success status. This patch acts as intermediatory to address the TODO item: * Get rid of custom function return values for vc04_services/interface. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../bcm2835-audio/bcm2835-vchiq.c | 4 +- .../include/linux/raspberrypi/vchiq.h | 1 - .../interface/vchiq_arm/vchiq_arm.c | 36 ++++++------- .../interface/vchiq_arm/vchiq_core.c | 54 +++++++++---------- .../interface/vchiq_arm/vchiq_dev.c | 18 +++---- .../vc04_services/vchiq-mmal/mmal-vchiq.c | 4 +- 6 files changed, 57 insertions(+), 60 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/= drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 0fd92affc264..d74110ca17ab 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -101,7 +101,7 @@ static int audio_vchi_callback(struct vchiq_instance *v= chiq_instance, struct vc_audio_msg *m; =20 if (reason !=3D VCHIQ_MESSAGE_AVAILABLE) - return VCHIQ_SUCCESS; + return 0; =20 m =3D (void *)header->data; if (m->type =3D=3D VC_AUDIO_MSG_TYPE_RESULT) { @@ -119,7 +119,7 @@ static int audio_vchi_callback(struct vchiq_instance *v= chiq_instance, } =20 vchiq_release_message(vchiq_instance, instance->service_handle, header); - return VCHIQ_SUCCESS; + return 0; } =20 static int diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 71f4cb5d5cfd..52c513e5cf3b 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -19,7 +19,6 @@ enum vchiq_reason { =20 enum vchiq_status { VCHIQ_ERROR =3D -1, - VCHIQ_SUCCESS =3D 0, VCHIQ_RETRY =3D 1 }; =20 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 fa92c34890e0..6e4e17272dad 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -724,7 +724,7 @@ void free_bulk_waiter(struct vchiq_instance *instance) =20 int vchiq_shutdown(struct vchiq_instance *instance) { - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; struct vchiq_state *state =3D instance->state; =20 if (mutex_lock_killable(&state->mutex)) @@ -761,7 +761,7 @@ int vchiq_connect(struct vchiq_instance *instance) } status =3D vchiq_connect_internal(state, instance); =20 - if (status =3D=3D VCHIQ_SUCCESS) + if (!status) instance->connected =3D 1; =20 mutex_unlock(&state->mutex); @@ -793,7 +793,7 @@ vchiq_add_service(struct vchiq_instance *instance, =20 if (service) { *phandle =3D service->handle; - status =3D VCHIQ_SUCCESS; + status =3D 0; } else { status =3D VCHIQ_ERROR; } @@ -822,7 +822,7 @@ vchiq_open_service(struct vchiq_instance *instance, if (service) { *phandle =3D service->handle; status =3D vchiq_open_service_internal(service, current->pid); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_remove_service(instance, service->handle); *phandle =3D VCHIQ_SERVICE_HANDLE_INVALID; } @@ -1004,7 +1004,7 @@ add_completion(struct vchiq_instance *instance, enum = vchiq_reason reason, return VCHIQ_RETRY; } else if (instance->closing) { vchiq_log_info(vchiq_arm_log_level, "service_callback closing"); - return VCHIQ_SUCCESS; + return 0; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); } @@ -1041,7 +1041,7 @@ add_completion(struct vchiq_instance *instance, enum = vchiq_reason reason, =20 complete(&instance->insert_event); =20 - return VCHIQ_SUCCESS; + return 0; } =20 int @@ -1066,14 +1066,14 @@ service_callback(struct vchiq_instance *instance, e= num vchiq_reason reason, service =3D handle_to_service(instance, handle); if (WARN_ON(!service)) { rcu_read_unlock(); - return VCHIQ_SUCCESS; + return 0; } =20 user_service =3D (struct user_service *)service->base.userdata; =20 if (!instance || instance->closing) { rcu_read_unlock(); - return VCHIQ_SUCCESS; + return 0; } =20 /* @@ -1110,7 +1110,7 @@ service_callback(struct vchiq_instance *instance, enu= m vchiq_reason reason, DEBUG_TRACE(SERVICE_CALLBACK_LINE); status =3D add_completion(instance, reason, NULL, user_service, bulk_userdata); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return status; @@ -1158,7 +1158,7 @@ service_callback(struct vchiq_instance *instance, enu= m vchiq_reason reason, vchiq_service_put(service); =20 if (skip_completion) - return VCHIQ_SUCCESS; + return 0; =20 return add_completion(instance, reason, header, user_service, bulk_userdata); @@ -1350,14 +1350,14 @@ vchiq_keepalive_thread_func(void *v) } =20 status =3D vchiq_connect(instance); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_connect failed %d", __fu= nc__, status); goto shutdown; } =20 status =3D vchiq_add_service(instance, ¶ms, &ka_handle); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_open_service failed %d",= __func__, status); goto shutdown; @@ -1386,14 +1386,14 @@ vchiq_keepalive_thread_func(void *v) while (uc--) { atomic_inc(&arm_state->ka_use_ack_count); status =3D vchiq_use_service(instance, ka_handle); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_use_service error %d", __func__, status); } } while (rc--) { status =3D vchiq_release_service(instance, ka_handle); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_release_service error %d", __func__, status); @@ -1446,13 +1446,13 @@ vchiq_use_internal(struct vchiq_state *state, struc= t vchiq_service *service, write_unlock_bh(&arm_state->susp_res_lock); =20 if (!ret) { - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; long ack_cnt =3D atomic_xchg(&arm_state->ka_use_ack_count, 0); =20 - while (ack_cnt && (status =3D=3D VCHIQ_SUCCESS)) { + while (ack_cnt && !status) { /* Send the use notify to videocore */ status =3D vchiq_send_remote_use_active(state); - if (status =3D=3D VCHIQ_SUCCESS) + if (!status) ack_cnt--; else atomic_add(ack_cnt, &arm_state->ka_use_ack_count); @@ -1708,7 +1708,7 @@ vchiq_check_service(struct vchiq_service *service) =20 read_lock_bh(&arm_state->susp_res_lock); if (service->service_use_count) - ret =3D VCHIQ_SUCCESS; + ret =3D 0; read_unlock_bh(&arm_state->susp_res_lock); =20 if (ret =3D=3D VCHIQ_ERROR) { 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 a543c29b1598..8b8f9e56d924 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -478,7 +478,7 @@ make_service_callback(struct vchiq_service *service, en= um vchiq_reason reason, vchiq_log_warning(vchiq_core_log_level, "%d: ignoring ERROR from callback to service %x", service->state->id, service->handle); - status =3D VCHIQ_SUCCESS; + status =3D 0; } =20 if (reason !=3D VCHIQ_MESSAGE_AVAILABLE) @@ -1135,7 +1135,7 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, =20 remote_event_signal(&state->remote->trigger); =20 - return VCHIQ_SUCCESS; + return 0; } =20 /* Called by the slot handler and application threads */ @@ -1223,7 +1223,7 @@ queue_message_sync(struct vchiq_state *state, struct = vchiq_service *service, if (VCHIQ_MSG_TYPE(msgid) !=3D VCHIQ_MSG_PAUSE) mutex_unlock(&state->sync_mutex); =20 - return VCHIQ_SUCCESS; + return 0; } =20 static inline void @@ -1303,7 +1303,7 @@ static int notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; =20 vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=3D%x rn=3D%x r= =3D%x", service->state->id, service->localport, (queue =3D=3D &service->bulk_tx) ? 't' : 'r', @@ -1357,7 +1357,7 @@ notify_bulks(struct vchiq_service *service, struct vc= hiq_bulk_queue *queue, complete(&service->bulk_remove_event); } if (!retry_poll) - status =3D VCHIQ_SUCCESS; + status =3D 0; =20 if (status =3D=3D VCHIQ_RETRY) request_poll(service->state, service, (queue =3D=3D &service->bulk_tx) ? @@ -1398,13 +1398,12 @@ poll_services_of_group(struct vchiq_state *state, i= nt group) */ service->public_fourcc =3D VCHIQ_FOURCC_INVALID; =20 - if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) !=3D - VCHIQ_SUCCESS) + if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_REMOVE); } else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) { vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d", state->id, service->localport, service->remoteport); - if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) !=3D VCHIQ_SU= CCESS) + if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_TERMINATE); } if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY)) @@ -2495,7 +2494,7 @@ vchiq_open_service_internal(struct vchiq_service *ser= vice, int client_id) service->version, service->version_min }; - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; =20 service->client_id =3D client_id; vchiq_use_service_internal(service); @@ -2506,7 +2505,7 @@ vchiq_open_service_internal(struct vchiq_service *ser= vice, int client_id) sizeof(payload), QMFLAGS_IS_BLOCKING); =20 - if (status !=3D VCHIQ_SUCCESS) + if (status) return status; =20 /* Wait for the ACK/NAK */ @@ -2602,11 +2601,11 @@ do_abort_bulks(struct vchiq_service *service) mutex_unlock(&service->bulk_mutex); =20 status =3D notify_bulks(service, &service->bulk_tx, NO_RETRY_POLL); - if (status !=3D VCHIQ_SUCCESS) + if (status) return 0; =20 status =3D notify_bulks(service, &service->bulk_rx, NO_RETRY_POLL); - return (status =3D=3D VCHIQ_SUCCESS); + return !status; } =20 static int @@ -2678,7 +2677,7 @@ int vchiq_close_service_internal(struct vchiq_service *service, int close_recv= d) { struct vchiq_state *state =3D service->state; - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; int is_server =3D (service->public_fourcc !=3D VCHIQ_FOURCC_INVALID); int close_id =3D MAKE_CLOSE(service->localport, VCHIQ_MSG_DSTPORT(service->remoteport)); @@ -2730,11 +2729,11 @@ vchiq_close_service_internal(struct vchiq_service *= service, int close_recvd) =20 release_service_messages(service); =20 - if (status =3D=3D VCHIQ_SUCCESS) + if (!status) status =3D queue_message(state, service, close_id, NULL, NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK); =20 - if (status !=3D VCHIQ_SUCCESS) { + if (status) { if (service->srvstate =3D=3D VCHIQ_SRVSTATE_OPENSYNC) mutex_unlock(&state->sync_mutex); break; @@ -2768,7 +2767,7 @@ vchiq_close_service_internal(struct vchiq_service *se= rvice, int close_recvd) break; } =20 - if (status =3D=3D VCHIQ_SUCCESS) + if (!status) status =3D close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD); break; =20 @@ -2862,7 +2861,7 @@ vchiq_connect_internal(struct vchiq_state *state, str= uct vchiq_instance *instanc complete(&state->connect); } =20 - return VCHIQ_SUCCESS; + return 0; } =20 void @@ -2884,7 +2883,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) { /* Unregister the service */ struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; =20 if (!service) return VCHIQ_ERROR; @@ -2926,7 +2925,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) srvstate_names[service->srvstate]); } =20 - if ((status =3D=3D VCHIQ_SUCCESS) && + if (!status && (service->srvstate !=3D VCHIQ_SRVSTATE_FREE) && (service->srvstate !=3D VCHIQ_SRVSTATE_LISTENING)) status =3D VCHIQ_ERROR; @@ -2942,7 +2941,7 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) { /* Unregister the service */ struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; =20 if (!service) return VCHIQ_ERROR; @@ -2987,8 +2986,7 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) srvstate_names[service->srvstate]); } =20 - if ((status =3D=3D VCHIQ_SUCCESS) && - (service->srvstate !=3D VCHIQ_SRVSTATE_FREE)) + if (!status && (service->srvstate !=3D VCHIQ_SRVSTATE_FREE)) status =3D VCHIQ_ERROR; =20 vchiq_service_put(service); @@ -3028,7 +3026,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, if (!offset && !uoffset) goto error_exit; =20 - if (vchiq_check_service(service) !=3D VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto error_exit; =20 switch (mode) { @@ -3121,7 +3119,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, QMFLAGS_IS_BLOCKING | QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK); - if (status !=3D VCHIQ_SUCCESS) + if (status) goto unlock_both_error_exit; =20 queue->local_insert++; @@ -3136,7 +3134,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, waiting: vchiq_service_put(service); =20 - status =3D VCHIQ_SUCCESS; + status =3D 0; =20 if (bulk_waiter) { bulk_waiter->bulk =3D bulk; @@ -3175,7 +3173,7 @@ vchiq_queue_message(struct vchiq_instance *instance, = unsigned int handle, if (!service) goto error_exit; =20 - if (vchiq_check_service(service) !=3D VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto error_exit; =20 if (!size) { @@ -3286,14 +3284,14 @@ vchiq_get_peer_version(struct vchiq_instance *insta= nce, unsigned int handle, sho if (!service) goto exit; =20 - if (vchiq_check_service(service) !=3D VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto exit; =20 if (!peer_version) goto exit; =20 *peer_version =3D service->peer_version; - status =3D VCHIQ_SUCCESS; + status =3D 0; =20 exit: if (service) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 7e297494437e..d9c4d550412e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -112,7 +112,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance= , unsigned int handle, struct vchiq_element *elements, unsigned long count) { struct vchiq_io_copy_callback_context context; - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; unsigned long i; size_t total_size =3D 0; =20 @@ -142,7 +142,7 @@ static int vchiq_ioc_create_service(struct vchiq_instan= ce *instance, { struct user_service *user_service =3D NULL; struct vchiq_service *service; - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; struct vchiq_service_params_kernel params; int srvstate; =20 @@ -190,7 +190,7 @@ static int vchiq_ioc_create_service(struct vchiq_instan= ce *instance, =20 if (args->is_open) { status =3D vchiq_open_service_internal(service, instance->pid); - if (status !=3D VCHIQ_SUCCESS) { + if (status) { vchiq_remove_service(instance, service->handle); return (status =3D=3D VCHIQ_RETRY) ? -EINTR : -EIO; @@ -577,7 +577,7 @@ static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct vchiq_instance *instance =3D file->private_data; - enum vchiq_status status =3D VCHIQ_SUCCESS; + int status =3D 0; struct vchiq_service *service =3D NULL; long ret =3D 0; int i, rc; @@ -598,12 +598,12 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsi= gned long arg) instance, &i))) { status =3D vchiq_remove_service(instance, service->handle); vchiq_service_put(service); - if (status !=3D VCHIQ_SUCCESS) + if (status) break; } service =3D NULL; =20 - if (status =3D=3D VCHIQ_SUCCESS) { + if (!status) { /* Wake the completion thread and ask it to exit */ instance->closing =3D 1; complete(&instance->insert_event); @@ -627,7 +627,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) status =3D vchiq_connect_internal(instance->state, instance); mutex_unlock(&instance->state->mutex); =20 - if (status =3D=3D VCHIQ_SUCCESS) + if (!status) instance->connected =3D 1; else vchiq_log_error(vchiq_arm_log_level, @@ -675,7 +675,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) status =3D (cmd =3D=3D VCHIQ_IOC_CLOSE_SERVICE) ? vchiq_close_service(instance, service->handle) : vchiq_remove_service(instance, service->handle); - if (status !=3D VCHIQ_SUCCESS) + if (status) break; } =20 @@ -868,7 +868,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) ret =3D -EINTR; } =20 - if ((status =3D=3D VCHIQ_SUCCESS) && (ret < 0) && (ret !=3D -EINTR) && (r= et !=3D -EWOULDBLOCK)) + if (!status && (ret < 0) && (ret !=3D -EINTR) && (ret !=3D -EWOULDBLOCK)) vchiq_log_info(vchiq_arm_log_level, " ioctl instance %pK, cmd %s -> status %d, %ld", instance, (_IOC_NR(cmd) <=3D VCHIQ_IOC_MAX) ? diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/driver= s/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 038881827336..6b5879a33780 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -559,7 +559,7 @@ static int service_callback(struct vchiq_instance *vchi= q_instance, =20 if (!instance) { pr_err("Message callback passed NULL instance\n"); - return VCHIQ_SUCCESS; + return 0; } =20 switch (reason) { @@ -643,7 +643,7 @@ static int service_callback(struct vchiq_instance *vchi= q_instance, break; } =20 - return VCHIQ_SUCCESS; + return 0; } =20 static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEC60C3DA6E for ; Fri, 23 Dec 2022 12:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236256AbiLWMYv (ORCPT ); Fri, 23 Dec 2022 07:24:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiLWMYp (ORCPT ); Fri, 23 Dec 2022 07:24:45 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA09FCCF; Fri, 23 Dec 2022 04:24:43 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 673C0492; Fri, 23 Dec 2022 13:24:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798282; bh=4vGgrqruh7jjyRCTWbh8trdOqBGMNpz0XJcv7YaOOkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1W30wFHEJMz3ZXU09Cr5dTJOe2M3yuOwN1v5tvKZkIMkIqmHhh3Y2MDLrX3KEUgT EJKzAaBThSOQVXbv+zHESQoaGrMbV49gxdVnj4t1OiOYvcfT1LM4Z+nVunTBAOiEiK qOA/jOiLKUDgVMydKeqG2M9kgpe5iUJTZePlNL0I= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 3/7] staging: vc04_services: Drop VCHIQ_ERROR usage Date: Fri, 23 Dec 2022 17:54:00 +0530 Message-Id: <20221223122404.170585-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the usage of VCHIQ_ERROR vchiq_status enum type. Replace it with -EINVAL to report the error in most cases, -ENOMEM for out-of-memory errors and -EHOSTDOWN for service shutdown. This patch acts as intermediatory to address the TODO item: * Get rid of custom function return values for vc04_services/interface. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../include/linux/raspberrypi/vchiq.h | 1 - .../interface/vchiq_arm/vchiq_arm.c | 24 +++++----- .../interface/vchiq_arm/vchiq_core.c | 44 +++++++++---------- .../interface/vchiq_arm/vchiq_dev.c | 6 +-- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 52c513e5cf3b..2ca4461d26ee 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -18,7 +18,6 @@ enum vchiq_reason { }; =20 enum vchiq_status { - VCHIQ_ERROR =3D -1, VCHIQ_RETRY =3D 1 }; =20 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 6e4e17272dad..2415baeccc9c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -501,7 +501,7 @@ int vchiq_platform_init(struct platform_device *pdev, s= truct vchiq_state *state) =20 vchiq_slot_zero =3D vchiq_init_slots(slot_mem, slot_mem_size); if (!vchiq_slot_zero) - return -EINVAL; + return -ENOMEM; =20 vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX] =3D (int)slot_phys + slot_mem_size; @@ -795,7 +795,7 @@ vchiq_add_service(struct vchiq_instance *instance, *phandle =3D service->handle; status =3D 0; } else { - status =3D VCHIQ_ERROR; + status =3D -EINVAL; } =20 vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, i= nstance, status); @@ -808,7 +808,7 @@ vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) { - enum vchiq_status status =3D VCHIQ_ERROR; + int status =3D -EINVAL; struct vchiq_state *state =3D instance->state; struct vchiq_service *service =3D NULL; =20 @@ -855,7 +855,7 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, un= signed int handle, const VCHIQ_BULK_TRANSMIT); break; default: - return VCHIQ_ERROR; + return -EINVAL; } =20 /* @@ -892,7 +892,7 @@ int vchiq_bulk_receive(struct vchiq_instance *instance,= unsigned int handle, VCHIQ_BULK_RECEIVE); break; default: - return VCHIQ_ERROR; + return -EINVAL; } =20 /* @@ -920,7 +920,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl =20 service =3D find_service_by_handle(instance, handle); if (!service) - return VCHIQ_ERROR; + return -EINVAL; =20 vchiq_service_put(service); =20 @@ -954,7 +954,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl waiter =3D kzalloc(sizeof(*waiter), GFP_KERNEL); if (!waiter) { vchiq_log_error(vchiq_core_log_level, "%s - out of memory", __func__); - return VCHIQ_ERROR; + return -ENOMEM; } } =20 @@ -1127,7 +1127,7 @@ service_callback(struct vchiq_instance *instance, enu= m vchiq_reason reason, vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); spin_lock(&msg_queue_spinlock); @@ -1590,7 +1590,7 @@ vchiq_instance_set_trace(struct vchiq_instance *insta= nce, int trace) int vchiq_use_service(struct vchiq_instance *instance, unsigned int handle) { - enum vchiq_status ret =3D VCHIQ_ERROR; + int ret =3D -EINVAL; struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); =20 if (service) { @@ -1604,7 +1604,7 @@ EXPORT_SYMBOL(vchiq_use_service); int vchiq_release_service(struct vchiq_instance *instance, unsigned int handle) { - enum vchiq_status ret =3D VCHIQ_ERROR; + int ret =3D -EINVAL; struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); =20 if (service) { @@ -1699,7 +1699,7 @@ int vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_state; - enum vchiq_status ret =3D VCHIQ_ERROR; + int ret =3D -EINVAL; =20 if (!service || !service->state) goto out; @@ -1711,7 +1711,7 @@ vchiq_check_service(struct vchiq_service *service) ret =3D 0; read_unlock_bh(&arm_state->susp_res_lock); =20 - if (ret =3D=3D VCHIQ_ERROR) { + if (ret) { vchiq_log_error(vchiq_susp_log_level, "%s ERROR - %c%c%c%c:%d service count %d, state count %d", __func__, VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->client_id, 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 8b8f9e56d924..640fdb28d1c0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -467,14 +467,14 @@ static inline int make_service_callback(struct vchiq_service *service, enum vchiq_reason rea= son, struct vchiq_header *header, void *bulk_userdata) { - enum vchiq_status status; + int status; =20 vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", service->state->id, service->localport, reason_names[reason], header, bulk_userdata); status =3D service->base.callback(service->instance, reason, header, serv= ice->handle, bulk_userdata); - if (status =3D=3D VCHIQ_ERROR) { + if (status && (status !=3D VCHIQ_RETRY)) { vchiq_log_warning(vchiq_core_log_level, "%d: ignoring ERROR from callback to service %x", service->state->id, service->handle); @@ -930,7 +930,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, if (!service) { WARN(1, "%s: service is NULL\n", __func__); mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EINVAL; } =20 WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | @@ -939,7 +939,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, if (service->closing) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EHOSTDOWN; } =20 quota =3D &state->service_quotas[service->localport]; @@ -989,13 +989,13 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, if (wait_for_completion_interruptible("a->quota_event)) return VCHIQ_RETRY; if (service->closing) - return VCHIQ_ERROR; + return -EHOSTDOWN; if (mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EHOSTDOWN; } spin_lock("a_spinlock); tx_end_index =3D SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride= - 1); @@ -1037,7 +1037,7 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, if (callback_result < 0) { mutex_unlock(&state->slot_mutex); VCHIQ_SERVICE_STATS_INC(service, error_count); - return VCHIQ_ERROR; + return -EINVAL; } =20 if (SRVTRACE_ENABLED(service, @@ -1185,7 +1185,7 @@ queue_message_sync(struct vchiq_state *state, struct = vchiq_service *service, if (callback_result < 0) { mutex_unlock(&state->slot_mutex); VCHIQ_SERVICE_STATS_INC(service, error_count); - return VCHIQ_ERROR; + return -EINVAL; } =20 if (service) { @@ -2520,7 +2520,7 @@ vchiq_open_service_internal(struct vchiq_service *ser= vice, int client_id) service->state->id, srvstate_names[service->srvstate], kref_read(&service->ref_count)); - status =3D VCHIQ_ERROR; + status =3D -EINVAL; VCHIQ_SERVICE_STATS_INC(service, error_count); vchiq_release_service_internal(service); } @@ -2638,7 +2638,7 @@ close_service_complete(struct vchiq_service *service,= int failstate) vchiq_log_error(vchiq_core_log_level, "%s(%x) called in state %s", __fun= c__, service->handle, srvstate_names[service->srvstate]); WARN(1, "%s in unexpected state\n", __func__); - return VCHIQ_ERROR; + return -EINVAL; } =20 status =3D make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NUL= L); @@ -2695,7 +2695,7 @@ vchiq_close_service_internal(struct vchiq_service *se= rvice, int close_recvd) __func__, srvstate_names[service->srvstate]); } else if (is_server) { if (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) { - status =3D VCHIQ_ERROR; + status =3D -EINVAL; } else { service->client_id =3D 0; service->remoteport =3D VCHIQ_PORT_FREE; @@ -2886,7 +2886,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) int status =3D 0; =20 if (!service) - return VCHIQ_ERROR; + return -EINVAL; =20 vchiq_log_info(vchiq_core_log_level, "%d: close_service:%d", service->state->id, service->localport); @@ -2895,7 +2895,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) || (service->srvstate =3D=3D VCHIQ_SRVSTATE_HIDDEN)) { vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } =20 mark_service_closing(service); @@ -2928,7 +2928,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) if (!status && (service->srvstate !=3D VCHIQ_SRVSTATE_FREE) && (service->srvstate !=3D VCHIQ_SRVSTATE_LISTENING)) - status =3D VCHIQ_ERROR; + status =3D -EINVAL; =20 vchiq_service_put(service); =20 @@ -2944,14 +2944,14 @@ vchiq_remove_service(struct vchiq_instance *instanc= e, unsigned int handle) int status =3D 0; =20 if (!service) - return VCHIQ_ERROR; + return -EINVAL; =20 vchiq_log_info(vchiq_core_log_level, "%d: remove_service:%d", service->state->id, service->localport); =20 if (service->srvstate =3D=3D VCHIQ_SRVSTATE_FREE) { vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } =20 mark_service_closing(service); @@ -2987,7 +2987,7 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) } =20 if (!status && (service->srvstate !=3D VCHIQ_SRVSTATE_FREE)) - status =3D VCHIQ_ERROR; + status =3D -EINVAL; =20 vchiq_service_put(service); =20 @@ -3014,7 +3014,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, const char dir_char =3D (dir =3D=3D VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; const int dir_msgtype =3D (dir =3D=3D VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; - enum vchiq_status status =3D VCHIQ_ERROR; + int status =3D -EINVAL; int payload[2]; =20 if (!service) @@ -3141,7 +3141,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, if (wait_for_completion_interruptible(&bulk_waiter->event)) status =3D VCHIQ_RETRY; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABORTED) - status =3D VCHIQ_ERROR; + status =3D -EINVAL; } =20 return status; @@ -3167,7 +3167,7 @@ vchiq_queue_message(struct vchiq_instance *instance, = unsigned int handle, size_t size) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); - enum vchiq_status status =3D VCHIQ_ERROR; + int status =3D -EINVAL; int data_id; =20 if (!service) @@ -3198,7 +3198,7 @@ vchiq_queue_message(struct vchiq_instance *instance, = unsigned int handle, copy_callback, context, size, 1); break; default: - status =3D VCHIQ_ERROR; + status =3D -EINVAL; break; } =20 @@ -3278,7 +3278,7 @@ release_message_sync(struct vchiq_state *state, struc= t vchiq_header *header) int vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handl= e, short *peer_version) { - enum vchiq_status status =3D VCHIQ_ERROR; + int status =3D -EINVAL; struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); =20 if (!service) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index d9c4d550412e..df274192937e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -130,7 +130,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance= , unsigned int handle, status =3D vchiq_queue_message(instance, handle, vchiq_ioc_copy_element_d= ata, &context, total_size); =20 - if (status =3D=3D VCHIQ_ERROR) + if (status =3D=3D -EINVAL) return -EIO; else if (status =3D=3D VCHIQ_RETRY) return -EINTR; @@ -364,7 +364,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, vchiq_service_put(service); if (ret) return ret; - else if (status =3D=3D VCHIQ_ERROR) + else if (status =3D=3D -EINVAL) return -EIO; else if (status =3D=3D VCHIQ_RETRY) return -EINTR; @@ -862,7 +862,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) vchiq_service_put(service); =20 if (ret =3D=3D 0) { - if (status =3D=3D VCHIQ_ERROR) + if (status =3D=3D -EINVAL) ret =3D -EIO; else if (status =3D=3D VCHIQ_RETRY) ret =3D -EINTR; --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34EE5C3DA6E for ; Fri, 23 Dec 2022 12:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236278AbiLWMY7 (ORCPT ); Fri, 23 Dec 2022 07:24:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236250AbiLWMYw (ORCPT ); Fri, 23 Dec 2022 07:24:52 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02109E73; Fri, 23 Dec 2022 04:24:51 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0050C881; Fri, 23 Dec 2022 13:24:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798289; bh=tIdAUZYjasufFp7wMiuzuyAHMdDEdT9Du3sMKJopgTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PfkRzrl6aSbL34btBK/BoJ8c3DrHfO4eOxilqWBpYkZc7f51+XaAivKiNsRLT3gmP 74dvif4RNvGQzrVhGsWYLClg924pO6gySYKJ5nC+2N8v3RIkhxY+m0QUDSnka+3T0r CnuLO+sa9u51TCmF2ysTY/8ut5FLckHeGFMM9UPY= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 4/7] staging: vc04_services: Drop VCHIQ_RETRY usage Date: Fri, 23 Dec 2022 17:54:01 +0530 Message-Id: <20221223122404.170585-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the usage of VCHIQ_RETRY vchiq_status enum type in most of the places and replace it with -EAGAIN. The exception to this replacement is vchiq_send_remote_use() and vchiq_send_remote_use_active() which will be addressed in the subsequent commit. This patch acts as intermediatory to address the TODO item: * Get rid of custom function return values for vc04_services/interface. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_arm.c | 18 ++--- .../interface/vchiq_arm/vchiq_core.c | 76 +++++++++---------- .../interface/vchiq_arm/vchiq_dev.c | 12 +-- 3 files changed, 53 insertions(+), 53 deletions(-) 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 2415baeccc9c..5cfad840bd18 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -728,7 +728,7 @@ int vchiq_shutdown(struct vchiq_instance *instance) struct vchiq_state *state =3D instance->state; =20 if (mutex_lock_killable(&state->mutex)) - return VCHIQ_RETRY; + return -EAGAIN; =20 /* Remove all services */ vchiq_shutdown_internal(state, instance); @@ -756,7 +756,7 @@ int vchiq_connect(struct vchiq_instance *instance) =20 if (mutex_lock_killable(&state->mutex)) { vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", _= _func__); - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; goto failed; } status =3D vchiq_connect_internal(state, instance); @@ -859,11 +859,11 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, = unsigned int handle, const } =20 /* - * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * vchiq_*_bulk_transfer() may return -EAGAIN, so we need * to implement a retry mechanism since this function is * supposed to block until queued */ - if (status !=3D VCHIQ_RETRY) + if (status !=3D -EAGAIN) break; =20 msleep(1); @@ -896,11 +896,11 @@ int vchiq_bulk_receive(struct vchiq_instance *instanc= e, unsigned int handle, } =20 /* - * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * vchiq_*_bulk_transfer() may return -EAGAIN, so we need * to implement a retry mechanism since this function is * supposed to block until queued */ - if (status !=3D VCHIQ_RETRY) + if (status !=3D -EAGAIN) break; =20 msleep(1); @@ -961,7 +961,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl status =3D vchiq_bulk_transfer(instance, handle, data, NULL, size, &waiter->bulk_waiter, VCHIQ_BULK_MODE_BLOCKING, dir); - if ((status !=3D VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter= ->bulk_waiter.bulk) { + if ((status !=3D -EAGAIN) || fatal_signal_pending(current) || !waiter->bu= lk_waiter.bulk) { struct vchiq_bulk *bulk =3D waiter->bulk_waiter.bulk; =20 if (bulk) { @@ -1001,7 +1001,7 @@ add_completion(struct vchiq_instance *instance, enum = vchiq_reason reason, DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); - return VCHIQ_RETRY; + return -EAGAIN; } else if (instance->closing) { vchiq_log_info(vchiq_arm_log_level, "service_callback closing"); return 0; @@ -1122,7 +1122,7 @@ service_callback(struct vchiq_instance *instance, enu= m vchiq_reason reason, vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); - return VCHIQ_RETRY; + return -EAGAIN; } else if (instance->closing) { vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); 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 640fdb28d1c0..9c64d5de810e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -474,7 +474,7 @@ make_service_callback(struct vchiq_service *service, en= um vchiq_reason reason, header, bulk_userdata); status =3D service->base.callback(service->instance, reason, header, serv= ice->handle, bulk_userdata); - if (status && (status !=3D VCHIQ_RETRY)) { + if (status && (status !=3D -EAGAIN)) { vchiq_log_warning(vchiq_core_log_level, "%d: ignoring ERROR from callback to service %x", service->state->id, service->handle); @@ -922,7 +922,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, =20 if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && mutex_lock_killable(&state->slot_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; =20 if (type =3D=3D VCHIQ_MSG_DATA) { int tx_end_index; @@ -963,7 +963,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, mutex_unlock(&state->slot_mutex); =20 if (wait_for_completion_interruptible(&state->data_quota_event)) - return VCHIQ_RETRY; + return -EAGAIN; =20 mutex_lock(&state->slot_mutex); spin_lock("a_spinlock); @@ -987,11 +987,11 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); if (wait_for_completion_interruptible("a->quota_event)) - return VCHIQ_RETRY; + return -EAGAIN; if (service->closing) return -EHOSTDOWN; if (mutex_lock_killable(&state->slot_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); @@ -1015,7 +1015,7 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, */ if (!(flags & QMFLAGS_NO_MUTEX_LOCK)) mutex_unlock(&state->slot_mutex); - return VCHIQ_RETRY; + return -EAGAIN; } =20 if (type =3D=3D VCHIQ_MSG_DATA) { @@ -1154,7 +1154,7 @@ queue_message_sync(struct vchiq_state *state, struct = vchiq_service *service, =20 if (VCHIQ_MSG_TYPE(msgid) !=3D VCHIQ_MSG_RESUME && mutex_lock_killable(&state->sync_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; =20 remote_event_wait(&state->sync_release_event, &local->sync_release); =20 @@ -1348,7 +1348,7 @@ notify_bulks(struct vchiq_service *service, struct vc= hiq_bulk_queue *queue, get_bulk_reason(bulk); status =3D make_service_callback(service, reason, NULL, bulk->userdata); - if (status =3D=3D VCHIQ_RETRY) + if (status =3D=3D -EAGAIN) break; } } @@ -1359,7 +1359,7 @@ notify_bulks(struct vchiq_service *service, struct vc= hiq_bulk_queue *queue, if (!retry_poll) status =3D 0; =20 - if (status =3D=3D VCHIQ_RETRY) + if (status =3D=3D -EAGAIN) request_poll(service->state, service, (queue =3D=3D &service->bulk_tx) ? VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY); =20 @@ -1526,14 +1526,14 @@ parse_open(struct vchiq_state *state, struct vchiq_= header *header) /* Acknowledge the OPEN */ if (service->sync) { if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) =3D=3D VCHIQ_RETRY) + &ack_payload, sizeof(ack_payload), 0) =3D=3D -EAGAIN) goto bail_not_ready; =20 /* The service is now open */ set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); } else { if (queue_message(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) =3D=3D VCHIQ_RETRY) + &ack_payload, sizeof(ack_payload), 0) =3D=3D -EAGAIN) goto bail_not_ready; =20 /* The service is now open */ @@ -1548,7 +1548,7 @@ parse_open(struct vchiq_state *state, struct vchiq_he= ader *header) fail_open: /* No available service, or an invalid request - send a CLOSE */ if (queue_message(state, NULL, MAKE_CLOSE(0, VCHIQ_MSG_SRCPORT(msgid)), - NULL, NULL, 0, 0) =3D=3D VCHIQ_RETRY) + NULL, NULL, 0, 0) =3D=3D -EAGAIN) goto bail_not_ready; =20 return 1; @@ -1687,7 +1687,7 @@ parse_message(struct vchiq_state *state, struct vchiq= _header *header) =20 mark_service_closing_internal(service, 1); =20 - if (vchiq_close_service_internal(service, CLOSE_RECVD) =3D=3D VCHIQ_RETR= Y) + if (vchiq_close_service_internal(service, CLOSE_RECVD) =3D=3D -EAGAIN) goto bail_not_ready; =20 vchiq_log_info(vchiq_core_log_level, "Close Service %c%c%c%c s:%u d:%d", @@ -1704,7 +1704,7 @@ parse_message(struct vchiq_state *state, struct vchiq= _header *header) claim_slot(state->rx_info); DEBUG_TRACE(PARSE_LINE); if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, - NULL) =3D=3D VCHIQ_RETRY) { + NULL) =3D=3D -EAGAIN) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -1802,7 +1802,7 @@ parse_message(struct vchiq_state *state, struct vchiq= _header *header) if (state->conn_state !=3D VCHIQ_CONNSTATE_PAUSE_SENT) { /* Send a PAUSE in response */ if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) =3D=3D VCHIQ_RETRY) + QMFLAGS_NO_MUTEX_UNLOCK) =3D=3D -EAGAIN) goto bail_not_ready; } /* At this point slot_mutex is held */ @@ -1919,7 +1919,7 @@ handle_poll(struct vchiq_state *state) =20 case VCHIQ_CONNSTATE_PAUSING: if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) !=3D VCHIQ_RETRY) { + QMFLAGS_NO_MUTEX_UNLOCK) !=3D -EAGAIN) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT); } else { /* Retry later */ @@ -1929,7 +1929,7 @@ handle_poll(struct vchiq_state *state) =20 case VCHIQ_CONNSTATE_RESUMING: if (queue_message(state, NULL, MAKE_RESUME, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_LOCK) !=3D VCHIQ_RETRY) { + QMFLAGS_NO_MUTEX_LOCK) !=3D -EAGAIN) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); } else { /* @@ -2085,9 +2085,9 @@ sync_func(void *v) if ((service->remoteport =3D=3D remoteport) && (service->srvstate =3D=3D VCHIQ_SRVSTATE_OPENSYNC)) { if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, - NULL) =3D=3D VCHIQ_RETRY) + NULL) =3D=3D -EAGAIN) vchiq_log_error(vchiq_sync_log_level, - "synchronous callback to service %d returns VCHIQ_RETRY", + "synchronous callback to service %d returns -EAGAIN", localport); } break; @@ -2510,7 +2510,7 @@ vchiq_open_service_internal(struct vchiq_service *ser= vice, int client_id) =20 /* Wait for the ACK/NAK */ if (wait_for_completion_interruptible(&service->remove_event)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; vchiq_release_service_internal(service); } else if ((service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) && (service->srvstate !=3D VCHIQ_SRVSTATE_OPENSYNC)) { @@ -2643,7 +2643,7 @@ close_service_complete(struct vchiq_service *service,= int failstate) =20 status =3D make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NUL= L); =20 - if (status !=3D VCHIQ_RETRY) { + if (status !=3D -EAGAIN) { int uc =3D service->service_use_count; int i; /* Complete the close process */ @@ -2724,7 +2724,7 @@ vchiq_close_service_internal(struct vchiq_service *se= rvice, int close_recvd) case VCHIQ_SRVSTATE_OPEN: if (close_recvd) { if (!do_abort_bulks(service)) - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; } =20 release_service_messages(service); @@ -2763,7 +2763,7 @@ vchiq_close_service_internal(struct vchiq_service *se= rvice, int close_recvd) break; =20 if (!do_abort_bulks(service)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; break; } =20 @@ -2847,15 +2847,15 @@ vchiq_connect_internal(struct vchiq_state *state, s= truct vchiq_instance *instanc =20 if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) { if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0, - QMFLAGS_IS_BLOCKING) =3D=3D VCHIQ_RETRY) - return VCHIQ_RETRY; + QMFLAGS_IS_BLOCKING) =3D=3D -EAGAIN) + return -EAGAIN; =20 vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTING); } =20 if (state->conn_state =3D=3D VCHIQ_CONNSTATE_CONNECTING) { if (wait_for_completion_interruptible(&state->connect)) - return VCHIQ_RETRY; + return -EAGAIN; =20 vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); complete(&state->connect); @@ -2902,7 +2902,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) =20 if (current =3D=3D service->state->slot_handler_thread) { status =3D vchiq_close_service_internal(service, NO_CLOSE_RECVD); - WARN_ON(status =3D=3D VCHIQ_RETRY); + WARN_ON(status =3D=3D -EAGAIN); } else { /* Mark the service for termination by the slot handler */ request_poll(service->state, service, VCHIQ_POLL_TERMINATE); @@ -2910,7 +2910,7 @@ vchiq_close_service(struct vchiq_instance *instance, = unsigned int handle) =20 while (1) { if (wait_for_completion_interruptible(&service->remove_event)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; break; } =20 @@ -2965,14 +2965,14 @@ vchiq_remove_service(struct vchiq_instance *instanc= e, unsigned int handle) service->public_fourcc =3D VCHIQ_FOURCC_INVALID; =20 status =3D vchiq_close_service_internal(service, NO_CLOSE_RECVD); - WARN_ON(status =3D=3D VCHIQ_RETRY); + WARN_ON(status =3D=3D -EAGAIN); } else { /* Mark the service for removal by the slot handler */ request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { if (wait_for_completion_interruptible(&service->remove_event)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; break; } =20 @@ -2996,7 +2996,7 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) =20 /* * This function may be called by kernel threads or user threads. - * User threads may receive VCHIQ_RETRY to indicate that a signal has been + * User threads may receive -EAGAIN to indicate that a signal has been * received and the call should be retried after being returned to user * context. * When called in blocking mode, the userdata field points to a bulk_waiter @@ -3053,7 +3053,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, &service->bulk_tx : &service->bulk_rx; =20 if (mutex_lock_killable(&service->bulk_mutex)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; goto error_exit; } =20 @@ -3062,11 +3062,11 @@ int vchiq_bulk_transfer(struct vchiq_instance *inst= ance, unsigned int handle, do { mutex_unlock(&service->bulk_mutex); if (wait_for_completion_interruptible(&service->bulk_remove_event)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; goto error_exit; } if (mutex_lock_killable(&service->bulk_mutex)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; goto error_exit; } } while (queue->local_insert =3D=3D queue->remove + @@ -3099,7 +3099,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, * claim it here to ensure that isn't happening */ if (mutex_lock_killable(&state->slot_mutex)) { - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; goto cancel_bulk_error_exit; } =20 @@ -3139,7 +3139,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instan= ce, unsigned int handle, if (bulk_waiter) { bulk_waiter->bulk =3D bulk; if (wait_for_completion_interruptible(&bulk_waiter->event)) - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABORTED) status =3D -EINVAL; } @@ -3219,11 +3219,11 @@ int vchiq_queue_kernel_message(struct vchiq_instanc= e *instance, unsigned int han data, size); =20 /* - * vchiq_queue_message() may return VCHIQ_RETRY, so we need to + * vchiq_queue_message() may return -EAGAIN, so we need to * implement a retry mechanism since this function is supposed * to block until queued */ - if (status !=3D VCHIQ_RETRY) + if (status !=3D -EAGAIN) break; =20 msleep(1); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index df274192937e..841e1a535642 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -132,7 +132,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance= , unsigned int handle, =20 if (status =3D=3D -EINVAL) return -EIO; - else if (status =3D=3D VCHIQ_RETRY) + else if (status =3D=3D -EAGAIN) return -EINTR; return 0; } @@ -192,7 +192,7 @@ static int vchiq_ioc_create_service(struct vchiq_instan= ce *instance, status =3D vchiq_open_service_internal(service, instance->pid); if (status) { vchiq_remove_service(instance, service->handle); - return (status =3D=3D VCHIQ_RETRY) ? + return (status =3D=3D -EAGAIN) ? -EINTR : -EIO; } } @@ -338,7 +338,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, goto out; } =20 - if ((status !=3D VCHIQ_RETRY) || fatal_signal_pending(current) || + if ((status !=3D -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { if (waiter->bulk_waiter.bulk) { /* Cancel the signal when the transfer completes. */ @@ -366,7 +366,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, return ret; else if (status =3D=3D -EINVAL) return -EIO; - else if (status =3D=3D VCHIQ_RETRY) + else if (status =3D=3D -EAGAIN) return -EINTR; return 0; } @@ -686,7 +686,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) */ if (user_service->close_pending && wait_for_completion_interruptible(&user_service->close_event)) - status =3D VCHIQ_RETRY; + status =3D -EAGAIN; break; } =20 @@ -864,7 +864,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsign= ed long arg) if (ret =3D=3D 0) { if (status =3D=3D -EINVAL) ret =3D -EIO; - else if (status =3D=3D VCHIQ_RETRY) + else if (status =3D=3D -EAGAIN) ret =3D -EINTR; } =20 --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1C27C4167B for ; Fri, 23 Dec 2022 12:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236289AbiLWMZD (ORCPT ); Fri, 23 Dec 2022 07:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236266AbiLWMY7 (ORCPT ); Fri, 23 Dec 2022 07:24:59 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD873722A; Fri, 23 Dec 2022 04:24:58 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D6A3492; Fri, 23 Dec 2022 13:24:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798297; bh=Uz/jtOm7K0pgw7vfRKWZw/6DeaYJhsIV5g5BVa7QStc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VVJknRnTsD/g2C3L9Kpz+ndih9fs0wSMl6r7YIwCc/pVkNqba+k09tiEKKR0fKLYY lKoF1wX/KCEktcnG6E6dk6f6DTVRgeQU/6pLnBJpAh84tqMJxJghyduMOFhVon0VHQ 2+29bsooIP+LcpXXHe0giX4Dta1bArGgYZ85zwak= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 5/7] vc04_services: vchiq_arm: Drop VCHIQ_RETRY usage on disconnect Date: Fri, 23 Dec 2022 17:54:02 +0530 Message-Id: <20221223122404.170585-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop the usage of VCHIQ_RETRY when the vchiq has connection status VCHIQ_CONNSTATE_DISCONNECTED. Disconnected status will not be valid to carry on a retry, hence replace the VCHIQ_RETRY with -ENOTCONN. This patch removes the usage of vCHIQ_RETRY completely and act as intermediatory to address the TODO item: * Get rid of custom function return values for vc04_services/interface. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 9c64d5de810e..ddb6d0f4daed 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3641,7 +3641,7 @@ vchiq_loud_error_footer(void) int vchiq_send_remote_use(struct vchiq_state *state) { if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) - return VCHIQ_RETRY; + return -ENOTCONN; =20 return queue_message(state, NULL, MAKE_REMOTE_USE, NULL, NULL, 0, 0); } @@ -3649,7 +3649,7 @@ int vchiq_send_remote_use(struct vchiq_state *state) int vchiq_send_remote_use_active(struct vchiq_state *state) { if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) - return VCHIQ_RETRY; + return -ENOTCONN; =20 return queue_message(state, NULL, MAKE_REMOTE_USE_ACTIVE, NULL, NULL, 0, 0); --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABBCC4332F for ; Fri, 23 Dec 2022 12:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236317AbiLWMZL (ORCPT ); Fri, 23 Dec 2022 07:25:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbiLWMZG (ORCPT ); Fri, 23 Dec 2022 07:25:06 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D092D3722B; Fri, 23 Dec 2022 04:25:05 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2632A881; Fri, 23 Dec 2022 13:24:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798304; bh=Teh9FEdU2+IIKkL8HiQ9YhI22GGJKUCmyjVYueFUfIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AukxRzirNyUq9LMGvC1efBHK5hFNjsMDd2L+BcxWehafa/Dqqgr/cA4dHuWwl5OIS gQR5Aj6F3J1Izc1VWO9fs5GcmzUuxZqWv9dvMZ+veLF+ORIGiEqjwKzPPzxLiYEQGT 8K5UeT7h1Re5J67+u5wTLKc8T73Kir3/q8s1Qjzo= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 6/7] staging: vc04_services: Drop enum vchiq_status remnants Date: Fri, 23 Dec 2022 17:54:03 +0530 Message-Id: <20221223122404.170585-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Drop all references to enum vchiq_status as they are no longer in use. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- .../include/linux/raspberrypi/vchiq.h | 4 ---- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 14 +++++++------- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 6 +++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 2ca4461d26ee..66965da11443 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -17,10 +17,6 @@ enum vchiq_reason { VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ }; =20 -enum vchiq_status { - VCHIQ_RETRY =3D 1 -}; - enum vchiq_bulk_mode { VCHIQ_BULK_MODE_CALLBACK, VCHIQ_BULK_MODE_BLOCKING, 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 5cfad840bd18..22de23f3af02 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -751,7 +751,7 @@ static int vchiq_is_connected(struct vchiq_instance *in= stance) =20 int vchiq_connect(struct vchiq_instance *instance) { - enum vchiq_status status; + int status; struct vchiq_state *state =3D instance->state; =20 if (mutex_lock_killable(&state->mutex)) { @@ -778,7 +778,7 @@ vchiq_add_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) { - enum vchiq_status status; + int status; struct vchiq_state *state =3D instance->state; struct vchiq_service *service =3D NULL; int srvstate; @@ -839,7 +839,7 @@ int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, = const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { - enum vchiq_status status; + int status; =20 while (1) { switch (mode) { @@ -877,7 +877,7 @@ int vchiq_bulk_receive(struct vchiq_instance *instance,= unsigned int handle, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { - enum vchiq_status status; + int status; =20 while (1) { switch (mode) { @@ -915,7 +915,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl unsigned int size, enum vchiq_bulk_dir dir) { struct vchiq_service *service; - enum vchiq_status status; + int status; struct bulk_waiter_node *waiter =3D NULL, *iter; =20 service =3D find_service_by_handle(instance, handle); @@ -1103,7 +1103,7 @@ service_callback(struct vchiq_instance *instance, enu= m vchiq_reason reason, */ if ((user_service->message_available_pos - instance->completion_remove) < 0) { - enum vchiq_status status; + int status; =20 vchiq_log_info(vchiq_arm_log_level, "Inserting extra MESSAGE_AVAILABLE"); @@ -1330,7 +1330,7 @@ vchiq_keepalive_thread_func(void *v) struct vchiq_state *state =3D (struct vchiq_state *)v; struct vchiq_arm_state *arm_state =3D vchiq_platform_get_arm_state(state); =20 - enum vchiq_status status; + int status; struct vchiq_instance *instance; unsigned int ka_handle; int ret; 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 ddb6d0f4daed..4e705a447a62 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2591,7 +2591,7 @@ release_service_messages(struct vchiq_service *servic= e) static int do_abort_bulks(struct vchiq_service *service) { - enum vchiq_status status; + int status; =20 /* Abort any outstanding bulk transfers */ if (mutex_lock_killable(&service->bulk_mutex)) @@ -2611,7 +2611,7 @@ do_abort_bulks(struct vchiq_service *service) static int close_service_complete(struct vchiq_service *service, int failstate) { - enum vchiq_status status; + int status; int is_server =3D (service->public_fourcc !=3D VCHIQ_FOURCC_INVALID); int newstate; =20 @@ -3212,7 +3212,7 @@ vchiq_queue_message(struct vchiq_instance *instance, = unsigned int handle, int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned i= nt handle, void *data, unsigned int size) { - enum vchiq_status status; + int status; =20 while (1) { status =3D vchiq_queue_message(instance, handle, memcpy_copy_callback, --=20 2.38.1 From nobody Wed Sep 17 12:27:46 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CACFAC3DA6E for ; Fri, 23 Dec 2022 12:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236321AbiLWMZT (ORCPT ); Fri, 23 Dec 2022 07:25:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236298AbiLWMZO (ORCPT ); Fri, 23 Dec 2022 07:25:14 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69004FCCF; Fri, 23 Dec 2022 04:25:13 -0800 (PST) Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:cd5d:4e48:3b91:9262:9565]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 682D0492; Fri, 23 Dec 2022 13:25:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671798312; bh=Xo4PgGMqXkAeAbAXamG4Agqq6zDHS6a3JUw2oXCCxcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNHAgoxhvTZb5g/t3sRmdo1fISxhqSourtvk2a6eUsvsZPlWCVyxocjj+Da9i7fUm RJOWfsT+76+cpSo1/4CPtZ/DgZDsJq/scSBkKsTnPPY9a2uPK4GJwDSbDcYsUpx9wC 1+hH65ZUd5Ec74/lm9JrevRiirNA5uuSBAgSLwiE= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Kees Cook , Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v3 7/7] staging: vc04_services: vchiq: Drop custom return values from TODO Date: Fri, 23 Dec 2022 17:54:04 +0530 Message-Id: <20221223122404.170585-8-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223122404.170585-1-umang.jain@ideasonboard.com> References: <20221223122404.170585-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The custom return values (enum vchiq_status) has been dropped. Remove the TODO entry for the same. Signed-off-by: Umang Jain Tested-by: Stefan Wahren --- drivers/staging/vc04_services/interface/TODO | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging= /vc04_services/interface/TODO index 97085a0b3223..6d9d4a800aa7 100644 --- a/drivers/staging/vc04_services/interface/TODO +++ b/drivers/staging/vc04_services/interface/TODO @@ -40,11 +40,6 @@ beneficial to go over all of them and, if correct, comme= nt on their merits. Extra points to whomever confidently reviews the remote_event_*() family of functions. =20 -* Get rid of custom function return values - -Most functions use a custom set of return values, we should force proper L= inux -error numbers. Special care is needed for VCHIQ_RETRY. - * Reformat core code with more sane indentations =20 The code follows the 80 characters limitation yet tends to go 3 or 4 level= s of --=20 2.38.1