platform/kernel/linux-rpi.git
10 years agogreybus: report gbuf errors
Alex Elder [Sat, 18 Oct 2014 02:03:49 +0000 (21:03 -0500)]
greybus: report gbuf errors

If a gbuf completion indicates an error has occurred, report it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: update gbuf status for completion handlers
Alex Elder [Fri, 17 Oct 2014 10:18:22 +0000 (05:18 -0500)]
greybus: update gbuf status for completion handlers

Currently, if a USB urb completes with an error, that error status
is not transferred back to the gbuf that it's associated with.  For
inbound data there's not a lot we can do about an error, but for
outbound data, this means there is no notification to the submitter
that something went wrong.

For outbound data copy the urb status directly back to the gbuf as
its status.  Follow USB's lead and set the status to -EINPROGRESS
while a gbuf is "in flight."  Assign a gbuf an initial status value
of -EBADR to help identify use of never-set status values.

When an inbound urb fails (SVC or CPort), currently the urb is just
leaked, more or less (i.e., we lose an urb posted to receive
incoming data).  Change that so such an error is reported, but
then re-submitted.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: add write retry support for i2c
Alex Elder [Fri, 17 Oct 2014 10:09:21 +0000 (05:09 -0500)]
greybus: add write retry support for i2c

It is expected that i2c writes may fail, and in that case the driver
simply retries some number of times before actually treating it as a
failure.  Define a GB_OP_RETRY status, which is interpreted by the
i2c driver as an indication a retry is in order.  We just translate
that into an EAGAIN error passed back to the i2c core.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: initial operations-based GPIO driver
Alex Elder [Thu, 16 Oct 2014 11:35:39 +0000 (06:35 -0500)]
greybus: initial operations-based GPIO driver

First cut.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: add i2c driver
Alex Elder [Thu, 16 Oct 2014 11:35:38 +0000 (06:35 -0500)]
greybus: add i2c driver

This patch adds the i2c driver, based on the use of Greybus operations
over Greybus connections.  It basically replaces almost all of what
was previously found in "i2c-gb.c".

When gb_connection_device_init(connection) is called, any connection
that talks the GREYBUS_PROTOCOL_I2C is passed to gb_i2c_device_init()
to be initialized.

Initialization involves verifying the code is able to support the
version of the protocol.  For I2C, we then query the functionality
mask, and set the retry count and timeout to default values.

After that, we set up the i2c device and associate it with the
connection.  The i2c_algorithm methods are then implemented
by translating them into Greybus operations.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: kill old cport handlers
Alex Elder [Thu, 16 Oct 2014 11:35:37 +0000 (06:35 -0500)]
greybus: kill old cport handlers

The original CPort message handlers are not needed.  All incoming
data is passed to handlers based on the protocol used over the
connection over which the data was transferred.  So get rid of the
old CPort handler code.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: kill off gbuf work queue
Alex Elder [Thu, 16 Oct 2014 11:35:36 +0000 (06:35 -0500)]
greybus: kill off gbuf work queue

At this point all incoming messages are handled by the operation
code, so this obviates the need for the gbuf workqueue.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: add device initialization
Alex Elder [Thu, 16 Oct 2014 11:35:35 +0000 (06:35 -0500)]
greybus: add device initialization

Set up the infrastructure for initializing connections based on
their protocol.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: move receive handling to operation layer
Alex Elder [Thu, 16 Oct 2014 11:35:34 +0000 (06:35 -0500)]
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>
10 years agogreybus: let operation layer examine incoming data
Alex Elder [Thu, 16 Oct 2014 11:35:33 +0000 (06:35 -0500)]
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>
10 years agogreybus: add gb_operation_find()
Alex Elder [Thu, 16 Oct 2014 11:35:32 +0000 (06:35 -0500)]
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>
10 years agogreybus: add response buffer to an operation
Alex Elder [Thu, 16 Oct 2014 11:35:31 +0000 (06:35 -0500)]
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>
10 years agogreybus: stop init_subdevs stuff
Alex Elder [Thu, 16 Oct 2014 11:35:30 +0000 (06:35 -0500)]
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>
10 years agogreybus: drop hd arg from submit_gbuf method
Alex Elder [Thu, 16 Oct 2014 11:35:29 +0000 (06:35 -0500)]
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>
10 years agogreybus: zero all data buffers
Alex Elder [Thu, 16 Oct 2014 11:35:28 +0000 (06:35 -0500)]
greybus: zero all data buffers

Don't assume the buffer data area will all be overwritten.  Zero all
buffer space, to avoid sending crap over the wire.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: don't restrict input buffer size
Alex Elder [Thu, 16 Oct 2014 11:35:27 +0000 (06:35 -0500)]
greybus: don't restrict input buffer size

Don't assume that input buffers have any particular content.  The
only thing the gbuf layer needs to be concerned with is the presence
of the cport_id byte at the beginning of a transfer.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: unlock hd mutex on free
Alex Elder [Thu, 16 Oct 2014 11:35:26 +0000 (06:35 -0500)]
greybus: unlock hd mutex on free

When free_hd() is called, hd_mutex is held.  It is the
responsibility of free_hd() to drop that mutex.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: unlock gbuf mutex on free
Alex Elder [Thu, 16 Oct 2014 11:35:25 +0000 (06:35 -0500)]
greybus: unlock gbuf mutex on free

To drop a reference on a gbuf, greybus_free_gbuf() is called.  That
uses kref_put_mutex() to drop the refernce under protection of
gbuf_mutex.  However the release routine, free_gbuf(), never
releases the mutex as it should.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: don't assume subdevs are valid
Alex Elder [Thu, 16 Oct 2014 11:35:24 +0000 (06:35 -0500)]
greybus: don't assume subdevs are valid

Most of the disconnect routines for the "subdevs" of a module
blindly assume that initialization of the subdev was successful.

Fix this by checking for null pointers.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: es1-ap-usb: handle -EPROTO in check_urb_status()
Matt Porter [Mon, 13 Oct 2014 07:00:53 +0000 (03:00 -0400)]
greybus: es1-ap-usb: handle -EPROTO in check_urb_status()

On a disconnect we can also have a status of -EPROTO. This results in
a flood of error messages due to the -EAGAIN handling of unsupported
status results. Fix this by also returning status when we have -EPROTO.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: Changes required for integrating into the Android build
John Stultz [Fri, 10 Oct 2014 21:42:33 +0000 (14:42 -0700)]
greybus: Changes required for integrating into the Android build

In order to easily integrate into the Android build, include
an Android.mk.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: greybus_manifest.h: add BSD license so that firmware can share it.
Greg Kroah-Hartman [Tue, 7 Oct 2014 03:37:53 +0000 (20:37 -0700)]
greybus: greybus_manifest.h: add BSD license so that firmware can share it.

10 years agogreybus: svc_msg.h: add bsd license to file so that firmware can use it.
Greg Kroah-Hartman [Tue, 7 Oct 2014 03:37:18 +0000 (20:37 -0700)]
greybus: svc_msg.h: add bsd license to file so that firmware can use it.

10 years agogreybus: greybus_id.h: checkpatch cleanup
Greg Kroah-Hartman [Tue, 7 Oct 2014 03:37:08 +0000 (20:37 -0700)]
greybus: greybus_id.h: checkpatch cleanup

10 years agogreybus: greybus.h: remove transfer_flags
Greg Kroah-Hartman [Tue, 7 Oct 2014 03:34:48 +0000 (20:34 -0700)]
greybus: greybus.h: remove transfer_flags

We didn't use them, so drop it.

Also some other checkpatch cleanups while I was in there.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agogreybus: connection: properly lock idr
Greg Kroah-Hartman [Tue, 7 Oct 2014 03:29:40 +0000 (20:29 -0700)]
greybus: connection: properly lock idr

We had a lock, but we never used it, so move it to be per-hd, like the
idr structure is.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 years agogreybus: fix gb_manifest_parse() successful return path
Matt Porter [Mon, 6 Oct 2014 17:46:36 +0000 (13:46 -0400)]
greybus: fix gb_manifest_parse() successful return path

Even if we successfully parse a manifest we are returning
failure. Instead, we now proudly proclaim success.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: gb_hd_connection_find(): fix "not found" case
Marti Bolivar [Mon, 6 Oct 2014 17:26:02 +0000 (13:26 -0400)]
greybus: gb_hd_connection_find(): fix "not found" case

Without this, null-testing the return value of this function is
broken.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix manifest parsing problem with descriptor payload
Matt Porter [Mon, 6 Oct 2014 13:58:44 +0000 (09:58 -0400)]
greybus: fix manifest parsing problem with descriptor payload

The internal struct manifest_desc needs the data payload, rather
than the entire descriptor with header to be populated into the
data field. Also fix two places where the parser was trying to
extract the entire descriptor with header for the data payload
field.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: get rid of gbuf->hdpriv
Alex Elder [Mon, 6 Oct 2014 11:53:13 +0000 (06:53 -0500)]
greybus: get rid of gbuf->hdpriv

Last time I tried to kill off gbuf->context my efforts were shot
down.  Now that I've got the connection infrastructure in place,
maybe I'll have more luck getting rid of gbuf->hdpriv.

The only place it's used is to stash the es1_ap_dev structure
pointer in the buffer.  But that information is now available
through the buffer's connection, so we don't need to use the
hdpriv field any more.

