greybus: update gbuf status for completion handlers

Currently, if a USB urb completes with an error, that error status
is not transferred back to the gbuf that it's associated with.  For
inbound data there's not a lot we can do about an error, but for
outbound data, this means there is no notification to the submitter
that something went wrong.

For outbound data copy the urb status directly back to the gbuf as
its status.  Follow USB's lead and set the status to -EINPROGRESS
while a gbuf is "in flight."  Assign a gbuf an initial status value
of -EBADR to help identify use of never-set status values.

When an inbound urb fails (SVC or CPort), currently the urb is just
leaked, more or less (i.e., we lose an urb posted to receive
incoming data).  Change that so such an error is reported, but
then re-submitted.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/greybus/gbuf.c b/drivers/staging/greybus/gbuf.c
index 348ee7c2..9b435af 100644
--- a/drivers/staging/greybus/gbuf.c
+++ b/drivers/staging/greybus/gbuf.c
@@ -54,6 +54,7 @@
 	gbuf->outbound = outbound;
 	gbuf->complete = complete;
 	gbuf->context = context;
+	gbuf->status = -EBADR;	/* Initial value--means "never set" */
 
 	/* Host controller specific allocation for the actual buffer */
 	retval = connection->hd->driver->alloc_gbuf_data(gbuf, size, gfp_mask);
@@ -98,6 +99,8 @@
 {
 	struct greybus_host_device *hd = gbuf->connection->hd;
 
+	gbuf->status = -EINPROGRESS;
+
 	return hd->driver->submit_gbuf(gbuf, gfp_mask);
 }