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>
This commit is contained in:
parent
d2a259f213
commit
9ec5411adf
|
@ -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)) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue