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: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Alex Elder 2014-11-18 13:26:44 -06:00 committed by Greg Kroah-Hartman
parent 9ec5411adf
commit a9163b2c30
4 changed files with 15 additions and 12 deletions

View File

@ -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.
*/
if ((!driver->buffer_alloc) || (!driver->buffer_free) ||
(!driver->submit_svc) ||
(!driver->submit_gbuf) ||
(!driver->kill_gbuf)) {
(!driver->buffer_cancel) ||
(!driver->submit_svc)) {
pr_err("Must implement all greybus_host_driver callbacks!\n");
return NULL;
}

View File

@ -226,13 +226,15 @@ static int submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
return retval;
}
static void kill_gbuf(struct gbuf *gbuf)
static void buffer_cancel(void *cookie)
{
struct urb *urb = gbuf->hcd_data;
if (!urb)
return;
struct urb *urb = cookie;
/*
* 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);
}
@ -240,9 +242,9 @@ static struct greybus_host_driver es1_driver = {
.hd_priv_size = sizeof(struct es1_ap_dev),
.buffer_alloc = buffer_alloc,
.buffer_free = buffer_free,
.submit_svc = submit_svc,
.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 */

View File

@ -81,10 +81,10 @@ struct greybus_host_driver {
void *(*buffer_alloc)(unsigned int size, gfp_t gfp_mask);
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,
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 {

View File

@ -115,8 +115,9 @@ static void greybus_kill_gbuf(struct gbuf *gbuf)
if (gbuf->status != -EINPROGRESS)
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
* supplied it was submitted for asynchronous completion, so we notify