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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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...
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...
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...
The Greybus spec was updated to have major=0 and minor=1 so update
this in the code.
Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
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>
The Greybus spec has been updated to clarify some of the original
intent of the SVC message definition. The svc_msg_header was:
struct svc_msg_header {
__u8 function;
__u8 message_type;
...
}
and is now
struct svc_msg_header {
__u8 function_id;
__u8 message_type;
...
}
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>
Have only tested USB device add/remove, the urbs seem to all be queued
up, no data has been tested to flow through yet.
Odds are the hc interface will have to change, but this is a good first
start to build on.
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).
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>
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>
The type field in a manifest descriptor header is in little endian
format. Make sure we interpret it that way.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
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>
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>
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>
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>
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>