greybus: kill greybus_{get,put}_gbuf()

These functions are never used, so we can get rid of them.
Since there's no reference-getting function any more, we no
longer need "gbuf_mutex" to avoid racing gets and puts, so
get rid of that too.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: kill gbuf->kref

Since there is only ever one reference to a gbuf, we don't need a
kref to figure out when it can be freed.  Get rid of the kref and
its supporting code.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: move the definition of struct gbuf

We no longer need struct gbuf defined in "greybus.h".  An upcoming
patch will embed a gbuf struct (not a pointer) into the operation
structure, and to do that we'll need the struct defined prior to the
operation.  Just move the gbuf definition into "operation.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: define struct gb_message

A Greybus buffer (gbuf) is a generic buffer used for data transfer
over a Greybus interconnect.  We only ever use gbufs in operations,
which always involve exactly two of them.  The lifetime of a gbuf is
therefore directly connected to the lifetime of an operation, so
there no real need to manage gbufs separate from operations.

This patch begins the process of removing the gbuf abstraction, on
favor of a new data type, gb_message.  The purpose of a gb_message
is--like a gbuf--to represent data to be transferred over Greybus.
However a gb_message is oriented toward the more restrictive way
we do Greybus transfers--as operation messages (either a request or
a response).

This patch simply defines the structure in its initial form, and
defines the request and response fields in a Greybus operation
structure as embedded instances of that type.  The gbuf pointer
is defined within the gb_message structure, and as a result lots
of code needs to be tweaked to reference the request and response
gbufs as subfields of the request and response structures.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: start using struct gb_message

This converts some of the operation code to start leveraging the
new gb_message type.  Instead of creating the request and response
gbufs, we initialize (and tear down with a new function) the
request and response message structures.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: move gbuf initialization to caller

Change greybus_alloc_gbuf() so all it does is allocate the gbuf data
structure.  Move all of the initialization of the gbuf structure in
the caller.  Do the inverse in the caller prior to freeing the gbuf
structure via greybus_free_gbuf().  Use a null gbuf->transfer_buffer
pointer rather than a null gbuf pointer to indicate an unused gbuf.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: use null gbuf->transfer_buffer

Make sure gbuf->transfer_buffer gets reset to NULL when the buffer
is freed.  We can leverage that to do a little extra error checking.
We'll also use a null transfer buffer in the next patch to indicate
an unused gbuf.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: embed gbufs into operation message structure

Embed the gbuf structures for operation messages into the message
structure rather than pointing to a dynamically allocated one.

Use a null gbuf->transfer_buffer pointer rather than a null gbuf
pointer to indicate an unused gbuf.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: kill the gbuf slab cache

Nobody dynamically allocates gbufs any more, so we can get rid of
the allocation and free routines, as as the slab cache and its
related code.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: kill off the last of gbuf.c

Only three functions remain in "gbuf.c".  Move one of them into
"connection.c" and the other two into "operation.c".

Some more cleanup is coming that will further straighten out gbufs
but for now there's no sense in drawing this out any longer.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>