So get rid of it, and use hd_to_es1(gbuf->connection->hd) to
get at what we need.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: kill __alloc_gbuf()
Alex Elder [Mon, 6 Oct 2014 11:53:12 +0000 (06:53 -0500)]
greybus: kill __alloc_gbuf()

GEt rid of __alloc_gbuf(), now that it's used in only one place.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: use alloc_gbuf_data() for both directions
Alex Elder [Mon, 6 Oct 2014 11:53:11 +0000 (06:53 -0500)]
greybus: use alloc_gbuf_data() for both directions

Change the "direction" flag field of a gbuf to be a Boolean called
"outbound".

Add a Boolean outbound flag to alloc_gbuf_data(), and use it for
allocating the data buffer for gbufs for data being transferred in
either direction.

Update free_gbuf_data() accordingly--letting the host device
driver's gbuf data free function handle all of them.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: allocate gbufs using the connection
Alex Elder [Mon, 6 Oct 2014 11:53:10 +0000 (06:53 -0500)]
greybus: allocate gbufs using the connection

Switch to using the connection rather than the host device as
the locus for doing Greybus buffer allocation.  A connection
encapsulates both the host device (whose driver is what's required
for allocation) and the *destination* cport id.  Record the
connection a gbuf is associated with rather than the host module and
(unspecified) cport id.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: look up connection for recevied messages
Alex Elder [Mon, 6 Oct 2014 11:53:09 +0000 (06:53 -0500)]
greybus: look up connection for recevied messages

Look up the connection that an incoming message is associated with.
This is the start of making message handling oriented toward the
the connection rather than the cport.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: add bg_hd_connection_find()
Alex Elder [Mon, 6 Oct 2014 11:53:08 +0000 (06:53 -0500)]
greybus: add bg_hd_connection_find()

Add a function that looks up a connection given the host device
pointer an the host cport id.  This will be used to determine which
connection an incoming message is associated with.

Replace the list tracking host device connections with a red-black
tree so lookup can scale and be done quickly.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: bury some dead code
Alex Elder [Mon, 6 Oct 2014 11:53:07 +0000 (06:53 -0500)]
greybus: bury some dead code

One data structure and a few fields in another one are no longer
used, and were not removed when they should have been.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix two misnamed functions
Alex Elder [Mon, 6 Oct 2014 11:53:06 +0000 (06:53 -0500)]
greybus: fix two misnamed functions

I guess I got a little hd crazy.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: manifest.c: minor sparse cleanup
Greg Kroah-Hartman [Sun, 5 Oct 2014 01:43:41 +0000 (18:43 -0700)]
greybus: manifest.c: minor sparse cleanup

10 years agogreybus: define gb_connection_err()
Alex Elder [Fri, 3 Oct 2014 20:05:22 +0000 (15:05 -0500)]
greybus: define gb_connection_err()

Define a function that prints error information about a Greybus
connection in a standard format.  This adopts the convention that
[M:I:C] represents the "path" the connection represents--specifying
the module id, the interface number on that module, and the
connection id on that interface.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: add a connection->private field
Alex Elder [Fri, 3 Oct 2014 20:05:21 +0000 (15:05 -0500)]
greybus: add a connection->private field

This will be used for driver-specific data for whatever drives the
other end of the connection.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: specify type when creating an operation
Alex Elder [Fri, 3 Oct 2014 20:05:20 +0000 (15:05 -0500)]
greybus: specify type when creating an operation

The type of an operation belongs in the operation header, which
shouldn't be touched by users of the interface.  So specify it
at operation creation time.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: gbuf: have caller set actual_length
Alex Elder [Fri, 3 Oct 2014 20:05:19 +0000 (15:05 -0500)]
greybus: gbuf: have caller set actual_length

A Greybus buffer has both a transfer_buffer_size field, which is the
size in bytes of the transfer buffer, and an actual_length field,
which is the number of bytes in that buffer that are actually
consumed.  The user of the buffer--and not the buffer allocation
method--should be setting the actual_length field.

Stop setting the actual length on the es1-ap-usb alloc_gbuf_data
method.  And *do* set it in gb_operation_create(), where we can
presume the operation being allocated will consume all the bytes
requested.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix module setup
Alex Elder [Fri, 3 Oct 2014 19:14:25 +0000 (14:14 -0500)]
greybus: fix module setup

The code that was setting up a module was not properly initializing
the module data structure.  Fixing this required a little rework.

Now gb_add_module() (which the host device pointer and module id)
allocates and initializes the structure, and passes it to
gb_manifest_parse() for populating it further.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: use ida for cport id allocation
Alex Elder [Fri, 3 Oct 2014 19:14:24 +0000 (14:14 -0500)]
greybus: use ida for cport id allocation

