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...
Matt Porter [Thu, 18 Sep 2014 19:25:42 +0000 (15:25 -0400)]
greybus: move versioning from svc message header to handshake function
The Greybus spec has been updated to improve the efficiency of the
version major/minor information that had been previously carried in
every SVC message header. The version major/minor is now provided
as part of the handshake function.
Update the SVC msg header and handshake function payload definitions
and move the version major/minor validation into the SVC handshake
handling routine.
Signed-off-by: Matt Porter <mporter@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
to match the spec. The function_id carries enum svc_function_id values
and message_type is now clarified to be a session layer level field
that is simply "data" or "error".
Change all references of function type to function id. For now, don't
parse the message_type field but add the two allowable svc_msg_type enums.
Signed-off-by: Matt Porter <mporter@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Thanks to Marti for pointing out the code didn't build properly on 3.10.
Added kernel_ver.h to handle any api mis-matches between the code and
older kernel versions.
Based on a patch from Alex Elder <elder@linaro.org>.
Alex's original description:
Every descriptor in a manifest is interpreted by greybus_new_module().
We call a function to do initialization based on descriptor's type.
Since we know the type of the descriptor at that point, we can pass
to the called function the actual sub-type it needs (i.e., the union
member associated with the type). This allows those functions to
be slightly simplified, and more focused.
Also change some size variables to have size_t type, and simplify a
few spots further by using sizeof(object) in place of sizeof(type).
Alex Elder [Tue, 9 Sep 2014 18:55:09 +0000 (13:55 -0500)]
greybus: fix manifest parsing size bug
The type-specific "create" routines that get called while parsing
the descriptor entries in the module manifest assume the size they
are provided is the size of their data portion only--not including
the descriptor header.
Compute this value in greybus_new_module(), and pass it to those
functions rather than the full descriptor size. Move a few
declarations to the innermost block that uses them.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Alex Elder [Tue, 9 Sep 2014 18:55:08 +0000 (13:55 -0500)]
greybus: validate descriptor sizes
When interpreting a manifest descriptor header, don't assume there
is enough space in the buffer to hold a descriptor header. Also,
verify the remaining buffer is at least as big as the reported
descriptor size.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Alex Elder [Tue, 9 Sep 2014 18:55:06 +0000 (13:55 -0500)]
greybus: call put_device() on error
As soon as we've called device_initialize() we're required to call
put_device() in order to drop our reference to the device structure.
This was missed in the error path in greybus_new_module(). Fix that.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Alex Elder [Tue, 9 Sep 2014 18:55:04 +0000 (13:55 -0500)]
greybus: define struct greybus_manifest
Define a structure that describes the entire greybus manifest.
Adjust greybus_new_module() to use that, making it explicit that
it's not just a header that's being provided to that function.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Alex Elder [Tue, 9 Sep 2014 18:55:03 +0000 (13:55 -0500)]
greybus: switch to the term "manifest"
We agreed to rename a few things to improve clarity. This patch
implements one of those changes. The blob of data that describes
what's relevant to Greybus within an Ara module will now be called
the "module manifest." In addition, in the context of Greybus we'll
also be calling what's in an Ara module a "module" or "Greybus module."
So this patch renames some structures and updates some comments. It
also renames "greybus_desc.h" to be "greybus_manifest.h", and renames
greybus_new_device() to be greybus_new_module().
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Alex Elder [Mon, 18 Aug 2014 23:25:12 +0000 (18:25 -0500)]
greybus: uart-gb: a few minor bug fixes
Here are a few small bug fixes in uart-gb.c:
- In wait_serial_change():
- Return -EINVAL if *none* of the relevant flags are set in
the "arg" parameter.
- Balance the spin_lock_irq() with an unlock call (not
another lock).
- Rearrange a nested if structure (not a bug fix).
- In tty_gb_probe():
- Reset the greybus_device driver data in case of error.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Alex Elder [Mon, 18 Aug 2014 23:25:11 +0000 (18:25 -0500)]
greybus: uart-gb: improve minor device number error checking
When alloc_minor() finds an available minor device number it
does not constrain the highest number desired. Instead, it
relies on its caller, tty_gb_probe() to see if the returned
number indicates all minor numbers have been exhausted.
There are a couple problems with this--or rather with this
code.
First, if an allocation is attempted *after* GB_NUM_MINORS
is returned, a new number greater than (but not equal to)
GB_NUM_MINORS will be allocated, and that won't produce
any error condition.
Second, alloc_minor() can return an error code (like -ENOMEM). And
its caller is only checking for GB_NUM_MINORS. If an error code
is returned, tty_gb_probe() simply uses it.
Change alloc_minor() so it requests minor device numbers in the
range 0..(GB_NUM_MINORS-1), and use an error return to detect
when the minor device numbers have been exhausted.
If alloc_minor() returns -ENOSPC (from idr_alloc()), translate that
to -ENODEV. The only other error we might see is -ENOMEM, and if
we get that, return it.
Finally, zero gb_tty->minor when it's released. (If this is
actually important a reserved value like GB_NUM_MINORS should
be used instead to signify a gb_tty with no minor assigned.)
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>