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>
This commit is contained in:
parent
00d52fb7e4
commit
0046b33ce5
@ -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);
|
||||
if (!service || service->base.callback != service_callback)
|
||||
continue;
|
||||
|
||||
vchiq_dump(dump_context, buf, len + 1);
|
||||
instance = service->instance;
|
||||
if (!instance || instance->mark)
|
||||
continue;
|
||||
|
||||
instance->mark = 1;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user