The ida mechanism for allocating ids may be overkill but it works.

Don't preallocate the id 0 for control.  That should be done
when initializing connections based on the manifest anyway.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix greybus_class_type symbol names
Alex Elder [Fri, 3 Oct 2014 19:14:23 +0000 (14:14 -0500)]
greybus: fix greybus_class_type symbol names

These were inadvertently not fixed when the type name was changed.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix some hasty bugs
Alex Elder [Fri, 3 Oct 2014 19:14:22 +0000 (14:14 -0500)]
greybus: fix some hasty bugs

Fix some omissions found in the code.
    - initialize and use the host device connections list
    - rename the interface connections list (was "functions")
    - use the interface connections list
    - define a spinlock protecting the connections lists
    - declare gb_operation_submit() in "operation.h"

And the cport id map lock is per-host device, it's shared across all
host devices.  There's no need for one in struct greybus_host_device.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: implement core module removal path
Matt Porter [Fri, 3 Oct 2014 18:32:35 +0000 (14:32 -0400)]
greybus: implement core module removal path

Implement gb_remove_module() by finding the gb_module to
be removed via the supplied module_id. Add support for
removing the actual device into greybus_remove_device()
after all the subdevs are disconnected.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix gb_add_module() by enabling the device_add()
Matt Porter [Fri, 3 Oct 2014 17:38:24 +0000 (13:38 -0400)]
greybus: fix gb_add_module() by enabling the device_add()

Without the gb_module device being added, we have no parent
device for any of the greybus subdevs to be added. Do the
device_add() before creating subdevs as we need it then
to register any children in the various greybus protocol
drivers.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: manifest: some minor sparse warning fixups.
Greg Kroah-Hartman [Fri, 3 Oct 2014 04:26:26 +0000 (21:26 -0700)]
greybus: manifest: some minor sparse warning fixups.

10 years agogreybus: operation: fix endian issue in the operation message header size field.
Greg Kroah-Hartman [Fri, 3 Oct 2014 04:25:21 +0000 (21:25 -0700)]
greybus: operation: fix endian issue in the operation message header size field.

10 years agogreybus: record connection protocol
Alex Elder [Thu, 2 Oct 2014 17:30:06 +0000 (12:30 -0500)]
greybus: record connection protocol

Record the protocol association with a connection when it gets
created.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: get rid of functions now...
Alex Elder [Thu, 2 Oct 2014 17:30:05 +0000 (12:30 -0500)]
greybus: get rid of functions now...

We decided yesterday that we would no longer support the notion of a
"function."  Instead, a connection will simply exist between the AP
and an interface on a module (and a CPort Id on each end).  What
was previously considered the "function type" will now be handled
as the "protocol" associated with the connection.

Update gb_connection_create() to take just the interface and a cport
id associated with that interface.

Right now every module points back to a host device, so for now
we'll establish the connection back to that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: allocate connection host cport id
Alex Elder [Thu, 2 Oct 2014 17:30:04 +0000 (12:30 -0500)]
greybus: allocate connection host cport id

Allocate a cport id from the host device whenever creating a
connection.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: create host device cport id map
Alex Elder [Thu, 2 Oct 2014 17:30:03 +0000 (12:30 -0500)]
greybus: create host device cport id map

A Greybus host device has a pool of CPort Ids it can use.  When we
establish a connection with a CPort on another module we will need
to allocate one from those that are available.

This patch adds a bitmap to the greybus host device structure that
allows cport ids to be allocated and freed as needed.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: October 1 updates
Alex Elder [Thu, 2 Oct 2014 17:30:02 +0000 (12:30 -0500)]
greybus: October 1 updates

Update the definitions in "greybus_manifest.h" to reflect the
changes to the Greybus specification made on October 1.

They are:
    - renaming "device" to be "interface"
    - renumbering greybus descriptor type
    - eliminating the notion of a "function"
    - defining a CPort's protocol in the CPort descriptor
    - having a "class" take on the types previously used for "function"
    - renaming "serial number" to be "unique id" (for now)
    - relying on an interface's maximum cport id to determine how
      much device+cport address space the interface consumes
    - adding a simple class descriptor
    - renaming gb_interface->interface_id to be gb_interface->id

This also reorders some things to match ordering in the document,
and adds some commentary for the various structures.

