Commit a9163b2c authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: cancel buffers via magic cookie

Change the interface for canceling in-flight buffers to take a magic
cookie value as argument rather than a gbuf.  Right now we pass the
gbuf->hcd_data pointer that's assumed to have been set by the submit
routine.  But the next patch will change the submit routine to
return the cookie to be used, and the caller will be responsible for
keeping track of it.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 9ec5411a
...@@ -170,9 +170,9 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver ...@@ -170,9 +170,9 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
* so that we don't have to every time we make them. * so that we don't have to every time we make them.
*/ */
if ((!driver->buffer_alloc) || (!driver->buffer_free) || if ((!driver->buffer_alloc) || (!driver->buffer_free) ||
(!driver->submit_svc) ||
(!driver->submit_gbuf) || (!driver->submit_gbuf) ||
(!driver->kill_gbuf)) { (!driver->buffer_cancel) ||
(!driver->submit_svc)) {
pr_err("Must implement all greybus_host_driver callbacks!\n"); pr_err("Must implement all greybus_host_driver callbacks!\n");
return NULL; return NULL;
} }
......
...@@ -226,13 +226,15 @@ static int submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask) ...@@ -226,13 +226,15 @@ static int submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
return retval; return retval;
} }
static void kill_gbuf(struct gbuf *gbuf) static void buffer_cancel(void *cookie)
{ {
struct urb *urb = gbuf->hcd_data; struct urb *urb = cookie;
if (!urb)
return;
/*
* We really should be defensive and track all outstanding
* (sent) buffers rather than trusting the cookie provided
* is valid. For the time being, this will do.
*/
usb_kill_urb(urb); usb_kill_urb(urb);
} }
...@@ -240,9 +242,9 @@ static struct greybus_host_driver es1_driver = { ...@@ -240,9 +242,9 @@ static struct greybus_host_driver es1_driver = {
.hd_priv_size = sizeof(struct es1_ap_dev), .hd_priv_size = sizeof(struct es1_ap_dev),
.buffer_alloc = buffer_alloc, .buffer_alloc = buffer_alloc,
.buffer_free = buffer_free, .buffer_free = buffer_free,
.submit_svc = submit_svc,
.submit_gbuf = submit_gbuf, .submit_gbuf = submit_gbuf,
.kill_gbuf = kill_gbuf, .buffer_cancel = buffer_cancel,
.submit_svc = submit_svc,
}; };
/* Common function to report consistent warnings based on URB status */ /* Common function to report consistent warnings based on URB status */
......
...@@ -81,10 +81,10 @@ struct greybus_host_driver { ...@@ -81,10 +81,10 @@ struct greybus_host_driver {
void *(*buffer_alloc)(unsigned int size, gfp_t gfp_mask); void *(*buffer_alloc)(unsigned int size, gfp_t gfp_mask);
void (*buffer_free)(void *buffer); void (*buffer_free)(void *buffer);
int (*submit_gbuf)(struct gbuf *gbuf, gfp_t gfp_mask);
void (*buffer_cancel)(void *cookie);
int (*submit_svc)(struct svc_msg *svc_msg, int (*submit_svc)(struct svc_msg *svc_msg,
struct greybus_host_device *hd); struct greybus_host_device *hd);
int (*submit_gbuf)(struct gbuf *gbuf, gfp_t gfp_mask);
void (*kill_gbuf)(struct gbuf *gbuf);
}; };
struct greybus_host_device { struct greybus_host_device {
......
...@@ -115,8 +115,9 @@ static void greybus_kill_gbuf(struct gbuf *gbuf) ...@@ -115,8 +115,9 @@ static void greybus_kill_gbuf(struct gbuf *gbuf)
if (gbuf->status != -EINPROGRESS) if (gbuf->status != -EINPROGRESS)
return; return;
gbuf->hd->driver->kill_gbuf(gbuf); gbuf->hd->driver->buffer_cancel(gbuf->hcd_data);
} }
/* /*
* An operations's response message has arrived. If no callback was * An operations's response message has arrived. If no callback was
* supplied it was submitted for asynchronous completion, so we notify * supplied it was submitted for asynchronous completion, so we notify
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment