Commit graph

7 commits

Author SHA1 Message Date
Greg Kroah-Hartman bf2329fd7d greybus: pwm-gb: convert to use gb_operation_sync
This converts the PWM protocol driver to use gb_operation_sync, removing
lots of places where the create/send/destroy pattern was being used to
send greybus messages.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2014-11-24 12:56:51 -08:00
Alex Elder 23383defa8 greybus: use errno for operation result
An in-core operation structure tracks the progress of an operation.
Currently it holds a result field that was intended to take the
status value that arrives in an operation response message header.

But operations can fail for reasons other than that, and it's
inconvenient to try to represent those using the operation status
codes.

So change the operation->result field to be an int, and switch to
storing negative errno values in it.  Rename it "errno" to make
it obvious how to interpret the value.

This patch makes another change, which simplifies the protocol drivers
a lot.  It's being done as part of this patch because it affects all
the same code as the above change does.  If desired I can split this
into two separate patches.

If a caller makes a synchronous gb_operation_request_send() request
(i.e., no callback function is supplied), and the operation request
and response messages were transferred successfully, have
gb_operation_request_send() return the result of the request (i.e.,
operation->errno).  This allows the caller (or more generally, any
caller of gb_request_wait() to avoid having to look at this field
for every successful send.

Any caller that does an asynchronous request will of course need
to look at request->errno in the callback function to see the
result of the operation.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-21 19:31:13 -08:00
Alex Elder c08b1ddaeb greybus: dynamically allocate requests and responses
Have an operation's request and response messages be dynamically
allocated rather than embedded in an operation.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-21 12:23:34 -08:00
Greg Kroah-Hartman 4589f06663 greybus: pwm-gb.c: fix up missing { } for else
This was a compiler warning, which looked correct, but was trying to
tell us something else...

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-19 17:02:21 -08:00
Alex Elder 25d0f81a0e greybus: remove status from all responses
This is a pervasive change, but not really a big one.  However:

        ==============  Pay attention to this ==============
	If you're doing any testing with "gbsim" you need to
	update that program in sync with this change, because
	it changes the protocol used between them.
        ==============  Pay attention to this ==============

The status of a request is now recorded in the header of a response
message.  The previous patch put that header status byte in place,
and this one removes the status byte from all the response
messages.

And finally, since we're modifying all these files anyway...
Use gb_operation_status_map() to come up with a return code
to use, given an operation response.  Right now most errors
simply result in -EIO getting returned.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-19 16:51:28 -08:00
Alex Elder 3690a826fa 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>
2014-11-17 17:19:20 -08:00
Matt Porter 34c6507ca8 greybus: add pwm protocol driver
Add a PWM driver that implements the Greybus PWM protocol.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-14 13:10:21 -08:00