Since greybus_function_type is gone, we eliminate the "type" field
from a function structure.  (Functions are going away, next.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix connection header declarations
Alex Elder [Thu, 2 Oct 2014 17:30:01 +0000 (12:30 -0500)]
greybus: fix connection header declarations

Changes to the create/destroy connection functions were not properly
reflected in the header file.  Fix that.  There's also no need to
include anything other than "greybus.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: kill off old manifest code
Alex Elder [Thu, 2 Oct 2014 02:54:19 +0000 (21:54 -0500)]
greybus: kill off old manifest code

Now that the new manifest code is in place, delete the old stuff
from "core.c".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: manifest cport descriptor parsing
Alex Elder [Thu, 2 Oct 2014 02:54:18 +0000 (21:54 -0500)]
greybus: manifest cport descriptor parsing

Add support for parsing one or more cports descriptors in a module
manifest.  There must be at least one for each interface, but we impose
no limit on the number of interfaces associated with a module.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: manifest interface descriptor parsing
Alex Elder [Thu, 2 Oct 2014 02:54:17 +0000 (21:54 -0500)]
greybus: manifest interface descriptor parsing

Add support for parsing one or more interface descriptors in a module
manifest.  There must be at least one, but we impose no limit on the
number of interfaces associated with a module.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: start improving manifest parsing
Alex Elder [Thu, 2 Oct 2014 02:54:16 +0000 (21:54 -0500)]
greybus: start improving manifest parsing

Currently the module manifest parsing code is sort of representative
only and is not really very useful.

This patch begins doing "real" parsing of the module manifest.
It scans the module manifest to identify the descriptors it holds.
It then verifies there's only one module descriptor found, and
initializes new some fields in the gb_module structure based on what
it contains (converting what's found to native byte order).
Note that if anything unexpected is found or other errors occur when
parsing the manifest, the parse fails.

Because we now save this converted information when it's parsed we
no longer have a greybus_descriptor_module struct within a struct
gb_module.  And because we've already converted these values, we can
do a little less work displaying values in sysfs.  (We also now show
vendor, product, and version values in the right byte order.)  This
eliminates the need for greybus_string(), so get rid of it.

It also slightly simplifies the greybus module matching code.

Move some existing parsing code into a new file, "manifest.c".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: introduce an operation abstraction
Alex Elder [Thu, 2 Oct 2014 02:54:15 +0000 (21:54 -0500)]
greybus: introduce an operation abstraction

This patch defines a new "operation" abstraction.  An operation is a
request from by one end of a connection to the function (or AP) on
the other, coupled with a matching response returned to the requestor.
The request indicates some action to be performed by the target of
the request (such as "read some data").  Once the action has
completed the target sends back an operation response message.
Additional data can be supplied by the sender with its request,
and/or by the target with its resposne message.

Each request message has a unique id, generated by the sender.
The sender recognizes the matching response by the presence
of this id value.  Each end of a connection is responsible
for creating unique ids for the requests it sends.

An operation also has a type, whose interpretation is dependent on
the function type on the end of the connection opposite the sender.
It is up to the creator of an operation to fill in the data (if any)
to be sent with the request.

Note that not all requests are initiated by the AP.  Incoming data
on a module function can result in a request message being sent from
that function to the AP to notify of the data's arrival.  Once the
AP has processed this, it sends a response to the sender.

Every operation response contains a status byte.  If it's value
is 0, the operation was successful.  Any other value indicates
an error.

Add a defintion of U16_MAX to "kernel_ver.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: introduce a connection abstraction
Alex Elder [Thu, 2 Oct 2014 02:54:14 +0000 (21:54 -0500)]
greybus: introduce a connection abstraction

Within a UniPro network a pair of CPorts can be linked to form a
UniPro Connection.  This patch creates a new abstraction to
represent an AP CPort that is connected with a CPort used by a
function within a Greybus module.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: define greybus function abstraction
Alex Elder [Thu, 2 Oct 2014 02:54:13 +0000 (21:54 -0500)]
greybus: define greybus function abstraction

Define new source files "function.h" and "function.c" to contain the
definitions of the Greybus function abstraction.  A Greybus function
represents an active entity connected to a CPort implemented by a
Greybus interface.  A Greybus function has a type, which defines the
protocol to be used to interact with the function.  A Greybus
interface normally has at least two functions, but potentially many
more.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: define greybus interface abstraction
Alex Elder [Thu, 2 Oct 2014 02:54:12 +0000 (21:54 -0500)]
greybus: define greybus interface abstraction

Define new source files "interface.h" and "interface.c" to contain
the definitions of the Greybus interface abstraction.  A Greybus
interface represents a UniPro device present in a UniPro module.
For Project Ara, each interface block on a module implements a
UniPro interface.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: isolate greybus module code
Alex Elder [Thu, 2 Oct 2014 02:54:11 +0000 (21:54 -0500)]
greybus: isolate greybus module code

Define new source files "module.h" and "module.c" to separate the
definitions of the Greybus module abstraction from other code.

Rename "greybus_module" to be "gb_module", for brevity.  Do the same
for a few other symbols with "greybus_module" in their names.  A few
(like greybus_module_id) are more visible outside this kernel module
so we'll keep their names more descriptive.

Add a definition for U8_MAX in "kernel_ver.h" (it appeared in 3.14).

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: descriptor type updates
Alex Elder [Thu, 2 Oct 2014 02:54:10 +0000 (21:54 -0500)]
greybus: descriptor type updates

Some more updates to the definition of a manifest descriptor.
    - We get rid of function descriptors.  The type of function is
      easily specified with the CPort it uses.
    - Add a new interface descriptor type.
    - Clean up the CPort descriptor structure, eliminating fields
      that serve no purpose and adding the function id field

The sysfs stuff will be updated a little later to add entries
for the Greybus interfaces associated with modules.

Rearrange the order of a few things in "greybus_manifest.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix error message on parse of cport descriptor size
Matt Porter [Wed, 1 Oct 2014 19:09:01 +0000 (15:09 -0400)]
greybus: fix error message on parse of cport descriptor size

Fix a simple cut and paste error that was reporting a serial
number header size error rather than a cport descriptor size
error.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: remove additional unused fields from the cport descriptor
Matt Porter [Wed, 1 Oct 2014 19:09:00 +0000 (15:09 -0400)]
greybus: remove additional unused fields from the cport descriptor

The Greybus spec was updated to remove some unused fields from the
CPort descriptor definition. Remove them from the structure so
we don't fail manifest parsing.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: clarify device vs module
Alex Elder [Wed, 1 Oct 2014 00:25:22 +0000 (19:25 -0500)]
greybus: clarify device vs module

The Project ARA MDK states that a single module can have more than
one interface block (up to 2 at the moment).  An interface block
consists of two bidirectional UniPro lanes (along with power and
detect lines), and effectively represents a UniPro Device (with
an id in the range 0-127).

The service messages currently use "module_id" everywhere, even
though in a lot of cases we really need to be talking about device
ids.  The easiest case of this to see is the "set route" request
directed at a switch; a switch has no notion of modules, just
UniPro devices.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: es1: no BUG_ON() code, report an error and recover.
Greg Kroah-Hartman [Wed, 1 Oct 2014 01:21:36 +0000 (18:21 -0700)]
greybus: es1: no BUG_ON() code, report an error and recover.

10 years agogreybus: kill struct gmod_cport
Alex Elder [Wed, 1 Oct 2014 00:25:21 +0000 (19:25 -0500)]
greybus: kill struct gmod_cport

A UniPro (short header) segment has a 5-bit field to represent a
CPort Id.  In addition, the 7-bit L3 short header holds a UniPro
device id.  There can be no more than 128 devices in a UniPro
network, but these two fields can be combined in ways to allow for
over 2000 CPorts within a single device.  As a result, a device id
is represented with one byte, and a CPort Id within a device is
always representable with a two byte value.

This patch changes integral values that reresent CPort Ids so they
use type u16 consistently.

Separately, the contents of the gmod_cport structure were mostly
fabricated, with the cport_id field being the only one that's
meaningful.  This patch gets rid of that structure, putting a
simple u16 to represent the CPort Id everywhere it had been used
before.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: es1-ap-usb: adjust SVC buffer size to handle worst case
Matt Porter [Tue, 30 Sep 2014 20:01:40 +0000 (16:01 -0400)]
greybus: es1-ap-usb: adjust SVC buffer size to handle worst case

The worst case message from the SVC->AP is a hotplug "plugged"
event. It includes the module manifest which may be up to 64KB
in size. Adjust our buffer allocation to allow for this.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: reorder greybus_svc_in() arguments
Alex Elder [Sat, 27 Sep 2014 01:55:35 +0000 (20:55 -0500)]
greybus: reorder greybus_svc_in() arguments

The two functions greybus_svc_in() and greybus_cport_in() do
very similar things, but their arguments are in a different order.
Move the greybus_host_device structure argument for greybus_svc_in()
to be first so the functions' prototypes are better aligned.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix version check
Alex Elder [Sat, 27 Sep 2014 01:55:34 +0000 (20:55 -0500)]
greybus: fix version check

When we read a module manifest we are required to verify that its
version is compatible with the version the present code is able
to parse.  All that's required is a check of the major version
number.  If the manifest's major version is greater than the
software, the software can't assume it can parse it.  All new
code must be able to parse all old versions of the format.  And
any difference in minor version is supposed to have no effect
on parsability.

Update the version check to enforce this policy, and reword the
error message to do a better job of explaining the situation.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: descriptor type is 1 byte
Alex Elder [Sat, 27 Sep 2014 01:55:33 +0000 (20:55 -0500)]
greybus: descriptor type is 1 byte

The spec was changed to require only one byte to represent the
type of a module descriptor.  Update our data type and the values
used to reflect that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix the guard in "greybus_manifest.h"
Alex Elder [Sat, 27 Sep 2014 01:55:32 +0000 (20:55 -0500)]
greybus: fix the guard in "greybus_manifest.h"

The tag in the #ifndef guard surrounding the content of
"greybus_manifest.h" needs to be updated to reflect the
actual name of the file.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix document version number
Alex Elder [Wed, 24 Sep 2014 10:16:17 +0000 (05:16 -0500)]
greybus: fix document version number

Two spots use the old "0.draft" version number for the Greybus
protocol specification.  We've updated that to be 0.1.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: update a few header file comments
Alex Elder [Wed, 24 Sep 2014 10:16:16 +0000 (05:16 -0500)]
greybus: update a few header file comments

Add a GPLv2 tag and reword some comments at the top of "greybus_desc.h"
and "svc_msg.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: some more renames
Alex Elder [Wed, 24 Sep 2014 10:16:14 +0000 (05:16 -0500)]
greybus: some more renames

This patch renames of symbols, for better clarity and consistency.

    cport -> cport_id (when it represents a cport *number*)
    send_svc_msg -> submit_svc (like submit_gbuf)
    greybus_cport_in_data -> greybus_cport_in
    gb_new_ap_msg -> greybus_svc_in (like greybus_cport_in)
    cport->number -> cport->id (like cport_id)

Making the svc and cport message stuff more similar is done with an
eye toward having SVC messages and messages exchanged with other
modules use some more common communication mechanisms.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: encapsulate URB status checking
Alex Elder [Wed, 24 Sep 2014 10:16:13 +0000 (05:16 -0500)]
greybus: encapsulate URB status checking

Define a new common function check_urb_status() that looks at the
status in a completed URB (containing incoming data) and issues
warnings in a consistent way.  It returns -EAGAIN to signal an
unrecognized status was seen, so the caller can ignore it and
re-post the URB to receive the next incoming data.  This
consolidates three blocks of code into one.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: update descriptor type enums to match renumbering in spec
Matt Porter [Sat, 27 Sep 2014 01:49:52 +0000 (20:49 -0500)]
greybus: update descriptor type enums to match renumbering in spec

Greybus spec updated the descriptor type values and added an
additional class descriptor type. Change the enum accordingly.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: update string descriptor length field to __u8 type to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:51 +0000 (20:49 -0500)]
greybus: update string descriptor length field to __u8 type to match spec

Greybus spec was updated to make the length field a single byte. Update
the type and remove endian handling of that field in the core.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: remove unused function descriptor fields and change class->function_type
Matt Porter [Sat, 27 Sep 2014 01:49:50 +0000 (20:49 -0500)]
greybus: remove unused function descriptor fields and change class->function_type

Greybus spec was updated to remove a number of unused function descriptor
fields. In addition, the class field was change to function_type to avoid
confusion with the concept of high-level class drivers.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: remove serial number descriptor to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:49 +0000 (20:49 -0500)]
greybus: remove serial number descriptor to match spec

