* 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)) {
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 */
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,
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);
{
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;
}
/*