greybus: drop hd arg from submit_gbuf method

Every gbuf is associated with a connection when it is created.  And
a connection contains a pointer to the host device that will carry
messages.  So there's no need for the submit_gbuf() method to have
the host device pointer passed to it, the function can get it from
the gbuf's connection.

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

Upcoming patches are going to set up devices based on what is
discovered in the module manifest.  Get rid of the hard-coded
initialization done by gb_init_subdevs(), along with other related
code.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: add response buffer to an operation

We need to track both request messages and response messages in
operations.  So add another gbuf (and payload pointer) field to
the operation structure, and rename them to indicate which one
is which.  Allow the creator specify the size of the response
buffer; just leave it a null pointer if the size is 0.

Define a new helper function gb_operation_gbuf_create() to
encapsulate creating either a request or a response buffer.

Any buffer associated with a connection will (eventually) have been
created as part of an operation.  So stash the operation pointer in
the gbuf as the context pointer.  Whether a buffer is for the
request or the response can be determined by pointer comparison.

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

Add a red-black tree indexed by operation id to a connection to
allow pending operations (whose requests are in-flight) to be
found when their matching response is recieved.

Assign the id at the time an operation is inserted, and update
the operation's message header(s) to include it.

Rename gb_connection_op_id() to be more consistent with the
naming conventions being used elsewhere.

(Noting now that this may switch to a simple list implementation
based on Greg's assertion that lists are faster than red-black trees
for up to a few hundred entries.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: let operation layer examine incoming data

Give the operation layer a chance to examine incoming data so that
it can handle it appropriately.

Treat the data as an operation message header.  If it's a response,
look up the operation it's associated with.  If it's not, create a
new operation.  Copy the incoming data into the request or response
buffer.  The next patch adds a work queue to pick up handling
the request or response from there.

Get rid of gb_operation_submit().  Instead, we have two functions,
one for sending an operation's request message, the other for
sending an operation's response message.

Not fully functional yet, still just filling things in...

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
greybus: move receive handling to operation layer

Create a work queue to do the bulk of processing of received
operation request or response messages.

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