Greybus spec was updated to remove the serial number descriptor and
move the serial number field to the, now mandatory, module descriptor.
Change everything accordingly.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: update descriptor module_id->module to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:48 +0000 (20:49 -0500)]
greybus: update descriptor module_id->module to match spec

Greybus spec was updated to change the name of the Module ID descriptor
to simply Module descriptor. Change everything accordingly.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: fix up coding style issue I caused with the last patch...
Greg Kroah-Hartman [Wed, 24 Sep 2014 03:58:58 +0000 (20:58 -0700)]
greybus: fix up coding style issue I caused with the last patch...

10 years agogreybus: embed workqueue structure in struct gbuf
Alex Elder [Tue, 23 Sep 2014 17:46:36 +0000 (12:46 -0500)]
greybus: embed workqueue structure in struct gbuf

A Greybus buffer containing outbound data is submitted to to the
underlying driver to be sent over a CPort.  Sending that data could
be deferred, so the submit operation completes asynchronously.  When
the send is done, a callback occurs, and the buffer is "completed",
and the buffer's completion routine is called.  The buffer is then
freed.

If data arrives on the CPort, greybus_cport_in_data() is called
to allocate a Greybus buffer and copy the received data into it.
Once that's done the buffer is completed, again allowing the
buffer's completion routine to finish any final tasks before
freeing the buffer.

