From 9ec5411adf7cd872424f579701a91fffd508270b Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Tue, 18 Nov 2014 13:26:43 -0600 Subject: [PATCH] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 3 +-- drivers/staging/greybus/es1-ap-usb.c | 17 ++++++++--------- drivers/staging/greybus/greybus.h | 2 +- drivers/staging/greybus/operation.c | 4 +++- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index ab50e2d6f817..0f03521c53f9 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -169,8 +169,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver * 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 98ab05d9cead..660c36367cbd 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -114,19 +114,18 @@ static void *buffer_alloc(unsigned int size, gfp_t gfp_mask) 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 void kill_gbuf(struct gbuf *gbuf) 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 82ab1e6973d2..f27dcaf067ca 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -80,7 +80,7 @@ struct greybus_host_driver { 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 e3669a7a7901..c04aced63204 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -264,7 +264,9 @@ static void gb_operation_message_exit(struct gb_message *message) { 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; } /* -- 2.20.1