diff options
Diffstat (limited to 'drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c')
-rw-r--r-- | drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 370 |
1 files changed, 190 insertions, 180 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 b1595b13dea8..02148a24818a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -84,7 +84,7 @@ static void suspend_timer_callback(struct timer_list *t); struct user_service { struct vchiq_service *service; void *userdata; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; char is_vchi; char dequeue_pending; char close_pending; @@ -103,7 +103,7 @@ struct bulk_waiter_node { struct list_head list; }; -struct vchiq_instance_struct { +struct vchiq_instance { struct vchiq_state *state; struct vchiq_completion_data completions[MAX_COMPLETIONS]; int completion_insert; @@ -172,16 +172,16 @@ static const char *const ioctl_names[] = { vchiq_static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); -static VCHIQ_STATUS_T -vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, VCHIQ_BULK_DIR_T dir); +static enum vchiq_status +vchiq_blocking_bulk_transfer(unsigned int handle, void *data, + unsigned int size, enum vchiq_bulk_dir dir); #define VCHIQ_INIT_RETRIES 10 -VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) +enum vchiq_status vchiq_initialise(struct vchiq_instance **instance_out) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state; - VCHIQ_INSTANCE_T instance = NULL; + struct vchiq_instance *instance = NULL; int i; vchiq_log_trace(vchiq_core_log_level, "%s called", __func__); @@ -230,9 +230,9 @@ failed: } EXPORT_SYMBOL(vchiq_initialise); -VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, @@ -267,14 +267,14 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) } EXPORT_SYMBOL(vchiq_shutdown); -static int vchiq_is_connected(VCHIQ_INSTANCE_T instance) +static int vchiq_is_connected(struct vchiq_instance *instance) { return instance->connected; } -VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_connect(struct vchiq_instance *instance) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, @@ -301,12 +301,12 @@ failed: } EXPORT_SYMBOL(vchiq_connect); -VCHIQ_STATUS_T vchiq_add_service( - VCHIQ_INSTANCE_T instance, +enum vchiq_status vchiq_add_service( + struct vchiq_instance *instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *phandle) + unsigned int *phandle) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; int srvstate; @@ -340,12 +340,12 @@ VCHIQ_STATUS_T vchiq_add_service( } EXPORT_SYMBOL(vchiq_add_service); -VCHIQ_STATUS_T vchiq_open_service( - VCHIQ_INSTANCE_T instance, +enum vchiq_status vchiq_open_service( + struct vchiq_instance *instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *phandle) + unsigned int *phandle) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; @@ -380,11 +380,11 @@ failed: } EXPORT_SYMBOL(vchiq_open_service); -VCHIQ_STATUS_T -vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, - unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) +enum vchiq_status +vchiq_bulk_transmit(unsigned int handle, const void *data, + unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { - VCHIQ_STATUS_T status; + enum vchiq_status status; switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: @@ -405,11 +405,11 @@ vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, } EXPORT_SYMBOL(vchiq_bulk_transmit); -VCHIQ_STATUS_T -vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) +enum vchiq_status +vchiq_bulk_receive(unsigned int handle, void *data, + unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { - VCHIQ_STATUS_T status; + enum vchiq_status status; switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: @@ -429,13 +429,13 @@ vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, } EXPORT_SYMBOL(vchiq_bulk_receive); -static VCHIQ_STATUS_T -vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, VCHIQ_BULK_DIR_T dir) +static enum vchiq_status +vchiq_blocking_bulk_transfer(unsigned int handle, void *data, + unsigned int size, enum vchiq_bulk_dir dir) { - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; struct vchiq_service *service; - VCHIQ_STATUS_T status; + enum vchiq_status status; struct bulk_waiter_node *waiter = NULL; service = find_service_by_handle(handle); @@ -515,8 +515,8 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, * ***************************************************************************/ -static VCHIQ_STATUS_T -add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, +static enum vchiq_status +add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) { @@ -582,9 +582,9 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, * ***************************************************************************/ -static VCHIQ_STATUS_T -service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, - VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) +static enum vchiq_status +service_callback(enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_userdata) { /* How do we ensure the callback goes to the right client? ** The service_user data points to a user_service record @@ -593,7 +593,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, */ struct user_service *user_service; struct vchiq_service *service; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; bool skip_completion = false; DEBUG_INITIALISE(g_state.local) @@ -630,7 +630,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, */ if ((user_service->message_available_pos - instance->completion_remove) < 0) { - VCHIQ_STATUS_T status; + enum vchiq_status status; vchiq_log_info(vchiq_arm_log_level, "Inserting extra MESSAGE_AVAILABLE"); @@ -772,8 +772,8 @@ static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, * vchiq_ioc_queue_message * **************************************************************************/ -static VCHIQ_STATUS_T -vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle, +static enum vchiq_status +vchiq_ioc_queue_message(unsigned int handle, struct vchiq_element *elements, unsigned long count) { @@ -804,8 +804,8 @@ vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle, static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_INSTANCE_T instance = file->private_data; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + struct vchiq_instance *instance = file->private_data; + enum vchiq_status status = VCHIQ_SUCCESS; struct vchiq_service *service = NULL; long ret = 0; int i, rc; @@ -827,7 +827,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* Remove all services */ i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { status = vchiq_remove_service(service->handle); unlock_service(service); if (status != VCHIQ_SUCCESS) @@ -907,7 +907,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &args.params, srvstate, instance, user_service_free); - if (service != NULL) { + if (service) { user_service->service = service; user_service->userdata = userdata; user_service->instance = instance; @@ -952,7 +952,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_CLOSE_SERVICE: case VCHIQ_IOC_REMOVE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; struct user_service *user_service; service = find_service_for_instance(instance, handle); @@ -985,10 +985,10 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_USE_SERVICE: case VCHIQ_IOC_RELEASE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; service = find_service_for_instance(instance, handle); - if (service != NULL) { + if (service) { status = (cmd == VCHIQ_IOC_USE_SERVICE) ? vchiq_use_service_internal(service) : vchiq_release_service_internal(service); @@ -1021,7 +1021,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) service = find_service_for_instance(instance, args.handle); - if ((service != NULL) && (args.count <= MAX_ELEMENTS)) { + if (service && (args.count <= MAX_ELEMENTS)) { /* Copy elements into kernel space */ struct vchiq_element elements[MAX_ELEMENTS]; @@ -1042,7 +1042,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_queue_bulk_transfer args; struct bulk_waiter_node *waiter = NULL; - VCHIQ_BULK_DIR_T dir = + enum vchiq_bulk_dir dir = (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; @@ -1107,7 +1107,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } kfree(waiter); } else { - const VCHIQ_BULK_MODE_T mode_waiting = + const enum vchiq_bulk_mode mode_waiting = VCHIQ_BULK_MODE_WAITING; waiter->pid = current->pid; mutex_lock(&instance->bulk_waiter_list_mutex); @@ -1343,11 +1343,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) spin_unlock(&msg_queue_spinlock); complete(&user_service->remove_event); - if (header == NULL) + if (!header) ret = -ENOTCONN; else if (header->size <= args.bufsize) { /* Copy to user space if msgbuf is not NULL */ - if ((args.buf == NULL) || + if (!args.buf || (copy_to_user((void __user *)args.buf, header->data, header->size) == 0)) { @@ -1368,7 +1368,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_GET_CLIENT_ID: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; ret = vchiq_get_client_id(handle); } break; @@ -1423,10 +1423,10 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_CLOSE_DELIVERED: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; service = find_closed_service_for_instance(instance, handle); - if (service != NULL) { + if (service) { struct user_service *user_service = (struct user_service *)service->base.userdata; close_delivered(user_service); @@ -1611,7 +1611,7 @@ struct vchiq_queue_bulk_transfer32 { compat_uptr_t data; unsigned int size; compat_uptr_t userdata; - VCHIQ_BULK_MODE_T mode; + enum vchiq_bulk_mode mode; }; #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 \ @@ -1666,7 +1666,7 @@ vchiq_compat_ioctl_queue_bulk(struct file *file, } struct vchiq_completion_data32 { - VCHIQ_REASON_T reason; + enum vchiq_reason reason; compat_uptr_t header; compat_uptr_t service_userdata; compat_uptr_t bulk_userdata; @@ -1919,7 +1919,7 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static int vchiq_open(struct inode *inode, struct file *file) { struct vchiq_state *state = vchiq_get_state(); - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); @@ -1951,7 +1951,7 @@ static int vchiq_open(struct inode *inode, struct file *file) static int vchiq_release(struct inode *inode, struct file *file) { - VCHIQ_INSTANCE_T instance = file->private_data; + struct vchiq_instance *instance = file->private_data; struct vchiq_state *state = vchiq_get_state(); struct vchiq_service *service; int ret = 0; @@ -2072,43 +2072,45 @@ out: * ***************************************************************************/ -void -vchiq_dump(void *dump_context, const char *str, int len) +int vchiq_dump(void *dump_context, const char *str, int len) { struct dump_context *context = (struct dump_context *)dump_context; + int copy_bytes; - if (context->actual < context->space) { - int copy_bytes; + if (context->actual >= context->space) + return 0; - if (context->offset > 0) { - int skip_bytes = min(len, (int)context->offset); + if (context->offset > 0) { + int skip_bytes = min_t(int, len, context->offset); - str += skip_bytes; - len -= skip_bytes; - context->offset -= skip_bytes; - if (context->offset > 0) - return; - } - copy_bytes = min(len, (int)(context->space - context->actual)); - if (copy_bytes == 0) - return; - if (copy_to_user(context->buf + context->actual, str, - copy_bytes)) - context->actual = -EFAULT; - context->actual += copy_bytes; - len -= copy_bytes; - - /* If tne terminating NUL is included in the length, then it - ** marks the end of a line and should be replaced with a - ** carriage return. */ - if ((len == 0) && (str[copy_bytes - 1] == '\0')) { - char cr = '\n'; - - if (copy_to_user(context->buf + context->actual - 1, - &cr, 1)) - context->actual = -EFAULT; - } + str += skip_bytes; + len -= skip_bytes; + context->offset -= skip_bytes; + if (context->offset > 0) + return 0; + } + copy_bytes = min_t(int, len, context->space - context->actual); + if (copy_bytes == 0) + return 0; + if (copy_to_user(context->buf + context->actual, str, + copy_bytes)) + return -EFAULT; + context->actual += copy_bytes; + len -= copy_bytes; + + /* + * If the terminating NUL is included in the length, then it + * marks the end of a line and should be replaced with a + * carriage return. + */ + if ((len == 0) && (str[copy_bytes - 1] == '\0')) { + char cr = '\n'; + + if (copy_to_user(context->buf + context->actual - 1, + &cr, 1)) + return -EFAULT; } + return 0; } /**************************************************************************** @@ -2117,8 +2119,7 @@ vchiq_dump(void *dump_context, const char *str, int len) * ***************************************************************************/ -void -vchiq_dump_platform_instances(void *dump_context) +int vchiq_dump_platform_instances(void *dump_context) { struct vchiq_state *state = vchiq_get_state(); char buf[80]; @@ -2130,37 +2131,43 @@ vchiq_dump_platform_instances(void *dump_context) for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = state->services[i]; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; - if (service && (service->base.callback == service_callback)) { - instance = service->instance; - if (instance) - instance->mark = 0; - } + if (!service || service->base.callback != service_callback) + continue; + + instance = service->instance; + if (instance) + instance->mark = 0; } for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = state->services[i]; - VCHIQ_INSTANCE_T instance; - - if (service && (service->base.callback == service_callback)) { - instance = service->instance; - if (instance && !instance->mark) { - len = snprintf(buf, sizeof(buf), - "Instance %pK: pid %d,%s completions %d/%d", - instance, instance->pid, - instance->connected ? " connected, " : - "", - instance->completion_insert - - instance->completion_remove, - MAX_COMPLETIONS); - - vchiq_dump(dump_context, buf, len + 1); - - instance->mark = 1; - } - } + struct vchiq_instance *instance; + int err; + + if (!service || service->base.callback != service_callback) + continue; + + instance = service->instance; + if (!instance || instance->mark) + continue; + + len = snprintf(buf, sizeof(buf), + "Instance %pK: pid %d,%s completions %d/%d", + instance, instance->pid, + instance->connected ? " connected, " : + "", + instance->completion_insert - + instance->completion_remove, + MAX_COMPLETIONS); + + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + instance->mark = 1; } + return 0; } /**************************************************************************** @@ -2169,9 +2176,8 @@ vchiq_dump_platform_instances(void *dump_context) * ***************************************************************************/ -void -vchiq_dump_platform_service_state(void *dump_context, - struct vchiq_service *service) +int vchiq_dump_platform_service_state(void *dump_context, + struct vchiq_service *service) { struct user_service *user_service = (struct user_service *)service->base.userdata; @@ -2192,7 +2198,7 @@ vchiq_dump_platform_service_state(void *dump_context, " (dequeue pending)"); } - vchiq_dump(dump_context, buf, len + 1); + return vchiq_dump(dump_context, buf, len + 1); } /**************************************************************************** @@ -2206,13 +2212,16 @@ vchiq_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct dump_context context; + int err; context.buf = buf; context.actual = 0; context.space = count; context.offset = *ppos; - vchiq_dump_state(&context, &g_state); + err = vchiq_dump_state(&context, &g_state); + if (err) + return err; *ppos += context.actual; @@ -2223,13 +2232,13 @@ struct vchiq_state * vchiq_get_state(void) { - if (g_state.remote == NULL) + if (!g_state.remote) printk(KERN_ERR "%s: g_state.remote == NULL\n", __func__); else if (g_state.remote->initialised != 1) printk(KERN_NOTICE "%s: g_state.remote->initialised != 1 (%d)\n", __func__, g_state.remote->initialised); - return ((g_state.remote != NULL) && + return (g_state.remote && (g_state.remote->initialised == 1)) ? &g_state : NULL; } @@ -2270,10 +2279,10 @@ vchiq_videocore_wanted(struct vchiq_state *state) return 1; } -static VCHIQ_STATUS_T -vchiq_keepalive_vchiq_callback(VCHIQ_REASON_T reason, +static enum vchiq_status +vchiq_keepalive_vchiq_callback(enum vchiq_reason reason, struct vchiq_header *header, - VCHIQ_SERVICE_HANDLE_T service_user, + unsigned int service_user, void *bulk_user) { vchiq_log_error(vchiq_susp_log_level, @@ -2287,9 +2296,9 @@ vchiq_keepalive_thread_func(void *v) struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T status; - VCHIQ_INSTANCE_T instance; - VCHIQ_SERVICE_HANDLE_T ka_handle; + enum vchiq_status status; + struct vchiq_instance *instance; + unsigned int ka_handle; struct vchiq_service_params params = { .fourcc = VCHIQ_MAKE_FOURCC('K', 'E', 'E', 'P'), @@ -2361,7 +2370,7 @@ exit: return 0; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_arm_init_state(struct vchiq_state *state, struct vchiq_arm_state *arm_state) { @@ -2563,10 +2572,10 @@ unblock_resume(struct vchiq_arm_state *arm_state) /* Initiate suspend via slot handler. Should be called with the write lock * held */ -VCHIQ_STATUS_T +enum vchiq_status vchiq_arm_vcsuspend(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); if (!arm_state) @@ -2684,12 +2693,12 @@ out: return resume; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, enum USE_TYPE_E use_type) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; + enum vchiq_status ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; int local_uc, local_entity_uc; @@ -2798,7 +2807,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, } if (ret == VCHIQ_SUCCESS) { - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; long ack_cnt = atomic_xchg(&arm_state->ka_use_ack_count, 0); while (ack_cnt && (status == VCHIQ_SUCCESS)) { @@ -2817,11 +2826,11 @@ out: return ret; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; + enum vchiq_status ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; @@ -2898,33 +2907,33 @@ vchiq_on_remote_release(struct vchiq_state *state) complete(&arm_state->ka_evt); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_service_internal(struct vchiq_service *service) { return vchiq_use_internal(service->state, service, USE_TYPE_SERVICE); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_release_service_internal(struct vchiq_service *service) { return vchiq_release_internal(service->state, service); } struct vchiq_debugfs_node * -vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_debugfs_node(struct vchiq_instance *instance) { return &instance->debugfs_node; } int -vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_use_count(struct vchiq_instance *instance) { struct vchiq_service *service; int use_count = 0, i; i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { use_count += service->service_use_count; unlock_service(service); } @@ -2932,26 +2941,26 @@ vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) } int -vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_pid(struct vchiq_instance *instance) { return instance->pid; } int -vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_trace(struct vchiq_instance *instance) { return instance->trace; } void -vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) +vchiq_instance_set_trace(struct vchiq_instance *instance, int trace) { struct vchiq_service *service; int i; i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { service->trace = trace; unlock_service(service); } @@ -2969,10 +2978,10 @@ static void suspend_timer_callback(struct timer_list *t) vchiq_check_suspend(state); } -VCHIQ_STATUS_T -vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) +enum vchiq_status +vchiq_use_service(unsigned int handle) { - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (service) { @@ -2983,10 +2992,10 @@ vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) return ret; } -VCHIQ_STATUS_T -vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle) +enum vchiq_status +vchiq_release_service(unsigned int handle) { - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (service) { @@ -3088,11 +3097,11 @@ vchiq_dump_service_use_state(struct vchiq_state *state) vchiq_dump_platform_use_state(state); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_state; - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; if (!service || !service->state) goto out; @@ -3128,35 +3137,36 @@ void vchiq_on_remote_use_active(struct vchiq_state *state) } void vchiq_platform_conn_state_changed(struct vchiq_state *state, - VCHIQ_CONNSTATE_T oldstate, - VCHIQ_CONNSTATE_T newstate) + enum vchiq_connstate oldstate, + enum vchiq_connstate newstate) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); + char threadname[16]; vchiq_log_info(vchiq_susp_log_level, "%d: %s->%s", state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate)); - if (state->conn_state == VCHIQ_CONNSTATE_CONNECTED) { - write_lock_bh(&arm_state->susp_res_lock); - if (!arm_state->first_connect) { - char threadname[16]; + if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED) + return; - arm_state->first_connect = 1; - write_unlock_bh(&arm_state->susp_res_lock); - snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", - state->id); - arm_state->ka_thread = kthread_create( - &vchiq_keepalive_thread_func, - (void *)state, + write_lock_bh(&arm_state->susp_res_lock); + if (arm_state->first_connect) { + write_unlock_bh(&arm_state->susp_res_lock); + return; + } + + arm_state->first_connect = 1; + write_unlock_bh(&arm_state->susp_res_lock); + snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", + state->id); + arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func, + (void *)state, + threadname); + if (IS_ERR(arm_state->ka_thread)) { + vchiq_log_error(vchiq_susp_log_level, + "vchiq: FATAL: couldn't create thread %s", threadname); - if (IS_ERR(arm_state->ka_thread)) { - vchiq_log_error(vchiq_susp_log_level, - "vchiq: FATAL: couldn't create thread %s", - threadname); - } else { - wake_up_process(arm_state->ka_thread); - } - } else - write_unlock_bh(&arm_state->susp_res_lock); + } else { + wake_up_process(arm_state->ka_thread); } } |