We use a workqueue to schedule calling the buffer's completion
function.  This patch does two things related to the work queue:
    - Renames the work queue "gbuf_workqueue" so its name more
      directly describes its purpose
    - Moves the work_struct needed for scheduling completions
      into the struct greybuf.  Previously a separate type
      was used, and dynamically allocated *at interrupt time*
      to hold this work_struct.  We can now do away with that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: get rid of a weird idiom
Alex Elder [Tue, 23 Sep 2014 17:46:33 +0000 (12:46 -0500)]
greybus: get rid of a weird idiom

It strikes me as strange to add one to a value while checking to see
if it exceeds a maximum.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: quick fix for sysfs serial number
Alex Elder [Tue, 23 Sep 2014 17:46:32 +0000 (12:46 -0500)]
greybus: quick fix for sysfs serial number

Let the serial number attribute have its own is_visible function.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: rename struct greybus_device
Alex Elder [Tue, 23 Sep 2014 00:19:03 +0000 (19:19 -0500)]
greybus: rename struct greybus_device

The greybus_device structure represents an Ara phone module.
It does *not* (necessarily) represent a UniPro device, nor any
device (like an i2c adapter) that might reside on an Ara module.

As such, rename struct greybus_device to be struct greybus_module.
Rename all symbols having that type to be "gmod" rather than "gdev".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: simple fixes
Alex Elder [Mon, 22 Sep 2014 23:53:02 +0000 (18:53 -0500)]
greybus: simple fixes

