diff options
author | Marcelo Diop-Gonzalez <marcgonzalez@google.com> | 2019-11-20 15:21:01 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-22 11:40:31 +0100 |
commit | 0046b33ce553f48551ea6e4879562d423ed3f1a0 (patch) | |
tree | 38b8ab1780149aca8d4b989f6039c00cbca9cbb5 /drivers | |
parent | 00d52fb7e4fd1b1b2dc3aa7e6844d074948485b3 (diff) | |
download | linux-0046b33ce553f48551ea6e4879562d423ed3f1a0.tar.bz2 |
staging: vchiq: Refactor indentation in vchiq_dump_* functions
Doing this helps with readability, and makes
the logic easier to follow.
Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20191120202102.249121-4-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 104 |
1 files changed, 53 insertions, 51 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 942b4768c88e..8f9cfa083264 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2076,40 +2076,40 @@ void 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; - if (context->offset > 0) { - int skip_bytes = min_t(int, len, 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_t(int, len, context->space - context->actual); - if (copy_bytes == 0) + str += skip_bytes; + len -= skip_bytes; + context->offset -= skip_bytes; + if (context->offset > 0) return; - if (copy_to_user(context->buf + context->actual, str, - copy_bytes)) + } + copy_bytes = min_t(int, len, 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 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)) context->actual = -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)) - context->actual = -EFAULT; - } } } @@ -2134,34 +2134,36 @@ vchiq_dump_platform_instances(void *dump_context) struct vchiq_service *service = state->services[i]; 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]; struct vchiq_instance *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; - } - } + 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); + + vchiq_dump(dump_context, buf, len + 1); + instance->mark = 1; } } |