greybus: free space without gbufs
Switch the host driver free routine to take a pointer to the
previously-allocated buffer that should be freed.
Rename the method to reflect it's no longer tied to a gbuf.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c
index ab50e2d..0f03521 100644
--- a/drivers/staging/greybus/core.c
+++ b/drivers/staging/greybus/core.c
@@ -169,8 +169,7 @@
* Validate that the driver implements all of the callbacks
* so that we don't have to every time we make them.
*/
- if ((!driver->buffer_alloc) ||
- (!driver->free_gbuf_data) ||
+ if ((!driver->buffer_alloc) || (!driver->buffer_free) ||
(!driver->submit_svc) ||
(!driver->submit_gbuf) ||
(!driver->kill_gbuf)) {
diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c
index 98ab05d..660c363 100644
--- a/drivers/staging/greybus/es1-ap-usb.c
+++ b/drivers/staging/greybus/es1-ap-usb.c
@@ -114,19 +114,18 @@
return buffer;
}
-/* Free the memory we allocated with a gbuf */
-static void free_gbuf_data(struct gbuf *gbuf)
+/* Free a previously-allocated buffer */
+static void buffer_free(void *buffer)
{
- u8 *transfer_buffer = gbuf->transfer_buffer;
+ u8 *allocated = buffer;
- /* Can be called with a NULL transfer_buffer on some error paths */
- if (!transfer_buffer)
+ /* Can be called with a NULL buffer on some error paths */
+ if (!allocated)
return;
/* Account for the space set aside for the prepended cport id */
- transfer_buffer -= GB_BUFFER_ALIGN;
- kfree(transfer_buffer);
- gbuf->transfer_buffer = NULL;
+ allocated -= GB_BUFFER_ALIGN;
+ kfree(allocated);
}
#define ES1_TIMEOUT 500 /* 500 ms for the SVC to do something */
@@ -240,7 +239,7 @@
static struct greybus_host_driver es1_driver = {
.hd_priv_size = sizeof(struct es1_ap_dev),
.buffer_alloc = buffer_alloc,
- .free_gbuf_data = free_gbuf_data,
+ .buffer_free = buffer_free,
.submit_svc = submit_svc,
.submit_gbuf = submit_gbuf,
.kill_gbuf = kill_gbuf,
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 82ab1e6..f27dcaf 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -80,7 +80,7 @@
size_t hd_priv_size;
void *(*buffer_alloc)(unsigned int size, gfp_t gfp_mask);
- void (*free_gbuf_data)(struct gbuf *gbuf);
+ void (*buffer_free)(void *buffer);
int (*submit_svc)(struct svc_msg *svc_msg,
struct greybus_host_device *hd);
int (*submit_gbuf)(struct gbuf *gbuf, gfp_t gfp_mask);
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index e3669a7..c04aced 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -264,7 +264,9 @@
{
message->operation = NULL;
message->payload = NULL;
- message->gbuf.hd->driver->free_gbuf_data(&message->gbuf);
+ message->gbuf.hd->driver->buffer_free(message->gbuf.transfer_buffer);
+ message->gbuf.transfer_buffer = NULL;
+ message->gbuf.transfer_buffer_length = 0;
}
/*