A few silly little fixes.
    - Clear out some unnecessary #includes in "debugfs.c"
    - Drop some unneeded parentheses in hd_to_es1()
    - Use &hd->hd_priv in hd_to_es1() to emphasize we are working
      with an embedded array, not a pointer
    - Fix a comment in the header for ap_probe()
    - Drop a duplicate #include in "gpio-gb.c"
    - Fix a use-before-set problem in set_serial_info()

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: initialize all fields in an SVC handshake message
Matt Porter [Mon, 22 Sep 2014 19:51:49 +0000 (15:51 -0400)]
greybus: initialize all fields in an SVC handshake message

Currently only the handshake_type is being initialized when
responding to an SVC handshake request. Update this to
explicitly set all header/payload fields appropriately.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: es1-ap-usb: fix svc control pipe flags
Matt Porter [Mon, 22 Sep 2014 19:51:48 +0000 (15:51 -0400)]
greybus: es1-ap-usb: fix svc control pipe flags

The control message flags currently indicate USB_DIR_IN, which
doesn't allow the data phase carrying the SVC message to be
send to the device. Change this to USB_DIR_OUT so our SVC
message buffer reaches the device.

Also, the recipient is USB_RECIP_OTHER but almost all real devices
that handle vendor setup requests seem to set this as
USB_RECIP_INTERFACE. As a result, functionfs-based gadgets don't handle
vendor setup requests with a recipient of OTHER. Change this to
USB_RECIP_INTERFACE to work with the functionfs-based emulator and
this should be no issue for the firmware to implement to match.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
10 years agogreybus: core: hook up the hotplug message
Greg Kroah-Hartman [Mon, 22 Sep 2014 02:17:55 +0000 (19:17 -0700)]
greybus: core: hook up the hotplug message

We should now try to parse the manifest and create a device based on the
manifest.  Not hooked up to the driver core yet, so removing it isn't
going to do anything except cause problems...

10 years agogreybus: ap: validate the rest of the svc message buffer sizes
Greg Kroah-Hartman [Mon, 22 Sep 2014 02:10:39 +0000 (19:10 -0700)]
greybus: ap: validate the rest of the svc message buffer sizes

10 years agogreybus: ap: start validating the message better
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:19:54 +0000 (18:19 -0700)]
greybus: ap: start validating the message better

We check the type of the message now.

Start to check the size of the payload to match the size of the message
type.  Still more work to do needed here.

Also "hooked up" the hotplug message, but doesn't call anything as the
core doesn't implement that yet...

10 years agogreybus: core.c: create empty functions to keep linking working for hotplug/remove
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:17:36 +0000 (18:17 -0700)]
greybus: core.c: create empty functions to keep linking working for hotplug/remove

10 years agogreybus: greybus.h: add function prototype for add/remove a module
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:17:12 +0000 (18:17 -0700)]
greybus: greybus.h: add function prototype for add/remove a module

10 years agogreybus: svc_msg.h: add data for hotplug message
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:16:41 +0000 (18:16 -0700)]
greybus: svc_msg.h: add data for hotplug message

10 years agogreybus: gbuf: clean up logic of who owns what "part" of the gbuf
Greg Kroah-Hartman [Mon, 22 Sep 2014 00:34:28 +0000 (17:34 -0700)]
greybus: gbuf: clean up logic of who owns what "part" of the gbuf

Started documenting the gbuf and how a greybus driver and a host
controller driver needs to interact with it, and the rest of the greybus
system.  It's crude documentation, but better than nothing for now...