From bfb287a17e79f8d9bd6a99cf79634c4493ad7028 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:09 -0500 Subject: [PATCH 01/15] greybus: interface: declare gb_interface_destroy() Add a public declaration for gb_interface_destroy(), matching gb_interface_create(). It's not yet used outside "interface.c" but I suppose it could be, and its scope is currently public. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/interface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index 558e6dbaa26b..e60a3705494e 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -51,6 +51,7 @@ struct gb_interface *gb_interface_find(struct greybus_host_device *hd, struct gb_interface *gb_interface_create(struct greybus_host_device *hd, u8 interface_id); +void gb_interface_destroy(struct gb_interface *intf); int gb_interface_init(struct gb_interface *intf, u8 device_id); void gb_interface_remove(struct greybus_host_device *hd, u8 interface_id); void gb_interfaces_remove(struct greybus_host_device *hd); From 006335a02677ed20dbff44f398a9cbf823db0293 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:10 -0500 Subject: [PATCH 02/15] greybus: looback: fix two typos Fix two misspellings. And add spaces around a '%' operator. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 08a77fee385a..08f77808e99d 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -183,7 +183,7 @@ gb_loopback_ro_attr(iteration_count, u); * Type of loopback message to send based on protocol type definitions * 0 => Don't send message * 2 => Send ping message continuously (message without payload) - * 3 => Send transer message continuously (message with payload, + * 3 => Send transfer message continuously (message with payload, * payload returned in response) * 4 => Send a sink message (message with payload, no payload in response) */ @@ -410,7 +410,7 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb) do_div(tmp, NSEC_PER_USEC); lat = tmp; - /* Log latency stastic */ + /* Log latency statistic */ gb_loopback_update_stats(&gb->latency, lat); kfifo_in(&gb->kfifo, (unsigned char *)&lat, sizeof(lat)); @@ -584,7 +584,7 @@ static ssize_t loopback_read(struct file *file, char __user *buf, size_t count, size_t fifo_len; int retval; - if (!count || count%sizeof(u32)) + if (!count || count % sizeof(u32)) return -EINVAL; mutex_lock(&gb->mutex); From 3f12c3ed21d9e28ae2dc50a6c567ee5d5c6054d1 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:11 -0500 Subject: [PATCH 03/15] greybus: loopback: drop unneeded casts for void pointers There is no need to cast a void pointer to a particular type. Drop the casts used in this way, mainly in the attribute definition macros. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 08f77808e99d..66059a96bb17 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -84,8 +84,7 @@ static ssize_t field##_show(struct device *dev, \ char *buf) \ { \ struct gb_connection *connection = to_gb_connection(dev); \ - struct gb_loopback *gb = \ - (struct gb_loopback *)connection->private; \ + struct gb_loopback *gb = connection->private; \ return sprintf(buf, "%"#type"\n", gb->field); \ } \ static DEVICE_ATTR_RO(field) @@ -96,8 +95,7 @@ static ssize_t name##_##field##_show(struct device *dev, \ char *buf) \ { \ struct gb_connection *connection = to_gb_connection(dev); \ - struct gb_loopback *gb = \ - (struct gb_loopback *)connection->private; \ + struct gb_loopback *gb = connection->private; \ return sprintf(buf, "%"#type"\n", gb->name.field); \ } \ static DEVICE_ATTR_RO(name##_##field) @@ -113,8 +111,7 @@ static ssize_t field##_show(struct device *dev, \ char *buf) \ { \ struct gb_connection *connection = to_gb_connection(dev); \ - struct gb_loopback *gb = \ - (struct gb_loopback *)connection->private; \ + struct gb_loopback *gb = connection->private; \ return sprintf(buf, "%"#type"\n", gb->field); \ } \ static ssize_t field##_store(struct device *dev, \ @@ -124,8 +121,7 @@ static ssize_t field##_store(struct device *dev, \ { \ int ret; \ struct gb_connection *connection = to_gb_connection(dev); \ - struct gb_loopback *gb = \ - (struct gb_loopback *)connection->private; \ + struct gb_loopback *gb = connection->private; \ mutex_lock(&gb->mutex); \ ret = sscanf(buf, "%"#type, &gb->field); \ if (ret != 1) \ @@ -423,7 +419,7 @@ static int gb_loopback_fn(void *data) { int error = 0; int ms_wait; - struct gb_loopback *gb = (struct gb_loopback *)data; + struct gb_loopback *gb = data; while (1) { if (!gb->type) From 3320e784550551ae8ae5c22d58e6b90addafe8a4 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:12 -0500 Subject: [PATCH 04/15] greybus: loopback: use U64_MAX for initialization Use the largest representable value when initializing the "min" field when resetting loopback statistics. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 66059a96bb17..cdefaffc2184 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -340,7 +340,7 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation) static void gb_loopback_reset_stats(struct gb_loopback *gb) { struct gb_loopback_stats reset = { - .min = 0xffffffff, + .min = U64_MAX, }; memcpy(&gb->latency, &reset, sizeof(struct gb_loopback_stats)); memcpy(&gb->throughput, &reset, sizeof(struct gb_loopback_stats)); From a6e7e53548b0d54aab0a5c5449e7093a495555d8 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:13 -0500 Subject: [PATCH 05/15] greybus: loopback: use u32 for stats update The only values supplied to gb_loopback_update_stats() are 32-bits, so change the type of the second argument to reflect that. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index cdefaffc2184..2042bed075d4 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -348,7 +348,7 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb) sizeof(struct gb_loopback_stats)); } -static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u64 val) +static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val) { if (stats->min > val) stats->min = val; From e051c82b2ba7fb3e237595c4f6d106e04a86baa1 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:14 -0500 Subject: [PATCH 06/15] greybus: loopback: record 32-bit min and max The minimum and maximum values for stats values are always 32 bits. Change the type for these fields to reflect this. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 2042bed075d4..2ec6c8071754 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -23,8 +23,8 @@ #include "greybus.h" struct gb_loopback_stats { - u64 min; - u64 max; + u32 min; + u32 max; u64 avg; u64 sum; u64 count; @@ -101,8 +101,8 @@ static ssize_t name##_##field##_show(struct device *dev, \ static DEVICE_ATTR_RO(name##_##field) #define gb_loopback_stats_attrs(field) \ - gb_loopback_ro_stats_attr(field, min, llu); \ - gb_loopback_ro_stats_attr(field, max, llu); \ + gb_loopback_ro_stats_attr(field, min, u); \ + gb_loopback_ro_stats_attr(field, max, u); \ gb_loopback_ro_stats_attr(field, avg, llu); #define gb_loopback_attr(field, type) \ @@ -340,7 +340,7 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation) static void gb_loopback_reset_stats(struct gb_loopback *gb) { struct gb_loopback_stats reset = { - .min = U64_MAX, + .min = U32_MAX, }; memcpy(&gb->latency, &reset, sizeof(struct gb_loopback_stats)); memcpy(&gb->throughput, &reset, sizeof(struct gb_loopback_stats)); From e13fc28f728ae6aa5e72c90a35d4fb0298205c6c Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:15 -0500 Subject: [PATCH 07/15] greybus: loopback: use a 32-bit count The count of statistical samples recorded is currently a 64-bit value. 32 bits is sufficient, and in fact anything more than that won't work for the do_div() call it's pass to anyway. So make the count field be 32 bits. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 2ec6c8071754..580e00247a78 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -27,7 +27,7 @@ struct gb_loopback_stats { u32 max; u64 avg; u64 sum; - u64 count; + u32 count; }; struct gb_loopback { From b937aa9e2a5e69cea4a0cc59b2d4dc7a0323ef60 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:16 -0500 Subject: [PATCH 08/15] greybus: loopback: error is an unsigned attribute The error count is unsigned, so fix the format specifier used in its attribute definition. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 580e00247a78..283a68448232 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -171,7 +171,7 @@ gb_loopback_stats_attrs(requests_per_second); /* Quantity of data sent and received on this cport */ gb_loopback_stats_attrs(throughput); /* Number of errors encountered during loop */ -gb_loopback_ro_attr(error, d); +gb_loopback_ro_attr(error, u); /* The current index of the for (i = 0; i < iteration_max; i++) loop */ gb_loopback_ro_attr(iteration_count, u); From 19c2a443c9efc87ae19d0ef7a5d212614a92479e Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:17 -0500 Subject: [PATCH 09/15] greybus: loopback: all read-only attributes are unsigned The only values passed to the gb_loopback_ro_attr() macro are unsigned 32-bit values. So there's no need to pass a "type" format specifier. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 283a68448232..6afacdba619f 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -78,14 +78,14 @@ module_param(kfifo_depth, uint, 0444); define_get_version(gb_loopback, LOOPBACK); /* interface sysfs attributes */ -#define gb_loopback_ro_attr(field, type) \ +#define gb_loopback_ro_attr(field) \ static ssize_t field##_show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ struct gb_connection *connection = to_gb_connection(dev); \ struct gb_loopback *gb = connection->private; \ - return sprintf(buf, "%"#type"\n", gb->field); \ + return sprintf(buf, "%u\n", gb->field); \ } \ static DEVICE_ATTR_RO(field) @@ -171,9 +171,9 @@ gb_loopback_stats_attrs(requests_per_second); /* Quantity of data sent and received on this cport */ gb_loopback_stats_attrs(throughput); /* Number of errors encountered during loop */ -gb_loopback_ro_attr(error, u); +gb_loopback_ro_attr(error); /* The current index of the for (i = 0; i < iteration_max; i++) loop */ -gb_loopback_ro_attr(iteration_count, u); +gb_loopback_ro_attr(iteration_count); /* * Type of loopback message to send based on protocol type definitions From 7a135a965c62f7abdf8f3acc5ca45a03d27b272c Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:18 -0500 Subject: [PATCH 10/15] greybus: loopback: use separate attribute macro for average Define a separate macro for displaying the average of the samples collected. This will be used so we can calculate the average only when requested, rather than every time a new value gets recorded. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 6afacdba619f..432eeabe963b 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -100,10 +100,21 @@ static ssize_t name##_##field##_show(struct device *dev, \ } \ static DEVICE_ATTR_RO(name##_##field) +#define gb_loopback_ro_avg_attr(name) \ +static ssize_t name##_avg_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + struct gb_connection *connection = to_gb_connection(dev); \ + struct gb_loopback *gb = connection->private; \ + return sprintf(buf, "%llu\n", gb->name.avg); \ +} \ +static DEVICE_ATTR_RO(name##_avg) + #define gb_loopback_stats_attrs(field) \ gb_loopback_ro_stats_attr(field, min, u); \ gb_loopback_ro_stats_attr(field, max, u); \ - gb_loopback_ro_stats_attr(field, avg, llu); + gb_loopback_ro_avg_attr(field); #define gb_loopback_attr(field, type) \ static ssize_t field##_show(struct device *dev, \ From ff71d395f3cd5e5efe4b9b3c94c2d41581fb9d8c Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:19 -0500 Subject: [PATCH 11/15] greybus: loopback: compute average stats on demand only Stop recording and updating the average every time a sample is recorded. Instead, compute it from the sum and count only when it's required. Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 432eeabe963b..e76f8a70d113 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -25,7 +25,6 @@ struct gb_loopback_stats { u32 min; u32 max; - u64 avg; u64 sum; u32 count; }; @@ -107,7 +106,11 @@ static ssize_t name##_avg_show(struct device *dev, \ { \ struct gb_connection *connection = to_gb_connection(dev); \ struct gb_loopback *gb = connection->private; \ - return sprintf(buf, "%llu\n", gb->name.avg); \ + struct gb_loopback_stats *stats = &gb->name; \ + u32 count = stats->count ? stats->count : 1; \ + u64 avg = stats->sum + count / 2; /* round closest */ \ + u32 rem = do_div(avg, count); \ + return sprintf(buf, "%llu.%06u\n", avg, 1000000 * rem / count); \ } \ static DEVICE_ATTR_RO(name##_avg) @@ -367,8 +370,6 @@ static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val) stats->max = val; stats->sum += val; stats->count++; - stats->avg = stats->sum; - do_div(stats->avg, stats->count); } static void gb_loopback_requests_update(struct gb_loopback *gb, u32 latency) From 1fb807cf6da0b65af4ba6ab100d38ebef17ff25e Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 3 Aug 2015 12:57:20 -0500 Subject: [PATCH 12/15] greybus: loopback: fix connection cleanup paths The error paths in gb_loopback_connection_init() are kind of screwed up--not in proper order, and the label naming convention seems a little inconsistent. Fix this, ensuring each error cleans up the setup that's been done up to that point. Use the convention that the label indicates the first thing that needs to be cleaned up. Reorder the statements in gb_loopback_connection_exit() to match the order of cleanup in gb_loopback_connection_init(). Signed-off-by: Alex Elder Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index e76f8a70d113..564276d90da2 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -490,19 +490,19 @@ static int gb_loopback_connection_init(struct gb_connection *connection) minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL); if (minor < 0) { retval = minor; - goto out_free; + goto out_sysfs; } /* Check the version */ retval = get_version(gb); if (retval) - goto out_get_ver; + goto out_minor; /* Calculate maximum payload */ gb->size_max = gb_operation_get_payload_size_max(connection); if (gb->size_max <= sizeof(struct gb_loopback_transfer_request)) { retval = -EINVAL; - goto out_get_ver; + goto out_minor; } gb->size_max -= sizeof(struct gb_loopback_transfer_request); @@ -510,7 +510,7 @@ static int gb_loopback_connection_init(struct gb_connection *connection) if (kfifo_alloc(&gb->kfifo, kfifo_depth * sizeof(u32), GFP_KERNEL)) { retval = -ENOMEM; - goto out_get_ver; + goto out_minor; } /* Create device entry */ @@ -518,13 +518,13 @@ static int gb_loopback_connection_init(struct gb_connection *connection) cdev_init(&gb->cdev, &loopback_fops); retval = cdev_add(&gb->cdev, gb->dev, 1); if (retval) - goto out_cdev; + goto out_kfifo; gb->device = device_create(loopback_class, &connection->dev, gb->dev, gb, "gb!loopback%d", minor); if (IS_ERR(gb->device)) { retval = PTR_ERR(gb->device); - goto out_device; + goto out_cdev; } /* Fork worker thread */ @@ -533,21 +533,25 @@ static int gb_loopback_connection_init(struct gb_connection *connection) gb->task = kthread_run(gb_loopback_fn, gb, "gb_loopback"); if (IS_ERR(gb->task)) { retval = PTR_ERR(gb->task); - goto out_kfifo; + goto out_device; } return 0; out_device: - cdev_del(&gb->cdev); + device_del(gb->device); out_cdev: - ida_simple_remove(&minors, minor); + cdev_del(&gb->cdev); out_kfifo: kfifo_free(&gb->kfifo); -out_get_ver: +out_minor: + ida_simple_remove(&minors, minor); +out_sysfs: sysfs_remove_groups(&connection->dev.kobj, loopback_groups); out_free: + connection->private = NULL; kfree(gb); + return retval; } @@ -555,13 +559,14 @@ static void gb_loopback_connection_exit(struct gb_connection *connection) { struct gb_loopback *gb = connection->private; + connection->private = NULL; if (!IS_ERR_OR_NULL(gb->task)) kthread_stop(gb->task); - cdev_del(&gb->cdev); - ida_simple_remove(&minors, MINOR(gb->dev)); device_del(gb->device); + cdev_del(&gb->cdev); kfifo_free(&gb->kfifo); + ida_simple_remove(&minors, MINOR(gb->dev)); sysfs_remove_groups(&connection->dev.kobj, loopback_groups); kfree(gb); } From 47a96858b526e14882438e455ec078fc7e51155b Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Tue, 4 Aug 2015 13:44:10 -0500 Subject: [PATCH 13/15] greybus: kernel_ver.h: define U32_MAX and U64_MAX These were not defined, and I just posted patches that use them. Signed-off-by: Alex Elder Tested-by: Mark Greer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/kernel_ver.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/greybus/kernel_ver.h b/drivers/staging/greybus/kernel_ver.h index c2e92df9f417..d0e05e656475 100644 --- a/drivers/staging/greybus/kernel_ver.h +++ b/drivers/staging/greybus/kernel_ver.h @@ -57,6 +57,14 @@ #define U16_MAX ((u16)(~0U)) #endif /* !U16_MAX */ +#ifndef U32_MAX +#define U32_MAX ((u32)(~0U)) +#endif /* !U32_MAX */ + +#ifndef U64_MAX +#define U64_MAX ((u64)(~0U)) +#endif /* !U64_MAX */ + /* * The GPIO api sucks rocks in places, like removal, so work around their * explicit requirements of catching the return value for kernels older than From 7fea641c94d645bf30712cb6e6c498597c7e5634 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 6 Aug 2015 12:44:52 +0530 Subject: [PATCH 14/15] greybus: raw: Print expected/actual payload size on mismatch Print (expected-payload-size actual-payload-size), when the size doesn't match for requests received by the module. This gives more details required for debugging the issue. Signed-off-by: Viresh Kumar Reviewed-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/raw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c index 3be96db2588b..a17a9868a08e 100644 --- a/drivers/staging/greybus/raw.c +++ b/drivers/staging/greybus/raw.c @@ -121,7 +121,8 @@ static int gb_raw_receive(u8 type, struct gb_operation *op) /* Verify size of payload */ if (op->request->payload_size < sizeof(*receive)) { - dev_err(raw->device, "raw receive request too small\n"); + dev_err(raw->device, "raw receive request too small (%zu < %zu)\n", + op->request->payload_size, sizeof(*receive)); return -EINVAL; } receive = op->request->payload; From 782c3b732889b5fbce796a4b548d47a43e4d8c42 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 6 Aug 2015 12:44:51 +0530 Subject: [PATCH 15/15] greybus: gpio: Print expected/actual payload size on mismatch Print (expected-payload-size actual-payload-size), when the size doesn't match for requests received by the module. This gives more details required for debugging the issue. Signed-off-by: Viresh Kumar Reviewed-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index 6539530a178c..caee9d19d723 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -366,7 +366,8 @@ static int gb_gpio_request_recv(u8 type, struct gb_operation *op) request = op->request; if (request->payload_size < sizeof(*event)) { - dev_err(ggc->chip.dev, "short event received\n"); + dev_err(ggc->chip.dev, "short event received (%zu < %zu)\n", + request->payload_size, sizeof(*event)); return -EINVAL; }