greybus: free space without gbufs
authorAlex Elder <elder@linaro.org>
Tue, 18 Nov 2014 19:26:43 +0000 (13:26 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 18 Nov 2014 20:48:53 +0000 (12:48 -0800)
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>
drivers/staging/greybus/core.c
drivers/staging/greybus/es1-ap-usb.c
drivers/staging/greybus/greybus.h
drivers/staging/greybus/operation.c

index ab50e2d..0f03521 100644 (file)
@@ -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)) {
index 98ab05d..660c363 100644 (file)
@@ -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,
index 82ab1e6..f27dcaf 100644 (file)
@@ -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);
index e3669a7..c04aced 100644 (file)
@@ -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;
 }
 
 /*