summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Bailon <abailon@baylibre.com>2016-02-25 18:19:14 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-02-25 17:05:31 -0800
commitd9048d8c96bfe2d18cdf7205b3de97aa344283a7 (patch)
treeb326955e23a885fff7825875dcc166eb99807c0b
parentd97bbf3ed6211c01bd7df77d405dee2e9846cd68 (diff)
greybus: loopback: Fix incoherency in calculations in the case of error
Currently, in case the case of error, statistics are updated for asynchronous but not for an asynchronous operation. Do not update the statistics in the case of error. Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r--drivers/staging/greybus/loopback.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index b40c95eb8801..a1f878b24e74 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -398,10 +398,8 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
do_gettimeofday(&ts);
operation = gb_operation_create(gb->connection, type, request_size,
response_size, GFP_KERNEL);
- if (!operation) {
- ret = -ENOMEM;
- goto error;
- }
+ if (!operation)
+ return -ENOMEM;
if (request_size)
memcpy(operation->request->payload, request, request_size);
@@ -410,6 +408,7 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
if (ret) {
dev_err(&gb->connection->bundle->dev,
"synchronous operation failed: %d\n", ret);
+ goto out_put_operation;
} else {
if (response_size == operation->response->payload_size) {
memcpy(response, operation->response->payload,
@@ -419,18 +418,20 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
"response size %zu expected %d\n",
operation->response->payload_size,
response_size);
+ ret = -EINVAL;
+ goto out_put_operation;
}
}
- gb_operation_put(operation);
-
-error:
do_gettimeofday(&te);
/* Calculate the total time the message took */
gb_loopback_push_latency_ts(gb, &ts, &te);
gb->elapsed_nsecs = gb_loopback_calc_latency(&ts, &te);
+out_put_operation:
+ gb_operation_put(operation);
+
return ret;
}
@@ -988,8 +989,9 @@ static int gb_loopback_fn(void *data)
if (error)
gb->error++;
+ else
+ gb_loopback_calculate_stats(gb);
gb->iteration_count++;
- gb_loopback_calculate_stats(gb);
}
send_count++;
if (us_wait)